ORG 0000H
AJMP START
ORG 000BH ;TO中断入口地址
AJMP SERVE ;跳转中断到中断服务
START:MOV R2,#0
MOV R3,#10
MAIN: MOV DPTR,#TAB
MOV A,R2
MOVC A,@A+DPTR
MOV P2,A
INC R2
MOV SP,#60H
MOV B,#10 ;设置循环次数10次
MOV TMOD,#01H ;设置T0工作在模式1
MOV TL0,#0B0H
MOV TH0,#3CH
SETB ET0
SETB EA
SETB TR0
DJNZ R3,MAIN
AJMP START
SERVE:MOV TL0,#0B0H
MOV TH0,#3CH
DJNZ B,LOOP ;一秒结束
CLR TR0
LOOP:RET
TAB:DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H
END
------解决方案--------------------------------------------------------
ORG 0000H
AJMP START
ORG 000BH ;TO中断入口地址
AJMP SERVE ;跳转中断到中断服务
START:
MOV SP,#60H
MOV TMOD,#01H ;设置T0工作在模式1
MOV TL0,#0B0H
MOV TH0,#3CH
SETB ET0
SETB EA
SETB TR0
MAIN:
MOV B,#10 ;设置循环次数10次
MOV R3,#10
MOV R2,#0
MOV DPTR,#TAB
JZ AJMP START
MAIN1:
MOV A,B
JZ MAIN
AJMP MAIN1
SERVE:
PUSH ACC
MOV TL0,#0B0H
MOV TH0,#3CH
DEC B
MOV A,R2
MOVC A,@A+DPTR
MOV P2,A
INC R2
POP ACC
RETI
TAB:DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H
END