Why do x86-64 instructions on 32-bit registers zero the upper part of the full 64-bit register?

后端 未结 3 1810
死守一世寂寞
死守一世寂寞 2020-11-21 05:20

In the x86-64 Tour of Intel Manuals, I read

Perhaps the most surprising fact is that an instruction such as MOV EAX, EBX automatically ze

3条回答
  •  没有蜡笔的小新
    2020-11-21 05:37

    It simply saves space in the instructions, and the instruction set. You can move small immediate values to a 64-bit register by using existing (32-bit) instructions.

    It also saves you from having to encode 8 byte values for MOV RAX, 42, when MOV EAX, 42 can be reused.

    This optimization is not as important for 8 and 16 bit ops (because they are smaller), and changing the rules there would also break old code.

提交回复
热议问题