51单片机驱动1602液晶汇编语言程序
2015-06-19 来源:51hei
LCMRS EQU P2.4
进入单片机查看更多内容>>
LCMRW EQU P2.5 LCMEN EQU P2.6 LCMDATA EQU P0 ORG 0000H LJMP MAIN ORG 0030H MAIN: MOV SP,#60H LCALL LCMSET LCALL LCMCLR MOV A,#80H LCALL LCMWR0 MOV DPTR,#TAB0 LCALL LCMWR2 MOV A,#0C0H LCALL LCMWR0 MOV DPTR,#TAB1 LCALL LCMWR2 SJMP $ TAB0: DB 'I AM YUAN MING',00H TAB1: DB 'NICE TO MEET YOU',00H LCMLAY: ;读忙程序,用于判断d7是否为0 PUSH ACC LOOP: CLR LCMEN CLR LCMRS SETB LCMRW SETB LCMEN MOV A,LCMDATA CLR LCMEN JB ACC.7,LOOP POP ACC LCALL DELAY RET LCMWR0: ;写入指令 LCALL LCMLAY CLR LCMEN CLR LCMRS CLR LCMRW SETB LCMEN MOV LCMDATA,A CLR LCMEN RET LCMWR1: ;写入数据 LCALL LCMLAY CLR LCMEN SETB LCMRS CLR LCMRW SETB LCMEN MOV LCMDATA,A CLR LCMEN RET LCMWR2: 写入字符串(字符串属于数据) PUSH ACC LOOP1: CLR A MOVC A,@A+DPTR JZ LOOP2 LCALL LCMWR1 INC DPTR LJMP LOOP1 LOOP2: POP ACC RET LCMSET: ;程序初始化 MOV A,#38H LCALL LCMWR0 MOV A,#08H LCALL LCMWR0 MOV A,#01H LCALL LCMWR0 MOV A,#06H LCALL LCMWR0 MOV A,#0CH LCALL LCMWR0 RET LCMCLR: ;清屏 MOV A,#01H LCALL LCMWR0 RET DELAY: MOV R6,#5 ;2.7MS延时子程序(作用尚不知) D1: MOV R7,#248 DJNZ R7,$ DJNZ R6,D1 RET END
相关文章