數碼管段選連線到微控制器P0口,位選連線到P2口 ORG 0000h MAIN: CALL DISPLAY AJMP MAIN DISPLAY: MOV R0,#0 MOV R1,#0x01 MOV DPTR,#TAB LOOP: INC R0 MOV A,R0 MOVC A,@A+DPTR MOV P0,#0 ;消隱 MOV P0,A ;送段碼 CALL DELAY MOV A,R1 ;送位碼 RL A ;移位 MOV P2,A MOV R1,A CALL DELAY CJNE R0,#8,LOOP ;判斷8次是否迴圈完成 RET DELAY: MOV R6,#25 DD: MOV R7,#50 DJNZ R7,$ DJNZ R6,DD RET TAB: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H END
數碼管段選連線到微控制器P0口,位選連線到P2口 ORG 0000h MAIN: CALL DISPLAY AJMP MAIN DISPLAY: MOV R0,#0 MOV R1,#0x01 MOV DPTR,#TAB LOOP: INC R0 MOV A,R0 MOVC A,@A+DPTR MOV P0,#0 ;消隱 MOV P0,A ;送段碼 CALL DELAY MOV A,R1 ;送位碼 RL A ;移位 MOV P2,A MOV R1,A CALL DELAY CJNE R0,#8,LOOP ;判斷8次是否迴圈完成 RET DELAY: MOV R6,#25 DD: MOV R7,#50 DJNZ R7,$ DJNZ R6,DD RET TAB: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H END