This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

inline assembly

Hi friends,

I am using inline assembly in my ISR routine. When i observe the generated sorce file. AT the start of ISR the compiler generates a code to save the ACC, DPL, DPH etc and the general purpose regi used by routine. Now i want to avoid the generation of code to save device context. I am using a saperate function to save and restore context. I want this becuse i am doing task switching in ISR so the restored context will be different then the saved one. I know that other compiler provides this facility by using control directives like "NAKED". Is there any such directive in KEIL compiler so that i can avoid generation of context save and restore by the compiler?

Thank you,
Dhaval Shah

Parents
  • I'm no assembler expert so this could be hopelessly wrong, but I think it is about as simple as this:

    CSEG AT 3 ;Address of interrupt vector
    JMP ISR

    CSEG AT 100 ;Some fairly arbitrary address within your code space
    ISR:
    ;Your code here
    RETI

    it is, with the caveat: you must save (by push/pop and/or register page change) all registers and flags that are used in the ISR. This is done automatically by the compiler, with the assembler, you are on your own. More "lurking" errors have been caused by assembler ISRs not totally saving what they use ( a classic I remember: using CJNE and not saving the CY) than anything else. Then, of course, we have the calling of subroutines that are also used in the main, I think to recall that the linker catch these when in C, but not when the ISR is in assembler.

    Erik

Reply
  • I'm no assembler expert so this could be hopelessly wrong, but I think it is about as simple as this:

    CSEG AT 3 ;Address of interrupt vector
    JMP ISR

    CSEG AT 100 ;Some fairly arbitrary address within your code space
    ISR:
    ;Your code here
    RETI

    it is, with the caveat: you must save (by push/pop and/or register page change) all registers and flags that are used in the ISR. This is done automatically by the compiler, with the assembler, you are on your own. More "lurking" errors have been caused by assembler ISRs not totally saving what they use ( a classic I remember: using CJNE and not saving the CY) than anything else. Then, of course, we have the calling of subroutines that are also used in the main, I think to recall that the linker catch these when in C, but not when the ISR is in assembler.

    Erik

Children