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

How to write interrupt function in assembly in keilc51?

I want to write the interrupt routines in assembly ,i don't want to use inline assembly.

Parents
  • A couple more tips:

    Keep your interrupt vectors and servicing routines in a separate source file (e.g. "IRQ.A51") to save yourself some work.

    Also, in Jon's code he did not explicitly show you that the service routines are typically placed in a relocatable segment, not an absolute segment. (And if your interrupt service routine is less than 8 bytes, you do not need the LJMP!)

    So, showing the segment declarations...

    IRQ_procs segment code
    
    cseg at vector_address1
        ljmp irq_name1
    .
    cseg at vector_address2.
        ljmp irq_name2
    .
    
    rseg IRQ_procs
    
    irq_name1:
        isr_code
        .
        .
        reti
    
    irq_name2:
    .
    .
    .
    

Reply
  • A couple more tips:

    Keep your interrupt vectors and servicing routines in a separate source file (e.g. "IRQ.A51") to save yourself some work.

    Also, in Jon's code he did not explicitly show you that the service routines are typically placed in a relocatable segment, not an absolute segment. (And if your interrupt service routine is less than 8 bytes, you do not need the LJMP!)

    So, showing the segment declarations...

    IRQ_procs segment code
    
    cseg at vector_address1
        ljmp irq_name1
    .
    cseg at vector_address2.
        ljmp irq_name2
    .
    
    rseg IRQ_procs
    
    irq_name1:
        isr_code
        .
        .
        reti
    
    irq_name2:
    .
    .
    .
    

Children