下面是一段C程序: #include <stdio.h> int interruptcnt; int second; void timer0 (void) interrupt 1 // 注意没有使用 "using 2" { if (++interruptcnt == 4000) { /* count to 4000 */ second++; /* second counter */ interruptcnt = 0; /* clear int counter */ } }
void main(void) { interruptcnt=0; second=0; printf("I do it in this way !"); } 编译器产生的T0中断的LST文件如下: ; FUNCTION timer0 (BEGIN) 0000 C0E0 PUSH ACC 0002 C0D0 PUSH PSW;!!!!!!!!!!!!!!!!!!!!!!!! 0004 75D000 MOV PSW,#00H;!!!!!!!!!!!!!!!!!!! 0007 C006 PUSH AR6;!!!!!!!!!!!!!!!!!!!!!!!! 0009 C007 PUSH AR7;!!!!!!!!!!!!!!!!!!!!!!!! ; SOURCE LINE # 9 ; SOURCE LINE # 11 000B 0500 R INC interruptcnt+01H 000D E500 R MOV A,interruptcnt+01H 000F 7002 JNZ ?C0004 0011 0500 R INC interruptcnt 0013 ?C0004: 0013 FF MOV R7,A 0014 AE00 R MOV R6,interruptcnt 0016 BE0F11 CJNE R6,#0FH,?C0002 0019 BFA00E CJNE R7,#0A0H,?C0002 ; SOURCE LINE # 12 ; SOURCE LINE # 13 001C 0500 R INC second+01H 001E E500 R MOV A,second+01H 0020 7002 JNZ ?C0005 0022 0500 R INC second 0024 ?C0005: ; SOURCE LINE # 14 0024 750000 R MOV interruptcnt,#00H 0027 750000 R MOV interruptcnt+01H,#00H ; SOURCE LINE # 15 ; SOURCE LINE # 16 002A ?C0002: 002A D007 POP AR7;!!!!!!!!!!!!!!!!!!!!!!!!!!!! 002C D006 POP AR6;!!!!!!!!!!!!!!!!!!!!!!!!!!!! 002E D0D0 POP PSW;!!!!!!!!!!!!!!!!!!!!!!!!!!!! 0030 D0E0 POP ACC 0032 32 RETI ; FUNCTION timer0 (END)
|