Mercurial > vba-clojure
comparison clojure/com/aurellem/gb/rlm_assembly.clj @ 391:2e9b2d27f32f
saving progress...
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 12 Apr 2012 00:20:16 -0500 |
parents | dbf7b5a2e9e7 |
children | 309614263aa9 |
comparison
equal
deleted
inserted
replaced
390:dbf7b5a2e9e7 | 391:2e9b2d27f32f |
---|---|
189 (def do-write-mode (Integer/parseInt "00010000" 2)) | 189 (def do-write-mode (Integer/parseInt "00010000" 2)) |
190 | 190 |
191 (defn main-bootstrap-program [start-address] | 191 (defn main-bootstrap-program [start-address] |
192 ;; Register Use: | 192 ;; Register Use: |
193 | 193 |
194 ;; BC persistent scratch | 194 ;; ED non-volitale scratch |
195 ;; | 195 |
196 ;; A user-input | 196 ;; A user-input |
197 ;; HL target-address | 197 ;; HL target-address |
198 ;; D current-mode | 198 ;; B bytes-to-write |
199 ;; E bytes-to-write | 199 ;; C current-mode |
200 | 200 |
201 | 201 ;; Modes (with codes) are: |
202 ;; Modes are: | |
203 | 202 |
204 ;; single-action-modes: | 203 ;; single-action-modes: |
205 ;; SET-MODE | 204 ;; SET-MODE |
206 ;; SET-TARGET-HIGH | 205 ;; SET-TARGET-HIGH 0x67 ;; A->H |
207 ;; SET-TARGET-LOW | 206 ;; SET-TARGET-LOW 0x6F ;; A->L |
208 ;; SET-WRITE-LENGTH | 207 ;; JUMP 0xE9 ;; jump to (HL) |
209 ;; JUMP | |
210 | 208 |
211 ;; multi-action-modes | 209 ;; multi-action-modes |
212 ;; WRITE | 210 ;; WRITE 0x47 ;; A->B |
213 | 211 |
214 | |
215 | |
216 (let [[start-high start-low] (disect-bytes-2 start-address) | 212 (let [[start-high start-low] (disect-bytes-2 start-address) |
217 jump-distance (+ (count (frame-metronome)) | 213 jump-distance (+ (count (frame-metronome)) |
218 (read-user-input)) | 214 (read-user-input)) |
219 | 215 |
220 init | 216 init |
221 [0xAF 0x5F 0x57 0x47] ;; 0->A; 0->E; 0->D; 0->B | 217 [0xAF 0x5F 0x57 0x47] ;; 0->A; 0->E; 0->D; 0->B |
222 | 218 |
223 | |
224 | |
225 | |
226 input | 219 input |
227 [0xC1 ;; pop BC so it's not volatile | 220 [0xC1 ;; pop BC so it's not volatile |
228 ;; some condition | 221 |
229 ;; to skip if not in input | |
230 ;; mode | |
231 | |
232 | |
233 | |
234 | |
235 0xE9 ;; jump to (HL) | |
236 | |
237 0x22 ;; A->(HL) ; inc HL | |
238 | |
239 | |
240 0x57 ;; A->D | |
241 | |
242 0x67 ;; A->H | |
243 0x6F ;; A->L | |
244 | |
245 0x47 ;; A->B | |
246 0x4F ;; A->C | 222 0x4F ;; A->C |
247 | 223 |
248 | 224 0xAF ;; test for output-mode (bytes-to-write > 0) |
225 0xB8 ;; (cp A B) | |
226 | |
227 0x20 ;; skip input section if | |
228 :to-output ;; we're not in input mode | |
229 | |
230 | |
231 :to-be-executed | |
232 | |
233 | |
234 ;; write mode to instruction to be executed (pun) | |
235 0xEA | |
236 :to-be-executed-address | |
237 0x18 ;; return | |
238 :to-beginning] | |
239 | |
240 output | |
241 [0x05 ;; DEC bytes-to-write (B) | |
242 | |
243 0x54 ;; | |
244 0x5D ;; HL->DE \ | |
245 ;; | | |
246 0x79 ;; C->A | this mess is all to do | |
247 0x12 ;; A->(DE) | 0x22 (LDI (HL), A) without | |
248 ;; | any repeating nybbles | |
249 0x23 ;; inc HL / | |
250 | |
251 ] | |
252 | |
253 | |
254 | |
255 | |
256 | |
257 | |
258 0x22 ;; A->(HL) ; inc HL | |
249 | 259 |
250 | 260 |
251 | 261 |
252 | 262 |
253 | 263 |