1、51 单片机常用数码管显示程序-之汇编篇 2010-07-21 03:35:46| 分类: 单片机 | 标签: 51 单片机 数码管 汇编程序 |字号大中小 订阅 一)显示数据缓存寄存器 70H,71H,72H,73H,74H,75H,76H,77H 。START:MOV 70H,#1MOV 71H,#2MOV 72H,#3MOV 73H,#4MOV 74H,#5MOV 75H,#6MOV 76H,#7MOV 77H,#8ACALL DISPAJMP STARTDISP: MOV R1,#70H MOV R5,#0FEH PLAY: MOV P0,#0FFH MOV A,R5 ANL P2,A
2、 MOV A,R1 MOV DPTR,#TAB MOVC A,A+DPTR MOV P0,A LCALL DL1MS INC R1 MOV A,P2 JNB ACC.7,ENDOUT RL A MOV R5,A MOV P2,#0FFH AJMP PLAY ENDOUT: MOV P2,#0FFH MOV P0,#0FFH RET TAB: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,0FFH;共阳数码管; 1MS 延时子程序,LED 显示用DL1MS: MOV R6,#14H ;DL1: MOV R7,#19HDL2: DJNZ R7,DL
3、2DJNZ R6,DL1RETEND二)START:;ORG 00HMOV 70H,#0C0H;0MOV 71H,#0F9H;1MOV 72H,#0A4H;2MOV 73H,#0B0H;3MOV 74H,#99H ;4MOV 75H,#92H ;5MOV 76H,#82H ;6MOV 77H,#0F8H;7ACALL DISPAJMP STARTDISP: MOV P0,70H CLR P2.7ACALL DL1MSSETB P2.7MOV P0,71H CLR P2.6ACALL DL1MSSETB P2.6MOV P0,72H CLR P2.5ACALL DL1MSSETB P2.5MOV
4、 P0,73H CLR P2.4ACALL DL1MSSETB P2.4MOV P0,74H CLR P2.3ACALL DL1MSSETB P2.3MOV P0,75H CLR P2.2ACALL DL1MSSETB P2.2MOV P0,76H CLR P2.1ACALL DL1MSSETB P2.1MOV P0,77H CLR P2.0ACALL DL1MSSETB P2.0RETDL1MS: MOV R6,#14H ;DL1: MOV R7,#19HDL2: DJNZ R7,DL2DJNZ R6,DL1RETEND三)START:ORG 00HMOV 70H,#1MOV 71H,#2M
5、OV 72H,#3MOV 73H,#4MOV 74H,#5MOV 75H,#6MOV 76H,#7MOV 77H,#8ACALL DISPAJMP STARTDISP: MOV R1,#70H MOV A,R1 MOV DPTR,#TAB MOVC A,A+DPTR MOV P0,A CLR P2.7LCALL DL1MS SETB P2.7MOV R1,#71H MOV A,R1 MOV DPTR,#TAB MOVC A,A+DPTR MOV P0,A CLR P2.6LCALL DL1MS SETB P2.6MOV R1,#72H MOV A,R1 MOV DPTR,#TAB MOVC A
6、,A+DPTR MOV P0,A CLR P2.5LCALL DL1MSSETB P2.5MOV R1,#73H MOV A,R1 MOV DPTR,#TAB MOVC A,A+DPTR MOV P0,A CLR P2.4LCALL DL1MS SETB P2.4MOV R1,#74H MOV A,R1 MOV DPTR,#TAB MOVC A,A+DPTR MOV P0,A CLR P2.3LCALL DL1MS SETB P2.3MOV R1,#75H MOV A,R1 MOV DPTR,#TAB MOVC A,A+DPTR MOV P0,A CLR P2.2LCALL DL1MSSETB
7、 P2.2MOV R1,#76H MOV A,R1 MOV DPTR,#TAB MOVC A,A+DPTR MOV P0,A CLR P2.1LCALL DL1MS SETB P2.1MOV R1,#77H MOV A,R1 MOV DPTR,#TAB MOVC A,A+DPTR MOV P0,A CLR P2.0LCALL DL1MS SETB P2.0RET TAB: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,0FFHDL1MS: MOV R6,#14H DL1: MOV R7,#19HDL2: DJNZ R7,DL2DJNZ R6,DL1RET END