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: May need to update avr-as [Was: [Solved] GAS: Register equates ?]


On 18.05.13 18:54, Jens Bauer wrote:
> Hi Erik.
> 
> Are you sure this works ?
> 
> Try using the register...

Ahhh ... err, let's check a little more thoroughly. The example didn't
actually try it as a register. First, directly confirming Andreas'
observation:

   ldi 17,42      ; = r17 , immediate value.

produces this in the objdump:

 154: 1a e2          ldi   r17, 0x2A   ; 42

So AVR is one of those which accept plain numbers for
registers, thereby allowing (almost) arbitrarily named registers.

But you're right, as this:

   rColor = 17
   ldi rColor,42

generates:

Error: register name or number from 0 to 31 required

The parser grammar apparently wants a recognised register name if it
begins with r/R. (That's what I incorrectly thought had been fixed.)
There is an unintrusive workaround, at the cost of an extra keystroke:

   _rColor = 17
   ldi _rColor,42

That does produce the same result, shown by objdump. 

It would take a lexer tweak to do better than that, I figure.
(One unlikely to be favoured for a multi-target assembler, I'm
guessing.)

Looking more closely at the:

   .equ r0, 0
   ...
   .equ r31, 31

in the include file I've used for many years, I realise that they are
not being used in simple assembler commands, but I needed them
"To allow (r16, r16+1) in macros". (I had convinced myself that they
were effective in more than the macro invocations. :(

That just leaves the question whether _rColor is close enough for your
use case?

mÃjn,

Erik

-- 
Wizards had always known that the act of observation changed the thing that
was observed, and sometimes forgot that it also changed the observer too.
                                   Terry Pratchett  -  Interesting times


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