Addressing Modes in Assembly Language (IA-32 NASM)

后端 未结 2 1884
臣服心动
臣服心动 2020-12-01 11:15

As the web-resources on this is sparse, I will, for the benefit of future searches, begin by listing the address modes for IA-32 Assembly Language (NASM) and then follow up

相关标签:
2条回答
  • 2020-12-01 11:45
    1. In NASM syntax, that instruction should be MOV EBX, MY_TABLE. What MOV EBX, [MY_TABLE] would do is load the first 4 bytes located at MY_TABLE into EBX. Another alternative would be to use LEA, as in LEA EBX, [MY_TABLE].

    2. In this case the tutorial is right. MY_TABLE is defined as an array of words. A word on the x86 is 2 bytes, so the second element of MY_TABLE is indeed located at MY_TABLE + 2.

    0 讨论(0)
  • 2020-12-01 12:02

    That tutorial is not even valid NASM code. For links to x86 guides / resources / manuals that don't suck, see the x86 tag wiki here on SO.

    MOV [EBX], 110 won't assemble because neither operand implies an operand-size. (I think even MASM won't assemble it, but some bad assemblers like emu8086 have a default operand size for instructions like this.) mov word [ebx], 110 would do a 16-bit store.

    MOV EBX, [MY_TABLE] will assemble but it loads the first 2 words from the table. mov ebx, MY_TABLE will put the address into a register.

    0 讨论(0)
提交回复
热议问题