This is the mail archive of the binutils@sources.redhat.com 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]

Addi on the AVR micro


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)

This is a very messy way off having to do it. I am sure that I am missing 
something but I can't see another way to do it.

Please help,
Thanks,
Jonathan Hunt
Please CC replies to <jhuntnz@users.sourceforge.net> since I'm not on this 
list

-- 
Jonathan Hunt (The Real Jonathan Hunt) <jhuntnz@users.sourceforge.net>
"He is no fool who gives that which he cannot keep to gain that which he 
cannot afford to lose." Jim Elliot


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