# HG changeset patch # User Robert McIntyre # Date 1334208016 18000 # Node ID 2e9b2d27f32fad8ced16c632ffcc6935307d9466 # Parent dbf7b5a2e9e7dfa83bf84e260f233e2d5ffbd2ec saving progress... diff -r dbf7b5a2e9e7 -r 2e9b2d27f32f clojure/com/aurellem/gb/rlm_assembly.clj --- a/clojure/com/aurellem/gb/rlm_assembly.clj Wed Apr 11 23:40:01 2012 -0500 +++ b/clojure/com/aurellem/gb/rlm_assembly.clj Thu Apr 12 00:20:16 2012 -0500 @@ -191,28 +191,24 @@ (defn main-bootstrap-program [start-address] ;; Register Use: - ;; BC persistent scratch - ;; + ;; ED non-volitale scratch + ;; A user-input ;; HL target-address - ;; D current-mode - ;; E bytes-to-write + ;; B bytes-to-write + ;; C current-mode - - ;; Modes are: + ;; Modes (with codes) are: ;; single-action-modes: ;; SET-MODE - ;; SET-TARGET-HIGH - ;; SET-TARGET-LOW - ;; SET-WRITE-LENGTH - ;; JUMP + ;; SET-TARGET-HIGH 0x67 ;; A->H + ;; SET-TARGET-LOW 0x6F ;; A->L + ;; JUMP 0xE9 ;; jump to (HL) ;; multi-action-modes - ;; WRITE + ;; WRITE 0x47 ;; A->B - - (let [[start-high start-low] (disect-bytes-2 start-address) jump-distance (+ (count (frame-metronome)) (read-user-input)) @@ -220,32 +216,46 @@ init [0xAF 0x5F 0x57 0x47] ;; 0->A; 0->E; 0->D; 0->B - + input + [0xC1 ;; pop BC so it's not volatile + + 0x4F ;; A->C + + 0xAF ;; test for output-mode (bytes-to-write > 0) + 0xB8 ;; (cp A B) + + 0x20 ;; skip input section if + :to-output ;; we're not in input mode + + + :to-be-executed - input - [0xC1 ;; pop BC so it's not volatile - ;; some condition - ;; to skip if not in input - ;; mode + ;; write mode to instruction to be executed (pun) + 0xEA + :to-be-executed-address + 0x18 ;; return + :to-beginning] + + output + [0x05 ;; DEC bytes-to-write (B) + + 0x54 ;; + 0x5D ;; HL->DE \ + ;; | + 0x79 ;; C->A | this mess is all to do + 0x12 ;; A->(DE) | 0x22 (LDI (HL), A) without + ;; | any repeating nybbles + 0x23 ;; inc HL / + + ] + + - - 0xE9 ;; jump to (HL) - 0x22 ;; A->(HL) ; inc HL - - - 0x57 ;; A->D - - 0x67 ;; A->H - 0x6F ;; A->L - - 0x47 ;; A->B - 0x4F ;; A->C - - + 0x22 ;; A->(HL) ; inc HL