x86 assembly program. I write 0xffffffffffffffff into the RSI register then I use MOV to load a constant (6). When I use ESI as the target, the higher bits become zeros, but not if I use SI or SIL as the target.
mov rdi, format ; "0x%016lx\n"
mov rsi, 0xffffffffffffffff
mov esi, 6
call _printf ; => 0x0000000000000006
… but …
mov rdi, format
mov rsi, 0xffffffffffffffff
mov si, 6
call _printf ; => 0xffffffffffff0006
… and …
mov rdi, format
mov rsi, 0xffffffffffffffff
mov sil, 6
call _printf ; => 0xffffffffffffff06
- Why this difference?
- Is this always true or only under some conditions?
- Where is this documented?
I already checked the section about the MOV instruction (Vol 1, 7.3.1.1) in the Intel® 64 and IA-32 Architectures Software Developer’s Manual, and I didn't find the information there. I also checked the section in Volume 2A 4.2 (M-Z) about the MOV instruction, but I find it a little difficult to understand.