1、- 1 -以下是一段程序实例,显示 “迎接北京 2008 奥运!”并缓慢向左移动。源程序如下:ORG 0000HSJMP STARTORG 000BHAJMP ZDORG 0030HSTART: MOV SCON,#00H;设串口为方式 0MOV SP,#60HMOV 20H,#00HMOV 21H,#00HMOV R1,#0FFHMOV R7,#02HMOV R4,#80HMOV TMOD,#02H;设 T0 为方式 2 定时(8 位自动重装载方式)MOV TH0,#01HMOV TL0,#01HSETB EASETB ET0SETB TR0L1: MOV R6,#00H;列扫描计数清零MO
2、V R0,#00HMOV A,R4D1: ACALL XIANSHI;左 8 位列扫描程序MOV P2,AACALL YS5MSRR AMOV P2,#00HINC R6CJNE R6,#08H,D1MOV A,R4D2: ACALL XIANSHI;右 8 位列扫描程序MOV P0,AACALL YS5MSRR AMOV P0,#00HINC R6CJNE R6,#10H,D2LJMP L1ZD: PUSH ACC;中断程序DJNZ R1,BACKMOV R1,#0FFHDJNZ R7,BACKMOV R7,#02HMOV A,DPL;调整数据指针ADD A,#02HMOV DPL,AMOV
3、 A,DPH- 2 -ADDC A,#00HMOV DPH,ABACK: POP ACCRETIXIANSHI:PUSH ACCMOV R2,#02HD3: MOV A,#TAB;读取表首地址ADD A,R0MOVC A,A+DPTR;读取数据并送显示MOV SBUF,AJBC TI,$CLR TIINC R0DJNZ R2,D3CJNE A,#0F0H,D4;检测汉字是否送完MOV DPL,#00HMOV DPH,#00HD4: POP ACCRETYS5MS: MOV R3,#02H;延时 5 毫秒D5: MOV R5,#248DJNZ R5,$DJNZ R3,D5RETTAB: DB 0
4、0H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H;“ “,显示用表格DB 00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H;“ “,DB 40H,40H,41H,20H,0CEH,1FH,04H,20H,00H,40H,0FCH,47H,04H,42H,02H,41H;DB 02H,40H,0FCH,5FH,04H,40H,04H,42H,04H,44H,0FCH,43H,00H,40H,00H,00H;“迎“,DB 08H,02H,08H,
5、42H,08H,81H,0FFH,7FH,88H,02H,68H,82H,24H,8AH,2CH,4EH;DB 0B4H,53H,25H,32H,26H,12H,34H,2EH,2CH,42H,24H,0C2H,20H,02H,00H,00H;“接“,DB 00H,10H,20H,30H,20H,18H,20H,08H,20H,04H,0FFH,7FH,00H,00H,00H,00H;DB 00H,00H,0FFH,3FH,40H,40H,20H,40H,30H,40H,18H,40H,10H,78H,00H,00H;“北“,DB 00H,00H,04H,20H,04H,10H,0E4H,19
6、H,24H,0DH,24H,41H,25H,81H,26H,7FH;DB 24H,01H,24H,01H,24H,05H,0E4H,0DH,06H,38H,04H,10H,00H,00H,00H,00H;“京“,DB 00H,00H,70H,30H,08H,28H,08H,24H,08H,22H,88H,21H,70H,30H,00H,00H;“2“,DB 00H,00H,0E0H,0FH,10H,10H,08H,20H,08H,20H,10H,10H,0E0H,0FH,00H,00H;“0“,DB 00H,00H,0E0H,0FH,10H,10H,08H,20H,08H,20H,10H,10
7、H,0E0H,0FH,00H,00H;“0“,DB 00H,00H,70H,1CH,88H,22H,08H,21H,08H,21H,88H,22H,70H,1CH,00H,00H;“8“,DB 00H,80H,00H,84H,0FEH,45H,22H,44H,2AH,25H,0B2H,14H,63H,0CH,0FEH,07H;- 3 -DB 62H,0CH,0B2H,14H,0AAH,25H,22H,24H,0FEH,45H,00H,0C4H,00H,44H,00H,00H;“奥“,DB 40H,40H,41H,20H,0CEH,1FH,04H,20H,00H,28H,20H,4CH,22H,
8、4AH,0A2H,49H;DB 62H,48H,22H,4CH,0A2H,44H,22H,45H,22H,5EH,22H,4CH,20H,40H,00H,00H;“运“,DB 00H,00H,00H,00H,00H,00H,0F0H,5FH,00H,00H,00H,00H,00H,00H,00H,00H;DB 00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H;“!“,DB 00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H;“,DB 00H,0F0H;结束标志END