This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/17098] New: Calling an absolute address fails on AVRs smaller than 16kB Flash
- From: "danni at specs dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Aug 2004 12:35:48 -0000
- Subject: [Bug c/17098] New: Calling an absolute address fails on AVRs smaller than 16kB Flash
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The cast of a number to a function:
((void(*)(void))0)();
works right for the ATMega16 and bigger, but wrong for all smaller AVRs, e.g.
ATMega8.
Listing ATMega16:
0000008e <main>:
int main( void )
{
8e: cf e5 ldi r28, 0x5F ; 95
90: d4 e0 ldi r29, 0x04 ; 4
92: de bf out 0x3e, r29 ; 62
94: cd bf out 0x3d, r28 ; 61
for(;;){
((void(*)(void))0)();
96: 0e 94 00 00 call 0x0
9a: fd cf rjmp .-6 ; 0x96
Listing ATMega8:
0000005c <main>:
int main( void )
{
5c: cf e5 ldi r28, 0x5F ; 95
5e: d4 e0 ldi r29, 0x04 ; 4
60: de bf out 0x3e, r29 ; 62
62: cd bf out 0x3d, r28 ; 61
for(;;){
((void(*)(void))0)();
64: fb df rcall .-10 ; 0x5c |<--- must be 0x00 !
66: fe cf rjmp .-4 ; 0x64
Mr. Jörg Wunsch assumed, there is a fault in the assembler and thus the rcall
and rjmp instructions are wrong for absolute destignation addresses.
But the jmp and call instructions are correct for absolute destignation addresses.
Beside this, I have detected a second fault in the assembler:
The ATmega8 support jmp and call like the ATMega16. But on using jmp and call
with inline assembler it was reported as:
Error: illegal opcode jmp for mcu atmega8
My GCC:
Reading specs from C:\AVR\WINAVR\BIN\..\lib\gcc-lib\avr\3.3.2\specs
Configured with: ../gcc-3.3.2/configure --prefix=e:/avrdev/install --host=mingw3
2 --build=mingw32 --target=avr --enable-languages=c,c++
Thread model: single
gcc version 3.3.2
Best regards,
Peter Dannegger
--
Summary: Calling an absolute address fails on AVRs smaller than
16kB Flash
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: danni at specs dot de
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17098