[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] GCC Functions
From: |
Joerg Wunsch |
Subject: |
Re: [avr-gcc-list] GCC Functions |
Date: |
Wed, 28 Nov 2001 16:19:54 +0100 |
User-agent: |
Mutt/1.2.5i |
As Patrick Lanphier wrote:
> Well the lights do not turn on when using the function when they do with
> the simple assignment statement.
They would even turn on without the assignment statement. ;-)
Again, the generated code looks OK. If this is actually your entire
program, something in your AVR must be broken. The only other option
is that something is wrong with the stack (in which case the function
call would never return), but normally, the framework of avr-gcc
handles the stack initialization etc. automatically. (If you look
into the generated assembler code, you can easily spot this.)
You can easily verify the result by running "avr-objdump --disassemble
demo1.elf":
Disassembly of section .text:
00000000 <.__start_of_init__>:
0: 0a c0 rjmp .+20 ; 0x16
...
0000004a <led1>:
4a: cf 93 push r28
4c: df 93 push r29
4e: cd b7 in r28, 0x3d ; 61
50: de b7 in r29, 0x3e ; 62
52: 10 92 60 00 sts 0x0060, r1
56: df 91 pop r29
58: cf 91 pop r28
5a: 08 95 ret
Register r1 contains always the constant 0 in avr-gcc.
The variable at 0x60 is "ledlight".
Note that all the fiddling with the frame pointer in r28/r29
is moot; if you use -O2, avr-gcc omits it.
0000005c <main>:
5c: cf ed ldi r28, 0xDF ; 223
5e: d0 e0 ldi r29, 0x00 ; 0
60: de bf out 0x3e, r29 ; 62
62: cd bf out 0x3d, r28 ; 61
This is the initialization of the stack pointer, pointing to the top
of RAM. avr-gcc always generates code for a 16-bit stack pointer,
although the '2313 only uses the lower stack pointer (register 0x3d).
Obviously :), there should be no program variables located at the top
of RAM.
64: 8f ef ldi r24, 0xFF ; 255
66: 87 bb out 0x17, r24 ; 23
68: 8f ef ldi r24, 0xFF ; 255
6a: 88 bb out 0x18, r24 ; 24
These are the outputs to DDRB and PORTB.
6c: ee df rcall .-36 ; 0x4a
The call to led1().
6e: 10 92 60 00 sts 0x0060, r1
The same as inline code inside main().
72: 80 91 60 00 lds r24, 0x0060
76: 88 bb out 0x18, r24 ; 24
78: fc cf rjmp .-8 ; 0x72
Your loop.
--
J"org Wunsch Unix support engineer
address@hidden http://www.interface-systems.de/~j/