(2)程序代码
1主程序
OKEQU20H
RINGEQU22H
ORG0000H
AJMPMAIN
ORG0003H
AJMPINT0SUB
ORG000BH
AJMPT0INT
ORG0013H
AJMPINT1SUB
ORG001BH
AJMPT1INT
ORG0040H
MAIN:MOVR1,#30
MOVR2,#60
MOVTMOD,#11H
MOVTH0,#0F0H
MOVTL0,#0FFH
MOVTH1,#3CH
MOVTL1,#0B0H
SETBEA
SETBET0
SETBET1
SETBEX0
SETBEX1
CLROK
CLRRING
SETBTR1
SETBTR0
2查询程序
START:MOVR5,#0BH
MOVR4,#0BH
MOVR3,#0BH
ACALLDISPLAY
JBP3.0,NEXT
ACALLDELAY
JBP3.0,NEXT
ACALLBARK
MOVA,R1
MOVR6,A
SETBOK
MOVR7,#01H
MOVR3,#0AH
AJMPCOUNT
NEXT:JNBP1.0,FALSE1
JNBP1.1,FALSE2
JNBP1.2,FALSE3
JNBP1.3,FALSE4
JNBP1.4,FALSE5
JNBP1.5,FALSE6
JNBP1.6,FALSE7
JNBP1.7,FALSE8
AJMPSTART
3非法抢答处理程序
FALSE1:MOVR3,#01H
AJMPERROR
FALSE2:MOVR3,#02H
AJMPERROR
FALSE3:MOVR3,#03H
AJMPERROR
FALSE4:MOVR3,#04H
AJMPERROR
FALSE5:MOVR3,#05H
AJMPERROR
FALSE6:MOVR3,#06H
AJMPERROR
FALSE7:MOVR3,#07H
AJMPERROR
FALSE8:MOVR3,#08H
4抢答、回答时间调整程序
=====INT0(抢答时间R1调整程序)=====
INT0SUB:MOVA,R1
MOVB,#0AH
DIVAB
MOVR5,A
MOVR4,B
MOVR3,#0AH
ACALLDISPLAY
JNBP3.4,INC0
JNBP3.5,DEC0
JNBP3.1,BACK0
AJMPINT0SUB
INC0:MOVA,R1
CJNEA,#63H,ADD0
MOVR1,#00H
ACALLDELAY1
AJMPINT0SUB
ADD0:INCR1
ACALLDELAY1
AJMPINT0SUB
DEC0:MOVA,R1
JZSETR1
DECR1
ACALLDELAY1
AJMPINT0SUB
SETR1:MOVR1,#63H
ACALLDELAY1
AJMPINT0SUB
BACK0:RETI
;=====INT1(回答时间R2调整程序)=====
INT1SUB:MOVA,R2
MOVB,#0AH
DIVAB
MOVR5,A
MOVR4,B
MOVR3,#0AH
ACALLDISPLAY
JNBP3.4,INC1
JNBP3.5,DEC1
JNBP3.1,BACK1
AJMPINT1SUB
INC1:MOVA,R2
CJNEA,#63H,ADD1
MOVR2,#00H
ACALLDELAY1
AJMPINT1SUB
ADD1:INCR2
ACALLDELAY1
AJMPINT1SUB
DEC1:MOVA,R2
JZSETR2
DECR2
ACALLDELAY1
AJMPINT1SUB
SETR2:MOVR2,#63H
ACALLDELAY1
AJMPINT1SUB
BACK1:RETI
5倒计时程序
REPEAT:MOVA,R2
MOVR6,A
CLRRING
COUNT:MOVR0,#00H
MOVTH1,#3CH
MOVTL1,#0B0H
RECOUNT:MOVA,R6
MOVB,#0AH
DIVAB
MOV30H,A
MOV31H,B
MOVR5,30H
MOVR4,31H
MOVA,R6
SUBBA,#07H
JNCLARGER
MOVA,R0
CJNEA,#0AH,FULL
CLRRING
AJMPCHECK
FULL:CJNEA,#14H,CHECK
SETBRING
MOVA,R6
JZQUIT
MOVR0,#00H
DECR6
AJMPCHECK
LARGER:MOVA,R0
CJNEA,#14H,CHECK
DECR6
MOVR0,#00H
CHECK:JNBP3.1,QUIT
JNBOK,CHECKK
AJMPNEXTT
CHECKK:JNBP3.0,REPEAT
NEXTT:ACALLDISPLAY
JBOK,ACCOUT
AJMPRECOUNT
ACCOUT:
MOVA,36H
JNBACC.0,TRUE1
JNBACC.1,TRUE2
JNBACC.2,TRUE3
JNBACC.3,TRUE4
JNBACC.4,TRUE5
JNBACC.5,TRUE6
JNBACC.6,TZ1
JNBACC.7,TZ2
AJMPRECOUNT
TZ1:JMPTRUE7
TZ2:JMPTRUE8
QUIT:CLROK
CLRRING
AJMPSTART
6正常抢答处理程序
TRUE1:ACALLBARK
MOVA,R2
MOVR6,A
MOVR3,#01H
CLROK
AJMPCOUNT
TRUE2:ACALLBARK
MOVA,R2
MOVR6,A
MOVR3,#02H
CLROK
AJMPCOUNT
TRUE3:ACALLBARK
MOVA,R2
MOVR6,A
MOVR3,#03H
CLROK
AJMPCOUNT
TRUE4:ACALLBARK
MOVA,R2
MOVR6,A
MOVR3,#04H
CLROK
AJMPCOUNT
TRUE5:ACALLBARK
MOVA,R2
MOVR6,A
MOVR3,#05H
CLROK
AJMPCOUNT
TRUE6:ACALLBARK
MOVA,R2
MOVR6,A
MOVR3,#06H
CLROK
AJMPCOUNT
TRUE7:ACALLBARK
MOVA,R2
MOVR6,A
MOVR3,#07H
CLROK
AJMPCOUNT
TRUE8:ACALLBARK
MOVA,R2
MOVR6,A
MOVR3,#08H
CLROK
AJMPCOUNT
7犯规抢答程序
ERROR:MOVR0,#00H
MOVTH1,#3CH
MOVTL1,#0B0H
MOV34H,R3
HERE:MOVA,R0
CJNEA,#06H,FLASH;0.3s
CLRRING
MOVR3,#0AH
MOVR4,#0AH
MOVR5,#0AH
AJMPCHECK1
FLASH:CJNEA,#0CH,CHECK1
SETBRING
MOVR0,#00H
MOVR3,34H
MOVR5,#0BH
MOVR4,#0BH
AJMPCHECK1
CHECK1:JNBP3.1,QUIT1
ACALLDISPLAY
AJMPHERE
QUIT1:CLRRING
CLROK
AJMPSTART
8其他功能程序
=====显示程序=====
DISPLAY:MOVDPTR,#DAT1
MOVA,R3
MOVCA,@A+DPTR
MOVP2,#0feH
MOVP0,A
ACALLDELAY2
MOVDPTR,#DAT2
MOVA,R5
MOVCA,@A+DPTR
MOVP2,#0fdH
MOVP0,A
ACALLDELAY2
MOVA,R4
MOVCA,@A+DPTR
MOVP2,#0fbH
MOVP0,A
ACALLDELAY2
RET
DAT1:DB00h,06h,5Bh,4Fh,66h,6Dh,7Dh,07h,7Fh,6Fh,00H,71H
DAT2:DB3Fh,06h,5Bh,4Fh,66h,6Dh,7Dh,07h,7Fh,6Fh,00H,71H
=====发声程序=====
BARK:SETBRING
ACALLDELAY1
ACALLDELAY1
CLRRING
RET
=====TO溢出中断(响铃程序)=====
T0INT:MOVTH0,#0ECH
MOVTL0,#0FFH
JNBRING,OUT;
CPLP3.6
OUT:RETI
;=====T1溢出中断(计时程序)=====
T1INT:MOVTH1,#3CH
MOVTL1,#0B0H
END
|