How to start "C" functions from HCS12 assembler ??

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to start "C" functions from HCS12 assembler ??

4,333 Views
Gizzzmo
Contributor I
Hello,

I would make a "secondary interrupt vector table" on a HCS12E128 in order to modify my "interrupt vectors" on the fly (they are in a protected part of the flash). I've made this "secondary interrupt vector table" with a assembler file and i wanna start "C" functions from this file but i dont find how (with a CALL or a JSR for example).

Gizmo.

P.S:smileyfrustrated:orry for my approximative english, i'm french
Labels (1)
0 Kudos
4 Replies

638 Views
Sten
Contributor IV

If your C functions are ordinary ISR routines (like interrupt void TimerISR(void) ) then you should call them with a plain JMP TimerISR. ISR C-routines are ended with a RTI instruction, and they must be called directly from the interrupt (and they must be in the non-paged area of the memory).

An other way to do it would be that your assembler routine calls ordinary C functions (like void TimerSecISR(void)) with a CALL TimerSecISR (if TimerSecISR is in paged memory) or JSR TimerSecISR (non-paged memory), but then your assembler routine must be aware of that the control will return to it after the routine completes and the RTI must be in the assembler code.

 

0 Kudos

638 Views
Gizzzmo
Contributor I
I've tried this but the assembler file doesn't find my C-routine.

How can I make him find my routine ?

Thx
0 Kudos

638 Views
Sten
Contributor IV
You have to use the XREF directive to tell the assembler that the routines are external. The linker will then take care of inserting the correct addresses into the generated code.
 
0 Kudos

638 Views
Gizzzmo
Contributor I
Thx a lot, it works really well :smileywink:
0 Kudos