1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
macro delay .t {
mov ecx,.t*1
local .a
.a: loop .a
}
org 100h
delay 200
call lcd.init
delay 200
call lcd.clear
mov ax,001h
call lcd.goto
mov al,'0'
call lcd.putc
mov ax,003h
call lcd.goto
mov si,message
call lcd.puts
@@:
in al,60h
cmp al,43h
je .exit
jmp @b
.exit:
mov ax,3
int 10h
ret
message db 'hello',0
;LPT connection
;pin 1 = E = .ctrl bit0 1
;pin 16 = RS = .ctrl bit2 4
;pin 14 = R/W = .ctrl bit3 8
;pins 2 to 9 = data = .data
;LCD connection
;pin 1 = gnd
;pin 2 = +5V
;pin 3 = contrast
;pin 4 = Register Select
;pin 5 = Read /Write
;pin 6 = Enable
;pins 7 to 14 = data
lcd:
.lpt=378h
.data=.lpt+0
.stat=.lpt+1
.ctrl=.lpt+2
.rs=4
.e=1
.rw=8
.p1:
mov dx,lcd.data
ret
.p3:
mov dx,lcd.ctrl
ret
.rs0:
in al,dx
or al,.rs
out dx,al
ret
.rs1:
in al,dx
and al,not .rs
out dx,al
ret
.e0:
in al,dx
or al,.e
out dx,al
ret
.e1:
in al,dx
and al,not .e
out dx,al
ret
.rw0:
in al,dx
or al,.rw
out dx,al
ret
.rw1:
in al,dx
and al,not .rw
out dx,al
ret
.clear:
mov dx,.ctrl
in al,dx
delay 20
or al,not 4
out dx,al
mov al,1
delay 20
call lcd.write
ret
.write:
mov dx,.data
out dx,al
mov dx,.ctrl
in al,dx
or al,1
out dx,al
mov dx,.ctrl
in al,dx
delay 20
and al,not 1
out dx,al
delay 20
ret
.init:
mov dx,.ctrl
in al,dx
delay 20
and al,4
out dx,al
delay 20
in al,dx
delay 20
or al,not 4
out dx,al
mov al,0fh
call lcd.write
delay 20
mov al,1
call lcd.write
delay 20
mov al,38h
call lcd.write
delay 20
ret
.goto:
;al=x
;ah=y
delay 20
push ax
mov dx,.ctrl
in al,dx
delay 20
or al,not 4
out dx,al
delay 20
pop ax
cmp ah,1
jne @f
add al,40h
@@:
cmp ah,2
jne @f
add al,10h
@@:
cmp ah,3
jne @f
add al,50h
@@:
or al,80h
call lcd.write
ret
.putc:
delay 20
rol ax,8
mov dx,.ctrl
in al,dx
delay 20
and al,4
out dx,al
delay 20
ror ax,8
call lcd.write
ret
.puts:
delay 20
mov dx,.ctrl
in al,dx
delay 20
and al,4
out dx,al
@@:
mov al,[si]
cmp al,0
je @f
call .putc
inc si
jmp @b
@@:
ret |
Partager