;program sections from the textbook Section 12.8 ;in the data segment MYDATA DB "HELLO" ;from the code segment: MOV CX,5 ;send 5 ASCII char to be displayed MOV SI,OFFSET MYDATA ;load offset address NEXT: MOV AL,[SI] ;get the character CALL NDATWRIT ;issue it to LCD INC SI ;next one CALL DELAY ;wait for next character LOOP NEXT ;until all are sent ; ... ;further code here ;data write to LCD without checking the busy flag, AL=char sent to LCD NDATWRIT PROC PUSH DX ;save DX MOV DX,PORTA ;DX=port A address OUT DX,AL ;issue the char to LCD MOV AL,00000101B ;RS=1,R/W=0, E=1 for H-to-L pulse MOV DX,PORTB ;port B address OUT DX,AL ;make enable high NOP ;for the high-to-low pulse NOP ;while RS=1 for data MOV AL,00000001B ;RS=1,R/W=0 AND E=0 for H-to-L pulse OUT DX,AL POP DX RET NDATWRIT ENDP ; The above code did not monitor the busy flag bit.However, it is recommended by the LCD ;manufacturer's data sheet to monitor the busy flag before sending the data. This ensures that the LCD is ;ready to receive data. See the code below. ;data write to LCD with checking the busy flag, AL=char sent to LCD DATAWRIT PROC ;This procedure writes ASCII data to LCD PUSH DX ;save DX MOV AH,AL ;save character to be sent to LCD MOV AL,90H ;make PA=input to read LCD status, PB=OUT MOV DX,CNTPORT ;DX=control port address OUT DX,AL ;issue to control reg MOV AL,00000110B ;RS=0 since busy flag is a command; R/W=1,E=1 MOV DX,PORTB ;port B address OUT DX,AL ;issue it to port B MOV DX,PORTA ;port A address AGAIN: IN AL,DX ;read busy flag (d7) ROL AL,1 ;sent to carry flag JC AGAIN ;IF CF=1 LCD not ready try again MOV AL,80H ;8255 PA=OUT to send character to LCD MOV DX,CONTPORT ;DX=control port address OUT DX,AL ;issue to 8255's control reg MOV AL,AH ;get the character to be sent to LCD MOV DX,PORTA ;DX=port A address OUT DX,AL ;issue the char to LCD MOV AL,00000101B ;RS=1 since it is data ;R/W=0,E=1 for H-to-L pulse MOV DX,PORTB ;port B address OUT DX,AL ;make enable high NOP ;for the high-to-low pulse NOP ;while RS=1 for data MOV AL,00000001B ;RS=1,R/W=0, E=0 for H-to-L pulse OUT DX,AL ;to port B POP DX ;restore DX RET ;return to caller DATAWRIT ENDP