This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Addi on the AVR micro
- To: jhuntnz at users dot sourceforge dot net
- Subject: Re: Addi on the AVR micro
- From: Denis Chertykov <denisc at overta dot ru>
- Date: 13 May 2001 11:57:56 +0400
- Cc: Denis Chertykov <denisc at overta dot ru>, binutils at sources dot redhat dot com
- References: <01051016531400.01268@bobbafett> <4rurdn3n.fsf@localhost.localdomain> <01051313144000.01599@bobbafett>
Jonathan Hunt <jhuntnz@users.sourceforge.net> writes:
> On Saturday 12 May 2001 15:48, you wrote:
> > Jonathan Hunt <jhuntnz@users.sourceforge.net> writes:
> > > Hi,
> > >
> > > The AVR has an instruction subi (subtract immediate) but no addi. So I
> > > use subi reg, -(num) to add immediate. However this poses a problem when
> > > you try and do it with a memory address like this:
> > >
> > > .data
> > > .org 0x00
> > > __X_60:
> > > mema: ; Real address is 0x60, offset address is 0x00
> > >
> > > .text
> > > subi r16, -mema ; Generates an error
> > > subi r16, 0x100 - mema ; Generates an error
> > > subi r16, !mema + 1 ; Uses the offset address of mema for
> > > the ! which makes
> > > ; it incorrrect
> > > ; The only work around I have found
> > > subi r16, lo8(__X_60_ + (0xff - 0x60) - mema)
> >
> > Use "subi r16, lo8(-(mema))"
> >
> > Denis.
>
> Thanks for the help but...
>
> After all that I find out if I'd just have put brackets around the address it
> would have work -- aargh!!! But why? Why does it require brackets? Is it
> intentional?
It's because I wrote a bad syntax parser for the avr-as.
Denis.