Any way to move 2 bytes in 32-bit x86 using MOV without causing a mode switch or cpu stall?

后端 未结 2 1391
心在旅途
心在旅途 2020-12-12 05:07

If I want to move 2 unsigned bytes from memory into a 32-bit register, can I do that with a MOV instruction and no mode switch?

I notice that you CAN do

2条回答
  •  被撕碎了的回忆
    2020-12-12 05:19

    stick to 32 bit mode and use 16 bit instructions

    mov eax, 0         ; clear the register
    mov ax, 10-binary  ; do 16 bit stuff
    

    Alternatively I guess I could move 4 bytes into the register and then somehow CMP just two of them

    mov eax, xxxx ; 32 bit num loaded
    mov ebx, xxxx
    cmp ax, bx    ; 16 bit cmp performed in 32 bit mode
    

提交回复
热议问题