code-robot
$MOD51fx
;**************** KHAI BAO_NGO VAO **********************
CHAY_THANG BIT P0.5
CHAY_LUI BIT P2.6
XOAY_PHAI BIT P2.7
XOAY_TRAI BIT P2.0
NANG_TAY BIT P2.5
HA_TAY BIT P2.4
TANG_TOC BIT P0.7
CHAY BIT P0.4
HT_HA BIT P2.2
HT_NANG BIT P2.1
ACT_ENCODER BIT EX0
PHASE_B BIT P3.3
;******************* KHAI BAO BIEN **********************
VUNG EQU 40H
BANH_TRAI_TD1 EQU 45H
BANH_PHAI_TD1 EQU 46H
BANH_TRAI_TD2 EQU 47H
BANH_PHAI_TD2 EQU 48H
BANH_TRAI_TD1_DAO EQU 49H
BANH_PHAI_TD1_DAO EQU 4AH
BANH_TRAI_TD2_DAO EQU 4BH
BANH_PHAI_TD2_DAO EQU 4CH
BANH_TRAI_TD3 EQU 4DH
BANH_PHAI_TD3 EQU 4EH
BANH_TRAI_TD4 EQU 4FH
BANH_PHAI_TD4 EQU 70H
BANH_TRAI_TD5 EQU 71H
BANH_PHAI_TD5 EQU 72H
BANH_TRAI_TD6 EQU 73H
BANH_PHAI_TD6 EQU 74H
;***************** KHAI BAO DONG CO *********************
MOTOR_NANG EQU CCAP2H
MOTOR_NANG_DAO BIT P3.5
BANH_PHAI EQU CCAP0H
BANH_PHAI_DAO BIT P3.3
BANH_TRAI EQU CCAP1H
BANH_TRAI_DAO BIT P3.4
;***************** CHUONG TRINH CHINH *******************
ORG 0000H
LJMP MAIN
ORG 0003H
LJMP NGAT_EX0
MAIN: MOV R0,#05
MOV R1,#100
; MOV IE,#10000000B
; SETB IT0
MOV CMOD,#0
SETB CR
MOV CCAPM4,#01000010B
MOV CCAPM2,#01000010B
MOV CCAPM3,#01000010B
MOV CCAPM1,#01000010B
MOV CCAPM0,#01000010B
MOV BANH_TRAI_TD1,#255 ;TOC DO NHANH
MOV BANH_PHAI_TD1,#255
MOV BANH_TRAI_TD2,#145 ;TOC DO CHAM
MOV BANH_PHAI_TD2,#125
MOV BANH_TRAI_TD3,#80 ;TOC DO CHAM XOAY PHAI
MOV BANH_PHAI_TD3,#90
MOV BANH_TRAI_TD4,#65 ;TOC DO CHAM XOAY TRAI
MOV BANH_PHAI_TD4,#70
MOV BANH_TRAI_TD5,#160 ;TOC DO NHANH XOAY PHAI
MOV BANH_PHAI_TD5,#140
MOV BANH_TRAI_TD6,#160 ;TOC DO NHANH XOAY TRAI
MOV BANH_PHAI_TD6,#140
MOV BANH_TRAI_TD1_DAO,#130 ;TOC DO LUI NHANH
MOV BANH_PHAI_TD1_DAO,#130
MOV BANH_TRAI_TD2_DAO,#50 ;TOC DO LUI CHAM
MOV BANH_PHAI_TD2_DAO,#50
TD:
CALL KIEM_TRA_NUT_NHAN
CALL DIEU_KHIEN_ROBOT
SJMP TD
;************ CHUONG TRINH KIEM TRA NUT NHAN ************
KIEM_TRA_NUT_NHAN:
KIEM_TRA_TH1: ;CHAY CHAM KHONG XOAY
MOV C,TANG_TOC
ANL C,NANG_TAY
ANL C,XOAY_TRAI
ANL C,XOAY_PHAI
ANL C,HA_TAY
ANL C,/CHAY
JNC KIEM_TRA_TH2
MOV VUNG,#30H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH2: ;CHAY NHANH KHONG XOAY
MOV C,NANG_TAY
ANL C,HA_TAY
ANL C,XOAY_TRAI
ANL C,XOAY_PHAI
ANL C,/CHAY
ANL C,/TANG_TOC
JNC KIEM_TRA_TH3
MOV VUNG,#31H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH3: ;CHAY CHAM + NANG TAY
MOV C,TANG_TOC
ANL C,HA_TAY
ANL C,XOAY_TRAI
ANL C,XOAY_PHAI
ANL C,/NANG_TAY
ANL C,/CHAY
JNC KIEM_TRA_TH4
MOV VUNG,#02H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH4: ;CHAY NHANH + NANG TAY
MOV C,HA_TAY
ANL C,XOAY_TRAI
ANL C,XOAY_PHAI
ANL C,/CHAY
ANL C,/TANG_TOC
ANL C,/NANG_TAY
JNC KIEM_TRA_TH5
MOV VUNG,#15H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH5: ;CHAY CHAM + HA TAY
MOV C,TANG_TOC
ANL C,NANG_TAY
ANL C,XOAY_TRAI
ANL C,XOAY_PHAI
ANL C,/CHAY
ANL C,/HA_TAY
JNC KIEM_TRA_TH6
MOV VUNG,#04H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH6: ;CHAY NHANH + HA TAY
MOV C,NANG_TAY
ANL C,XOAY_TRAI
ANL C,XOAY_PHAI
ANL C,/CHAY
ANL C,/TANG_TOC
ANL C,/HA_TAY
JNC KIEM_TRA_TH7
MOV VUNG,#05H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH7: ;CHAY LUI CHAM
MOV C,TANG_TOC
ANL C,NANG_TAY
ANL C,HA_TAY
ANL C,/CHAY_LUI
JNC KIEM_TRA_TH8
MOV VUNG,#06H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH8: ;CHAY LUI NHANH
MOV C,NANG_TAY
ANL C,HA_TAY
ANL C,/CHAY_LUI
ANL C,/TANG_TOC
JNC KIEM_TRA_TH9
MOV VUNG,#07H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH9: ;CHAY LUI CHAM + NANG TAY
MOV C,HA_TAY
ANL C,TANG_TOC
ANL C,/NANG_TAY
ANL C,/CHAY_LUI
JNC KIEM_TRA_TH10
MOV VUNG,#08H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH10: ;CHAY LUI NHANH + NANG TAY
MOV C,HA_TAY
ANL C,/CHAY_LUI
ANL C,/TANG_TOC
ANL C,/NANG_TAY
JNC KIEM_TRA_TH11
MOV VUNG,#09H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH11: ;CHAY LUI CHAM + HA TAY
MOV C,TANG_TOC
ANL C,NANG_TAY
ANL C,/HA_TAY
ANL C,/CHAY_LUI
JNC KIEM_TRA_TH12
MOV VUNG,#0AH
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH12: ;CHAY LUI NHANH + HA TAY
MOV C,NANG_TAY
ANL C,/CHAY_LUI
ANL C,/TANG_TOC
ANL C,/HA_TAY
JNC KIEM_TRA_TH13
MOV VUNG,#0BH
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH13: ;XOAY PHAI CHAM
MOV C,TANG_TOC
ANL C,NANG_TAY
ANL C,HA_TAY
ANL C,CHAY
ANL C,XOAY_TRAI
ANL C,/XOAY_PHAI
JNC KIEM_TRA_TH14
MOV VUNG,#0CH
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH14: ;XOAY PHAI NHANH
MOV C,XOAY_TRAI
ANL C,NANG_TAY
ANL C,HA_TAY
ANL C,CHAY
ANL C,XOAY_TRAI
ANL C,/XOAY_PHAI
ANL C,/TANG_TOC
JNC KIEM_TRA_TH15
MOV VUNG,#0DH
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH15: ;XOAY TRAI CHAM
MOV C,TANG_TOC
ANL C,NANG_TAY
ANL C,HA_TAY
ANL C,CHAY
ANL C,XOAY_PHAI
ANL C,/XOAY_TRAI
JNC KIEM_TRA_TH16
MOV VUNG,#0EH
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH16: ;XOAY TRAI NHANH
MOV C,XOAY_PHAI
ANL C,NANG_TAY
ANL C,HA_TAY
ANL C,CHAY
ANL C,XOAY_PHAI
ANL C,/XOAY_TRAI
ANL C,/TANG_TOC
JNC KIEM_TRA_TH17
MOV VUNG,#0FH
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH17: ;NANG TAY GAP
MOV C,HA_TAY
ANL C,XOAY_TRAI
ANL C,XOAY_PHAI
ANL C,/NANG_TAY
JNC KIEM_TRA_TH18
MOV VUNG,#10H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH18: ;HA TAY GAP
MOV C,NANG_TAY
ANL C,TANG_TOC
ANL C,XOAY_TRAI
ANL C,XOAY_PHAI
ANL C,/HA_TAY
JNC KIEM_TRA_TH21
MOV VUNG,#11H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH21:
MOV C,NANG_TAY
ANL C,HA_TAY
ANL C,CHAY_THANG
ANL C,CHAY_LUI
ANL C,XOAY_PHAI
ANL C,XOAY_TRAI
ANL C,/TANG_TOC
JNC KIEM_TRA_TH22
MOV VUNG,#14H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH22:
MOV C,NANG_TAY
ANL C,HA_TAY
ANL C,CHAY_THANG
ANL C,CHAY_LUI
ANL C,XOAY_PHAI
ANL C,XOAY_TRAI
ANL C,TANG_TOC
JNC KIEM_TRA_TH23
MOV VUNG,#14H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH23:
MOV C,NANG_TAY
ANL C,HA_TAY
ANL C,CHAY_THANG
ANL C,CHAY_LUI
ANL C,XOAY_PHAI
ANL C,XOAY_TRAI
ANL C,/TANG_TOC
JNC KIEM_TRA_TH24
MOV VUNG,#16H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH24:
MOV C,NANG_TAY
ANL C,HA_TAY
ANL C,CHAY_THANG
ANL C,CHAY_LUI
ANL C,XOAY_PHAI
ANL C,XOAY_TRAI
ANL C,TANG_TOC
JNC KIEM_TRA_TH25
MOV VUNG,#16H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH25: ;CHAY XOAY PHAI CHAM + NANG TAY
MOV C,XOAY_TRAI
ANL C,TANG_TOC
ANL C,HA_TAY
ANL C,/NANG_TAY
ANL C,/XOAY_PHAI
ANL C,/CHAY
JNC KIEM_TRA_TH26
MOV VUNG,#17H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH26: ;CHAY XOAY PHAI NHANH + NANG TAY
MOV C,XOAY_TRAI
ANL C,HA_TAY
ANL C,/TANG_TOC
ANL C,/NANG_TAY
ANL C,/XOAY_PHAI
ANL C,/CHAY
JNC KIEM_TRA_TH27
MOV VUNG,#18H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH27: ;CHAY XOAY TRAI CHAM + NANG TAY
MOV C,XOAY_PHAI
ANL C,HA_TAY
ANL C,TANG_TOC
ANL C,/NANG_TAY
ANL C,/XOAY_TRAI
ANL C,/CHAY
JNC KIEM_TRA_TH28
MOV VUNG,#19H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH28: ;CHAY XOAY TRAI NHANH + NANG TAY
MOV C,XOAY_PHAI
ANL C,HA_TAY
ANL C,/TANG_TOC
ANL C,/NANG_TAY
ANL C,/XOAY_TRAI
ANL C,/CHAY
JNC KIEM_TRA_TH29
MOV VUNG,#1AH
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH29: ;CHAY XOAY PHAI CHAM + HA TAY
MOV C,XOAY_TRAI
ANL C,TANG_TOC
ANL C,NANG_TAY
ANL C,/HA_TAY
ANL C,/XOAY_PHAI
ANL C,/CHAY
JNC KIEM_TRA_TH30
MOV VUNG,#1BH
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH30: ;CHAY XOAY PHAI NHANH + HA TAY
MOV C,XOAY_TRAI
ANL C,NANG_TAY
ANL C,/TANG_TOC
ANL C,/HA_TAY
ANL C,/XOAY_PHAI
ANL C,/CHAY
JNC KIEM_TRA_TH31
MOV VUNG,#1CH
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH31: ;CHAY XOAY TRAI CHAM + HA TAY
MOV C,XOAY_PHAI
ANL C,NANG_TAY
ANL C,TANG_TOC
ANL C,/HA_TAY
ANL C,/XOAY_TRAI
ANL C,/CHAY
JNC KIEM_TRA_TH32
MOV VUNG,#1DH
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH32: ;CHAY XOAY TRAI NHANH + HA TAY
MOV C,XOAY_PHAI
ANL C,NANG_TAY
ANL C,/TANG_TOC
ANL C,/HA_TAY
ANL C,/XOAY_TRAI
ANL C,/CHAY
JNC KIEM_TRA_TH33
MOV VUNG,#1EH
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH33: ;NANG_TAY_GAP_QUA
MOV C,NANG_TAY
ANL C,HA_TAY
ANL C,/TANG_TOC
ANL C,/CHAY_THANG
JNC KIEM_TRA_TH34
MOV VUNG,#1FH
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH34: ;NANG_TAY_GAP_QUA
MOV C,NANG_TAY
ANL C,HA_TAY
ANL C,TANG_TOC
ANL C,/CHAY_THANG
JNC KIEM_TRA_TH35
MOV VUNG,#1FH
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH35: ;GAP QUA
MOV C,NANG_TAY
ANL C,/TANG_TOC
ANL C,/HA_TAY
JNC KIEM_TRA_TH36
MOV VUNG,#20H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH36: ;CHAY CHAM XOAY PHAI
MOV C,TANG_TOC
ANL C,NANG_TAY
ANL C,XOAY_TRAI
ANL C,HA_TAY
ANL C,/XOAY_PHAI
ANL C,/CHAY
JNC KIEM_TRA_TH37
MOV VUNG,#21H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH37: ;CHAY CHAM XOAY TRAI
MOV C,TANG_TOC
ANL C,NANG_TAY
ANL C,XOAY_PHAI
ANL C,HA_TAY
ANL C,/XOAY_TRAI
ANL C,/CHAY
JNC KIEM_TRA_TH38
MOV VUNG,#22H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH38: ;CHAY NHANH XOAY PHAI
MOV C,NANG_TAY
ANL C,HA_TAY
ANL C,XOAY_TRAI
ANL C,/CHAY
ANL C,/TANG_TOC
ANL C,/XOAY_PHAI
JNC KIEM_TRA_TH39
MOV VUNG,#24H
JMP THOAT_KIEM_TRA_NUT_NHAN
KIEM_TRA_TH39: ;CHAY NHANH XOAY TRAI
MOV C,NANG_TAY
ANL C,HA_TAY
ANL C,XOAY_PHAI
ANL C,/CHAY
ANL C,/TANG_TOC
ANL C,/XOAY_TRAI
JNC THOAT_KIEM_TRA_NUT_NHAN
MOV VUNG,#23H
JMP THOAT_KIEM_TRA_NUT_NHAN
THOAT_KIEM_TRA_NUT_NHAN:
RET
;***************** DIEU KHIEN ROBOT *****************
DIEU_KHIEN_ROBOT:
MOV A,VUNG
CJNE A,#30H,DK_TH1
CALL CHAY_TIEN
JMP THOAT_DK_ROBOT
DK_TH1:
MOV A,VUNG
CJNE A,#31H,DK_TH2
CALL CHAY_THANG_NHANH
JMP THOAT_DK_ROBOT
DK_TH2:
MOV A,VUNG
CJNE A,#02H,DK_TH3
CALL CHAY_CHAM_NANG
JMP THOAT_DK_ROBOT
DK_TH3:
MOV A,VUNG
CJNE A,#15H,DK_TH4
CALL CHAY_NHANH_NANG
JMP THOAT_DK_ROBOT
DK_TH4:
MOV A,VUNG
CJNE A,#04H,DK_TH5
CALL CHAY_CHAM_HA
JMP THOAT_DK_ROBOT
DK_TH5:
MOV A,VUNG
CJNE A,#05H,DK_TH6
CALL CHAY_NHANH_HA
JMP THOAT_DK_ROBOT
DK_TH6:
MOV A,VUNG
CJNE A,#06H,DK_TH7
CALL CHAY_LUI_CHAM
JMP THOAT_DK_ROBOT
DK_TH7:
MOV A,VUNG
CJNE A,#07H,DK_TH8
CALL CHAY_LUI_NHANH
JMP THOAT_DK_ROBOT
DK_TH8:
MOV A,VUNG
CJNE A,#08H,DK_TH9
CALL LUI_CHAM_NANG
JMP THOAT_DK_ROBOT
DK_TH9:
MOV A,VUNG
CJNE A,#09H,DK_TH10
CALL LUI_NHANH_NANG
JMP THOAT_DK_ROBOT
DK_TH10:
MOV A,VUNG
CJNE A,#0AH,DK_TH11
CALL LUI_CHAM_HA
JMP THOAT_DK_ROBOT
DK_TH11:
MOV A,VUNG
CJNE A,#0BH,DK_TH12
CALL LUI_NHANH_HA
JMP THOAT_DK_ROBOT
DK_TH12:
MOV A,VUNG
CJNE A,#0CH,DK_TH13
CALL XOAY_PHAI_CHAM
JMP THOAT_DK_ROBOT
DK_TH13:
MOV A,VUNG
CJNE A,#0DH,DK_TH14
CALL XOAY_PHAI_NHANH
JMP THOAT_DK_ROBOT
DK_TH14:
MOV A,VUNG
CJNE A,#0EH,DK_TH15
CALL XOAY_TRAI_CHAM
JMP THOAT_DK_ROBOT
DK_TH15:
MOV A,VUNG
CJNE A,#0FH,DK_TH16
CALL XOAY_TRAI_NHANH
JMP THOAT_DK_ROBOT
DK_TH16:
MOV A,VUNG
CJNE A,#10H,DK_TH17
CALL NANG_TAY_GAP
JMP THOAT_DK_ROBOT
DK_TH17:
MOV A,VUNG
CJNE A,#11H,DK_TH20
CALL HA_TAY_GAP
JMP THOAT_DK_ROBOT
DK_TH20:
MOV A,VUNG
CJNE A,#14H,DK_TH22
CALL DUNG_ROBOT
JMP THOAT_DK_ROBOT
DK_TH22:
MOV A,VUNG
CJNE A,#16H,DK_TH23
CALL DUNG_ROBOT2
JMP THOAT_DK_ROBOT
DK_TH23:
MOV A,VUNG
CJNE A,#17H,DK_TH24
CALL XOAY_PHAI_CHAM_NANG
JMP THOAT_DK_ROBOT
DK_TH24:
MOV A,VUNG
CJNE A,#18H,DK_TH25
CALL XOAY_PHAI_NHANH_NANG
JMP THOAT_DK_ROBOT
DK_TH25:
MOV A,VUNG
CJNE A,#19H,DK_TH26
CALL XOAY_TRAI_CHAM_NANG
JMP THOAT_DK_ROBOT
DK_TH26:
MOV A,VUNG
CJNE A,#1AH,DK_TH27
CALL XOAY_TRAI_NHANH_NANG
JMP THOAT_DK_ROBOT
DK_TH27:
MOV A,VUNG
CJNE A,#1BH,DK_TH28
CALL XOAY_PHAI_CHAM_HA
JMP THOAT_DK_ROBOT
DK_TH28:
MOV A,VUNG
CJNE A,#1CH,DK_TH29
CALL XOAY_PHAI_NHANH_HA
JMP THOAT_DK_ROBOT
DK_TH29:
MOV A,VUNG
CJNE A,#1DH,DK_TH30
CALL XOAY_TRAI_CHAM_HA
JMP THOAT_DK_ROBOT
DK_TH30:
MOV A,VUNG
CJNE A,#1EH,DK_TH32
CALL XOAY_TRAI_NHANH_HA
JMP THOAT_DK_ROBOT
DK_TH32:
MOV A,VUNG
CJNE A,#20H,DK_TH33
CALL HA_TAY_GAP_CHAM
JMP THOAT_DK_ROBOT
DK_TH33:
MOV A,VUNG
CJNE A,#21H,DK_TH34
CALL CHAY_CHAM_XOAY_PHAI
JMP THOAT_DK_ROBOT
DK_TH34:
MOV A,VUNG
CJNE A,#22H,DK_TH35
CALL CHAY_CHAM_XOAY_TRAI
JMP THOAT_DK_ROBOT
DK_TH35:
MOV A,VUNG
CJNE A,#24H,DK_TH36
CALL CHAY_NHANH_XOAY_PHAI
JMP THOAT_DK_ROBOT
DK_TH36:
MOV A,VUNG
CJNE A,#23H,THOAT_DK_ROBOT
CALL CHAY_NHANH_XOAY_TRAI
JMP THOAT_DK_ROBOT
THOAT_DK_ROBOT:
RET
;***************** CHAY TIEN CHAM *******************
CHAY_TIEN:
MOV BANH_TRAI,#00
MOV BANH_PHAI,#00
CALL DELAY_FET
SETB BANH_TRAI_DAO
SETB BANH_PHAI_DAO
CALL DELAY_FET
CHAY_TIEN1:
MOV BANH_TRAI,#255
MOV BANH_PHAI,#210
CALL KIEM_TRA_NUT_NHAN
CALL KIEM_TRA_TOC_DO
MOV A,VUNG
CJNE A,#30H,THOAT_CHAY_TIEN
JMP CHAY_TIEN1
THOAT_CHAY_TIEN:
MOV BANH_TRAI,#00
MOV BANH_PHAI,#00
CALL DELAY_FET
SETB BANH_TRAI_DAO
SETB BANH_PHAI_DAO
RET
;*************** CHAY TIEN NHANH ******************
CHAY_THANG_NHANH:
MOV BANH_TRAI,#00
MOV BANH_PHAI,#00
CALL DELAY_FET
SETB BANH_TRAI_DAO
SETB BANH_PHAI_DAO
CALL DELAY_FET
MOV BANH_TRAI,#255
MOV BANH_PHAI,#220
CHAY_THANG_NHANH1:
CALL KIEM_TRA_NUT_NHAN
MOV A,VUNG
CJNE A,#31H,THOAT_CHAY_THANG_NHANH
JMP CHAY_THANG_NHANH1
THOAT_CHAY_THANG_NHANH:
MOV BANH_TRAI,#00
MOV BANH_PHAI,#00
CALL DELAY_FET
SETB BANH_TRAI_DAO
SETB BANH_PHAI_DAO
RET
;************* CHAY TIEN CHAM & NANG **************
;************* CHAY TIEN CHAM & NANG **************
CHAY_CHAM_NANG:
JNB HT_NANG,THOAT_CHAY_CHAM_NANG
MOV BANH_TRAI,#00
MOV BANH_PHAI,#00
MOV MOTOR_NANG,#00
CALL DELAY_FET
SETB BANH_TRAI_DAO
SETB BANH_PHAI_DAO
SETB MOTOR_NANG_DAO
CALL DELAY_FET
MOV BANH_TRAI,#200
MOV BANH_PHAI,#175
MOV MOTOR_NANG,#255
CHAY_CHAM_NANG1:
JNB HT_NANG,THOAT_CHAY_CHAM_NANG
CALL KIEM_TRA_NUT_NHAN
MOV A,VUNG
CJNE A,#02H,THOAT_CHAY_CHAM_NANG_DUNG
JMP CHAY_CHAM_NANG1
THOAT_CHAY_CHAM_NANG:
MOV BANH_TRAI,BANH_TRAI_TD2
MOV BANH_PHAI,BANH_PHAI_TD2
MOV MOTOR_NANG,#00
CALL DELAY_FET
SETB MOTOR_NANG_DAO
CALL KIEM_TRA_NUT_NHAN
MOV A,VUNG
CJNE A,#02H,THOAT_CHAY_CHAM_NANG_DUNG
JMP THOAT_CHAY_CHAM_NANG
THOAT_CHAY_CHAM_NANG_DUNG:
MOV BANH_TRAI,#00
MOV BANH_PHAI,#00
MOV MOTOR_NANG,#00
CALL DELAY_FET
SETB BANH_TRAI_DAO
SETB BANH_PHAI_DAO
SETB MOTOR_NANG_DAO
RET
;************* CHAY TIEN NHANH & NANG
Bạn đang đọc truyện trên: Truyen2U.Net