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.

ASM > Using assembly labels as C variables

#17603 - poslundc - Thu Mar 11, 2004 12:57 am

In order to improve the performance of an ISR I am attempting to use space local to the ISR as my global variables, then accessing those variables from C. Here is what I'm trying to do:

Code:
   .global   InterruptHandler, JumpRoutine

InterruptHandler:
   blah blah ISR code
   bx      lr

JumpRoutine:
   .space   4


... That's my ASM file. The code all goes into IWRAM and is properly aligned. Then in C code:

Code:
extern u32   *JumpRoutine;

void ISR_EnableHBlank(void)
{
   ... code ...

   *JumpRoutine = (u32)MyHBlankFunction;
}


By all rights, this should work, but for some reason it generates a "segmentation fault" on linking. (Something which I haven't run into since the days when I was accessing invalid array members in my Unix terminal programs... and that was always at run-time only!)

I've tried a few variations on my syntax but to no avail. Does anyone know how to do this?

Thanks,

Dan.

#17609 - poslundc - Thu Mar 11, 2004 2:07 am

Blargh, it wasn't the technique at all, it was a misnamed function... >:P

Dan.

#17619 - sajiimori - Thu Mar 11, 2004 5:30 am

You might still report the error to the linker dev team. If it's not a distribution or OS issue, it is surely a linker bug.

#17628 - poslundc - Thu Mar 11, 2004 2:55 pm

I'm only using version 3.0.4 of gcc anyway, so it is probably not worthwhile to report a bug in an outdated version.

Dan.