Author Topic: Invalid effective address  (Read 17873 times)

nobody

  • Guest
Invalid effective address
« on: June 14, 2006, 10:41:51 AM »
Hi,
Could anybody tell me why the following code generates "Invalid effective address" error???

mov ax,0x10
   mov dx,[ax]

I want "dx" to be filled with the value which is pointed to by "ax" (0x10 in the above example).
Thanx,

nobody

  • Guest
Re: Invalid effective address
« Reply #1 on: June 14, 2006, 11:00:30 AM »
'Cause it's not a valid effective address? :)

There's a section in the manual on this - I don't find it too "beginner friendly".

16-bit addressing modes are *extremely* limited. Optional offset, plus optional base register, plus optional index register. bx and bp are valid base registers (bp defaults to using ss). si and di are valid index registers. That's it.

32-bit addressing modes are *much* more flexible. Fortunately, you can use 32-bit addressing in 16-bit code. Just change ax to eax and it'll work. Assuming you're targetting 386+. If you want it to run on a 16-bit CPU, use the valid 16-bit registers.

Best,
Frank