Day06
作者:互联网
数码管
ORG 0000H
AJMP START
ORG 0030H
START:
MOV R0,#0
SETB P2.0
SETB P2.1
LOOP:
MOV A,R0
LCALL SHOW
JNB P2.0,INCR
JNB P2.1,DECR
JMP LOOP
INCR:
JNB P2.0,INCR
CJNE R0,#9,AAA
MOV R0,#0
JMP LOOP
AAA:
INC R0
JMP LOOP
DECR:
JNB P2.1,DECR
CJNE R0,#0,ZERO
MOV R0,#9
JMP LOOP
ZERO:
DEC R0
JMP LOOP
SHOW:
MOV A,R0
MOV DPTR,#LED
MOVC A,@A+DPTR
MOV P0,A
RET
LED:
DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H
END
数码管译码器
ORG 00H
AJMP START
ORG 30H
START:
MOV A,#0
SETB P2.0
SETB P2.1
LOOP:
MOV P0,A
JNB P2.0,INCR
JNB P2.1,DECR
JMP LOOP
INCR:JNB P2.0,INCR
CJNE A,#9,AAA
MOV A,#0
JMP LOOP
AAA:
INC A
JMP LOOP
DECR:
JNB P2.1,DECR
CJNE A,#0,ZERO
MOV A,#9
JMP LOOP
ZERO:DEC A
JMP LOOP
END
二位数码管
COUNT EQU 30H;储存单元用于记录十进制数
SP1 BIT P3.7
ORG 00H
AJMP START
ORG 40H
START:MOV COUNT,#00H
NEXT:MOV A,COUNT
MOV B,#10
DIV AB
MOV DPTR,#TABLE
MOVC A,@A+DPTR
MOV P0,A
MOV A,B
MOVC A,@A+DPTR
MOV P2,A
LOOP:
JNB SP1,INCR
JMP LOOP
INCR:JNB SP1,INCR
INC COUNT
MOV A,COUNT
CJNE A,#100,NEXT
LJMP START
TABLE:
DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH
END
标签:INCR,R0,JMP,Day06,MOV,JNB,LOOP 来源: https://www.cnblogs.com/Unclesundada/p/16284206.html