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

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

[avr-gcc-list] 8-bit return values again


From: Dusan Ferbas
Subject: [avr-gcc-list] 8-bit return values again
Date: Wed, 26 Sep 2007 00:13:13 +0200

Hi guys,

when I searched this list for "8-bit return values", I found 2 threads. Described snippets seems to me more about switch/case & _expression_ optimization:
http://lists.gnu.org/archive/html/avr-gcc-list/2003-06/msg00000.html
http://lists.gnu.org/archive/html/avr-gcc-list/2003-06/msg00005.html

------------------
I want to solve case, when a function is declared as u_char(char, int8, etc.). It is compiled in a way, that it returns a value in the R24,R25 register pair. This is true not only with literals (see example below), but also with byte variables. R25 value is never used in a calling code (see assembler listing below).

Any idea ? Any plans for resolving this ?

typedef   signed char   s_rslt;
...
s_rslt next_inpIndex(long *IndexValue)
{
  if (*IndexValue < BIN_NUM_OF_INPUTS)
  {
    (*IndexValue)++;
    return (s_rslt)1;
  }
  else
    return (s_rslt)0;
}

---
        ldi r24,lo8(1)
        ldi r25,hi8(1)
         ret
.L7:
        ldi r24,lo8(0)
        ldi r25,hi8(0)
         ret
...
        call next_inpIndex
        tst r24                            //No test of R25 in calling code
        brne .+2

Dusan


reply via email to

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