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)