This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Addressing functions in avr-as


On Jun 9, 2010, at 2:57 PM, Johannes Bauer wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hello list,
> 
> I'm unsure if this is the correct list, if not please hint me to the
> right place.
> 
> I have some trouble with macros on avr-as. Let's say I have the
> following code:
> 
> 
> .macro mangleAddress addr
> 	ldi r16, ((\addr) & 0x0000ff) >> 0
> 	ldi r17, ((\addr) & 0x00ff00) >> 8
> 	ldi r18, ((\addr) & 0xff0000) >> 16
> .endm
> 
> Then I'm able to use it in the following fashion:
> 
> mangleAddress 123456
> 
> Which results in the expected:
> 
> 0:       00 e4           ldi     r16, 0x40       ; 64
> 2:       12 ee           ldi     r17, 0xE2       ; 226
> 4:       21 e0           ldi     r18, 0x01       ; 1
> 
> Also, this works, too (compiles and links fine):
> 
> jmp foobar
> 
> However, what does not is
> 
> mangeAddress foobar
> 
> Where I'd like the linker to resolve the address and then enter them
> into the macro as above. How can I achieve something like that?

Hi,

this is expected.  You mustn't arithmetic like '(addr & 0xff00) >> 8', instead you need to specify the relocation
to use, such as pm_hh8, pm_hi8 and pm_lo8.

Tristan.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]