What do the brackets mean in x86 asm?

前端 未结 8 1854
旧时难觅i
旧时难觅i 2020-11-30 20:51

Given the following code:

L1     db    \"word\", 0

       mov   al, [L1]
       mov   eax, L1

What do the brackets ([L1]) represent?

相关标签:
8条回答
  • 2020-11-30 21:20

    The brackets mean to de-reference an address. For example

    mov eax, [1234]
    

    means, mov the contents of address 1234 to EAX. So:

    1234 00001
    

    EAX will contain 00001.

    0 讨论(0)
  • 2020-11-30 21:26

    They mean that instead of moving the value of the register or numeric value L1 into the register al, treat the register value or numeric value L1 as a pointer into memory, fetch the contents of that memory address, and move that contents into al.

    In this instance, L1 is a memory location, but the same logic would apply if a register name was in the brackets:

    mov al, [ebx]
    

    Also known as a load.

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