Why MOV AH,1 is not supported in 64 bit mode of intel microprocessor?

后端 未结 2 737
北海茫月
北海茫月 2020-12-20 03:29

In the book \"THE INTEL MICROPROCESSORS\" of Barry B. Brey, it is written that

MOV AH, 1

is not allowed in 64 bit mode, but allowed in 32

相关标签:
2条回答
  • 2020-12-20 03:50

    Please also note that, according to the Intel optimization manual, the use of 8-bit register is discouraged for some processors, while for other not. Currently, it is only discourage for Knights Landing, but in future the list of processors where 8-bit and 16-bit instructions would work slower may grow. Intel wrote the following in the manual:

    Instructions that operate on 8-bit or 16-bit registers are not optimized in hardware in the Knights Landing microarchitecture. In general, it is faster to use integer instructions operating on 32-bit or 64-bit general purpose registers than 8-bit or 16-bit registers.

    Although the Knights Landing is not a general-purpose CPU, I anticipate the tendency that on all future processors, probably, in a next major microarchitecture change, namely, since the Icelake microarchitecture, which is the Intel CPU microarchitecture based on the 10nm node that is expected to replace Cannonlake in 2019 - the 8-bit and 16-bit register operation will be slow, and not just write, but the read also (Disclaimer: this anticipation of mine is a pure speculation).

    So, back to the ah register - you cannot encode, for example, movzx r8, ah in 64-bit mode, but you can encode anything with the ah register per se, e.g. mov ah, 1 - because AMD has designed the 64-bit mode in such a way that the old instructions are encoded the same way as in the old 32-bit mode.

    0 讨论(0)
  • 2020-12-20 03:58

    There is no problem with mov ah,1. It runs just fine in X64 mode.

    The opcode for it is b4 01.

    The only time when mov ah is not allowed is when the mov has a REX prefix.

    from: http://www.felixcloutier.com/x86/MOV.html

    ***In 64-bit mode, r/m8 can not be encoded to access the following byte registers if a REX prefix is used: AH, BH, CH, DH.

    In that case the high byte registers (AH, BH, CH, and DH) are redefined as DIL, SIL, BPL and SPL. But this is only if a REX prefix is present.

    Instructions with a REX prefix are:

    anything with the R8..R15 regs and parts thereof
    anything that accesses the new 8 bit regs: DIL, SIL, BPL, SPL
    anything that accesses 64 bit registers.
    
    0 讨论(0)
提交回复
热议问题