Address computation



Hi,

the ISA of my processor can handle immediate operands of max.
16bits. So, to store a 32bit base pointer into a 32bit address
register, the manual suggest the usage of a combination of two
instructions:

MOVH AREG, ((absolute address+0x8000)>>16) & 0xFFFF and
LEA AREG, AREG (off16) # off16 = (absolute address & 0xFFFF)

where
* the absolute address is 32bit,
* MOVH moves the 16bit value of the second operand to the
most-significant half-word of AREG and set the least-significant
16 bits to zero.
* LEA computes the effective address with
effective address = second AREG + sign_ext(off16);
first AREG = EA[31:0];

The thing I don't understand here is the addition of 0x8000 in
the MOVH instruction before shifting. Why is this done? If the
16th bit is already 1 in the value of absolute address, then
the addition would also modify the most-significant 16 bits.

Regards,
Tim
.



Relevant Pages

  • Re: Address computation
    ... the ISA of my processor can handle immediate operands of max. ... most-significant half-word of AREG and set the least-significant ... the MOVH instruction before shifting. ... 16th bit is already 1 in the value of absolute address, ...
    (alt.lang.asm)
  • Re: Address computation
    ... the ISA of my processor can handle immediate operands of max. ... most-significant half-word of AREG and set the least-significant ... the MOVH instruction before shifting. ... 16th bit is already 1 in the value of absolute address, ...
    (alt.lang.asm)