-
Notifications
You must be signed in to change notification settings - Fork 0
/
002_hello-world.s
178 lines (155 loc) · 4.22 KB
/
002_hello-world.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
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
; the following 65C02 assembly code prints "Hello world!" on the
; LCD, character by character, without any stack and thus with no
; subroutine calls.
; ports of the 65C22 versatile interface adapter.
PORTB = $6000 ; port B of the versatile interface.
PORTA = $6001 ; port A of the versatile interface.
DDRB = $6002 ; port B is controlled by DDRB at 6002.
DDRA = $6003 ; port A is controlled by DDRA at 6003.
; hardware uses 3 top bits of PORTA to control the LDC display. PORTA ~ EWS*****.
E = %10000000 ; enables the LCD display for control.
RW = %01000000 ; 0 to write, 1 to read.
RS = %00100000 ; 0 to access Instruction Register (IR), 1 for Data Register (DR).
.org $8000
;; resets the internals of the CPU and interface for proper use.
reset:
; initialize the LCD.
lda #%11111111 ; Set all pins on port B to output
sta DDRB
lda #%11100000 ; Set top 3 pins on port A to output
sta DDRA
lda #%00111000 ; Set 8-bit mode; 2-line display; 5x8 font
sta PORTB
lda #0 ; Clear RS/RW/E bits
sta PORTA
lda #E ; Set the E bit. to send instruction
sta PORTA
lda #0 ; Clear RS/RW/E bits
sta PORTA
lda #%00001110 ; Display on; cursor on; blink off
sta PORTB
lda #0 ; Clear RS/RW/E bits
sta PORTA
lda #E ; Set the E bit. to send instruction
sta PORTA
lda #0 ; Clear RS/RW/E bits
sta PORTA
lda #%00000110 ; Increment and shift cursor; don't shift display
sta PORTB
lda #0 ; Clear RS/RW/E bits
sta PORTA
lda #E ; Set the E bit. to send instruction
sta PORTA
lda #0 ; Clear RS/RW/E bits
sta PORTA
; print "Hello world!" character by character.
lda #"H"
sta PORTB
lda #RS ; Set RS; Clear RW/E bits
sta PORTA
lda #(RS | E) ; Set the E bit. to send instruction
sta PORTA
lda #RS ; Clear the E bit.
sta PORTA
lda #"e"
sta PORTB
lda #RS ; Set RS; Clear RW/E bits
sta PORTA
lda #(RS | E) ; Set the E bit. to send instruction
sta PORTA
lda #RS ; Clear the E bit.
sta PORTA
lda #"l"
sta PORTB
lda #RS ; Set RS; Clear RW/E bits
sta PORTA
lda #(RS | E) ; Set the E bit. to send instruction
sta PORTA
lda #RS ; Clear the E bit.
sta PORTA
lda #"l"
sta PORTB
lda #RS ; Set RS; Clear RW/E bits
sta PORTA
lda #(RS | E) ; Set the E bit. to send instruction
sta PORTA
lda #RS ; Clear the E bit.
sta PORTA
lda #"o"
sta PORTB
lda #RS ; Set RS; Clear RW/E bits
sta PORTA
lda #(RS | E) ; Set the E bit. to send instruction
sta PORTA
lda #RS ; Clear the E bit.
sta PORTA
lda #","
sta PORTB
lda #RS ; Set RS; Clear RW/E bits
sta PORTA
lda #(RS | E) ; Set the E bit. to send instruction
sta PORTA
lda #RS ; Clear the E bit.
sta PORTA
lda #" "
sta PORTB
lda #RS ; Set RS; Clear RW/E bits
sta PORTA
lda #(RS | E) ; Set the E bit. to send instruction
sta PORTA
lda #RS ; Clear the E bit.
sta PORTA
lda #"w"
sta PORTB
lda #RS ; Set RS; Clear RW/E bits
sta PORTA
lda #(RS | E) ; Set the E bit. to send instruction
sta PORTA
lda #RS ; Clear the E bit.
sta PORTA
lda #"o"
sta PORTB
lda #RS ; Set RS; Clear RW/E bits
sta PORTA
lda #(RS | E) ; Set the E bit. to send instruction
sta PORTA
lda #RS ; Clear the E bit.
sta PORTA
lda #"r"
sta PORTB
lda #RS ; Set RS; Clear RW/E bits
sta PORTA
lda #(RS | E) ; Set the E bit. to send instruction
sta PORTA
lda #RS ; Clear the E bit.
sta PORTA
lda #"l"
sta PORTB
lda #RS ; Set RS; Clear RW/E bits
sta PORTA
lda #(RS | E) ; Set the E bit. to send instruction
sta PORTA
lda #RS ; Clear the E bit.
sta PORTA
lda #"d"
sta PORTB
lda #RS ; Set RS; Clear RW/E bits
sta PORTA
lda #(RS | E) ; Set the E bit. to send instruction
sta PORTA
lda #RS ; Clear the E bit.
sta PORTA
lda #"!"
sta PORTB
lda #RS ; Set RS; Clear RW/E bits
sta PORTA
lda #(RS | E) ; Set the E bit. to send instruction
sta PORTA
lda #RS ; Clear the E bit.
sta PORTA
; end of program.
loop:
jmp loop
.org $fffc
.word reset
.word $0000