|
keil编译没报错 但是放到仿真里面数码表里的数字不会动
DISPLAYNUM EQU 51H
COUNTER EQU 52H
NSNORM EQU 53H
EWNORM EQU 54H
NSPEAK EQU 55H
EWPEAK EQU 56H
NSPUT EQU 57H
EWPUT EQU 58H
DIRECTION EQU 00H
DISPLAYYELLOW EQU 01H
ONESECOND EQU 02H
SETNEW EQU 03H
LOADNEWFLAG EQU 04H
NR EQU P0.0
NY EQU P0.1
NG EQU P0.2
ER EQU P0.3
EY EQU P0.4
EG EQU P0.5
BREAKRULE EQU P2.0
SOUND EQU P2.1
PEAKorNORM EQU P2.2
ALLSTOP EQU P2.3
ALLGO EQU P2.4
NSTHROUGH EQU P2.5
EWTHROUGH EQU P2.6
SELECTDIR EQU P2.7
ORG 0000H
LJMP MAIN
ORG 0003H
LJMP RESET
ORG 000BH
LJMP TIME
ORG 001BH
LJMP DOG
ORG 0100H
MAIN: MOV NSNORM,#28H
MOV EWNORM,#14H
MOV NSPEAK,#1EH
MOV EWPEAK,#0AH
REMAIN:MOV COUNTER,#0AH
SETB DIRECTION
CLR DISPLAYYELLOW
CLR ONESECOND
CLR SETNEW
CLR SOUND
JNB PEAKorNORM,PEAKINPUT
MOV NSPUT,NSNORM
MOV EWPUT,EWNORM
SJMP DISPLAYNUMPUT
PEAKINPUT: MOV NSPUT,NSPEAK
MOV EWPUT,EWPEAK
DISPLAYNUMPUT: MOV DISPLAYNUM,NSPUT
MOV SP,#5FH
MOV TMOD,#11H
LCALL FEEDDOG
MOV TL0,#0B0H
MOV TH0,#3CH
START: SETB EX0
SETB IT0
SETB TR0
SETB ET0
SETB ET1
SETB PX0
CLR PT0
SETB PT1
SETB EA
LCALL LIGHT
LCALL DISPLAYLED
;------------------------------???????----------------------------------------
LOOP: LCALL FEEDDOG
JB SETNEW,REMAIN
;------------------------------????? 1 ????-------------------------------------
JNB ONESECOND,ALLRED
CLR ONESECOND
DEC DISPLAYNUM
MOV A,DISPLAYNUM
CJNE A,#02H,EQ0
SETB DISPLAYYELLOW
LCALL LIGHT
LJMP NUMDECLINE
EQ0: CJNE A,#00H,NUMDECLINE
CLR DISPLAYYELLOW
CPL DIRECTION
LCALL LIGHT
LCALL RELOAD
NUMDECLINE: LCALL DISPLAYLED
;------------------------------???????------------------------------------------
ALLRED:JB ALLSTOP,NSCLEAR
CLR TR0
SETB NR
CLR NY
CLR NG
SETB ER
CLR EY
CLR EG
ALLREDWAIT: LCALL FEEDDOG
JB ALLSTOP,ALLREDBACK
SJMP ALLREDWAIT
ALLREDBACK: SETB TR0
LCALL LIGHT
;------------------------------??????------------------------------------------
NSCLEAR: JB NSTHROUGH,EWCLEAR
CLR TR0
CLR NR
CLR NY
SETB NG
SETB ER
CLR EY
CLR EG
NSCLEARWAIT: LCALL FEEDDOG
JB NSTHROUGH,NSCLEARBACK
SJMP NSCLEARWAIT
NSCLEARBACK: SETB TR0
LCALL LIGHT
;------------------------------???????------------------------------------------
EWCLEAR: JB EWTHROUGH,ALLYELLOW
CLR TR0
SETB NR
CLR NY
CLR NG
CLR ER
CLR EY
SETB EG
EWCLEARWAIT: LCALL FEEDDOG
JB EWTHROUGH,EWCLEARBACK
SJMP EWCLEARWAIT
EWCLEARBACK: SETB TR0
LCALL LIGHT
SJMP ALLYELLOW
;------------------------------??????------------------------------------------
NEXT: LJMP CHECKRULE
ALLYELLOW: JB ALLGO,NEXT
CLR TR0
CLR NR
SETB NY
CLR NG
CLR ER
SETB EY
CLR EG
ALLYELLOWWAIT: LCALL FEEDDOG
JB ALLGO,ALLYELLOWBACK
JB ALLSTOP,NSC
SETB NR
CLR NY
CLR NG
SETB ER
CLR EY
CLR EG
WAITA: LCALL FEEDDOG
JB ALLSTOP,BACKA
SJMP WAITA
BACKA: CLR NR
SETB NY
CLR NG
CLR ER
SETB EY
CLR EG
NSC: JB NSTHROUGH,EWC
CLR NR
CLR NY
SETB NG
SETB ER
CLR EY
CLR EG
WAITN:LCALL FEEDDOG
JB NSTHROUGH,BACKN
SJMP WAITN
BACKN: CLR NR
SETB NY
CLR NG
CLR ER
SETB EY
CLR EG
EWC: JB EWTHROUGH,ALLYELLOWWAIT
SETB NR
CLR NY
CLR NG
CLR ER
CLR EY
SETB EG
WAITE: LCALL FEEDDOG
JB EWTHROUGH,BACKE
SJMP WAITE
BACKE: CLR NR
SETB NY
CLR NG
CLR ER
SETB EY
CLR EG
LJMP ALLYELLOWWAIT
ALLYELLOWBACK: SETB TR0
LCALL LIGHT
;-----------------------------???????-------------------------------------------
CHECKRULE: JB BREAKRULE,CLEARSOUND
CPL SOUND
LJMP SETPEAK
CLEARSOUND: CLR SOUND
;-----------------------------?????-------------------------------------------
SETPEAK: JNB PEAKorNORM,LOADPEAK
MOV NSPUT,NSNORM
MOV EWPUT,EWNORM
LJMP LOOP
LOADPEAK: MOV NSPUT,NSPEAK
MOV EWPUT,EWPEAK
LJMP LOOP
;----------------------------T0 ?ж?,??????-------------------------------------
TIME: CLR EA
PUSH Acc
PUSH PSW
SETB EA
MOV TL0,#0B0H
MOV TH0,#3CH
DJNZ COUNTER,TIMERET
SETB ONESECOND
MOV COUNTER,#0AH
TIMERET:CLR EA
POP PSW
POP Acc
SETB EA
RETI
;----------------------------T1 ?ж?,????????-----------------------------------
DOG: POP Acc
POP Acc
CLR A
PUSH Acc
PUSH Acc
RETI
;-------------------------------???????-----------------------------------------
RESET: CLR ES
CLR ET1
CLR EX1
CLR ET0
CLR EX0
PUSH Acc
PUSH PSW
SETB LOADNEWFLAG
CLR TR0
CLR TR1
MOV TMOD,#51H
SETB TR1
SETB NR
CLR NY
CLR NG
SETB ER
CLR EY
CLR EG
BEGIN: MOV TL1,#00H
MOV TH1,#00H
OBSERVE: MOV DISPLAYNUM,TL1
LCALL DISPLAYLED
RESETWAIT: JNB P3.4,TERMINATE
JNB P3.3,LOADNEW
SETB LOADNEWFLAG
JNB P3.5,OBSERVE
SJMP RESETWAIT
LOADNEW: JNB LOADNEWFLAG,RESETWAIT
JNB PEAKorNORM,PEAKSELECT
JNB SELECTDIR,EWN
MOV NSNORM,TL1
CLR LOADNEWFLAG
LJMP BEGIN
EWN: MOV EWNORM,TL1
CLR LOADNEWFLAG
LJMP BEGIN
PEAKSELECT: JNB SELECTDIR,EWP
MOV NSPEAK,TL1
CLR LOADNEWFLAG
LJMP BEGIN
EWP: MOV EWPEAK,TL1
CLR LOADNEWFLAG
LJMP BEGIN
TERMINATE: POP PSW
POP Acc
SETB ES
SETB ET1
SETB EX1
SETB ET0
SETB EX0
SETB SETNEW
RETI
;----------------------------????????------------------------------------------
DISPLAYLED: MOV B,#10
MOV A,DISPLAYNUM
DIV AB
SWAP A
ADD A,B
MOV P1,A
RET
;----------------------------????????------------------------------------------
LIGHT: JNB DIRECTION,EWLIGHT
JNB DISPLAYYELLOW,SE01
CLR NR
SETB NY
CLR NG
SETB ER
CLR EY
CLR EG
LJMP LIGHTRET
SE01: CLR NR
CLR NY
SETB NG
SETB ER
CLR EY
CLR EG
LJMP LIGHTRET
EWLIGHT: JNB DISPLAYYELLOW,SE02
SETB NR
CLR NY
CLR NG
CLR ER
SETB EY
CLR EG
LJMP LIGHTRET
SE02: SETB NR
CLR NY
CLR NG
CLR ER
CLR EY
SETB EG
LIGHTRET:
RET
;-------------------------------????????????-----------------------------------
RELOAD:JNB DIRECTION,SE03
MOV DISPLAYNUM,NSPUT
SJMP RELOADRET
SE03: MOV DISPLAYNUM,EWPUT
RELOADRET:
RET
;----------------------------------ι??------------------------------------------
FEEDDOG: MOV TH1,#01BH
MOV TL1,#0E0H
SETB TR1
RET
;--------------------------------------------------------------------------------
END
|
|