Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly Language > Re: Address com...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 4983 of 5163
Post > Topic >>

Re: Address computation

by Phil Carmody <thefatphil_demunged@[EMAIL PROTECTED] > Apr 29, 2008 at 03:03 PM

[Superseding prior response, typo in example.]

Tim Frink <plfriko@[EMAIL PROTECTED]
> writes:
> 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 ****fting. 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.

If bit 15 (value 8000) is 1, then sign extension would add 
ffff0000, which is subtracting 10000. So you need to add
1 to the value loaded into the top 16 bits to ensure it's 
10000 higher.

Just try it with the example 00008000 to see why it works.

Phil
-- 
Dear aunt, let's set so double the killer delete select all.
-- Microsoft voice recognition live demonstration
 




 3 Posts in Topic:
Address computation
Tim Frink <plfriko@[EM  2008-04-29 10:15:53 
Re: Address computation
Phil Carmody <thefatph  2008-04-29 14:03:59 
Re: Address computation
Phil Carmody <thefatph  2008-04-29 15:03:22 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 18:17:48 CDT 2008.