Addi on the AVR micro
Denis Chertykov
denisc@overta.ru
Sun May 13 01:05:00 GMT 2001
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.
More information about the Binutils
mailing list