This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ARM interrupts


Hello,

When I compile the following c program:

void at91_default_irq_handler() __attribute__
((interrupt ("FIQ")));

void at91_default_irq_handler()
{
}

Then I get the following assembly code:

entry code:
1) str ip, [sp, #-4]!
2) mov ip, sp
3) sub lr, lr, #4
4) stmfd sp!, {fp, ip, lr, pc}
5) sub fp, ip, #4
... (user code)

exit code:
6) ldmea fp, {fp, ip, pc}^

Explanation:
ip = r12
fp = r11 (frame pointer)
sp = r13 (spack pointer, banked = free register for
irq)
lr = r14 (return addres + 4)
pc = r15 = program counter

When an interrupt occurs, 
1) ip is pushed on the private stack
2) sp is copied to ip
3) lr (return address) is adjusted (arm dependend)
4) pc, lr, ip, fp are pushed on the stack in that
order
5) fp = ip - 4 (points to org. sp - 8)

6) values are read from stack, where (see point 4)
pc = lr (return address, arm equvalent for return)
ip = ip
fp = fp
(cpsr is restored, the status flags before the
interrupt)

What I see is, that:
1) sp is never restored, there still are 5 long words
on the private stack
2) ip is never restored, it contains sp+4 (from point
2)

Who can explain this?

Eric de Jong
The Netherlands

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]