ORG 00H MAIN: CALL CTA;goi chuong trinh con CALL CTB CALL CTC JMP MAIN CTA: ;sang dan led MOV R1,#8;quet 8 led LAP: SETB P2.0;thiet lap bit chan data len 1 cho led sang CALL DELAY SETB P2.1;tao xung mo cho bit vao chan SH CALL DELAY CLR P2.1;tao xung dong khong cho bit vao chan SH CALL DELAY SETB P2.2;tao xung mo ST cho bit xuat ra cac chan led CALL DELAY CLR P2.2;tao xung dong ST khong cho bit xuat ra cac chan led CALL DELAY DJNZ R1,LAP ;tat dan led MOV R1,#8 LAP1: CLR P2.0;thiet lap bit chan data len 1 cho led sang CALL DELAY SETB P2.1 CALL DELAY CLR P2.1 CALL DELAY SETB P2.2 CALL DELAY CLR P2.2 CALL DELAY DJNZ R1,LAP1 RET CTB:;sang 1 led chay MOV R4,#3 NHAY: SETB P2.0 CALL DELAY SETB P2.1 CALL DELAY CLR P2.1 SETB P2.2 CALL DELAY CLR P2.2 CALL DELAY MOV R1,#7 LAP2: CLR P2.0 SETB P2.1 CLR P2.1 SETB P2.2 CLR P2.2 CALL DELAY CALL DELAY DJNZ R1,LAP2 DJNZ R4,NHAY RET CTC:;sang nhap nhay led MOV R4,#3 NHAY1: MOV R1,#8 LAP3: SETB P2.0 SETB P2.1 CLR P2.1 DJNZ R1,LAP3 SETB P2.2 CLR P2.2 CALL DELAY MOV R1,#8 LAP4: CLR P2.0 SETB P2.1 CLR P2.1 DJNZ R1,LAP4 SETB P2.2 CLR P2.2 CALL DELAY DJNZ R4,NHAY1 RET DELAY:;chuong trinh tao tre MOV R0,#200 LOOP: MOV R2,#200 LOOP1: DJNZ R2,LOOP1 DJNZ R0,LOOP RET END
Đăng nhận xét