1、ORG 0000HMOV R4,#08H ;一个字,八字节代码MOV P2,#0A0H ;利用 p2 口第二功能MOV R1,#00HMOV A,#00HMOVX R1,A ;关显示NEW_CODE:MOV 61H,#04H ;此程序有四个字MOV DPTR,#DIS_CODE;DIP: MOV 69H,#40H ;一个字停留的速度RD_DISP:MOV R3,#80H ;选通一行MOV R2,#00H ;送出字码RDISP1: MOV A,#00H ;MOVX R1,A ;关显示MOV A,R3 ;ACALL SEND ;送出选通行代码MOV A,R2 ;MOVC A,A+DPTRMOVX
2、R1,A ;送出字码ACALL DELAYT ;延时INC R2MOV A,R3RR AMOV R3,ADJNZ R4,RDISP1 ;送完一个字代码吗?MOV R4,#08H ;重新初始化 r4DJNZ 69H,RD_DISP ;速度系数没有循环完,继续MOV R7,#08H ;指针 dptr 加 8DEC_CODE:INC DPTR ;指向下一个字代码DJNZ R7,DEC_CODE ;四个字都循环了一遍了吗?DJNZ 61H,DIPMOV 61H,#02HSJMP NEW_CODESEND: MOV PCON,#80H ;初始化串行口MOV TMOD,#20H ;为方式 0MOV TH1
3、,#98HCLR ET1SETB TR1MOV SCON,#00HCLR ESMOV A,R3MOV SBUF,A ;把选通行代码送出W1: JNB TI,W1 ;等待数据送出CLR TI ;数据送出后,中断标志清零RET;DELAYT:MOV R7,#01HDLY1: MOV R6,#0FFHDLY2: DJNZ R6,DLY2DJNZ R7,DLY1RETDIS_CODE: DB 10H,0FEH,92H,0FEH,92H,0FEH,11H,1FHDIS_CODE1:DB 0FFH,0FFH,18H,18H,18H,18H,0FFH,0FFHDIS_CODE2: DB 10H,0FEH,92H,0FEH,92H,0FEH,11H,1FHDIS_CODE3: DB 3EH,04H,08H,0FFH,08H,04H,14H,08H