-
Notifications
You must be signed in to change notification settings - Fork 2
/
cpu_up_kim.a65
170 lines (143 loc) · 2.99 KB
/
cpu_up_kim.a65
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
; This program sets the PAL/KIM's LEDs to display the message, "CPU UP"
; similar to the message from the Heathkit 6800 trainer. It just always
; struck me as kind of cool...
;
; By Jim McClanahan, W4JBM, Feb 2021
;
; This is not optimized at all. Some things could be moved into the
; delay subroutine to reduce the size. This is total brute force and
; direct writes to the control registers.
;
; Build with:
; $ 64tass --intel-hex cpu_up_kim.a65 -o cpu_up_kim.hex -m --verbose-list -L cpu_up_kim.lst
; $ srec_cat cpu_up_kim.hex -intel -o cpu_up_kim.mos -MOS_Technologies
; $ unix2dos cpu_up_kim.mos
; $ cp cpu_up_kim.mos ~
;
; The addresses of the 6530/6532 used to control the LED display:
;
SAD = $1740 ; A side Data
PADD = $1741 ; A side Data Direction
SBD = $1742 ; B side Data
PBDD = $1743 ; B side Data Direction
; Note: For Data Direction, 0 is input and 1 is output.
A_INIT = $7F ; (PA6 - PA0 are outputs)
B_INIT = $1E ; (PA4 - PA1 are outputs)
;
; PAL/KIM 6502 LED Segment Layout
;
; A ---
; F | | B
; G ---
; E | | C
; D ---
;
; PA0 (1) = A
; PA1 (2) = B
; PA2 (4) = C
; PA3 (8) = D
; PA4 (16) = E
; PA5 (32) = F
; PA6 (64) = G
;
; CPU_ UP would translate into:
;
; C = A+D+E+F = 1+8+16+32 = 57
; P = A+B+E+F+G = 1+2+16+32+64 = 115
; U = B+C+D+E+F = 2+4+8+16+32 = 62
; _ (blank) = 0
;
; U = B+C+D+E+F = 2+4+8+16+32 = 62
; P = A+B+E+F+G = 1+2+16+32+64 = 115
;
C = 57
P = 115
U = 62
BLNK = 0
;
; Position Selection is done with PB1 through PB4 feeding a 1-of-10
; decoder. Then output 4, 5, 6, 7, 8, and 9 are used. It isn't that
; hard to build a truth table for this, but the values are also
; well documented.
;
LED1 = $08
LED2 = $0A
LED3 = $0C
LED4 = $0E
LED5 = $10
LED6 = $12
LEDOFF = $00
;
; DECODER PORT B
; POS OUT D C B A INP
; 1 4 0 1 0 0 $08
; 2 5 0 1 0 1 $0A
; 3 6 0 1 1 0 $0C
; 4 7 0 1 1 1 $0E
;
; 5 8 1 0 0 0 $10
; 6 9 1 0 0 1 $12
;
; Note: Because the decoder is feed starting with PB1 instead of PB2
; we have to add an extra zero to the end of our calculation
; (effectively doubling the value).
;
; Location isn't particularly important...
* = $0200
START: LDA #A_INIT ; Set the data direction bits
STA PADD
LDA #B_INIT
STA PBDD
; Display "CPU_"
DSPLY: LDA #C ; Load the pattern for the
STA SAD ; seven segments...
LDA #LED1 ; Load the pointer to the
STA SBD ; right position..
JSR DELAY ; Pause a bit
LDA #LEDOFF ; Blank things before going
STA SBD ; to the next one
LDA #P
STA SAD
LDA #LED2
STA SBD
JSR DELAY
LDA #LEDOFF
STA SBD
LDA #U
STA SAD
LDA #LED3
STA SBD
JSR DELAY
LDA #LEDOFF
STA SBD
LDA #BLNK
STA SAD
LDA #LED4
STA SBD
JSR DELAY
LDA #LEDOFF
STA SBD
; Display "UP"
LDA #U
STA SAD
LDA #LED5
STA SBD
JSR DELAY
LDA #LEDOFF
STA SBD
LDA #P
STA SAD
LDA #LED6
STA SBD
JSR DELAY
LDA #LEDOFF
STA SBD
FINSH: JMP DSPLY ; Now do it again...
DELAY: LDY #2 ; Just a simple delay routine
LDX #255
DLOOP: DEX
BNE DLOOP
DEY
BNE DLOOP
RTS
.END