clear upper 32 bits of rbx
What i开发者_高级运维s the fastest instruction to clear the upper 32 bits of a x86_64 GPR (r?x) ?
Perhaps in some circumstances it may end up not being the faster method, but in general it should: use mov reg32, reg32
Intel syntax examples:
mov ebx, ebx ; The topmost 32 bits of rbx will be cleared
mov r11d, r11d ; The topmost 32 bits of r11 will be cleared
The reason it works is because when you write a 32-bit register, its 64-bit brother gets its upper 32 bits cleared. Same would happen with "or reg32, reg32", "and reg32, reg32", "add reg32, 0", etc.
Before using some method to clear the upper 32 bits, make sure you actually need to do such thing, as it may happen that your code can start working with 32-bit operation (which will clear the upper 32 bits automatically), before you need to work with 64-bit wide operands.
Isn't plain old and
good enough?
and rbx,0ffffffffh
精彩评论