我正在用 8255 用 80188 对 LCD 进行编程。我正在编写一个基本代码来显示一些文本,但它不起作用。如下:
STI
PORTA EQU 0080H
PORTB EQU 0081H
PORTC EQU 0082H
CWR EQU 0083H
;set 8255 output
MOV AL, 89H
MOV DX, CWR
OUT DX, AL ;send the control word
NEXT:
call far ptr lcd
JMP NEXT
lcd proc far
PUSH DX
PUSH CX
PUSH BX
PUSH AX
设置:
; 移动 AX, DATA_SEG ; 移动 AX,AX ; mov ES,AX
;The following sends all the necessary commands to the LCD
MOV AL, 38H ;initialize LCD for 2 lines & 5*7 matrix
CALL COMNDWRT ;write the command to LCD
CALL DELAY ;wait before issuing the next command
CALL DELAY
;this command needs lots of delay
CALL DELAY
MOV AL, 0EH ;send command for LCD on, cursor on 0000 1110b
CALL COMNDWRT
CALL DELAY
MOV AL, 01 ;clear LCD
CALL COMNDWRT
CALL DELAY
MOV AL, 06 ;command for shifting cursor right
CALL COMNDWRT
CALL DELAY
COMNDWRT PROC ;this procedure writes commands to LCD
PUSH DX ;save DX
MOV DX, PORTB ; connected to LCD
OUT DX, AL ;send the code to Port B
MOV DX, PORTC
MOV AL, 00000100B ;RS=0,R/W=0,E=1 for H-To-L pulse
OUT DX, AL ; send setup to PORT C
NOP
NOP
MOV AL, 00000000B ;RS=0,R/W=0,E=0 for H-To-L pulse
OUT DX, AL
POP DX
RET
COMNDWRT ENDP
MOV AL, 1 ;display ‘1’ letter
CALL DATWRIT ;issue it to LCD
CALL DELAY ;wait before issuing the next character
MOV AL, 2 ;display ‘2’ letter
CALL DATWRIT ;issue it to LCD
CALL DELAY ;wait before issuing the next character
MOV AL, 5 ;display ‘5’ letter
CALL DATWRIT ;issue it to LCD
CALL DELAY ;wait
;data write to LCD without checking the busy flag
;AL = char sent to LCD
DATWRIT PROC
PUSH DX ;save DX
MOV DX, PORTB ;DX=port B 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, PORTC ;port C address
OUT DX, AL ;make enable high
MOV AL, 00000001B ;RS=1,R/W=0 and E=0 for H-to-L pulse
OUT DX, AL
POP DX
RET
DATWRIT ENDP
DELAY PROC
MOV CX, 1325 ;1325*15.085 usec = 20 msec
PUSH AX
W1: IN AL, 61H
AND AL, 00010000B
CMP AL, AH
JE W1
MOV AH, AL
LOOP W1
POP AX
RET
DELAY ENDP
;JMP SETUP
POP AX
POP BX
POP CX
POP DX
ret
液晶显示器
CODE_SEG ENDS 结束
谁能告诉我是否遗漏了什么?