Mình đang làm đồ án quét led 7 đoạn hiển thị từ 00 đến 9999 với yêu cầu cứ 1s là tăng một giá trị, mình tìm được code này nhưng chưa hiểu code. Nhờ mọi người giúp
ORG 00
MAIN:
MOV R1,#0
LAPLAI:
MOV R0,#0
LAP:
CALL HIENTHI
INC R0
CJNE R0,#100,LAP
INC R1
CJNE R1,#100,LAPLAi
JMP MAIN
HIENTHI:
MOV R7,#100
QUET:
MOV P3,#00H
MOV A,R0
MOV B,#10
DIV AB
MOV DPTR,#MALED
MOVC A,@A+DPTR
MOV P2,A
CALL DELAY
SETB P3.1
CALL DELAY
CLR P3.1
MOV A,B
MOVC A,@A+DPTR
MOV P2,A
SETB P3.0
CALL DELAY
CLR P3.0
CALL DELAY
MOV A,R1
MOV B,#10
DIV AB
MOV DPTR,#MALED
MOVC A,@A+DPTR
MOV P2,A
CALL DELAY
SETB P3.3
CALL DELAY
CLR P3.3
MOV A,B
MOVC A,@A+DPTR
MOV P2,A
SETB P3.2
CALL DELAY
CLR P3.2
CALL DELAY
RET
MALEDB 11000000B,11111001B,10100100B,10110000B,10011001B, 10010010B,10000010B,11111000B,10000000B,10010000B
DELAY:
MOV R3,#100
LAP1:
MOV R2,#12
LAPA:
NOP
NOP
NOP
NOP
DJNZ R2,LAPA
DJNZ R3,LAP1
RET
END
Đây là file mô phỏng :
http://www.dientuvietnam.net/forums/...51-00-9999.zip
ORG 00
MAIN:
MOV R1,#0
LAPLAI:
MOV R0,#0
LAP:
CALL HIENTHI
INC R0
CJNE R0,#100,LAP
INC R1
CJNE R1,#100,LAPLAi
JMP MAIN
HIENTHI:
MOV R7,#100
QUET:
MOV P3,#00H
MOV A,R0
MOV B,#10
DIV AB
MOV DPTR,#MALED
MOVC A,@A+DPTR
MOV P2,A
CALL DELAY
SETB P3.1
CALL DELAY
CLR P3.1
MOV A,B
MOVC A,@A+DPTR
MOV P2,A
SETB P3.0
CALL DELAY
CLR P3.0
CALL DELAY
MOV A,R1
MOV B,#10
DIV AB
MOV DPTR,#MALED
MOVC A,@A+DPTR
MOV P2,A
CALL DELAY
SETB P3.3
CALL DELAY
CLR P3.3
MOV A,B
MOVC A,@A+DPTR
MOV P2,A
SETB P3.2
CALL DELAY
CLR P3.2
CALL DELAY
RET
MALEDB 11000000B,11111001B,10100100B,10110000B,10011001B, 10010010B,10000010B,11111000B,10000000B,10010000B
DELAY:
MOV R3,#100
LAP1:
MOV R2,#12
LAPA:
NOP
NOP
NOP
NOP
DJNZ R2,LAPA
DJNZ R3,LAP1
RET
END
Đây là file mô phỏng :
http://www.dientuvietnam.net/forums/...51-00-9999.zip
Comment