以下程式實現6位數碼管,每一位依次迴圈顯示0--9
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
MOV P2,#0FEH
MOV A,#00H
MOV DPTR,#TAB
LOOP:
MOVC A,@A+DPTR
MOV P0,A
LCALL DELAY
INC A
CJNE A,#0AH,LOOP
MOV A,P2
RL A
MOV P2,A
JB ACC.6,SS1
SS1:
CLR A
SJMP LOOP
DELAY:
MOV R1,#2
L1: MOV R2,#200
L2: MOV R3,#200
L3: DJNZ R3,L1
DJNZ R2,L2
DJNZ R1,L3
RET SJMP $
ORG 0080H
TAB:
DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H
END
以下程式實現6位數碼管,每一位依次迴圈顯示0--9
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
MOV P2,#0FEH
MOV A,#00H
MOV DPTR,#TAB
LOOP:
MOVC A,@A+DPTR
MOV P0,A
LCALL DELAY
INC A
CJNE A,#0AH,LOOP
MOV A,P2
RL A
MOV P2,A
JB ACC.6,SS1
MOV P2,#0FEH
SS1:
CLR A
SJMP LOOP
DELAY:
MOV R1,#2
L1: MOV R2,#200
L2: MOV R3,#200
L3: DJNZ R3,L1
DJNZ R2,L2
DJNZ R1,L3
RET SJMP $
ORG 0080H
TAB:
DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H
END