Pregunta

Can someone please explain what the difference between the following two are? I'm finding it a little difficult to understand the concepts behind addressing modes

mov ax, [bx + di + 10]
mov ax, [bx + di] + 10

Thanks so much!

¿Fue útil?

Solución

You labelled this MASM32 but neither instruction is legitimate for x86. Unless you are doing 16 bit programming, in which case you should make that clear.

mov ax, [bx+di+10]

Is not legal in x86 because it uses 16 bit addressing. The following is allowed, however:

mov ax, [ebx+edi+10]

Which means take the value of ebx, add it to the value of edi, and add 10 to that value. Then treat the final value as a pointer. Take the word (2 bytes) pointed to by that address and assign the value to ax.

mov ax, [bx+di]+10

Is not legal similarly (16 bit addressing). If you were to do:

mov ax, [ebx+edi]+10

That is also not allowed since mov does not allow an extra input after [ebx+edi]

Otros consejos

There is no difference!

You can check with debugger...

mov ax, [bx + di + 10]
mov ax, [bx + di] + 10

Compiler will compile boath instructions to: 8B443B0A

So, ax should load the 16 bit value from address: bx + di + 10

Suppose bx=10 , di = 10.

In case 1,

mov ax, [30]

The value at memory location 30 will be copied to AX register

In case 2,

mov ax, [20]+10

The value at memory location 20, lets say X, add 10h to it X+10h, will be copied to AX register.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top