1

I need to translate the Assembler command MOV BL,[ALPHA] into machine code of intels 8086 processor. Therefore, ALPHA is an 1 Byte variable at the 11th Position of the Data Segment, which is already loaded in the DS Register.

I already translated MOV AL,[ALPHA] in another task I've got. Here I found the MOV AL/AX,addr in the instruction set table so I could translate the whole thing into 1010|0000 1010|0000 or A0 10 in machine code.

I tend to use MOV r/m1,r/m2 of the instruction set table, but I am not 100% sure because I got problems when selecting the r/m part. Since this is the preparation for an exam I would be really happy if someone could help :)

Ba5t14n
  • 719
  • 2
  • 5
  • 20

1 Answers1

5

That must be a strange instruction set table because there is no mov r/m1,r/m2 (you can't have two memory references). Better try the official intel one. What you need is mov r8, r/m8. The encoding for that is 8A /r. Using Table 2-1. 16-Bit Addressing Forms with the ModR/M Byte you can see that operand BL with a 16 bit displacement disp16 means a modrm byte of 1E followed by 16 bit displacement, so the complete instruction is 8A 1E 0A 00. You can verify that with an assembler:

8A1E0A00                mov bl, [10]

PS: It's unclear what offset you really want, but I trust you can fill in the correct one.

Jester
  • 56,577
  • 4
  • 81
  • 125
  • Thanks for your time you invest. I think I understand know. In our table we have this one rule and set the bit in which direction we go manually (by setting the 7th bit of that thing 0 or 1 [as far as I understood]), in case of two adresses we must see the problem by ourself. But I could follow your answer with my script :) A short edit for your answer for other users seeing this: the 11th position translates to `0A 00` and we got no displacement in this task so I think we are fine with this Many thanks & have a nice weekend (: – Ba5t14n May 24 '15 at 00:35
  • The displacement is the `0A 00` ;) – Jester May 24 '15 at 00:37
  • Okay, `0A 00` is the displacement. But for which adress is this the disp.? For the next instruction? For data? I think I understood how physical adresses where made in the 8086, but where (code/data/somewhat else) enables that offset? Is an answer possible without further information or does the BL register is used by a specific other register? – Ba5t14n May 24 '15 at 00:47
  • It's your address, which in this case is just a displacement (offset) because you don't have a register in the destination address. The valid forms include `[displacement]`, `[bx+displacement]`, `[bp+si+displacement]` and such. – Jester May 24 '15 at 00:50
  • Ah yeah, so I'm going to have the data from 0x00A00h in my BL register?! – Ba5t14n May 24 '15 at 00:52
  • Data from `0x000A` (+`ds` segment base), since x86 is little endian. And that address is your `ALPHA`. – Jester May 24 '15 at 00:53