đây là code đèn giao thông , các anh giải thích giúp em
$MOD51
ORG 00H
MAIN:
MOV P0,#0FBH
MOV P1,#26H
MOV R1,#6
EEE:
ACALL DELAY
DEC P1
DJNZ R1,EEE
ACALL DELAY
MOV P1,#19H
MOV R1,#9
FFF:
ACALL DELAY
DEC P1
DJNZ R1,FFF
ACALL DELAY
MOV P1,#09H
MOV R1,#9
GGG:
ACALL DELAY
DEC P1
DJNZ R1,GGG
ACALL DELAY
MOV P1,#20H
MOV P0,#0FEH
ACALL DELAY
MOV P1,#19H
MOV R1,#9
BBB:
ACALL DELAY
DEC P1
DJNZ R1,BBB
ACALL DELAY
MOV P1,#09H
MOV R1,#9
CCC:
ACALL DELAY
DEC P1
DJNZ R1,CCC
ACALL DELAY
MOV P0,#0FDH
MOV P1,#05H
MOV R1,#5
DDD:
ACALL DELAY
DEC P1
DJNZ R1,DDD
ACALL DELAY
SJMP MAIN
DELAY:
PUSH 00H
MOV TMOD,#01H
MOV R0,#100
AAA:
MOV TH0,#HIGH(-10000)
MOV TL0,#LOW(-10000)
SETB TR0
JNB TF0,$
CLR TF0
CLR TR0
DJNZ R0,AAA
POP 00H
RET
END
$MOD51
ORG 00H
MAIN:
MOV P0,#0FBH
MOV P1,#26H
MOV R1,#6
EEE:
ACALL DELAY
DEC P1
DJNZ R1,EEE
ACALL DELAY
MOV P1,#19H
MOV R1,#9
FFF:
ACALL DELAY
DEC P1
DJNZ R1,FFF
ACALL DELAY
MOV P1,#09H
MOV R1,#9
GGG:
ACALL DELAY
DEC P1
DJNZ R1,GGG
ACALL DELAY
MOV P1,#20H
MOV P0,#0FEH
ACALL DELAY
MOV P1,#19H
MOV R1,#9
BBB:
ACALL DELAY
DEC P1
DJNZ R1,BBB
ACALL DELAY
MOV P1,#09H
MOV R1,#9
CCC:
ACALL DELAY
DEC P1
DJNZ R1,CCC
ACALL DELAY
MOV P0,#0FDH
MOV P1,#05H
MOV R1,#5
DDD:
ACALL DELAY
DEC P1
DJNZ R1,DDD
ACALL DELAY
SJMP MAIN
DELAY:
PUSH 00H
MOV TMOD,#01H
MOV R0,#100
AAA:
MOV TH0,#HIGH(-10000)
MOV TL0,#LOW(-10000)
SETB TR0
JNB TF0,$
CLR TF0
CLR TR0
DJNZ R0,AAA
POP 00H
RET
END
Comment