Get the upper half of the EAX register

前端 未结 4 1614
旧巷少年郎
旧巷少年郎 2020-12-20 19:52

In x86 assembly language, is there any way to obtain the upper half of the EAX register? I know that the AX register already contains the lower hal

4条回答
  •  生来不讨喜
    2020-12-20 20:25

    For 16-bit mode, this is the smallest (not fastest) code: only 4 bytes.

    push eax  ; 2 bytes: prefix + opcode 
    pop ax    ; 1 byte: opcode
    pop bx    ; 1 byte: opcode
    

    It's even more compact than single instruction shld ebx,eax,16 which occupies 5 bytes of memory.

提交回复
热议问题