Comment by pm2222

Comment by pm2222 3 days ago

7 replies

>> Additionally, the higher 8 bits of rax, rbx, rcx and rdx can be referred to as ah, bh, ch and dh.

Did you mean “ax, bx, cx, dx”?

ordu 3 days ago

ax, bx, cx, dx are 16 bit registers referring to the lower 16 bits of rax, rbx, rcx, and rdx respectively. Bits 0..8 can be referred as al/bl/cl/dl, bits 8..16 as ah/bh/ch/dh.

  • wunused 3 days ago

    It's ambiguous, but I believe the comment you are replying to suggests that the sentence should read:

    >> Additionally, the higher 8 bits of ax, bx, cx and dx can be referred to as ah, bh, ch and dh.

anamexis 3 days ago

Those would be the lower 8 bits, no?

  • wunused 3 days ago

    In a 64 bit register, e.g., RAX, AL refers to the lowest 8 bits [0-7] and AH refers to the next 8 bits [8-15].

    Together, AX refers to bits [0-15]. EAX refers to [0-31].

    It's counterintuitive (or at least, inconsistent) that we have a name for bits [8-15] but not for [16-31] or [32-63]. My fuzzy understanding is that this came about from legacy decisions.

    This page has a helpful visualization at the top: https://www.cs.uaf.edu/2017/fall/cs301/lecture/09_11_registe...

    • [removed] 3 days ago
      [deleted]