从1302中读出的数据放在67H(高两位年)66H(低两位年)65H(月)64H(星期)63H(日);62H(小时)61h(分钟)60H(秒)57H(农历月)56H(农历日)
上传时间: 2014-12-04
上传用户:
键盘实现电子琴功能....用61h和1ah端口实现
上传时间: 2014-01-15
上传用户:362279997
万年历程序 从1302中读出的数据放在67H(高两位年)66H(低两位年)65H(月)64H(星期)63H(日) 62H(小时)61h(分钟)60H(秒)57H(农历月)56H(农历日) 显示缓冲单元7CH-7BH(4CH-4BH)(年低位),7AH-79H(4AH-49H)月,78H(48H)星期, 77H-76H(47H-46H)日,75H-74H(45H-44H)小时,73H-72H(43H-42H)分钟,71H-70H(41H-40H)秒 5EH-5DH(55H-54H)农历年,5CH-5BH(53H-52H)农历月,5AH-59H(51H-50H)农历日 闰月标志为F0,定时器T1为调整时候闪烁用。 1302在设置调整时间后,要改为禁止写入状态,否则在上电复位的时候就发生误写入,使时间值加1分钟 次程序中的段码表只适用于该特殊的硬件,具体的段码表由具体的硬件决定
上传时间: 2017-06-07
上传用户:erkuizhang
带中文字库的128X64是一种具有4位/8位并行、2线或3线串行多种接口方式,内部含有国标一级、二级简体中文字库的点阵图形液晶显示模块;其显示分辨率为128×64, 内置8192个16*16点汉字,和128个16*8点ASCII字符集.利用该模块灵活的接口方式和简单、方便的操作指令,可构成全中文人机交互图形界面。可以显示8×4行16×16点阵的汉字. 也可完成图形显示.低电压低功耗是其又一显著特点。由该模块构成的液晶显示方案与同类型的图形点阵液晶显示模块相比,不论硬件电路结构或显示程序都要简洁得多,且该模块的价格也略低于相同点阵的图形液晶模块。 基本特性: 低电源电压(VDD:+3.0--+5.5V) 显示分辨率:128×64点 内置汉字字库,提供8192个16×16点阵汉字(简繁体可选) 内置 128个16×8点阵字符 2MHZ时钟频率 显示方式:STN、半透、正显 驱动方式:1/32DUTY,1/5BIAS 视角方向:6点 背光方式:侧部高亮白色LED,功耗仅为普通LED的1/5—1/10 通讯方式:串行、并口可选 内置DC-DC转换电路,无需外加负压 无需片选信号,简化软件设计 工作温度: 0℃ - +55℃ ,存储温度: -20℃ - +60℃ 12864(带字库汉字显示演示程序) ;*************************************************************************** ;* sxj1974@163.com (51c51 test web) www.8951.com * ;* Create by :石学军 www.51c51.com 更多例程请登陆网站 * ;*************************************************************************** RS EQU P2.0 RW EQU P2.1 E EQU P2.2 PSB EQU P2.3 RST EQU P2.5 ;----------------------------------------------- LCD_X EQU 30H LCD_Y EQU 31H COUNT EQU 32H COUNT1 EQU 33H COUNT2 EQU 34H COUNT3 EQU 35H ;----------------------------------------------- LCD_DATA EQU 36H LCD_DATA1 EQU 37H LCD_DATA2 EQU 38H STORE EQU 39H ;----------------------------------------------- ORG 0000H LJMP MAIN ORG 0100H ;----------------------------------------------- MAIN: MOV SP,#5FH CLR RST ;复位 LCALL DELAY4 SETB RST NOP SETB PSB ;通讯方式为8位数据并口 ;********************初始化********************** LGS0: MOV A,#34H ;34H--扩充指令操作 LCALL SEND_I MOV A,#30H ;30H--基本指令操作 LCALL SEND_I MOV A,#01H ;清除显示 LCALL SEND_I MOV A,#06H ;指定在资料写入或读取时,光标的移动方向 LCALL SEND_I ;DDRAM 的地址计数器(AC)加1 MOV A,#0CH ;开显示,关光标,不闪烁 LCALL SEND_I ;=============================================== TU_PLAY1: MOV DPTR,#TU_TAB1 ;显示图形 LCALL PHO_DISP LCALL DELAY3 ;================================================= ;;显示汉字和字符 ;加入80ms的延时,使你能够看清楚显示的过程 ;根据汉字显示坐标分段写入(顺序写入) ;================================================= HAN_WR2: LCALL CLEAR_P HAN_WR2A: MOV DPTR,#TAB1A ;显示汉字和字符 MOV COUNT,#10H ;地址计数器设为16。 MOV A,#80H ;第一行起始地址 LCALL SEND_I LCALL QUSHU HAN_WR2B: MOV DPTR,#TAB1B ;显示汉字和字符 MOV COUNT,#10H ;地址计数器设为16。 MOV A,#90H ;第二行起始地址 LCALL SEND_I LCALL QUSHU HAN_WR2C: MOV DPTR,#TAB1C ;显示汉字和字符 MOV COUNT,#10H ;地址计数器设为16。 MOV A,#88H ;第三行起始地址 LCALL SEND_I LCALL QUSHU HAN_WR2D: MOV DPTR,#TAB1D ;显示汉字和字符 MOV COUNT,#10H ;地址计数器设为16。 MOV A,#98H ;第四行起始地址 LCALL SEND_I LCALL QUSHU LCALL DELAY3 LCALL FLASH LCALL CLEAR_P JMP TU_PLAY2 ;---------------------------------------------- ;TU_PLAY1: MOV DPTR,#TU_TAB1 ;显示图形 LCALL PHO_DISP LCALL DELAY3 ;---------------------------------------------- TU_PLAY2: MOV DPTR,#TU_TAB2 ;显示图形 LCALL PHO_DISP LCALL DELAY3 ;---------------------------------------------- TU_PLAY3: MOV DPTR,#TU_TAB4 ;显示图形 LCALL PHO_DISP LCALL DELAY3 ;----------------------------------------------- ;显示点阵 ;----------------------------------------------- LATPLAY1: MOV A,#01H ;清屏 LCALL SEND_I MOV LCD_DATA1,#0CCH ;显示点阵 MOV LCD_DATA2,#0CCH LCALL LAT_DISP LCALL DELAY3 LCALL CLEAR_P KU_PLAY2: LJMP TU_PLAY1 ;=============================================== ;全屏显示图形子程序 ;=============================================== PHO_DISP: MOV COUNT3,#02H MOV LCD_X,#80H PHO_DISP1: MOV LCD_Y,#80H MOV COUNT2,#20H PHO_DISP2: MOV COUNT1,#10H LCALL WR_ZB PHO_DISP3: CLR A MOVC A,@A+DPTR LCALL SEND_D INC DPTR DJNZ COUNT1,PHO_DISP3 INC LCD_Y DJNZ COUNT2,PHO_DISP2 MOV LCD_X,#88H DJNZ COUNT3,PHO_DISP1 MOV A,#36H LCALL SEND_I MOV A,#30H LCALL SEND_I RET ;---------------------------------------------- CLRRAM: MOV LCD_DATA1,#00H ;GDRAM写0子程序 MOV LCD_DATA2,#00H LCALL LAT_DISP RET ;============================================== ;显示点阵子程序 ;============================================== LAT_DISP: MOV COUNT3,#02H MOV LCD_X,#80H LAT_DISP1: MOV LCD_Y,#80H CLR F0 MOV COUNT2,#20H LAT_DISP2: MOV COUNT1,#10H LCALL WR_ZB LAT_DISP3: JB F0,LAT_DISP32 MOV LCD_DATA,LCD_DATA1 AJMP LAT_DISP31 LAT_DISP32: MOV LCD_DATA,LCD_DATA2 LAT_DISP31: MOV A,LCD_DATA LCALL SEND_D DJNZ COUNT1,LAT_DISP31 INC LCD_Y CPL F0 DJNZ COUNT2,LAT_DISP2 MOV LCD_X,#88H DJNZ COUNT3,LAT_DISP1 MOV A,#36H LCALL SEND_I MOV A,#30H LCALL SEND_I RET ;--------------------------------------------- WR_ZB: MOV A,#34H LCALL SEND_I MOV A,LCD_Y LCALL SEND_I MOV A,LCD_X LCALL SEND_I MOV A,#30H LCALL SEND_I RET ;=============================================== FLASH: MOV A,#08H ;关闭显示 LCALL SEND_I LCALL DELAY5 MOV A,#0CH ;开显示,关光标,不闪烁 LCALL SEND_I LCALL DELAY5 MOV A,#08H ;关闭显示 LCALL SEND_I LCALL DELAY5 MOV A,#0CH ;开显示,关光标,不闪烁 LCALL SEND_I LCALL DELAY5 MOV A,#08H ;关闭显示 LCALL SEND_I LCALL DELAY5 RET ;================================================== ;清屏 ;================================================== CLEAR_P: MOV A,#01H ;清屏 LCALL SEND_I MOV A,#34H LCALL SEND_I MOV A,#30H LCALL SEND_I RET ;================================================== ;查表取数据送显示 ;================================================== QUSHU: CLR A MOVC A,@A+DPTR ;查表取数据 LCALL SEND_D ;送显示 INC DPTR LCALL DELAY4 ;延时80ms, DJNZ COUNT,QUSHU RET ;=============================================== ;写数据子程序 ;RS=1,RW=0,E=高脉冲,D0-D7=数据 ;=============================================== SEND_D: LCALL CHK_BUSY ;写数据子程序 SETB RS CLR RW MOV P0,A SETB E NOP NOP CLR E RET ;=============================================== ;写指令子程序 ;RS=0,RW=0,E=高脉冲,D0-D7=指令码 ;=============================================== SEND_I: LCALL CHK_BUSY CLR RS CLR RW MOV P0,A SETB E NOP NOP CLR E RET ;================================================ ;读数据子程序 ;RS=1,RW=1,E=H,D0-D7=数据 ;================================================ READ_D: LCALL CHK_BUSY ;读数据子程序 SETB RS SETB RW SETB E NOP MOV A,P0 CLR E MOV STORE,A RET ;================================================ ;;测忙碌子程序 ;RS=0,RW=1,E=H,D0-D7=状态字 ;================================================ CHK_BUSY: MOV P0,#0FFH ;测忙碌子程序 CLR RS SETB RW SETB E JB P0.7,$ CLR E RET ;================================================ ;延时子程序 DELAY3: MOV R5,#16H DEL31: MOV R6,#100 DEL32: MOV R7,#0FFH DEL33: DJNZ R7,DEL33 DJNZ R6,DEL32 DJNZ R5,DEL31 RET DELAY2: MOV R6,#0CH DEL21: MOV R7,#18H DEL22: DJNZ R7,DEL22 DJNZ R6,DEL21 RET DELAY1: MOV R6,#06H DEL11: MOV R7,#08H DEL12: DJNZ R7,DEL12 DJNZ R6,DEL11 RET DELAY4: MOV R6,#100 DEL41: MOV R7,#200 DEL42: DJNZ R7,DEL42 DJNZ R6,DEL41 RET DELAY5: MOV R5,#05H DEL51: MOV R6,#100 DEL52: MOV R7,#0FFH DEL53: DJNZ R7,DEL53 DJNZ R6,DEL52 DJNZ R5,DEL51 RET ;*********************************************** TAB1: TAB1A: DB ' 51单片机学习网(深圳学林电子有限公司) ' ;显示在第一行 TAB1C: DB '自学单片机第一站' ;显示在第三行 TAB1B: DB ' WWW.8951.COM ' ;显示在第二行 TAB1D: DB 'TEL 755-89956892' ;显示在第四行 ;*-------------------------------------------------------------------- * ;* Bitmap点阵数据表 * ;* 图片: E:\图形8.bmp,横向取模左高位,数据排列:从左到右从上到下 * ;* 图片尺寸: 128 * 64 * ;*-------------------------------------------------------------------- * TU_TAB1: ; 数据表 db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 3Ch, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 7Fh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h,0FFh,0C0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 01h,0BFh,0F8h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 01h,0FFh,0DCh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 01h, 1Fh,0FEh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 01h,0DFh,0FFh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h,0FFh,0FFh, 19h, 8Ch, 03h, 06h, 00h, 18h, 00h,0FFh,0E1h db 80h, 00h, 00h, 00h, 00h, 3Fh,0FFh, 0Ch,0CCh, 03h, 06h, 00h, 18h, 00h,0FFh,0E1h db 80h, 00h, 00h, 00h, 00h, 7Fh,0FFh, 04h, 58h, 03h, 06h, 01h,0FFh,0C0h, 00h,0C1h db 80h, 00h, 00h, 00h, 00h, 7Fh,0DAh, 3Fh,0FEh, 0Fh,0DFh,0C1h,0FFh,0C0h, 01h, 81h db 80h, 00h, 00h, 00h, 00h, 7Fh, 8Ch, 3Fh,0FEh, 0Fh,0DFh,0C1h, 98h,0C0h, 07h, 01h db 80h, 00h, 00h, 00h, 00h, 7Fh,0B8h, 30h, 06h, 03h, 06h, 01h, 98h,0C0h, 06h, 01h db 80h, 00h, 00h, 00h, 00h,0FEh,0C0h, 0Fh,0F8h, 03h, 8Eh, 01h,0FFh,0C3h,0FFh,0F9h db 80h, 00h, 00h, 00h, 00h, 7Eh, 00h, 0Fh,0F8h, 07h,0CFh, 01h, 98h,0C3h,0FFh,0F9h db 80h, 00h, 00h, 00h, 00h, 7Fh, 00h, 00h, 60h, 07h, 5Fh, 81h, 98h,0C0h, 06h, 01h db 80h, 00h, 00h, 00h, 00h, 7Fh, 80h, 3Fh,0FEh, 0Fh, 36h,0C1h,0FFh,0C0h, 06h, 01h db 80h, 00h, 00h, 00h, 00h, 1Fh, 80h,0BFh,0FEh, 0Bh, 36h, 61h,0FFh,0C0h, 06h, 01h db 80h, 00h, 00h, 00h, 00h, 1Fh,0C7h, 00h,0C0h, 03h, 66h, 21h, 98h, 30h, 06h, 01h db 80h, 00h, 00h, 00h, 15h, 5Fh,0C7h, 00h,0C0h, 03h, 06h, 00h, 18h, 30h, 06h, 01h db 80h, 00h, 02h,0E0h, 06h, 7Fh,0CEh, 03h,0C0h, 03h, 06h, 00h, 1Fh,0F0h, 1Eh, 01h db 80h, 00h, 04h, 54h, 4Fh,0FFh,0FCh, 01h, 80h, 03h, 06h, 00h, 0Fh,0E0h, 0Ch, 01h db 80h, 00h, 03h,0FDh, 3Fh,0FFh,0D9h,0C0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 1Dh,0FFh,0FFh,0FFh, 87h, 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 2Bh,0FFh,0F8h, 7Fh, 06h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 3Fh,0BFh,0F8h, 09h, 0Fh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 1Fh, 9Fh,0F0h, 00h,0BCh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 9Dh,0FEh, 1Fh, 8Fh,0F0h, 00h,0F8h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 9Fh,0FCh, 17h, 8Fh,0F0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 81h,0FFh,0CFh, 9Fh,0E0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 82h,0FFh,0FFh, 9Ch, 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 81h, 7Fh,0FFh,0FCh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 6Fh,0FEh, 30h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 03h,0FCh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 34h, 14h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 0Eh, 18h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 02h, 30h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 01h,0E0h, 00h, 00h, 7Fh, 04h, 00h, 3Fh, 82h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 7Fh, 0Ch, 00h, 3Fh, 86h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 7Fh, 1Ch, 00h, 3Fh, 8Eh, 00h, 00h, 00h, 00h, 01h db 83h,0BBh, 9Dh,0DCh,0EEh,0E0h, 70h, 7Ch, 38h, 38h, 3Eh, 00h,0E0h, 38h, 3Bh, 31h db 83h,0BBh, 9Dh,0DCh,0EEh,0E0h, 70h, 7Ch, 3Ch, 38h, 3Eh, 00h,0F0h, 7Ch, 3Fh,0F9h db 83h,0BBh, 9Dh,0DCh,0EEh,0E0h, 76h, 1Ch, 7Eh, 3Bh, 0Eh, 01h,0F8h,0FEh, 3Fh,0F9h db 83h,0BBh, 9Dh,0DCh,0EEh,0E0h, 7Fh, 1Ch, 76h, 3Fh, 8Eh, 01h,0D8h,0EEh, 3Bh,0B9h db 83h,0BBh, 9Dh,0DCh,0EEh,0E0h, 7Fh, 1Ch, 76h, 3Fh, 8Eh, 01h,0D8h,0EEh, 3Bh,0B9h db 83h,0BBh, 9Dh,0DCh,0EEh,0E0h, 77h, 1Ch, 76h, 3Bh, 8Eh, 01h,0D8h,0EEh, 3Bh,0B9h db 81h,0BBh, 0Dh,0D8h, 6Eh,0C0h, 07h, 1Ch, 70h, 03h, 8Eh, 01h,0C0h,0EEh, 3Bh,0B9h db 81h,0ABh, 0Dh, 58h, 6Ah,0C0h, 07h, 1Ch, 70h, 03h, 8Eh, 01h,0C0h,0EEh, 3Bh,0B9h db 81h,0ABh, 0Dh, 58h, 6Ah,0C0h, 77h, 1Ch, 70h, 3Bh, 8Eh, 01h,0C0h,0EEh, 3Bh,0B9h db 81h,0ABh, 0Dh, 58h, 6Ah,0C0h, 77h, 1Ch, 76h, 3Bh, 8Eh, 01h,0D8h,0EEh, 3Bh,0B9h db 81h,0EFh, 0Fh, 78h, 7Bh,0C0h, 77h, 1Ch, 76h, 3Bh, 8Eh, 01h,0D8h,0EEh, 3Bh,0B9h db 81h,0EFh, 0Fh, 78h, 7Bh,0DCh, 77h, 1Ch, 76h, 3Bh, 8Eh, 39h,0D8h,0EEh, 3Bh,0B9h db 81h,0EFh, 0Fh, 78h, 7Bh,0DCh, 7Fh, 1Ch, 7Eh, 3Fh, 8Eh, 39h,0F8h,0FEh, 3Bh,0B9h db 81h,0EFh, 0Fh, 78h, 7Bh,0DCh, 3Eh, 1Ch, 3Ch, 1Fh, 0Eh, 38h,0F0h, 7Ch, 3Bh,0B9h db 81h,0EFh, 0Fh, 78h, 7Bh,0DCh, 1Ch, 1Ch, 3Ch, 0Eh, 0Eh, 38h,0F0h, 78h, 3Bh,0B9h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh ;*-------------------------------------------------------------------- * ;* Bitmap点阵数据表 * ;* 图片: E:\图形12.bmp,横向取模左高位,数据排列:从左到右从上到下 * ;* 图片尺寸: 128 * 64 * ;*-------------------------------------------------------------------- * TU_TAB2: ; 数据表 db 40h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 03h, 65h,0E8h, 80h, 00h, 01h db 9Ah,0D6h,0B4h, 42h, 00h, 00h, 00h, 00h, 00h, 00h, 34h,0DAh,0D0h, 00h, 00h, 01h db0A4h, 00h, 02h, 10h, 6Bh, 30h, 00h, 00h, 00h, 00h, 8Bh,0FFh, 30h, 00h, 00h, 01h db 42h,0D6h,0B0h, 42h, 80h, 00h, 00h, 00h, 00h, 16h, 77h,0FEh,0C0h, 00h, 00h, 01h db 42h,0D6h,0B0h, 42h, 80h, 00h, 00h, 00h, 00h, 16h, 77h,0FEh,0C0h, 00h, 00h, 01h db0B9h, 20h, 04h, 00h, 00h, 02h, 10h, 00h, 00h, 00h,0BCh,0BCh, 00h, 00h, 00h, 01h db 46h,0D6h,0B1h,0ACh, 6Bh, 30h, 00h, 00h, 02h, 29h,0CBh, 40h, 00h, 00h, 00h, 01h db0FFh,0F9h, 04h, 01h, 00h, 00h, 00h, 00h, 01h, 16h,0B4h,0A0h, 00h, 00h, 00h, 01h db0FFh,0FFh,0F2h, 50h, 00h, 40h, 00h, 00h, 00h, 29h, 4Bh, 00h, 00h, 00h, 00h, 01h db0FFh,0FFh,0F2h, 50h, 00h, 40h, 00h, 00h, 00h, 29h, 4Bh, 00h, 00h, 00h, 00h, 01h db0FFh,0FFh,0BDh, 82h, 94h, 00h, 40h, 00h, 00h,0C9h, 30h, 02h, 00h, 00h, 00h, 01h db0FFh,0FFh,0FBh,0B0h, 00h, 08h, 00h, 00h, 05h, 16h, 44h, 40h, 00h, 00h, 00h, 01h db0FFh,0FFh,0FFh,0EFh, 90h, 40h, 00h, 00h, 00h, 21h, 00h, 04h,0C8h, 30h, 00h, 01h db0A5h,0FFh,0FFh,0FDh, 6Bh, 00h, 00h, 00h, 00h,0C8h, 00h, 99h, 16h,0FAh, 40h, 01h db0A5h,0FFh,0FFh,0FDh, 6Bh, 00h, 00h, 00h, 00h,0C8h, 00h, 99h, 16h,0FAh, 40h, 01h db 82h, 2Fh,0FFh,0FFh,0E8h, 84h, 00h, 00h, 00h, 00h, 08h, 00h,0DFh,0FFh,0ECh, 01h db 24h,0C1h, 7Fh,0FFh,0F4h, 30h, 00h, 00h, 00h, 00h, 00h,0A7h,0FFh,0FFh,0FCh, 01h db 42h, 28h, 05h,0BFh,0FBh, 80h, 00h, 00h, 00h, 00h, 04h, 1Bh,0FFh,0FFh,0FFh, 81h db 98h,0C1h, 4Ah, 53h,0ECh, 48h, 00h, 00h, 00h, 00h, 40h, 7Fh,0FFh,0FFh,0FFh,0E1h db 98h,0C1h, 4Ah, 53h,0ECh, 48h, 00h, 00h, 00h, 00h, 40h, 7Fh,0FFh,0FFh,0FFh,0E1h db 42h, 28h, 00h, 0Ch, 77h, 82h, 00h, 00h, 00h, 00h, 33h,0BFh,0FFh,0FFh,0FFh, 89h db 18h,0C1h, 4Ah, 51h, 9Bh, 74h, 00h, 00h, 00h, 00h, 04h,0FFh, 3Fh,0FFh,0DFh,0F1h db0C2h, 28h, 00h, 0Ch, 04h, 80h, 00h, 00h, 00h, 00h, 40h,0FEh, 1Fh,0F9h,0C3h,0F9h db 1Ah,0D6h,0B5h,0A1h, 6Bh, 75h, 80h, 00h, 00h, 00h, 8Fh,0FCh, 3Fh,0F2h, 0Fh, 1Fh db 1Ah,0D6h,0B5h,0A1h, 6Bh, 75h, 80h, 00h, 00h, 00h, 8Fh,0FCh, 3Fh,0F2h, 0Fh, 1Fh db0C5h, 29h, 79h, 8Ch, 00h, 88h, 00h, 00h, 00h, 00h, 03h,0F8h, 1Fh,0C8h, 52h, 81h db 22h,0FFh,0FFh,0F2h, 6Bh, 35h, 80h, 00h, 00h, 00h, 37h,0C2h, 3Fh,0FBh,0FCh, 09h db 9Ah,0FFh,0FFh,0FFh, 00h, 48h, 00h, 00h, 00h, 00h, 07h,0D8h, 1Fh,0FFh,0E3h, 81h db 9Ah,0FFh,0FFh,0FFh, 00h, 48h, 00h, 00h, 00h, 00h, 07h,0D8h, 1Fh,0FFh,0E3h, 81h db 47h,0FFh,0FFh,0FFh,0F3h, 35h, 80h, 00h, 00h, 00h, 8Fh,0C1h, 0Fh,0FFh,0ACh, 01h db0B9h,0FFh,0FFh,0FFh,0FCh, 4Ah, 20h, 00h, 00h, 00h, 0Fh,0A4h, 07h,0FEh, 40h, 01h db 5Fh,0FFh,0C7h,0FFh,0FCh,0B5h, 80h, 00h, 00h, 00h, 4Fh,0DAh,0FFh,0F8h, 00h, 01h db0A7h,0FFh,0B7h,0FFh,0FFh, 8Ah, 20h, 00h, 00h, 00h, 0Fh,0FFh,0EFh, 40h, 00h, 01h db0A7h,0FFh,0B7h,0FFh,0FFh, 8Ah, 20h, 00h, 00h, 00h, 0Fh,0FFh,0EFh, 40h, 00h, 01h db 7Fh,0FFh, 47h,0FDh, 7Fh,0C5h, 80h, 00h, 00h, 00h, 3Fh,0DAh,0D0h, 00h, 00h, 01h db0A7h,0FEh, 37h,0FFh, 7Ch,0FAh, 50h, 00h, 00h, 00h, 0Ch,0A4h, 08h, 00h, 00h, 01h db0DFh,0FEh, 43h,0FFh,0F8h,0C1h, 80h, 00h, 00h, 00h, 48h, 01h, 00h, 00h, 00h, 01h db 27h,0FFh, 4Bh,0FFh,0FFh,0FAh, 2Ch, 00h, 00h, 00h, 03h, 58h, 20h, 00h, 00h, 01h db 27h,0FFh, 4Bh,0FFh,0FFh,0FAh, 2Ch, 00h, 00h, 00h, 03h, 58h, 20h, 00h, 00h, 01h db 9Bh,0FFh,0C3h,0FFh,0FFh,0F1h,0C0h, 00h, 00h, 00h, 08h, 00h, 00h, 00h, 00h, 01h db 64h, 3Fh,0FDh,0FFh, 6Bh, 7Ch, 10h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 03h,0D7h,0FFh,0FDh, 10h, 01h,0A0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0D8h, 29h, 4Fh,0A2h, 80h,0B5h, 90h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0D8h, 29h, 4Fh,0A2h, 80h,0B5h, 90h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 05h, 10h,0B0h, 4Ch, 0Bh, 08h, 40h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0A0h,0C9h, 0Ah, 00h, 00h, 42h, 10h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 04h, 10h, 40h, 21h, 64h, 09h,0A0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0A2h,0C1h, 35h, 8Ch, 00h, 44h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0A2h,0C1h, 35h, 8Ch, 00h, 44h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 00h, 16h, 00h, 21h, 14h, 09h,0A0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0A5h, 00h,0B5h, 80h, 83h, 44h, 0Ch, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 00h, 26h, 00h, 12h, 08h, 09h,0A0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0DAh, 00h,0B4h, 40h, 60h, 44h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0DAh, 00h,0B4h, 40h, 60h, 44h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h,0C8h, 00h, 00h, 04h, 01h,0A0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0A2h, 20h, 89h, 91h, 10h, 8Ah, 10h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 44h, 06h, 00h, 00h, 00h, 30h, 40h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 44h, 06h, 00h, 00h, 00h, 30h, 40h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh ;*-------------------------------------------------------------------- * ;*-------------------------------------------------------------------- * ;* Bitmap点阵数据表 * ;* 图片: E:\图形13.bmp,横向取模左高位,数据排列:从左到右从上到下 * ;* 图片尺寸: 128 * 64 * ;*-------------------------------------------------------------------- * TU_TAB4: ; 漂亮姑娘看过来 db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h 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, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 11h,0FFh, 80h, 40h, 08h, 30h, 10h, 20h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Ch, 68h, 3Fh,0FFh, 08h, 30h, 11h,0F8h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Ch, 68h, 3Fh,0FFh, 08h, 30h, 11h,0F8h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h,0FFh, 00h, 00h, 7Fh,0FEh, 7Dh, 08h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 11h, 6Bh, 07h,0FCh, 16h, 30h, 2Dh,0F8h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Dh,0FFh, 04h, 0Ch, 16h, 30h, 2Dh, 08h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Ch, 00h, 3Fh,0FFh, 16h, 30h, 2Dh,0F8h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Ch, 00h, 3Fh,0FFh, 16h, 30h, 2Dh,0F8h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Ch,0FFh, 30h, 01h, 66h,0FEh, 2Dh, 26h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 1Ch, 00h, 03h,0F0h, 76h, 82h, 2Dh, 28h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Dh,0FFh, 82h, 11h, 08h, 82h, 11h, 10h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Ch, 8Bh, 04h, 11h, 16h, 82h, 2Dh, 28h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Ch, 8Bh, 04h, 11h, 16h, 82h, 2Dh, 28h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Dh, 18h,0B8h, 1Fh, 60h,0FEh, 41h,0C6h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 07h, 8Fh,0FFh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 08h, 70h, 40h,0EFh, 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 08h, 70h, 40h,0EFh, 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 10h, 00h, 80h, 10h, 60h, 00h, 0Fh,0FFh, 30h, 0Ch, 00h, 80h, 00h, 00h, 00h db 00h, 20h, 18h, 38h, 20h, 60h, 00h, 00h, 60h, 08h, 0Ch, 1Fh,0FCh, 1Ch, 00h, 00h db 00h,0C0h, 64h, 45h, 00h, 60h, 00h, 03h,0FCh, 0Bh,0FFh, 00h, 80h, 3Eh, 00h, 00h db 00h,0C1h, 00h, 01h, 00h, 10h, 00h, 00h, 80h, 00h, 0Ch, 08h, 88h, 3Eh, 00h, 00h db 00h,0C1h, 00h, 01h, 00h, 10h, 00h, 00h, 80h, 00h, 0Ch, 08h, 88h, 3Eh, 00h, 00h db 01h, 01h, 00h, 00h,0C0h, 10h, 00h, 1Fh,0FFh,0BDh, 8Ch, 06h,0B0h, 3Eh, 00h, 00h db 02h, 0Eh, 18h, 1Ch,0C0h, 10h, 00h, 01h, 00h, 04h, 4Ch, 7Fh,0FEh, 1Ch, 00h, 00h db 02h, 16h, 64h, 22h, 20h, 10h, 00h, 03h,0FCh, 04h, 4Ch, 01h,0C0h, 1Ch, 00h, 00h db 02h, 16h, 64h, 22h, 20h, 10h, 00h, 03h,0FCh, 04h, 4Ch, 01h,0C0h, 1Ch, 00h, 00h db 04h,0E8h, 83h, 41h, 1Ch, 08h, 00h, 0Dh, 04h, 04h, 0Ch, 06h,0B0h, 00h, 00h, 00h db 07h, 10h, 8Fh, 47h, 03h, 88h, 00h, 11h,0FCh, 04h, 3Ch, 08h, 88h, 1Ch, 00h, 00h db 00h, 20h, 6Ch, 26h, 01h, 78h, 00h, 01h, 04h, 0Ah, 00h, 70h, 86h, 1Ch, 00h, 00h db 00h,0C0h, 18h, 1Ch, 00h, 80h, 00h, 01h,0FCh, 31h,0FFh, 00h, 80h, 00h, 00h, 00h db 00h,0C0h, 18h, 1Ch, 00h, 80h, 00h, 01h,0FCh, 31h,0FFh, 00h, 80h, 00h, 00h, 00h db 00h,0C1h, 87h, 80h, 00h, 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 01h, 06h, 78h, 3Ch, 20h, 60h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 01h, 08h, 07h,0C2h,0C0h, 60h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 01h, 08h, 00h, 01h,0C0h, 60h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 01h, 08h, 00h, 01h,0C0h, 60h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 01h, 08h, 18h, 01h,0C0h, 60h, 00h, 00h, 00h,0F1h,0F3h, 87h,0C0h, 00h, 00h, 00h db 00h,0C6h, 18h,0C2h, 20h, 80h, 00h, 00h, 03h, 0Eh, 1Ch, 78h, 70h, 00h, 00h, 00h db 00h,0C1h, 00h,0C2h, 00h, 80h, 00h, 00h, 04h, 44h, 11h, 10h, 38h, 00h, 00h, 00h db 00h, 26h,0E0h, 04h, 01h, 00h, 00h, 00h, 04h, 80h, 12h, 00h, 38h, 00h, 00h, 00h db 00h, 26h,0E0h, 04h, 01h, 00h, 00h, 00h, 04h, 80h, 12h, 00h, 38h, 00h, 00h, 00h db 00h, 11h, 18h, 38h, 03h, 00h, 00h, 00h, 04h, 80h, 12h, 00h, 38h, 00h, 00h, 00h db 00h, 0Eh, 87h,0C2h, 1Ch, 00h, 00h, 00h, 04h, 00h, 10h, 00h, 38h, 00h, 00h, 00h db 00h, 01h,0E0h, 04h,0E0h, 00h, 00h, 00h, 03h, 00h, 1Ch, 00h, 70h, 00h, 00h, 00h db 00h, 1Eh, 18h, 3Fh, 1Eh, 00h, 00h, 00h, 00h, 80h, 32h, 00h,0C0h, 00h, 00h, 00h db 00h, 1Eh, 18h, 3Fh, 1Eh, 00h, 00h, 00h, 00h, 80h, 32h, 00h,0C0h, 00h, 00h, 00h db 00h, 38h, 07h,0C0h, 0Fh, 00h, 00h, 00h, 00h, 40h, 61h, 01h, 80h, 00h, 00h, 00h db 00h,0E9h,0FFh,0FFh, 0Dh, 80h, 00h, 00h, 00h, 31h,0C0h, 87h, 00h, 00h, 00h, 00h db 01h,0E9h, 1Bh,0B9h, 0Dh,0E0h, 00h, 00h, 00h, 0Bh, 80h, 6Eh, 00h, 00h, 00h, 00h db 03h,0C9h,0F0h, 1Fh, 0Ch,0F0h, 00h, 00h, 00h, 06h, 00h, 18h, 00h, 00h, 00h, 00h db 03h,0C9h,0F0h, 1Fh, 0Ch,0F0h, 00h, 00h, 00h, 06h, 00h, 18h, 00h, 00h, 00h, 00h db 07h, 06h,0E0h, 06h, 10h, 78h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 07h,0C1h, 00h, 00h, 20h,0F8h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 07h,0E0h, 80h, 00h,0C1h,0F8h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 07h,0E0h, 80h, 00h,0C1h,0F8h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh end
上传时间: 2013-10-13
上传用户:123啊
单片机指令系统原理 51单片机的寻址方式 学习汇编程序设计,要先了解CPU的各种寻址法,才能有效的掌握各个命令的用途,寻址法是命令运算码找操作数的方法。在我们学习的8051单片机中,有6种寻址方法,下面我们将逐一进行分析。 立即寻址 在这种寻址方式中,指令多是双字节的,一般第一个字节是操作码,第二个字节是操作数。该操作数直接参与操作,所以又称立即数,有“#”号表示。立即数就是存放在程序存储器中的常数,换句话说就是操作数(立即数)是包含在指令字节中的。 例如:MOV A,#3AH这条指令的指令代码为74H、3AH,是双字节指令,这条指令的功能是把立即数3AH送入累加器A中。MOV DPTR,#8200H在前面学单片机的专用寄存器时,我们已学过,DPTR是一个16位的寄存器,它由DPH及DPL两个8位的寄存器组成。这条指令的意思就是把立即数的高8位(即82H)送入DPH寄存器,把立即数的低8位(即00H)送入DPL寄存器。这里也特别说明一下:在80C51单片机的指令系统中,仅有一条指令的操作数是16位的立即数,其功能是向地址指针DPTR传送16位的地址,即把立即数的高8位送入DPH,低8位送入DPL。 直接寻址 直接寻址方式是指在指令中操作数直接以单元地址的形式给出,也就是在这种寻址方式中,操作数项给出的是参加运算的操作数的地址,而不是操作数。例如:MOV A,30H 这条指令中操作数就在30H单元中,也就是30H是操作数的地址,并非操作数。 在80C51单片机中,直接地址只能用来表示特殊功能寄存器、内部数据存储器以及位地址空间,具体的说就是:1、内部数据存储器RAM低128单元。在指令中是以直接单元地址形式给出。我们知道低128单元的地址是00H-7FH。在指令中直接以单元地址形式给出这句话的意思就是这0-127共128位的任何一位,例如0位是以00H这个单元地址形式给出、1位就是以01H单元地址给出、127位就是以7FH形式给出。2、位寻址区。20H-2FH地址单元。3、特殊功能寄存器。专用寄存器除以单元地址形式给出外,还可以以寄存器符号形式给出。例如下面我们分析的一条指令 MOV IE,#85H 前面的学习我们已知道,中断允许寄存器IE的地址是80H,那么也就是这条指令可以以MOV IE,#85H 的形式表述,也可以MOV 80H,#85H的形式表述。 关于数据存储器RAM的内部情况,请查看我们课程的第十二课。 直接寻址是唯一能访问特殊功能寄存器的寻址方式! 大家来分析下面几条指令:MOV 65H,A ;将A的内容送入内部RAM的65H单元地址中MOV A,direct ;将直接地址单元的内容送入A中MOV direct,direct;将直接地址单元的内容送直接地址单元MOV IE,#85H ;将立即数85H送入中断允许寄存器IE 前面我们已学过,数据前面加了“#”的,表示后面的数是立即数(如#85H,就表示85H就是一个立即数),数据前面没有加“#”号的,就表示后面的是一个地址地址(如,MOV 65H,A这条指令的65H就是一个单元地址)。 寄存器寻址 寄存器寻址的寻址范围是:1、4个工作寄存器组共有32个通用寄存器,但在指令中只能使用当前寄存器组(工作寄存器组的选择在前面专用寄存器的学习中,我们已知道,是由程序状态字PSW中的RS1和RS0来确定的),因此在使用前常需要通过对PSW中的RS1、RS0位的状态设置,来进行对当前工作寄存器组的选择。2、部份专用寄存器。例如,累加器A、通用寄存器B、地址寄存器DPTR和进位位CY。 寄存器寻址方式是指操作数在寄存器中,因此指定了寄存器名称就能得到操作数。例如:MOV A,R0这条指令的意思是把寄存器R0的内容传送到累加器A中,操作数就在R0中。INC R3这条指令的意思是把寄存器R3中的内容加1 从前面的学习中我产应可以理解到,其实寄存器寻址方式就是对由PSW程序状态字确定的工作寄存器组的R0-R7进行读/写操作。 寄存器间接寻址 寄存间接寻址方式是指寄存器中存放的是操作数的地址,即操作数是通过寄存器间接得到的,因此称为寄存器间接寻址。 MCS-51单片机规定工作寄存器的R0、R1做为间接寻址寄存器。用于寻址内部或外部数据存储器的256个单元。为什么会是256个单元呢?我们知道,R0或者R1都是一个8位的寄存器,所以它的寻址空间就是2的八次方=256。例:MOV R0,#30H ;将值30H加载到R0中 MOV A,@R0 ;把内部RAM地址30H内的值放到累加器A中 MOVX A,@R0 ;把外部RAM地址30H内的值放到累加器A中 大家想想,如果用DPTR做为间址寄存器,那么它的寻址范围是多少呢?DPTR是一个16位的寄存器,所以它的寻址范围就是2的十六次方=65536=64K。因用DPTR做为间址寄存器的寻址空间是64K,所以访问片外数据存储器时,我们通常就用DPTR做为间址寄存器。例:MOV DPTR,#1234H ;将DPTR值设为1234H(16位) MOVX A,@DPTR ;将外部RAM或I/O地址1234H内的值放到累加器A中 在执行PUSH(压栈)和POP(出栈)指令时,采用堆栈指针SP作寄存器间接寻址。例:PUSH 30H ;把内部RAM地址30H内的值放到堆栈区中堆栈区是由SP寄存器指定的,如果执行上面这条命令前,SP为60H,命令执行后会把内部RAM地址30H内的值放到RAM的61h内。 那么做为寄存器间接寻址用的寄存器主要有哪些呢?我们前面提到的有四个,R0、R1、DPTR、SP 寄存器间接寻址范围总结:1、内部RAM低128单元。对内部RAM低128单元的间接寻址,应使用R0或R1作间址寄存器,其通用形式为@Ri(i=0或1)。 2、外部RAM 64KB。对外部RAM64KB的间接寻址,应使用@DPTR作间址寻址寄存器,其形式为:@DPTR。例如MOVX A,@DPTR;其功能是把DPTR指定的外部RAM的单元的内容送入累加器A中。外部RAM的低256单元是一个特殊的寻址区,除可以用DPTR作间址寄存器寻址外,还可以用R0或R1作间址寄存器寻址。例如MOVX A,@R0;这条指令的意思是,把R0指定的外部RAM单元的内容送入累加器A。 堆栈操作指令(PUSH和POP)也应算作是寄存器间接寻址,即以堆栈指针SP作间址寄存器的间接寻址方式。 寄存器间接寻址方式不可以访问特殊功能寄存器!! 寄存器间接寻址也须以寄存器符号的形式表示,为了区别寄存器寻址我寄存器间接寻址的区别,在寄存器间接寻址方式式中,寄存器的名称前面加前缀标志“@”。 基址寄存器加变址寄存器的变址寻址 这种寻址方式以程序计数器PC或DPTR为基址寄存器,累加器A为变址寄存器,变址寻址时,把两者的内容相加,所得到的结果作为操作数的地址。这种方式常用于访问程序存储器ROM中的数据表格,即查表操作。变址寻址只能读出程序内存入的值,而不能写入,也就是说变址寻址这种方式只能对程序存储器进行寻址,或者说它是专门针对程序存储器的寻址方式。例:MOVC A,@A+DPTR这条指令的功能是把DPTR和A的内容相加,再把所得到的程序存储器地址单元的内容送A假若指令执行前A=54H,DPTR=3F21H,则这条指令变址寻址形成的操作数地址就是54H+3F21H=3F75H。如果3F75H单元中的内容是7FH,则执行这条指令后,累加器A中的内容就是7FH。 变址寻址的指令只有三条,分别如下:JMP @A+DPTRMOVC A,@A+DPTRMOVC A,@A+PC 第一条指令JMP @A+DPTR这是一条无条件转移指令,这条指令的意思就是DPTR加上累加器A的内容做为一个16位的地址,执行JMP这条指令是,程序就转移到A+DPTR指定的地址去执行。 第二、三条指令MOVC A,@A+DPTR和MOVC A,@A+PC指令这两条指令的通常用于查表操作,功能完全一样,但使用起来却有一定的差别,现详细说明如下。我们知道,PC是程序指针,是十六位的。DPTR是一个16位的数据指针寄存器,按理,它们的寻址范围都应是64K。我们在学习特殊功能寄存器时已知道,程序计数器PC是始终跟踪着程序的执行的。也就是说,PC的值是随程序的执行情况自动改变的,我们不可以随便的给PC赋值。而DPTR是一个数据指针,我们就可以给空上数据指针DPTR进行赋值。我们再看指令MOVC A,@A+PC这条指令的意思是将PC的值与累加器A的值相加作为一个地址,而PC是固定的,累加器A是一个8位的寄存器,它的寻址范围是256个地址单元。讲到这里,大家应可明白,MOVC A,@A+PC这条指令的寻址范围其实就是只能在当前指令下256个地址单元。所在,这在我们实际应用中,可能就会有一个问题,如果我们需要查询的数据表在256个地址单元之内,则可以用MOVC A,@A+PC这条指令进行查表操作,如果超过了256个单元,则不能用这条指令进行查表操作。刚才我们已说到,DPTR是一个数据指针,这个数据指针我们可以给它赋值操作的。通过赋值操作。我们可以使MOVC A,@A+DPTR这条指令的寻址范围达到64K。这就是这两条指令在实际应用当中要注意的问题。 变址寻址方式是MCS-51单片机所独有的一种寻址方式。 位寻址 80C51单片机有位处理功能,可以对数据位进行操作,因此就有相应的位寻址方式。所谓位寻址,就是对内部RAM或可位寻址的特殊功能寄存器SFR内的某个位,直接加以置位为1或复位为0。 位寻址的范围,也就是哪些部份可以进行位寻址: 1、我们在第十二课学习51单片机的存储器结构时,我们已知道在单片机的内部数据存储器RAM的低128单元中有一个区域叫位寻址区。它的单元地址是20H-2FH。共有16个单元,一个单元是8位,所以位寻址区共有128位。这128位都单独有一个位地址,其位地址的名字就是00H-7FH。这里就有一个比较麻烦的问题需要大家理解清楚了。我们在前面的学习中00H、01H。。。。7FH等等,所表示的都是一个字节(或者叫单元地址),而在这里,这些数据都变成了位地址。我们在指令中,或者在程序中如何来区分它是一个单元地址还是一个位地址呢?这个问题,也就是我们现在正在研究的位寻址的一个重要问题。其实,区分这些数据是位地址还是单元地址,我们都有相应的指令形式的。这个问题我们在后面的指令系统学习中再加以论述。 2、对专用寄存器位寻址。这里要说明一下,不是所有的专用寄存器都可以位寻址的。具体哪些专用寄存器可以哪些专用寄存器不可以,请大家回头去看看我们前面关于专用寄存器的相关文章。一般来说,地址单元可以被8整除的专用寄存器,通常都可以进行位寻址,当然并不是全部,大家在应用当中应引起注意。 专用寄存器的位寻址表示方法: 下面我们以程序状态字PSW来进行说明 D7 D6 D5 D4 D3 D2 D1 D0 CY AC F0 RS1 RS0 OV P 1、直接使用位地址表示:看上表,PSW的第五位地址是D5,所以可以表示为D5H MOV C,D5H 2、位名称表示:表示该位的名称,例如PSW的位5是F0,所以可以用F0表示 MOV C,F0 3、单元(字节)地址加位表示:D0H单元位5,表示为DOH.5 MOV C,D0H.5 4、专用寄存器符号加位表示:例如PSW.5 MOV C,PSW.5 这四种方法实现的功能都是相同的,只是表述的方式不同而已。 例题: 1. 说明下列指令中源操作数采用的寻址方式。 MOV R5,R7 答案:寄存器寻址方式 MOV A,55H 直接寻址方式 MOV A,#55H 立即寻址方式 JMP @A+DPTR 变址寻址方式 MOV 30H,C 位寻址方式 MOV A,@R0 间接寻址方式 MOVX A,@R0 间接寻址方式 改错题 请判断下列的MCS-51单片机指令的书写格式是否有错,若有,请说明错误原因。 MOV R0,@R3 答案:间址寄存器不能使用R2~R7。 MOVC A,@R0+DPTR 变址寻址方式中的间址寄存器不可使用R0,只可使用A。 ADD R0,R1 运算指令中目的操作数必须为累加器A,不可为R0。 MUL AR0 乘法指令中的乘数应在B寄存器中,即乘法指令只可使用AB寄存器组合。
上传时间: 2013-11-11
上传用户:caozhizhi
微型计算机课程设计论文—通用微机发声程序的汇编设计 本文讲述了在微型计算机中利用可编程时间间隔定时器的通用发声程序设计,重点讲述了程序的发声原理,节拍的产生,按节拍改变的动画程序原理,并以设计一个简单的乐曲评分程序为引子,分析程序设计的细节。关键字:微机 8253 通用发声程序 动画技术 直接写屏 1. 可编程时间间隔定时器8253在通用个人计算机中,有一个可编程时间间隔定时器8253,它能够根据程序提供的计数值和工作方式,产生各种形状和各种频率的计数/定时脉冲,提供给系统各个部件使用。本设计是利用计算机控制发声的原理,编写演奏乐曲的程序。 在8253/54定时器内部有3个独立工作的计数器:计数器0,计数器1和计数器2,每个计数器都分配有一个断口地址,分别为40H,41H和42H.8253/54内部还有一个公用的控制寄存器,端地址为43H.端口地址输入到8253/54的CS,AL,A0端,分别对3个计数器和控制器寻址. 对8353/54编程时,先要设定控制字,以选择计数器,确定工作方式和计数值的格式.每计数器由三个引脚与外部联系,见教材第320页图9-1.CLK为时钟输入端,GATE为门控信号输入端,OUT为计数/定时信号输入端.每个计数器中包含一个16位计数寄存器,这个计数器时以倒计数的方式计数的,也就是说,从计数初值逐次减1,直到减为0为止. 8253/54的三个计数器是分别编程的,在对任一个计数器编程时,必须首先讲控制字节写入控制寄存器.控制字的作用是告诉8253/54选择哪个计数器工作,要求输出什么样的脉冲波形.另外,对8253/54的初始化工作还包括,向选定的计数器输入一个计数初值,因为这个计数值可以是8为的,也可以是16为的,而8253/5的数据总线是8位的,所以要用两条输出指令来写入初值.下面给出8253/54初始化程序段的一个例子,将计数器2设定为方式3,(关于计数器的工作方式参阅教材第325—330页)计数初值为65536. MOV AL,10110110B ;选择计数器2,按方式3工作,计数值是二进制格式 OUT 43H,AL ; j将控制字送入控制寄存器 MOV AL,0 ;计数初值为0 OUT 42H,AL ;将计数初值的低字节送入计数器2 OUT 42H,AL ;将计数初值的高字节送入计数器2 在IBM PC中8253/54的三个时钟端CLK0,CLK1和CLK2的输入频率都是1.1931817MHZ. PC机上的大多数I/O都是由主板上的8255(或8255A)可编程序外围接口芯片(PPI)管理的.关于8255A的结构和工作原理及应用举例参阅教材第340—373页.教材第364页的”PC/XT机中的扬声器接口电路”一节介绍了扬声器的驱动原理,并给出了通用发声程序.本设计正是基于这个原理,通过编程,控制加到扬声器上的信号的频率,奏出乐曲的.2.发声程序的设计下面是能产生频率为f的通用发声程序:MOV AL, 10110110B ;8253控制字:通道2,先写低字节,后写高字节 ;方式3,二进制计数OUT 43H, AL ;写入控制字MOV DX, 0012H ;被除数高位MOV AX, 35DEH ;被除数低位 DIV ID ;求计数初值n,结果在AX中OUT 42H, AL ;送出低8位MOV AL, AHOUT 42H,AL ;送出高8位IN AL, 61h ;读入8255A端口B的内容MOV AH, AL ;保护B口的原状态OR AL, 03H ;使B口后两位置1,其余位保留OUT 61h,AL ;接通扬声器,使它发声
上传时间: 2013-10-17
上传用户:sunjet
4位八段数码管的十进制加计数仿真实验,程序采用汇编语言编写。此程序在仿真软件上与EDN-51实验板上均通过。仿真图中的数码管位驱动采用74HC04,如按EDN-51板上用想同的PNP三极管驱动在仿真软件上则无法正常显示。程序共分5块,STAR0为数据初始化,STAR2为计数子程序,STAR3为4位数码管动态显示子程序,STAR4为按键扫描子程序,STS00是延时子程序。由于EDN-51实验板上没装BCD译码器,所以编写程序比较烦琐。 程序如下: ORG 0000H LJMP STAR0 ;转程序 SRAR0ORG 0200H ;程序地址 0200HSTAR0: CLR 00 ;位 00 清 0 MOV P1,#0FFH ;#0FFH-->P1 MOV P2,#0FH ;#0FH-->P2 MOV P0,#0FFH ;#0FFH-->P0 MOV 30H,#00H ;#00H-->30H MOV 31H,#00H ;#00H-->30H MOV 32H,#00H ;#00H-->30H MOV 33H,#00H ;#00H-->30H LJMP STAR3 ;转程序 SRAR3STAR2: MOV A,#0AH ;#0AH-->A INC 30H ;30H+1 CJNE A,30H,STJE ;30H 与 A 比较,不等转移 STJE MOV 30H,#00H ;#00H-->30H INC 31H ;31H+1 CJNE A,31H,STJE ;31H 与 A 比较,不等转移 STJE MOV 31H,#00H ;#00H-->31H INC 32H ;32H+1 CJNE A,32H,STJE ;32H 与 A 比较,不等转移 STJE MOV 32H,#00H ;#00H-->32H INC 33H ;33H+1 CJNE A,33H,STJE ;33H 与 A 比较,不等转移 STJE MOV 33H,#00H ;#00H-->33H MOV 32H,#00H ;#00H-->32H MOV 31H,#00H ;#00H-->31H MOV 30H,#00H ;#00H-->30HSTJE: RET ;子程序调用返回STAR3: MOV R0,#30H ;#30H-->R0 MOV R6,#0F7H ;#0F7H-->R6SMG0: MOV P1,#0FFH ;#0FFH-->P1 MOV A,R6 ;R6-->A MOV P1,A ;A-->P1 RR A ;A向右移一位 MOV R6,A ;A-->R6 MOV A,@R0 ;@R0-->A ADD A,#04H ;#04H-->A MOVC A,@A+PC ;A+PC--> MOV P0,A ;A-->P0 AJMP SMG1 ;转程序 SMG1SDATA: DB 0C0H,0F9H,0A4H,0B0H,99H DB 92H,82H,0F8H,80H,90H SMG1: LCALL STAR4 ;转子程序 SRAR4 LCALL STS00 ;转子程序 STS00 INC R0 ;R0+1 CJNE R6,#07FH,SMG0 ;#07FH 与 R6 比较,不等转移 SMG0 AJMP STAR3 ;转程序 SRAR3STAR4: JNB P2.0,ST1 ;P2.0=0 转 ST1 CLR 00 ;位 00 清 0 SJMP ST3 ;转ST3ST1: JNB 00,ST2 ;位 00=0 转 ST2 SJMP ST3 ;转 ST3ST2: LCALL STAR2 ;调子程序 STAR2 SETB 00 ;位 00 置 1ST3: RET ;子程序调用返回ORG 0100H ;地址 0100HSTS00: MOV 60H,#003H ;#003H-->60H (211)DE001: MOV 61h,#0FFH ;#0FFH-->61h (255)DE002: DJNZ 61h,DE002 ;61h 减 1 不等于 0 转 DE002 DJNZ 60H,DE001 ;60H 减 1 不等于 0 转 DE001 RET ;子程序调用返回 END ;结束 上次的程序共有293句,经小组成员建议,本人经几天的研究写了下面的这个程序,现在的程序用了63句,精简了230句。功能没有减。如谁有更简练的程序,请发上来,大家一起学习。 4位八段数码管的十进制加计数仿真实验(含电路图和仿真文件)
上传时间: 2013-10-11
上传用户:sssl
PLC TM卡开发系统汇编程序(ATM8051) ;***************** 定义管脚*************************SCL BIT P1.0SDA BIT P1.1GC BIT P1.2BZ BIT P3.6LEDI BIT P1.4LEDII BIT P1.5OK BIT 20H.1OUT1 BIT P1.3OUT2 BIT P1.0OUT3 BIT P1.1RXD BIT P3.0TXD BIT P3.1PCV BIT P3.2WPC BIT P3.3RPC BIT P3.5LEDR BIT P3.4LEDL BIT P3.6TM BIT P3.7;********************定义寄存器***********************ROMDTA EQU 30H;NUMBY EQU 61h;SLA EQU 60H;MTD EQU 2FH;MRD EQU 40H;TEMP EQU 50H;;ORG 00H;;INDEX:MOV P1, #00H;MOV P2, #0FFHMOV MTD ,#00HCALL REEMOV R0,40HCJNE R0,#01,NO;MOV P2,#1CHLJMP VIMEN MOV P2,#79HACALL TOUCHRESET ;JNC NO ;CALL READTM ;CJNE A,#01H,NO;NOPMOV MTD, #00HCALL WEENOPMOV P2,#4AHSETB BZCALL TIMECLR BZMOV PCON, #0FFHVIME:CALL TIME1CALL TOUCHRESETJNC VIMECALL READTMCJNE A, #01H,VIME;NOPNOPNOPIII: MOV MTD,#00HCALL REECALL BBJNB OK,NO1LJMP ZHUNO1:MOV MTD,#10H
上传时间: 2014-03-24
上传用户:448949
51汇编程序实例:举一例说明:流水灯加数码管 LOOP: ; 标号CLR P2.6 ;选中p2.6 数码管左边的8字使能SETB P2.7 ;p2.7不使能。 右边的数码管消隐MOV P0,#28H ;把28h送p0口;数码管显示 0LCALL DELAY ;延时MOV P0,#0FFH ;0ffh 送p0口,数码管清除CLR P1.0 ;点亮p1.0发光管MOV P0,#7EH ;把7eh送p0口;数码管显示 1LCALL DELAYMOV P0,#0FFHCLR P1.1 ;点亮p1.0发光管CLR P1.0 ;点亮p1.0发光管MOV P0,#0A2H ;数码管显示 2LCALL DELAYMOV P0,#0FFHCLR P1.2CLR P1.1CLR P1.0MOV P0,#62H ;数码管显示 3LCALL DELAYMOV P0,#0FFHCLR P1.3CLR P1.2CLR P1.1CLR P1.0MOV P0,#74H ;数码管显示 4LCALL DELAYMOV P0,#0FFHCLR P1.4CLR P1.3CLR P1.2CLR P1.1CLR P1.0MOV P0,#61h ;数码管显示 5;LCALL DELAYMOV P0,#0FFHCLR P1.5CLR P1.4CLR P1.3CLR P1.2CLR P1.1CLR P1.0MOV P0,#21H ; 数码管显示 6LCALL DELAYMOV P0,#0FFHCLR P1.6CLR P1.5CLR P1.4CLR P1.3CLR P1.2CLR P1.1CLR P1.0MOV P0,#7AH ; 数码管显示 7LCALL DELAYMOV P0,#0FFHCLR P1.7CLR P1.6CLR P1.5CLR P1.4CLR P1.3CLR P1.2CLR P1.1CLR P1.0MOV P0,#20H ; 数码管显示 8LCALL DELAYMOV P0,#0FFHLCALL DELAYMOV P0,#0FFHMOV P1,#0FFH;程序到此结果为左边的数码管显示0,1,2,3,4,5,6,7,8;p1.0------------p1.7指示灯依次点亮SETB P2.6 ; 左边的8消隐CLR P2.7 ;选中p2.7 数码管右边的8字使能 ,;MOV P0,#28HLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHCLR P1.0MOV P0,#7EHLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHCLR P1.1MOV P0,#0A2HLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHCLR P1.2MOV P0,#62HLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHCLR P1.3MOV P0,#74HLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHCLR P1.4MOV P0,#61hLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHCLR P1.5MOV P0,#21HLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHCLR P1.6MOV P0,#7AHLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHCLR P1.7MOV P0,#20HLCALL DELAYMOV P0,#0FFHMOV P1,#0FFHMOV P0,#0FFHMOV P1,#0FFH;这一段和上一段基本相同, 不同的是右边的数码管依次显示012345678,左边的不亮;;同时p1口的灯流动显示:AJMP LOOP; 注意: 程序运行到此跳转到开始标号,重复执行:DELAY: ;延时子程序;参考前面的教程:CLR P3.3 ;注意小喇叭在3.3口, 这里可以使小喇叭发出嗒,嗒声MOV R7,#255NOPNOPD1:MOV R6,#255setb p3.3D2: DJNZ R6,D2clr p3.3DJNZ R7,D1SETB P3.3RETENDLOOP: ; 标号CLR P2.6 ;选中p2.6 数码管左边的8字使能SETB P2.7 ;p2.7不使能。 右边的数码管消隐MOV P0,#28H ;把28h送p0口;数码管显示 0 ;28为1010000LCALL DELAY ; 延时程序MOV P0,#0FFH ;0ffh 送p0口,数码管清除;P0口为11111111CLR P1.0 ;点亮p1.0发光管; P1。0为电平,P0口为11111110MOV P0,#7EH ;把7eh送p0口;数码管显示 1; P1。0为低电平,P0口为11111110LCALL DELAY ; 延时程序MOV P0,#0FFHMOV P0,#0FFH ;0ffh 送p0口,数码管清除;P0口为11111111 清一次显示这条是清显示的
上传时间: 2013-10-31
上传用户:gundamwzc
4.asm…… 响铃程序,输入一个数字字符N,响铃N次。(完成)ysk3.asm ……显示一个星型倒三角。m1.asm ………编程将键盘输入的8位无符号二进制数转化为十六进制数和十进制数,并输出结果form.asm ……采用子程序编程按以下三种格式(██,◣,◥)打印九九乘法表:(完成)char.asm ……小写字母a b c d ……x y z的ASCII码分别为61h 62H 63H 64H……78H 79H 7AH, 而大写字母A B C D ….X Y Z的ASCII码分别为41H 42H 43H 44H …58H 59H 5AH, 使用串处理指令编程从键盘输入16个字符(大小写字母及其它字母均有), 存入以BUF1开始的一片存储区中,并将其传送到以BUF2开始的一片存储区中, 在传送是将其中的小写字母均改为大写字母,并将第一个小写字母在串中的位置 (距串头BUF1的相对位移量)以十六进制形式输出。(完成)
上传时间: 2013-12-22
上传用户:zhyiroy