SADDR EQU 0100H WADDR EQU 0200H CSADDR EQU 8000H XPOS EQU 20H YPOS EQU 21H ORG 0000H JMP START START: MOV SP,#60H MAIN: MOV R7,#’0’ MNP: CALL LCDRESET MOV A,R7 CALL LCDFILL CALF DELAY INC R7 MOV A,R7 CJNE A,#’9’+1MNP MOV A,#’ ‘ CALL LCDFILL CALL DELAY JMP MAIN LCDFILL: MOV B,A MOV YPOS,#0 LFLPB MOV XPOS,#0 LFL PA: MOV A,B CALL LCDWRITE INC XPOS MOV A,XPOS CJNE A,#20,LFLPA INC YPOS MOV A,YPOS CJNE A,#4,LFLPB RET LCDPOS: PUSH ACC CLR C MOV A,XPOS SUBB A,#20 JC LPSLBX MOV XPOS,#0 LPSLBX: ANL YPOS,#03H MOV A,YPOS CJNE A,#00H,LPSLA1 MOV A,XPOS JMP LPLAX LPS LA1: CJNE A,#01,LPS LA2 MOV A,XPOS ADD A,#40H JMP LPS LAX LPSLA2: CJNE A,#02,LPS LAY MOV A,XPOS ADD A, #14H JMP LPSLAX LPSLAY: MOV A,XPOS ADD A,#54H LPSLAX: ORL A,#80H CALL LCDWC POP ACC RET LCDWRITE: CALL L CDPOS CALL CDWD RET LCDRESET: CALL DELAY5MS CALL DELAY5MS CALL DELAY5MS MOV A,#38H CALL LCDWCN CALL DELAY5MS MOV A,#38H CALL L CDWCN CALL DELAY5MS MOV A,#38H CALL LCDWCN MOV A,#38H CALL LCDWC MOV A,#08H CALL LCDWC MOV A,#01H CALL L CDWC MOV A,#06H CALL LCDWC MOV A,#0CH CALL LCDWC RET LCDWC: CALL WAITIDLE LCDWCN: MOV DPTR,#CSADDR MOV @DPTR,:A RET LCDWD: CALL WAITIDLE MOV DPTR,#CSADDR+RSADDR MOVX @DPTR,A RET WAITIDLE: PUSH ACC MOV DPTR,#CSADDR+RWADDR WTDPA: MOVX A,@DPTR JB ACC.7,WTDPA POP ACC RET DELAY5MS: MOV R1,#25 DL5PA: MOV R2,#100H DJNZ R2,$ DJNZ R1,DL5PA RET DELAY: MOV R0,#20 DLPA: MOV R1,#100 DLPB: MOV R2,#100 DJNZ R2,$ DJNZ R1,DLPB DJNZ R0,DLPB RET END