Search code examples
assemblyx86-16addressing-mode

The instruction "mov ax,[ax]" wont compile


Im using a x8086 emulator called "emu8086". I wrote simple code and when i run it, it gives me an error. I cant figure out what is the problem. http://prntscr.com/8bpivm


Solution

  • [AX] is not a valid effective address. Here's a list of the valid 16-bit addressing forms (source):

    [BX + val]
    [SI + val]
    [DI + val]
    [BP + val]
    [BX + SI + val]
    [BX + DI + val]
    [BP + SI + val]
    [BP + DI + val]
    [address]
    

    The + val part denotes an 8-bit or 16-bit displacement, and can be omitted, so you can write [BX] instead of [BX + 0].

    You can also find these in Intel's Software Developer's Manuals, vol 2A, Table 2-1. 16-Bit Addressing Forms with the ModR/M Byte.