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


Juergen Suessmaier <juergen@ffab.tide.ti.com> wrote:
>To my knowledge it isn't possible to write interrupt routines with
>the GNU compiler,
At least for the M68K.  There are function attributes to define a
function as an interrupt handler for the H8/300 and M32R processors
(I don't know why they use different keywords though).  Feel free
to implement the same for the M68K.

>writing a small assembly routine that pushes all registers onto the
>stack, calls the C routine, pops all registers back from stack
Note that you don't need to save all registers, just those that
aren't saved during a normal function call.  Assuming no FP code
within the interrrupt handler, the following is sufficient:

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

Note that with care, it might be possible to use gcc's asm() directive
to turn a normal function into an interrupt handler.  This approach is
likely to be fairly fragile (ie you'll need to check the generated
assembler to make sure the code is still correct).

>Of course you can now call handleInterrupt() directly from your main
>C program, as long as you don't expect any reentrance problems
This also applies to any functions called within your interrupt handler.
It's worthwhile carefully studying the fine print on any library calls
you make - you definitely don't want to be trying to debug problems
caused by nested calls of non-reentrant functions.

Peter
--
Peter Jeremy (VK2PJ)                    peter.jeremy@alcatel.com.au
Alcatel Australia Limited
41 Mandible St                          Phone: +61 2 9690 5019
ALEXANDRIA  NSW  2015                   Fax:   +61 2 9690 5247
________________________________________________
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.