m68k & Interrupts

Art Berggreen art@acc.com
Mon Sep 14 08:46:00 GMT 1998


>Hi ho,
>I would like to have some suggestions about the dealings with
>interrupts  under gcc.
>I am new to gcc, so please be patient and start with Adam & Eva 8-)! 
>(Formerly, I used hitech tools which support a special function type for
>interrupts.)
>
>What is the best way to handle the interrupt service routines? I really
>do not mean assembler for the interrupt routines itself ;-)!
>
>One possible solution. that I can think of, is to use somekind of a
>wrapper function written in assembler, which one and only function is to
>call the actual c-function.
>


Unless GCC is extended to add an "interrupt" attribute to function
typing, I believe that a small bit of assembler to save volatile
registers, jsr to a C function, then restore registers and execute
an RTE is the cleanest way to go.

Something on the order of:

	.extern	c_function
	.global	intr_rtn

	.section .text
intr_rtn:
	movem.l	%d0-%d1/%a0-%a1,-(%sp)
	jsr	c_function
	movem.l (%sp)+,%d0-%d1/%a0-%a1
	rte

You may also want to consider things like switching to an interrupt
stack and then restoring before returning.  You may also want to push
some argument onto the stack before calling the C function (just
make sure to clean up the stack properly after the call returns).

Art




More information about the crossgcc mailing list