Why would one use “movl $1,

后端 未结 6 1470
旧时难觅i
旧时难觅i 2021-01-31 10:30

As the title states, why would one use \"movl $1, %eax\" as opposed to, say, \"movb $1, %eax\", I was told that movl would zero out the high order bits of %eax, but isn\'t %eax

6条回答
  •  星月不相逢
    2021-01-31 10:50

    %eax is 32 bits on 32-bit machines. %ax is 16 bits, and %ah and %al are its 8-bit high and low constituents.

    Therefore movl is perfectly valid here. Efficiency-wise, movl will be as fast as movb, and zeroing out the high 3 bytes of %eax is often a desirable property. You might want to use it as a 32-bit value later, so movb isn't a good way to move a byte there.

提交回复
热议问题