Address computation
- From: Tim Frink <plfriko@xxxxxxxx>
- Date: Tue, 29 Apr 2008 10:15:53 +0000 (UTC)
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
.
- Follow-Ups:
- Re: Address computation
- From: Phil Carmody
- Re: Address computation
- From: Phil Carmody
- Re: Address computation
- Prev by Date: Re: Code Profilers suitable for asm applications
- Next by Date: Re: Address computation
- Previous by thread: Code Profilers suitable for asm applications
- Next by thread: Re: Address computation
- Index(es):
Relevant Pages
|