We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
Sorry, I forgot reponse to Graham. 1. I did tell the compiler my wish: optimize(9,size). Maybe it's keil's policy for interrupt function as you mention. 2. Since my chip support dual pointer, and keil's documents said it will improve the performance of may library functions, so I use it! In fact, I will use NOMODDP2 on those ISR functions (I have verify those ISRs won't call any improved functions), then, the extra code will be "PUSH DPS, and MOVE DPS,#0" which takes only 5 machin cycles. The extra latency is fine for my project.
"keil's documents said it will improve the performance of may [many?] library functions" Actually, the manual says, "Using additional data pointers can improve the performance of the following library functions: memcpy, memmove, memcmp, strcpy, and strcmp." (my ephasis). So that's only five library functions, and no guarantee that it will actually help! You need to examine whether any improvement in these few library functions is actually worthwhile in your application, considering the impact of the extra saves on your interrupt performance - which seems, from your post, to be your major concern?