public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* ARM interrupts
@ 2003-01-22 18:22 Eric de Jong
  2003-01-22 18:46 ` Richard Earnshaw
  2003-01-23 18:08 ` Nick Clifton
  0 siblings, 2 replies; 7+ messages in thread
From: Eric de Jong @ 2003-01-22 18:22 UTC (permalink / raw)
  To: gcc; +Cc: ericdejong

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-01-26 15:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-22 18:22 ARM interrupts Eric de Jong
2003-01-22 18:46 ` Richard Earnshaw
2003-01-23 18:08 ` Nick Clifton
2003-01-23 18:25   ` Richard Earnshaw
2003-01-23 18:30     ` Richard Earnshaw
2003-01-26 20:28     ` Nick Clifton
2003-01-26 20:31     ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).