Nguyên văn bởi thi tran
Xem bài viết
phần code:
INCLUDE 89c51.mc
ORG 0000H
MAIN:
MOV A,#ffh
MOV p0,A
MOV p1,A
MOV p2,A
MOV p3,A
LJMP pro0
RET
PRO0:
MOV R1,#8
ty1: MOV A,#55h
MOV p0,A
MOV p1,A
MOV p2,A
MOV p3,A
LCALL DELAYcham
MOV A,#0aah
MOV p0,A
MOV p1,A
MOV p2,A
MOV p3,A
LCALL DELAYcham
DJNZ R1,ty1
LJMP nhapnhay
RET
nhapnhay:
MOV R0,#20
bbb: MOV p0,#00h
MOV p1,#00h
MOV p2,#00h
MOV p3,#00h
call delay
MOV p0,#0ffh
MOV p1,#0ffh
MOV p2,#0ffh
MOV p3,#0ffh
call delay
DJNZ R0,bbb
LJMP pro1
RET
...................
LJMP main
RET
delay:
MOV R5,#60
lap2: MOV R6,#60
lap1: MOV R7,#5
DJNZ R7,$
DJNZ R6,lap1
DJNZ R5,lap2
RET
delaycham:
MOV R0,#30
DEL: MOV R1,#0FfH
DJNZ R1,$
DJNZ R0,DEL
RET
END
Comment