3

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!

Carl Norum
  • 219,201
  • 40
  • 422
  • 469
Yuki
  • 155
  • 10

3 Answers3

3

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

GJ.
  • 10,810
  • 2
  • 45
  • 62
3

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]

Mike Kwan
  • 24,123
  • 12
  • 63
  • 96
-4

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.

Madhur Ahuja
  • 22,211
  • 14
  • 71
  • 124