M68K C Interrupt Handler
Peter Barada
pbarada@mail.wm.sps.mot.com
Tue Jan 16 08:14:00 GMT 2001
>Does anyone know how to write m68k interrupt handlers in C? My (possibly
>incorrect/incomplete) understanding of the issues are that:
>(1) Normal function calls generated by the compiler will not work as
>interrupt functions,
>(2) I need to save all registers,
>(3) I can now execute my handler specific C code including any HW specific
>start-of-interrupt and end-of-interrupt processing,
>(4) I need to restore registers,
>(5) I need to do a return from interrupt (rte).
It's trivial to write an interrupt handler in assembler that calls out
to your C interrupt function for the 68k:
ASM_IRQ_handler:
moveml %a0/%a1/%d0/%d1,-(%sp)
jsr C_IRQ_handler
moveml (%sp)+,%a0/%a1/%d0/%d1
rte
You only need to save a0/a1/d0/d1 since all the other registers are
saved/restored by the compiler, and the SR register is already on the
stack from the interrupt itself. Since you mention a straight m68k,
there's no FPU to worry about.
Of course you'll have to determine the syntax that your assembler
understands for movem. I've seen it using as above, and also as:
movm.l #0xyyyy,-(%sp)
where 'yyyy' is the bit mask in the movem instruction. See what your
C compiler cranks out at the start/end of functions for an idea....
--
Peter Barada Peter.Barada@motorola.com
Wizard 781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola) 781-270-0193 (fax)
------
Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
More information about the crossgcc
mailing list