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

Can keil optimize the interrupt routines?

When I set optimize(9,size) to a interrupt function, which should be optimize for "Common Block Subroutines", but it wasn't!
All interrupt funtions contain following duplicate blocks(see BOLD):


    PUSH    ACC
    PUSH    B
    PUSH    DPH
    PUSH    DPL
    PUSH    DPH1
    PUSH    DPL1
    PUSH    DPS
    MOV     DPS,#00H
    PUSH    PSW


    MOV     PSW,#010H ;Depend on using.
    LCALL   MyFunc


    POP     PSW
    POP     DPS
    POP     DPL1
    POP     DPH1
    POP     DPL
    POP     DPH
    POP     B
    POP     ACC
    RETI


Because I have so many interrupt functions. The optimize could save some code space, isn't it?

Parents
  • Funtionally, you are quite right - no reason why what you suggest will not work. However, interrupts are generally time critical so it may be that the optimiser leaves this bit of common code alone for the sake of speed.

    By-the-way, if you do have many interrupts, you may get better performance by turning off dual data pointers. memcpy() etc will run a little slower, but interrupts willl have fewer registers to save/restore.

Reply
  • Funtionally, you are quite right - no reason why what you suggest will not work. However, interrupts are generally time critical so it may be that the optimiser leaves this bit of common code alone for the sake of speed.

    By-the-way, if you do have many interrupts, you may get better performance by turning off dual data pointers. memcpy() etc will run a little slower, but interrupts willl have fewer registers to save/restore.

Children
  • The optimize could save some code space, isn't it?
    I believe that if you made my_func inline the optimizer would have a better idea of what to save. E.g if my_func uses the dptr it must be saved, if not no need, but with a call it is probablyu more that the optimizer can handle to figure out if dptr is used..

    Erik