x86 Calculating AX given AH and AL?

后端 未结 1 822
刺人心
刺人心 2020-11-27 08:37

I\'m having trouble understanding registers in x86 Assembly, I know that EAX is the full 32 bits, AX is the lower 16 bits, and then AH and AL the higher and lower 8 bits of

相关标签:
1条回答
  • 2020-11-27 09:15

    As suggested by Peter Cordes, I would imagine the data as hexadecimal values:

    RR RR RR RR EE EE HH LL
    |           |     || ||
    |           |     || AL
    |           |     AH  |
    |           |     |___|
    |           |     AX  |
    |           |_________|
    |           EAX       |
    |_____________________|
    RAX
    

    ...where RAX is the 64-bit register which exists in x86-64.

    So if you had AH = 0x12 and AL = 0x34, like this:

    00 00 00 00 00 00 12 34
    |           |     || ||
    |           |     || AL
    |           |     AH  |
    |           |     |___|
    |           |     AX  |
    |           |_________|
    |           EAX       |
    |_____________________|
    RAX
    

    ...then you had AX = 0x1234 and EAX = 0x00001234 etc.

    Note that, as shown in this chart, AH is the only "weird" register here which is not aligned with the lower bits. The others (AL, AX, EAX, RAX for 64-bit) are just different sizes but all aligned on the right. (For example, the two bytes marked EE EE in the chart don't have a register name on their own.)

    0 讨论(0)
提交回复
热议问题