This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to mix C and Assembly ISRs?

Hi,

my project has 100% of the interrupt handlers written in asm.  That's the way it's always been done.  Many of these ISRs do call C functions which return back to the asm function.  I've been trying unsuccessfully to eliminate one or more of these asm functions and replace them by 100% C ISRs.  It seems like the majority of people use C ISRs (ie #pragma vector= blah blah).  What's the trick?  How do I de-activate my existing asm code for a particular vector and replace it with a C handler? 

I tried removing the associated code from the .asm file but the compiler says there's a segment conflict for segment INTVEC and that in my .C file there's a segment part of type COMMON while in my .asm file there's a segment part of type RELOCATABLE.  Any help appreciated, thanks!

 

 

  • In my experience ASM vectors are usually declared in a RELOCATABLE segment using directives like DW (for Declare Word) or DC.W (for Declare Constant Word) followed by the label that identifies the ISR entry point.  In your case that segment is the INTVEC segment.

    You need to find the INTVEC segment in your ASM source code.  It will have those assembler directives.  Then delete the one entry for the handler you want to do it pure C.  Replace the entry with an ORG statement if your assembler allows it to move the location counter ahead by 2. ("ORG  $ + 2").  If your assembler doesn't allow ORG in a relocatable segment, then you'll have to create another segment and adjust your linker file.

    Full disclosure - I've never actually tried this.  You may also have to tell your linker that the INTVEC segment allows overlapping with other segments.  Good luck.

    Jeff

**Attention** This is a public forum