gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > how to enable crt0.s interrupts in devkitadv r5b3

#25202 - subatomic - Wed Aug 18, 2004 1:37 pm

I see on other tutorial sites that I have to modify a crt0.s to enable interrupts. In devkitadvance I see a directory called crtls that has the one copy of crt0.s and a makefile. anyone know what I have to do to compile this for interrupts? the doc file is empty for crtls, and the config-crt0.h seems to have an INI_INTR_VECT set to default already...

Basically my code links with or without the interrupt function table, so that tells me that it isn't enabled in crt0.s... I did try to recompile crt0.s, and I did try hooking up the iterrupt table, setting the flags, etc... as outlined at the pern project tutorial...

I'm pretty sure I didn't know what to change in crt0.s, so this is probably where the error lies...


thanks
-kevin


ps.. (I compile (and link) my game with g++ file1.cpp file2.cpp ... filen.cpp and without any special flags or anything...

Does anyone have a link to documentation or some advice on how to add interrupt support to my project that compiles with devkitadvance? It's all C++ by the way in case that matters...)

#25212 - col - Wed Aug 18, 2004 9:20 pm

Interrupt handling was removed from the crt0 in r5b3 - iirc, the reasoning was that crt0 is not the correct place for Interrupt service - as interrupts have nothing do with c or c++ language implementation.

What you can do is cut'n'paste the interrupt handler from Jeff Frohweins crt0 into a seperate .s file e.g. 'interrupts.s'

Then assemble and link that in with the rest of your project ..

At the top of your your new .s file you'll need to put the routine in iwram, export intr_main, import IntrTable...
Code:

    .SECTION    .iwram,"ax",%progbits
    .EXTERN     IntrTable
    .GLOBAL     intr_main
    .ALIGN
    .ARM


somewhere in your project code you will need to tell the hardware where the handler is - a good place is near the start of main... somthing like:

Code:

*(u32 *)0x03fffffc = (u32)intr_main;


I hope this is enough to get you started :)

cheers

col

#25252 - subatomic - Thu Aug 19, 2004 2:58 pm

awsome reply. thanks!. searching around. I also saw this implementation in the tonc library which seems to work pretty well (and an awsome explaination)...

http://user.chem.tue.nl/jakvijn/tonc/interrupts.htm


With this and your reply above, it's good to finally understand the background of why crt0 wasn't working for me with interrupts... good to know the back story for sure.
_________________
---
http://www.subatomicglue.com