avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] It is more than: .byte SYMA - SYMB


From: Erik Christiansen
Subject: Re: [avr-gcc-list] It is more than: .byte SYMA - SYMB
Date: Mon, 15 Sep 2003 19:19:50 +1000
User-agent: Mutt/1.3.28i

On Mon, Sep 15, 2003 at 09:30:52AM +0200, Joerg Wunsch wrote:
> If not, i'm confused, since as far as i can tell, in the above,
> d - c is an assembly-time constant expression.

Jörg, that makes two of us! (Though I'm still wading through the gas
gumpf)

To avoid any variability due to .align issues, a simpler and more sorely
needed case shows the same behaviour, regardless of how we sneak up on
the offset:

   .section .bss,"a"
   .org 0
aa: .space 32
bb:

   offset = bb - aa

  .section .text,"ax",@progbits
   ldi   YH,hi8(aa)
   ldi   YL,lo8(aa)
   ldd   r16,Y+offset   <- Error: constant value required

   adiw  Y,offset       <- Error: constant value required

c: ldi   r16,offset     <- Warning: expression possibly out of 8-bit range
   add   YL,r16

d: ldi   r16,pm_lo8(d-c)   <- But this one is OK

Now both the differences are similarly nailed down, I think. (Even if the
.org is redundant here.)

The most obviously useful application of this avr addressing mode appears to be
fixed indexing into data structs. If the assembler accepts that a codespace
offset is constant enough to use as an immediate data operand, how does it lose
that attribute when the offset is in another section?

In the gas "info" I read: [
   In fact, every address `as' ever uses is expressed as
     (SECTION) + (OFFSET INTO SECTION)
]

If (SECTION + OFFSET_bb) - (SECTION + OFFSET_aa) is equal to
              OFFSET_bb  - OFFSET_aa

then that's still a constant, and gas has the data required for it to
treat it as such, doesn't it? (Now, what's the smiley that combines a
puzzled frown with a wry grimace?)

Regards,
Erik




reply via email to

[Prev in Thread] Current Thread [Next in Thread]