问题描述
我对x86寄存器的理解是,每个寄存器都可以被整个32位代码访问,并且被分成多个可访问的寄存器.
My understanding of x86 registers say that each register can be accessed by the entire 32 bit code and it is broken into multiple accessible registers.
在此示例中,EAX
是一个32位寄存器,如果调用AX
,它将返回前16位,如果调用AH
或AL
,它将返回16之后的后8位.位和AL
应该返回最后8位.
In this example EAX
being a 32 bit register, if we call AX
it should return the first 16 bits, and if we call AH
or AL
it should return the next 8 bits after the 16 bits and AL
should return the last 8 bits.
所以我的问题是,因为我并不真正相信这是它的运行方式.如果我们将32位值也存储为EAX
存储:
So my question, because I don't truly believe is this is how it operates. If we store the 32 bit value aka EAX
storing:
0000 0100 0000 1000 0110 0000 0000 0111
因此,如果我们访问AX
,它将返回
So if we access AX
it should return
0000 0100 0000 1000
如果我们阅读AH
,它应该返回
if we read AH
it should return
0000 0100
,当我们阅读AL
时,它应该返回
and when we read AL
it should return
0000 0111
这是正确的吗?如果AH
真正具有什么价值?
Is this correct? and if it is what value does AH
truly hold?
推荐答案
不,那不是很正确.
EAX is the full 32-bit value
AX is the lower 16-bits
AL is the lower 8 bits
AH is the bits 8 through 15 (zero-based)
为完整起见,除上述内容(基于32位CPU)之外,还有64位Intel/AMD CPU
For completeness, in addition to the above, which was based on a 32-bit CPU, 64-bit Intel/AMD CPUs have
RAX, which hold a 64-bit value, and where EAX is mapped to the lower 32 bits.
这篇关于AX,AH,AL如何映射到EAX?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!