LCD汇编程序示例.docx
《LCD汇编程序示例.docx》由会员分享,可在线阅读,更多相关《LCD汇编程序示例.docx(18页珍藏版)》请在冰豆网上搜索。
LCD汇编程序示例
LCD汇编程序示例(lm016l)(总11页)
;----------逐字依次输入方式-----------
COMEQU20H;指令寄存器
DATEQU21H;数据寄存器
CW_AddEQU8000H;指令口写地址
CR_AddEQU8200H;指令口读地址
DW_AddEQU8100H;数据口写地址
DR_AddEQU8300H;数据口读地址
ORG0000H
MAIN:
MOVSP,#60H
MOVA,#30H;功能指令设置
MOVDPTR,#CW_Add
MOVR2,#03H
L1:
MOVX@DPTR,A
LCALLDELAY
DJNZR2,L1
MOVCOM,#38H;设置工作方式
LCALLPR1
MOVCOM,#01H;清屏
LCALLPR1
MOVCOM,#06H;设置输入方式
LCALLPR1
MOVCOM,#0FH;设置显示方式
LCALLPR1
MOVCOM,#80H;设置DDRAM地址00H
LCALLPR1
MOVDPTR,#TAB
MOVR2,#12;显示前8位
MOVR3,#00
WRIN:
MOVA,R3
MOVCA,@A+DPTR
MOVDAT,A
LCALLPR2
LCALLDELAY
INCR3
DJNZR2,WRIN
SJMP$
;-------写指令代码子程序---------
PR1:
PUSHDPH
PUSHDPL
PUSHACC
MOVDPTR,#CR_ADD
PR11:
MOVXA,@DPTR
JB,PR11
MOVA,COM
MOVDPTR,#CW_ADD
MOVX@DPTR,A
POPACC
POPDPL
POPDPH
RET
;--------写显示数据子程序----------
PR2:
PUSHDPH
PUSHDPL
PUSHACC
MOVDPTR,#CR_ADD
PR21:
MOVXA,@DPTR
JB,PR21
MOVA,DAT
MOVDPTR,#DW_ADD
MOVX@DPTR,A
POPACC
POPDPL
POPDPH
RET
DELAY:
MOVR6,#00H
MOVR7,#00H
DELAY1:
NOP
DJNZR7,DELAY1
DJNZR6,DELAY1
RET
TAB:
DB43H,75H,72H,73H,6FH,72H,20H;Cursor
DB57H,72H,69H,74H,65H;write
END
;----------逐字依次输入,两行显示方式-----------
COMEQU20H;指令寄存器
DATEQU21H;数据寄存器
CW_AddEQU8000H;指令口写地址
CR_AddEQU8200H;指令口读地址
DW_AddEQU8100H;数据口写地址
DR_AddEQU8300H;数据口读地址
ORG0000H
MAIN:
MOVSP,#60H
MOVA,#30H;功能指令设置
MOVDPTR,#CW_ADD
MOVR2,#03H
L1:
MOVX@DPTR,A
LCALLDELAY
DJNZR2,L1
MOVCOM,#38H;设置工作方式
LCALLPR1
MOVCOM,#06H;设置显示方式
LCALLPR1
MOVCOM,#0fH;清屏
LCALLPR1
MOVCOM,#01H;设置输入方式
LCALLPR1
MOVCOM,#80H;设置DDRAM地址00H
LCALLPR1
MOVDPTR,#TAB
MOVR2,#07;显示前8位
MOVR3,#00H
WRIN:
MOVA,R3
MOVCA,@A+DPTR
MOVDAT,A
LCALLPR2
LCALLDELAY
INCR3
DJNZR2,WRIN
MOVCOM,#0C0H;设置DDRAM地址40H
LCALLPR1
MOVR2,#05H;显示后4位
WRIN1:
MOVA,R3
MOVCA,@A+DPTR
MOVDAT,A
LCALLPR2
LCALLDELAY
INCR3
DJNZR2,WRIN1
SJMPMAIN
;-------写指令代码子程序---------
PR1:
PUSHDPH
PUSHDPL
PUSHACC
MOVDPTR,#CR_ADD
PR11:
MOVXA,@DPTR
JB,PR11
MOVA,COM
MOVDPTR,#CW_ADD
MOVX@DPTR,A
POPACC
POPDPL
POPDPH
RET
;--------写显示数据子程序----------
PR2:
PUSHDPH
PUSHDPL
PUSHACC
MOVDPTR,#CR_ADD
PR21:
MOVXA,@DPTR
JB,PR21
MOVA,DAT
MOVDPTR,#DW_ADD
MOVX@DPTR,A
POPACC
POPDPL
POPDPH
RET
DELAY:
MOVR6,#00H
MOVR7,#00H
DELAY1:
NOP
DJNZR7,DELAY1
DJNZR6,DELAY1
RET
TAB:
DB43H,75H,72H,73H,6FH,72H,20H;Cursor
DB57H,72H,69H,74H,65H;write
END
;----------光标左移输入,两行显示方式-----------
COMEQU20H
DATEQU21H
CW_ADDEQU8000H
CR_ADDEQU8200H
DW_ADDEQU8100H
DR_ADDEQU8300H
ORG0000H
MAIN:
MOVSP,#60H
MOVA,#30H;功能指令设置
MOVDPTR,#CW_ADD
MOVR2,#03H
L1:
MOVX@DPTR,A
LCALLDELAY
DJNZR2,L1
MOVCOM,#38H;设置工作方式
LCALLPR1
MOVCOM,#01H;清屏
LCALLPR1
MOVCOM,#06H;设置输入方式
LCALLPR1
MOVCOM,#0FH;设置显示方式
LCALLPR1
MOVCOM,#04H;设置输入方式,减方式
LCALLPR1
MOVCOM,#0C5H;设置DDRAM地址44H
LCALLPR1
MOVDPTR,#TAB
MOVR2,#05;显示后5位
MOVR3,#11;从第12位开始显示
WRIN:
MOVA,R3
MOVCA,@A+DPTR
MOVDAT,A
LCALLPR2
LCALLDELAY
DECR3
DJNZR2,WRIN
MOVCOM,#87H;设置DDRAM地址07H
LCALLPR1
MOVR2,#08H;显示前8位
WRIN1:
MOVA,R3
MOVCA,@A+DPTR
MOVDAT,A
LCALLPR2
LCALLDELAY
DECR3
DJNZR2,WRIN1
SJMP$
;-------写指令代码子程序---------
PR1:
PUSHDPH
PUSHDPL
PUSHACC
MOVDPTR,#CR_ADD
PR11:
MOVXA,@DPTR
JB,PR11
MOVA,COM
MOVDPTR,#CW_ADD
MOVX@DPTR,A
POPACC
POPDPL
POPDPH
RET
;--------写显示数据子程序----------
PR2:
PUSHDPH
PUSHDPL
PUSHACC
MOVDPTR,#CR_ADD
PR21:
MOVXA,@DPTR
JB,PR21
MOVA,DAT
MOVDPTR,#DW_ADD
MOVX@DPTR,A
POPACC
POPDPL
POPDPH
RET
DELAY:
MOVR6,#00H
MOVR7,#00H
DELAY1:
NOP
DJNZR7,DELAY1
DJNZR6,DELAY1
RET
TAB:
DB43H,75H,72H,73H,6FH,72H,20H;Cursor
DB57H,72H,69H,74H,65H;write
END
;----------左滚动输入方式-----------
COMEQU20H;指令寄存器
DATEQU21H;数据寄存器
CW_AddEQU8000H;指令口写地址
CR_AddEQU8200H;指令口读地址
DW_AddEQU8100H;数据口写地址
DR_AddEQU8300H;数据口读地址
ORG0000H
MAIN:
MOVSP,#60H
MOVA,#30H;功能指令设置
MOVDPTR,#CW_ADD
MOVR2,#03H
L1:
MOVX@DPTR,A
LCALLDELAY
DJNZR2,L1
MOVCOM,#38H;设置工作方式
LCALLPR1
MOVCOM,#01H;清屏
LCALLPR1
MOVCOM,#06H;设置输入方式
LCALLPR1
MOVCOM,#0EH;设置显示方式
LCALLPR1
MOVCOM,#07H;设置输入方式,画面滚动
LCALLPR1
MOVCOM,#8cH;设置DDRAM地址07H
LCALLPR1
MOVDPTR,#TAB
MOVR2,#012;显示前7位
MOVR3,#00
WRIN:
MOVA,R3
MOVCA,@A+DPTR
MOVDAT,A
LCALLPR2
LCALLDELAY
INCR3
DJNZR2,WRIN
SJMP$
;-------写指令代码子程序---------
PR1:
PUSHDPH
PUSHDPL
PUSHACC
MOVDPTR,#CR_ADD
PR11:
MOVXA,@DPTR
JB,PR11
MOVA,COM
MOVDPTR,#CW_ADD
MOVX@DPTR,A
POPACC
POPDPL
POPDPH
RET
;--------写显示数据子程序----------
PR2:
PUSHDPH
PUSHDPL
PUSHACC
MOVDPTR,#CR_ADD
PR21:
MOVXA,@DPTR
JB,PR21
MOVA,DAT
MOVDPTR,#DW_ADD
MOVX@DPTR,A
POPACC
POPDPL
POPDPH
RET
DELAY:
MOVR6,#00H
MOVR7,#00H
DELAY1:
NOP
DJNZR7,DELAY1
DJNZR6,DELAY1
RET
TAB:
DB43H,75H,72H,73H,6FH,72H,20H;Cursor
DB57H,72H,69H,74H,65H;write
END
;----------自定义字符库方式-----------
COMEQU20H
DATEQU21H
CW_ADDEQU8000H
CR_ADDEQU8200H
DW_ADDEQU8100H
DR_ADDEQU8300H
ORG0000H
MAIN:
MOVSP,#60H
MOVA,#30H;功能指令设置
MOVDPTR,#CW_ADD
MOVR2,#03H
L1:
MOVX@DPTR,A
LCALLDELAY
DJNZR2,L1
MOVCOM,#38H;设置工作方式
LCALLPR1
MOVCOM,#01H;清屏
LCALLPR1
MOVCOM,#06H;设置输入方式
LCALLPR1
MOVCOM,#0FH;设置显示方式
LCALLPR1
LCALLCG_WRITE;调用自定义的字库子程序
MOVCOM,#80H;设置DDRAM地址
LCALLPR1
MOVDPTR,#TABDY;设置字表首地址
MOVR2,#08
MOVR3,#00H
LOOP1:
MOVA,R3
MOVCA,@A+DPTR
MOVDAT,A
LCALLPR2
INCR3
DJNZR2,LOOP1
MOVCOM,#0C0H;设置DDRAM地址
LCALLPR1
MOVR2,#08H
LOOP2:
MOVA,R3
MOVCA,@A+DPTR
MOVDAT,A
LCALLPR2
INCR3
DJNZR2,LOOP2
SJMP$
CG_WRITE:
MOVCOM,#40H;编字库
LCALLPR1
MOVR2,#64
MOVR3,#00H
MOVDPTR,#CGTAB;设置字模数据的首地址
CG1:
MOVA,R3
MOVCA,@A+DPTR
MOVDAT,A
LCALLPR2
INCR3
DJNZR2,CG1
RET
;-------写指令代码子程序---------
PR1:
PUSHDPH
PUSHDPL
PUSHACC
MOVDPTR,#CR_ADD
PR11:
MOVXA,@DPTR
JB,PR11
MOVA,COM
MOVDPTR,#CW_ADD
MOVX@DPTR,A
POPACC
POPDPL
POPDPH
RET
;--------写显示数据子程序----------
PR2:
PUSHDPH
PUSHDPL
PUSHACC
MOVDPTR,#CR_ADD
PR21:
MOVXA,@DPTR
JB,PR21
MOVA,DAT
MOVDPTR,#DW_ADD
MOVX@DPTR,A
POPACC
POPDPL
POPDPH
RET
DELAY:
MOVR6,#00H
MOVR7,#00H
DELAY1:
NOP
DJNZR7,DELAY1
DJNZR6,DELAY1
RET
CGTAB:
DB08H,0FH,12H,0FH,0AH,1FH,02H,02H;"年"代码=00H
DB0FH,09H,0FH,09H,0FH,09H,11H,00H;"月"代码=01H
DB1FH,11H,11H,1FH,11H,11H,1FH,00H;"日"代码=02H
DB11H,0AH,04H,1FH,04H,1FH,04H,00H;"$"代码=03H
DB0EH,00H,1FH,0AH,0AH,0AH,13H,00H;"元"代码=04H
DB18H,18H,07H,08H,08H,08H,07H,00H;"摄氏度"代码=05H
DB04H,0AH,15H,04H,04H,04H,04H,00H;"↑"代码=06H
DB17H,15H,15H,15H,15H,15H,17H,00H;"10"代码=07H
TABDY:
DB57H,46H,48H,30H,36H,00H,34H,01H;WFH06年4月
DB33H,02H,54H,3DH,32H,33H,05H,06H;3日T=23摄氏度↑
END