changeset 398:0591dcddf831

fixed bug where variables would be overwritten.
author Robert McIntyre <rlm@mit.edu>
date Fri, 13 Apr 2012 05:28:17 -0500
parents 9b0d79cad624
children ddb3c6299619
files clojure/com/aurellem/gb/rlm_assembly.clj
diffstat 1 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/rlm_assembly.clj	Fri Apr 13 04:56:01 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/rlm_assembly.clj	Fri Apr 13 05:28:17 2012 -0500
     1.3 @@ -208,7 +208,7 @@
     1.4                           (count (read-user-input)))
     1.5  
     1.6          init
     1.7 -        [0xAF 0x5F 0x57 0x47] ;; 0->A; 0->E; 0->D; 0->B
     1.8 +        [0xAF 0x4F 0x57 0x47] ;; 0->A; 0->C; 0->D; 0->B
     1.9  
    1.10          input
    1.11          [0xC1  ;; pop BC so it's not volatile
    1.12 @@ -217,15 +217,24 @@
    1.13           0xAF  ;; test for output-mode (bytes-to-write > 0)
    1.14           0x00  ;; (cp A B)
    1.15           0x7B  ;; E->A
    1.16 -         
    1.17           0x20  ;; skip input section if
    1.18           :to-output ;; we're not in input mode 
    1.19 -                  
    1.20 +       
    1.21           :to-be-executed
    1.22  
    1.23           ;; write mode to instruction-to-be-executed (pun)
    1.24           0xEA
    1.25           :to-be-executed-address
    1.26 +
    1.27 +         0x0C ;; inc C
    1.28 +         0xCB
    1.29 +         0x41 ;; test bit 0 of C
    1.30 +         0x20 ;; if (0 == (C % 2))
    1.31 +         0x04
    1.32 +         0xAF ;; put a no op (0x00) in to-be-executed
    1.33 +         0xEA
    1.34 +         :to-be-executed-address
    1.35 +         
    1.36           0x18           ;; return
    1.37           :to-beginning-1]
    1.38          
    1.39 @@ -243,9 +252,7 @@
    1.40          ;;  0x05 ;; DEC bytes-to-write (B)
    1.41          ;;  0x20 ;; if there are no more bytes to write,
    1.42          ;;  0x04
    1.43 -        ;;  0xAF ;; put a no op (0x00) in to-be-executed
    1.44 -        ;;  0xEA
    1.45 -        ;;  :to-be-executed-address
    1.46 +        ;; 
    1.47                    
    1.48          ;;  0x18
    1.49          ;;  :to-beginning-2]
    1.50 @@ -328,6 +335,7 @@
    1.51    (let [after
    1.52          (-> (bootstrap-base)
    1.53              (step [])
    1.54 +            (step [])
    1.55              (step (buttons 0x67))
    1.56              (step (buttons n))
    1.57              )]