Rv: [Tinyos-help] AVR GCC compiler problems

José Moyano josehmoyano at yahoo.com.ar
Fri Feb 29 13:00:19 PST 2008

Below this words, there is the last mail that I sent to tinyos-help. Check the last two "push" at address 00000A4A and 00000A4B. The pushed registers, shouldn't be R18 and R19 instead of R28 and R29? I'm using AT90CAN128, and TinyOS 1.1

----- Mensaje reenviado ----
De: José Moyano <josehmoyano at yahoo.com.ar>
Para: tinyos-help at Millennium.Berkeley.EDU
Enviado: jueves 28 de febrero de 2008, 15:35:43
Asunto: Re: [Tinyos-help] AVR GCC compiler problems

Thanks you all for your help. I check the "app.c", and is ok. Later, I load "main.ihex" with AVR Studio, copy it to notepad, and find the problematic routine code.

+00000A3C:   924F        PUSH    R4               Push register on stack [CPSCAN]
+00000A3D:   925F        PUSH    R5               Push register on stack
+00000A3E:   926F        PUSH    R6               Push register on stack
+00000A3F:   927F        PUSH    R7               Push register on
+00000A40:   928F        PUSH    R8               Push register on stack
+00000A41:   929F        PUSH    R9               Push register on stack
+00000A42:   92AF       
 PUSH    R10              Push register on stack
+00000A43:   92BF        PUSH    R11              Push register on stack
+00000A44:   92CF        PUSH    R12              Push register on stack
+00000A45:   92DF        PUSH    R13              Push register on stack
+00000A46:   92EF        PUSH    R14              Push register on stack
+00000A47:   92FF        PUSH    R15              Push register on stack
+00000A48:   930F        PUSH    R16              Push register on stack
+00000A49:   931F        PUSH    R17              Push register on stack
+00000A4A:   93CF        PUSH   
 R28              Push register on stack
+00000A4B:   93DF        PUSH    R29              Push register on stack
The parameters are saved here for the first call.
+00000A4C:   2E58        MOV    
 R5,R24           Copy register
+00000A4D:   014A        MOVW    R8,R20           Copy register pair
+00000A4E:   015B        MOVW    R10,R22          Copy register pair
 0168        MOVW    R12,R16          Copy register pair
+00000A50:   0179        MOVW    R14,R18          Copy register pair
if (call CANReceive.setReceive[channel](id, mask)) {
+00000A51:   940E0B1A    CALL    0x00000B1A      
 Call subroutine <<<<<<<<<<< The first call
+00000A53:   2388        TST     R24              Test for Zero or Minus
+00000A54:   F409        BRNE    PC+0x02          Branch if not equal
+00000A55:   C0B0        RJMP    PC+0x00B1        Relative jump
+00000A56:   0000        NOP                      No operation
+00000A57:   0000        NOP                      No operation
+00000A58:   0000        NOP                      No operation
+00000A59:   0000        NOP                      No operation
+00000A5A:   0000       
 NOP                      No operation
+00000A5B:   0000        NOP                      No operation
+00000A5C:   0000        NOP                      No operation
+00000A5D:   0000        NOP                      No operation
+00000A5E:   0000        NOP                      No operation
+00000A5F:   0000       
 NOP                      No operation
+00000A60:   0000        NOP                      No operation
+00000A61:   0000        NOP                      No operation
+00000A62:   E087        LDI     R24,0x07         Load immediate
+00000A63:   2E48        MOV     R4,R24           Copy register
+00000A64:   0C45        ADD     R4,R5            Add without carry
The parameters are restored here, for the second call
+00000A65:   01B5        MOVW    R22,R10          Copy register pair
+00000A66:   01A4        MOVW    R20,R8           Copy register pair
+00000A67:   2D84        MOV    
 R24,R4           Copy register
call CANReceive.setReceive[channel + 7](id, mask);
+00000A68:   940E0B1A    CALL    0x00000B1A       Call subroutine <<<<<<<<<<< The second call

As you can see, in the second call, r20, r22 and r24 are reloaded, but r18 and r16 are not. So one of my 32-bit parameters isn't reloaded. In the called routine, r18 and r19 are used, but not saved in stack, so r18 and r19 change their value. I don't know if this is an error, is it? Can I avoid this behavior somehow?

    command result_t CPSSetReceive.setReceive[uint8_t channel](uint32_t id, uint32_t mask) {
        if (call CANReceive.setReceive[channel](id, mask)) {
            if (channel == 3)
                if (mask != CAN_DEFAULT_MASK)
                    call Leds.yellowOff();
            call CANReceive.setReceive[channel + 7](id, mask);

Tarjeta de crédito Yahoo! de Banco Supervielle.Solicitá tu nueva Tarjeta de crédito. De tu PC directo a tu casa. 
 Visitá www.tuprimeratarjeta.com.ar

      Los referentes más importantes en compra/ venta de autos se juntaron:
Demotores y Yahoo!
Ahora comprar o vender tu auto es más fácil. Vistá ar.autos.yahoo.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20080229/03e737b5/attachment-0001.htm

More information about the Tinyos-help mailing list