A homework question I don't understand the answer to:
Assuming all registers start at 0, what is the value of the RBX registers at the end of this assembly code?
mov $31, %bl
sal $32, %rbx
movl $32, %ebx
sar $31, %rbx
I predicted that the answer would be 62, by assuming that movl $32, %ebx
should only affect the lower 32 bits. However, when I run this code in SASM, it seems that movl
also zeros-out the upper 32 bits, and the answer is 0. Is this expected behavior? Is this a bug in SASM? Why does movl
affect the upper 32 bits?