1

Can someone help me with understanding x64 asm behaviour? I cant find any kind of documentation for that.

So, basically, we have:

  • x64 register RAX.
  • x32 register EAX.
  • x16 register AX.
  • x8 register AL.

and now code:

mov rax, -1 (0xFFFFFFFFFFFFFFFF)
add al, 1

result will be 0xFFFFFFFFFFFFFF00 (correct, al register overflow, but we change only AL 1 byte)

mov rax, -1 (0xFFFFFFFFFFFFFFFF)
add ax, 1

result will be 0xFFFFFFFFFFFF0000 (correct, ax register overflow, but we change only AX 2 bytes)

mov rax, -1 (0xFFFFFFFFFFFFFFFF)
add eax, 1

result will be 0x0000000000000000 (wtf?, eax register overflow, but result change all 8 bytes instead of 4. Why it is 0x0000000000000000 but not 0xFFFFFFFF00000000)

1 Answers1

1

32-bit operands generate a 32-bit result, zero-extended to a 64-bit result in the destination general-purpose register.

Thats is. Thanks!

mov rax, 0x6666666666666666
add eax, 1

result confirm this and will be 0x0000000066666667