This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


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

Re: IRQ on M68K


> I remember, there was once discussion about topic IRQ in M68K,
> but at that time the case was calling IRQ routine in C from
> assembler code. On my case I need to call IRQ routine in C from
> C main program. I add an "interrupt" attribute to function 
> typing, but GCC doesn't recognize such kind of syntax.
> Can anybody share with me how to do that??

To my knowledge it isn't possible to write interrupt routines with
the GNU compiler, so the only possible solution to that problem is
writing a small assembly routine that pushes all registers onto the
stack, calls the C routine, pops all registers back from stack and
returns with an RTE instruction. The actual interrupt handler is
then coded in C and called from this little assembly stub.

Example:

IrqAsm:  movem.l %d0-%d7/%a0-%a6,-(%a7)
         jsr     handleInterrupt
         movem.l (%a7)+,%d0-%d7/%a0-%a6
         rte

void handleInterrupt ( void )
{
  ...
}

Of course you can now call handleInterrupt() directly from your main
C program, as long as you don't expect any reentrance problems (remember
that if you call the handler from your main program, it might be called
by a "real" interrupt at the same time).

Best regards,
Juergen
-------------------------------------------------------------------------
Juergen Suessmaier
Texas Instruments Deutschland         EMail:
Automation Software Group             juergen@ti.com
Haggertystr 1                         juergen@jss01.ntakpe.com
D-85356 Freising, Germany             Juergen.Suessmaier@FernUni-Hagen.de
-------------------------------------------------------------------------

________________________________________________
To get help for the crossgcc list, send mail to
crossgcc-request@cygnus.com with the text 'help'
(without the quotes) in the body of the message.