Search code examples
assemblyx86protected-mode

Does offset operator in x86 returns logical address or offset address?


In real address mode:

mov esi, OFFSET var ;esi 32 bit

In protected mode:

MOV si, OFFSET arr  ;si  16 bit

; but MOV instructions works only if both the destination and source have same size 

Please help me clear my concept I am beginner.


Solution

  • MOV si, OFFSET arr in 32-bit protected mode code will presumably truncate the address to 16 bit, giving you the low 16 bits of it.

    mov esi, OFFSET var in 16-bit real mode will give you the offset zero-extended to 32-bit, I expect.

    That's what NASM does, for foo: mov esi, foo in a file by itself.
    You get 66 BE 00000000 mov esi,0x0.