If a little bit more complex interrupt function is required the compiler genrates wrong code (olny with -O flag set).
Compiler generats: sub lr, lr, #4 stmfd sp!, {r.., lr} . . . ldmfd sp!, {r.., lr} subs pc, lr, #4 Here the LR is decremented one time too mutch. Ether first or the second "sub" is wrong. It should be: sub lr, lr, #4 stmfd sp!, {r.., lr} . . . ldmfd sp!, {r.., lr}^ (the last '^' is important) P.S. Since I can't add any attachments now. I'll try this after 'commit'. -- Summary: arm-elf-gcc generating wrong code with -O flag at functions with __attribute__ ((interrupt ("IRQ"))) Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: th dot r dot klein at web dot de GCC host triplet: i386-freebds-elf GCC target triplet: arm-unknown-elf http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25428