YJDoc2 / 8086-Emulator

An Intel 8086 Emulator created in Rust.
Apache License 2.0
340 stars 49 forks source link

LEA instruction not working #7

Closed gipic closed 2 years ago

gipic commented 2 years ago

I have this string declared like the helloworld example: hello: DB "Hello World" ; store string

Now I have just one instruction: LEA DX, hello

it should load the address of hello string inside DX but it doesn't compile.

Errors: Syntax Error at line 5:16 : LEA DX, hello : Unexpected Token : hello

Thank you!

PS: Please can you implement service 0x09 (MOV AH, 0x09) with INT 0x21 ??? This way I could easly print strings like with EMU8086.

YJDoc2 commented 2 years ago

Hey, the issue is that for LEA, you need to specify word before the label, as LEA DX, word hello . One of the reasons is this emulators expects you to explicitly write what kind of data you mean (byte or word) when you use label or memory. That said, I'm not sure why this only supports word and not byte as technically the address of that label should be the same in either case :thinking: I'll check why it is so, but in the meantime, adding word before label should solve the issue mentioned.

As for printing strings, INT 0x10H supports printing stings to stdout, check out https://github.com/YJDoc2/8086-Emulator/blob/master/examples/hello_world.s for its use.

Hope this helps!

gipic commented 2 years ago

Thanks!