Question

In 64-bit mode, the default address size is 64 bits. If the address-size override prefix (67h) is present, the address size is 32-bits.

I'm aware of the fact that canonical 64-bit addresses have bits 63 through the most significant implemented bit either all 0s or all 1s. Is the 32-bit address (obtained by prefixing 67h to an instruction in 64-bit mode) required to be in canonical form? If yes, how is this canonical form defined?

Was it helpful?

Solution

Canonical addresses are formed by sign-extending the significant part (the lower 48 bits) of a virtual address; the most significant bit is treated as the sign.

Speculating on this now (not willing to look it up - but that's also not necessary to answer your question) - there's two conceivable behaviours for 32bit addresses in 64bit mode:

  1. The CPU treats it like the use of a 32bit register/operand, i.e. zero-extend to 64bit / implicitly treat the high 32bit as zeroes
    In this case, any 32bit address is canonical because any 64bit address 0x00000000xxxxxxxx is canonical.
  2. The CPU treats it as "32bit significant" and sign-extends to 64bit from the most significant bit of the 32bit address
    In this case as well, any 32bit address is canonical, because then the 32bit range would map from 0xffffffff80000000 ... 0x000000007fffffff - again, all of which are canonical.

Since the result (32bit addresses always implicitly being of canonical form) is the same, it doesn't matter what the CPU actually does - 32bit addresses are canonical, period.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top