Chương 15: CHÖÔNG TRÌNH HEÄ THOÁNG ;CHUONG TRINH DEM SAN PHAM VA DONG HOP ; KHAI BAO CAC BIEN HANG CWR4 EQU 4003H ;CWR4 ROLE_BC EQU 4000H ;PORTA4 CAMBIEN EQU 4001H ;PORTB4 NGO_DP1 EQU 4002H ;PORTC4 CWR6 EQU 6003H ;CWR6 HIENTHI EQU 6000H ;PORTA6 ROLE_DH EQU 6001H ;PORTB6 CHONLED EQU 6002H ;PORTC6 LED70 EQU 70H LED71 EQU 71H LED72 EQU 72H LED73 EQU 73H LED74 EQU 74H LED75 EQU 75H LED76 EQU 76H LED77 EQU 77H LUU_SPL EQU 78H ;Luu san pham (byte thap) LUU_SPH EQU 79H ;Luu san pham (byte cao) DEM_SPL EQU 7AH ;Dem san pham (byte thap) DEM_SPH EQU 7BH ;Dem san pham (byte cao) LUUHOPL EQU 7CH LUUHOPH EQU 7DH DEMHOPL EQU 7EH DEMHOPH EQU 7FH COUNT0 EQU -10000 DELAY1 EQU 50 DELAY2 EQU 20 TOCDO1 EQU 9 COUNT1 EQU -250 BLK EQU 0FH START EQU 0CH NO BIT 7DH YES BIT 7EH LUU_CY BIT 7FH ; CHUONG TRINH CHINH ORG 00H LJMP BAT_DAU0 ORG 1BH LJMP NGAT_T1 ORG 30H BAT_DAU0: MOV R1,#LED77 MOV R2,#TOCDO1 MOV TMOD,#21H MOV TH1,#COUNT1 LCALL KD_NV SETB TR1 SETB ET1 SETB EA BAT_DAU1: MOV 2EH,#00H MOV 30H,#00H MOV 31H,#00H MOV 32H,#00H MOV 33H,#00H MOV 34H,#00H MOV 35H,#00H MOV 36H,#00H MOV 37H,#00H MOV 38H,#00H MOV 39H,#00H MOV 3AH,#00H MOV 3BH,#00H MOV 3CH,#00H MOV 3DH,#00H MOV 3EH,#00H MOV 3FH,#00H MOV 40H,#00H MOV 41H,#00H MOV 42H,#00H MOV 43H,#00H MOV 44H,#00H MOV 45H,#00H MOV 46H,#00H MOV 47H,#00H MOV 48H,#00H MOV 49H,#00H MOV 4AH,#00H MOV 4BH,#00H MOV 4CH,#00H MOV 4DH,#00H MOV 4EH,#00H MOV 4FH,#00H MOV 50H,#00H MOV 51H,#00H MOV 52H,#00H MOV 53H,#00H MOV 54H,#00H MOV 55H,#00H MOV 56H,#00H MOV 57H,#00H BAT_DAU: MOV DEMHOPL,#00H MOV DEMHOPH,#00H MOV DEM_SPL,#00H MOV DEM_SPH,#00H INC 2EH MOV 77H,2EH MOV 76H,#BLK MOV 75H,#BLK MOV 74H,#BLK MOV 73H,#BLK MOV 72H,#BLK MOV 71H,#0AH MOV 70H,#10H MOV R4,#250 LCALL DELAY MOV LED70,#0DH ;'N' MOV LED71,#0BH ;'H' MOV LED72,#0AH ;'A' MOV LED73,#0EH ;'P' LCALL NHAPHOP LCALL NHAP_SP MOV DPTR,#ROLE_BC MOV A,#0FFH ;Cho phep bang chuyen hoat dong MOVX @DPTR,A DEM: LCALL BLANK LCALL DAUDO MOV A,DEM_SPL LCALL TANG_1 MOV DEM_SPL,A JNC DU_SP? MOV A,DEM_SPH LCALL TANG_1 MOV DEM_SPH,A DU_SP?: MOV A,DEM_SPH CJNE A,LUU_SPH,DEM MOV A,DEM_SPL CJNE A,LUU_SPL,DEM LCALL BLANK MOV R4,#DELAY1 LCALL DELAY MOV A,#00H MOV DPTR,#ROLE_DH MOVX @DPTR,A MOV R4,#DELAY2 LCALL DELAY MOV A,#0FFH MOVX @DPTR,A MOV DEM_SPL,#00H MOV DEM_SPH,#00H MOV A,DEMHOPL LCALL TANG_1 MOV DEMHOPL,A JNC DUHOP? MOV A,DEMHOPH LCALL TANG_1 MOV DEMHOPH,A DUHOP?: MOV A,DEMHOPH CJNE A,LUUHOPH,DEM MOV A,DEMHOPL CJNE A,LUUHOPL,DEM LCALL BLANK KETTHUC: MOV DPTR,#ROLE_BC MOV A,#00H MOVX @DPTR,A MOV A,2EH LCALL LUU L14: LCALL IN_HEX CJNE A,#0EH,L12 MOV 77H,#BLK MOV 76H,#BLK MOV 75H,#BLK MOV 74H,#BLK MOV 73H,#BLK MOV 72H,#BLK MOV 71H,#0AH MOV 70H,#10H L13: LCALL IN_HEX PUSH ACC CLR C SUBB A,#0AH POP ACC JNC L13 MOV 77H,A LCALL DELAY LCALL XEM MOV 74H,#0CH MOV DEMHOPL,LUUHOPL MOV DEMHOPH,LUUHOPH MOV DEM_SPL,LUU_SPL MOV DEM_SPH,LUU_SPH LCALL BLANK LCALL DELAY LJMP L14 L12: MOV A,2EH CJNE A,#09H,L15 LJMP BAT_DAU1 L15: LJMP BAT_DAU ; KHAI BAO CHUONG TRINH CON ;CHUONG TRINH CON LUU SO HOP, SO SAN PHAM LUU: NOP L0: CJNE A,#01H,L1 MOV 30H,LUUHOPL MOV 31H,LUUHOPH MOV 32H,LUU_SPL MOV 33H,LUU_SPH LJMP L10 L1: CJNE A,#02H,L2 MOV 34H,LUUHOPL MOV 35H,LUUHOPH MOV 36H,LUU_SPL MOV 37H,LUU_SPH LJMP L10 L2: CJNE A,#03H,L3 MOV 38H,LUUHOPL MOV 39H,LUUHOPH MOV 3AH,LUU_SPL MOV 3BH,LUU_SPH LJMP L10 L3: CJNE A,#04H,L4 MOV 3CH,LUUHOPL MOV 3DH,LUUHOPH MOV 3EH,LUU_SPL MOV 3FH,LUU_SPH LJMP L10 L4: CJNE A,#05H,L5 MOV 40H,LUUHOPL MOV 41H,LUUHOPH MOV 42H,LUU_SPL MOV 43H,LUU_SPH LJMP L10 L5: CJNE A,#06H,L6 MOV 44H,LUUHOPL MOV 45H,LUUHOPH MOV 46H,LUU_SPL MOV 47H,LUU_SPH LJMP L10 L6: CJNE A,#07H,L7 MOV 48H,LUUHOPL MOV 49H,LUUHOPH MOV 4AH,LUU_SPL MOV 4BH,LUU_SPH LJMP L10 L7: CJNE A,#08H,L8 MOV 4CH,LUUHOPL MOV 4DH,LUUHOPH MOV 4EH,LUU_SPL MOV 4FH,LUU_SPH LJMP L10 L8: CJNE A,#09H,L10 MOV 50H,LUUHOPL MOV 51H,LUUHOPH MOV 52H,LUU_SPL MOV 53H,LUU_SPH L10: RET ; ;CHUONG TRINH CON XEM XEM: NOP CJNE A,#00H,H0 MOV LUUHOPL,#0FFH MOV LUUHOPH,#0FFH MOV LUU_SPL,#0FFH MOV LUU_SPH,#0FFH LJMP H9 H0: CJNE A,#01H,H1 MOV LUUHOPL,30H MOV LUUHOPH,31H MOV LUU_SPL,32H MOV LUU_SPH,33H LJMP H9 H1: CJNE A,#02H,H2 MOV LUUHOPL,34H MOV LUUHOPH,35H MOV LUU_SPL,36H MOV LUU_SPH,37H LJMP H9 H2: CJNE A,#03H,H3 MOV LUUHOPL,38H MOV LUUHOPH,39H MOV LUU_SPL,3AH MOV LUU_SPH,3BH LJMP H9 H3: CJNE A,#04H,H4 MOV LUUHOPL,3CH MOV LUUHOPH,3DH MOV LUU_SPL,3EH MOV LUU_SPH,3FH LJMP H9 H4: CJNE A,#05H,H5 MOV LUUHOPL,40H MOV LUUHOPH,41H MOV LUU_SPL,42H MOV LUU_SPH,43H LJMP H9 H5: CJNE A,#06H,H6 MOV LUUHOPL,44H MOV LUUHOPH,45H MOV LUU_SPL,46H MOV LUU_SPH,47H LJMP H9 H6: CJNE A,#07H,H7 MOV LUUHOPL,48H MOV LUUHOPH,49H MOV LUU_SPL,4AH MOV LUU_SPH,4BH LJMP H9 H7: CJNE A,#08H,H8 MOV LUUHOPL,4CH MOV LUUHOPH,4DH MOV LUU_SPL,4EH MOV LUU_SPH,4FH LJMP H9 H8: CJNE A,#09H,H9 MOV LUUHOPL,50H MOV LUUHOPH,51H MOV LUU_SPL,52H MOV LUU_SPH,53H LJMP H9 H9: RET ; ;CHUONG TRINH CON CHO HIEN THI NGAT_T1: MOV LUU_CY,C DJNZ R2,THOATT1 MOV R2,#TOCDO1 PUSH ACC PUSH DPH PUSH DPL MOV DPTR,#CHONLED MOV A,R1 SWAP A MOVX @DPTR,A MOV DPTR,#HIENTHI MOV A,@R1 LCALL TRABANG MOVX @DPTR,A DEC R1 POP DPL POP DPH POP ACC CJNE R1,#LED70-1,THOATT1 MOV R1,#LED77 THOATT1: MOV C,LUU_CY RETI ; ;CHUONG TRINH CON KHOI DONG THIET BI . Chương 15: CHÖÔNG TRÌNH HEÄ THOÁNG ;CHUONG TRINH DEM SAN PHAM VA DONG HOP ; KHAI BAO CAC BIEN HANG. DEM_SPL,LUU_SPL MOV DEM_SPH,LUU_SPH LCALL BLANK LCALL DELAY LJMP L14 L12: MOV A,2EH CJNE A,#09H,L15 LJMP BAT_DAU1 L15: LJMP BAT_DAU ; KHAI BAO CHUONG TRINH CON ;CHUONG TRINH CON LUU SO HOP, SO SAN PHAM LUU: