-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlcd2.s
101 lines (73 loc) · 1.04 KB
/
lcd2.s
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
PORTB=$6000
PORTA=$6001
DDRB=$6002
DDRA=$6003
E=%10000000
RW=%01000000
RS=%00100000
.org $8000
reset:
lda #$ff
sta DDRB
sta DDRA
lda #$01 ; clear display
jsr lcd_sendInstruction
lda #$06 ; Left-to-right, shift off
jsr lcd_sendInstruction
lda #$0e ; Display on, cursor on, blink off
jsr lcd_sendInstruction
lda #$38 ; 8-bit mode, 2-lines, 5x8 Font
jsr lcd_sendInstruction
lda #"L"
jsr lcd_sendChar
lda #"i"
jsr lcd_sendChar
lda #"n"
jsr lcd_sendChar
lda #"u"
jsr lcd_sendChar
lda #"s"
jsr lcd_sendChar
loop:
jmp loop
lcd_wait:
pha
lda #0
sta DDRB ; PORT B as inputs
lcd_busy:
lda #RW ; read from display
sta PORTA
lda #(RW|E)
sta PORTA
lda PORTB
and #%10000000
bne lcd_busy
lda #0
sta PORTA
lda #$ff
sta DDRB ; PORT B as outputs
pla
rts
lcd_sendInstruction:
jsr lcd_wait
sta PORTB
lda #0
sta PORTA
lda #E
sta PORTA
lda #0
sta PORTA
rts
lcd_sendChar:
jsr lcd_wait
sta PORTB
lda #0
sta PORTA
lda #(E|RS)
sta PORTA
lda #0
sta PORTA
rts
.org $fffc
.word reset
.word $ffff