TMAX EQU 209
TMIN EQU 199
ALARMU BIT 08H
ALARMD BIT 09H
DISBUF EQU 40H
ADADDR EQU 0DFF8H
LEDC EQU 0BFF8H
LEDS EQU 7FFFH
EOC BIT P1.0
ALARM BIT P1.1
HEAT BIT P1.2
RED BIT P1.3
GREEN BIT P1.4
ORG 0000H
LJMP MAIN
ORG 100H
MAIN:CLR ALARM
CLR HEAT
CLR GREEN
SETB RED
MOV SP,#5FH
CLR A
ST:MOV DPTR,#ADADDR
LCALL AD
JB ALARMU,OVER
JB ALARMD,LOWER
CLR GREEN
SETB RED
CHBCD:MOV A,R4
MOV R6,A
MOV A,R5
MOV R7,A
LCALL BCD2
MOV 43H,#12
MOV 40H,R4
MOV A,R5
ANL A,#0F0H
SWAP A
MOV 41H,A
MOV A,R5
ANL A,#0FH
MOV 42H,A
LCALL DISP
SJMP ST
LOWER:CLR HEAT
BJ:SETB ALARM
CLR RED
SETB GREEN
SJMP CHBCD
OVER:SETB HEAT
SJMP BJ
AD:MOVX @DPTR,A
LP1:JB EOC,$
MOVX A,@DPTR
CJNE A,#TMAX,COMPH
COMPH:JNC SETMU
CJNE A,#TMIN,COMPL
CLRMARK:CLR ALARMU
CLR ALARMD
CHCODE:MOV R6,#0
MOV R7,A
MOV R2,#03H
MOV R3,#0E7H
LCALL NMUL
MOV R6,#0
MOV R7,#255
LCALL NDIV
RET
SETMU:SETB ALARMU
CLR ALARMD
SJMP CHCODE
COMPL:JC SETMD
SJMP CLRMARK
SETMD:SETB ALARMD
CLR ALARMU
SJMP CHCODE
BCD2:CLR A
MOV R3,A
MOV R4,A
MOV R5,A
MOV R2,#10H
HB3:MOV A,R7
RLC A
MOV R7,A
MOV A,R6
RLC A
MOV R6,A
MOV A,R5
ADDC A,R5
DA A
MOV R5,A
MOV A,R4
ADDC A,R4
DA A
MOV R4,A
MOV A,R3
ADDC A,R3
MOV R3,A
DJNZ R2,HB3
RET
DISP:MOV R4,#250
DISP1:MOV R0,#DISBUF
MOV R1,#0FEH
MOV R3,#4
DISP3:MOV DPTR,#LEDS
MOV A,R1
MOVX @DPTR,A
MOV A,@R0
CJNE R1,#11111011,D2
ADD A,#17
D2:MOV DPTR,#DSE
MOVC A,@A+DPTR
MOV DPTR,#LEDC
MOVX @DPTR,A
LCALL DELAY
INC R0
MOV A,R1
RL A
MOV R1,A
DJNZ R3,DISP3
DJNZ R4,DISP1
MOV DPTR,#LEDS
MOV A,#0
MOVX @DPTR,A
RET
DSE:DB 3FH,06H,5BH,4FH,66H
DB 6DH,7DH,07H,7FH,6FH
DB 77H,7CH,39H,5EH,79H
DB 71H,00H
DB BFH,86H,0DBH,0CFH,0E6H
DB EDH,0FDH,87H,0FFH,0EFH
END