zero out top 32 bits of 64-bit register

后端 未结 1 651
没有蜡笔的小新
没有蜡笔的小新 2020-12-06 13:35

Using amd64 assembly, whats the best way to zero out the top 32 bits of a 64-bit register, e.g. zero out the bits of rax that are not covered by eax? It appears that I cann

相关标签:
1条回答
  • 2020-12-06 14:23

    movl %eax, %eax or mov eax, eax, depending on the assembler in use.

    see: Intel® 64 and IA-32 Architectures - Software Developer’s Manual, Volume 1, 3.4.1.1 : General-Purpose Registers in 64-Bit Mode.

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

    I should also add, in regards to @HansPassant's comment: 7.3.1.7 :

    The MOVSXD instruction operates on 64-bit data. It sign-extends a 32-bit value to 64 bits.

    0 讨论(0)
提交回复
热议问题