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

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

[avr-gcc-list] Re: Wierd Calls.


From: David Brown
Subject: [avr-gcc-list] Re: Wierd Calls.
Date: Tue, 10 Mar 2009 19:44:56 +0100
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)

As I've told you before, if you think there is something odd about the generated assembly code, no one can give you more than very general guesses unless you post a minimal compilable code snippet.

At first glance, I agree with Eric - I think you probably have a mixup between word addresses and byte addresses and the generated code is correct (i.e., the call is to *byte* address 0x62c, while the lcd_init routine is at *word* address 0x62c). gcc likes to think in terms of byte addresses, while avr studio (I'm guessing that's what you are using) will probably show things in flash with word addresses.

As well as the assembly files listing suggested by Eric, generate a map file and look at that - it might give you a clue.

mvh.,

David


David VanHorn wrote:
I'm probably doing something wrong again..
I've seen this on and off, as I'm stepping through the compiled code in the asm window. I will have a call that makes no sense to me, sort of randomly appearing as I change the code, and dissapearing for no obvious reason. It's always to the lcd_init routine, even though this code has nothing to do with the LCD... Below is where it's currently happening.
This SHOULD just load BIN with a value between 0 and 31.
It has to pull data from Raw_Data[0] according to the value of Raw_Data_Index which will be between 0 and 511. Raw_Samples is 512, and Sample_Bins is 32. 1051: Bin = (Raw_Data[0][Raw_Data_Index]) / (Raw_Samples / Sample_Bins); // Find the bin for the old raw data +0000031B: 90C00076 LDS R12,0x0076 Load direct from data space +0000031D: 90D00077 LDS R13,0x0077 Load direct from data space
+0000031F:   01F6        MOVW      R30,R12        Copy register pair
+00000320:   53EC        SUBI      R30,0x3C       Subtract immediate
+00000321: 4FFF SBCI R31,0xFF Subtract immediate with carry +00000322: 8180 LDD R24,Z+0 Load indirect with displacement
+00000323:   E06F        LDI       R22,0x0F       Load immediate
+00000324:   940E062C    CALL      0x0000062C     Call subroutine
+00000326:   2FA8        MOV       R26,R24        Copy register
+00000327:   E0B0        LDI       R27,0x00       Load immediate
I don't understand why it's calling the LCD routine..
609: }/* lcd_init */
+0000062C:   1B99        SUB       R25,R25        Subtract without carry
+0000062D:   E079        LDI       R23,0x09       Load immediate
+0000062E:   C004        RJMP      PC+0x0005      Relative jump
+0000062F:   1F99        ROL       R25            Rotate Left Through Carry
+00000630:   1796        CP        R25,R22        Compare
+00000631:   F008        BRCS      PC+0x02        Branch if carry set






reply via email to

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