[Top][All Lists]

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

[avr-gcc-list] Double Warnings

From: User Tomdean
Subject: [avr-gcc-list] Double Warnings
Date: Fri, 2 Sep 2005 20:42:36 -0700 (PDT)

I want to force the use of X and Z with global variables.  These two
variables are ONLY used to handle a ring buffer.  I need to minimize
the code size.

register uint8_t *HEAD asm ("r30");  /* Z */
register uint8_t *TAIL asm ("r28");  /* X */

and, in an interrupt handler,

void SIG_ADC (void) __attribute__ ((naked));
void SIG_ADC (void) {
  register uint8_t tmp;
  register uint8_t HEAD_hi asm ("r31");
   * Added the if(...) for stack limit and turn on all LED's for testing.
   * If this runs for a while without error, take out the if {...}
  tmp = SREG;
  *HEAD++ = ADCH;
  if (HEAD_hi > 0x03) {
        HEAD = (uint8_t *)0x0100;
   * the buffer MAY be full, depending if the UMP2 can accept a
   * byte within the next 6.4 uSec.  Anyway, we NEVER want to get this
   * close to being full.
  if (HEAD == TAIL) { TRACE_ON(7); lost_count ++; }
  SREG = tmp;

But, avr-objdump shows

0000011c <__vector_14>:
 11c:   3f b7           in      r19, 0x3f       ; 63
 11e:   25 b1           in      r18, 0x05       ; 5
 120:   df 01           movw    r26, r30
 122:   2d 93           st      X+, r18
 124:   fd 01           movw    r30, r26
 126:   f4 30           cpi     r31, 0x04       ; 4
 128:   10 f0           brcs    .+4             ; 0x12e <__vector_14+0x12>
 12a:   e0 e0           ldi     r30, 0x00       ; 0
 12c:   f1 e0           ldi     r31, 0x01       ; 1
 12e:   ec 17           cp      r30, r28
 130:   fd 07           cpc     r31, r29
 132:   19 f4           brne    .+6             ; 0x13a <__vector_14+0x1e>
 134:   97 9a           sbi     0x12, 7 ; 18
 136:   0f 5f           subi    r16, 0xFF       ; 255
 138:   1f 4f           sbci    r17, 0xFF       ; 255
 13a:   3f bf           out     0x3f, r19       ; 63
 13c:   18 95           reti

So, Z is moved to X and X is used in the auto increment mode, then X
is moved back to Z!.  The use of Y in the main() function is even
worse!  It does not use the auto increment function.

How can I force the compiler to use X, Y, or Z for these global
variables and to use the autoincrement mode?


reply via email to

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