diff clojure/com/aurellem/gb/rlm_assembly.clj @ 402:eee219d1a259

all tests passed.
author Robert McIntyre <rlm@mit.edu>
date Fri, 13 Apr 2012 09:47:34 -0500
parents 0262094d0914
children ea37e98e188e
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/rlm_assembly.clj	Fri Apr 13 09:24:02 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/rlm_assembly.clj	Fri Apr 13 09:47:34 2012 -0500
     1.3 @@ -274,8 +274,9 @@
     1.4          {:output-start []
     1.5           :to-output
     1.6           (->signed-8-bit
     1.7 -          (- (symbol-index :output-start program**)
     1.8 -             (symbol-index :to-output program**)))}
     1.9 +          (dec
    1.10 +           (- (symbol-index :output-start program**)
    1.11 +              (symbol-index :to-output program**))))}
    1.12  
    1.13          program*
    1.14          (flatten (replace resolve-internal-jumps program**))
    1.15 @@ -317,7 +318,7 @@
    1.16    (letfn [(test-H [state n]
    1.17              (let [after
    1.18                    (-> state
    1.19 -                      (step (buttons set-H))
    1.20 +                      (step (buttons set-H-mode))
    1.21                        (step (buttons n))
    1.22                        (step []))]
    1.23                ;;(println "desired H =" n "actual =" (H after))
    1.24 @@ -338,10 +339,10 @@
    1.25              (step [])           ; make sure it can handle blanks
    1.26              (step [])           ; at the beginning.
    1.27              (step [])                      
    1.28 -            (step (buttons set-H))     ; select set-H
    1.29 +            (step (buttons set-H-mode))     ; select set-H
    1.30              (step (buttons target-high))
    1.31              (step [])
    1.32 -            (step (buttons set-L))
    1.33 +            (step (buttons set-L-mode))
    1.34              (step (buttons target-low))
    1.35              (step [])
    1.36              (step (buttons write-mode))
    1.37 @@ -355,24 +356,33 @@
    1.38              (step []))]
    1.39              (println "before :" (get-mem-region before))
    1.40              (println "after  :" (get-mem-region after))
    1.41 -            ;;(assert (= assembly (take 4 (get-mem-region after))))
    1.42 +            (assert (= assembly (take 4 (get-mem-region after))))
    1.43      after))
    1.44  
    1.45 -(defn test-jump-mode []
    1.46 +(defn test-jump []
    1.47    (let [target-address 0xC00F
    1.48          [target-high target-low] (disect-bytes-2 target-address)
    1.49          post-jump
    1.50 -        (-> (test-write-bytes-mode)
    1.51 +        (-> (test-write-bytes)
    1.52 +            (step (buttons set-H-mode))     ; select set-H
    1.53 +            (step (buttons target-high))
    1.54              (step [])
    1.55 +            (step (buttons set-L-mode))
    1.56 +            (step (buttons target-low))
    1.57              (step [])
    1.58 -            (step [])
    1.59 -            (step (buttons 0xFF))           ; Select JUMP mode.
    1.60 -            (step (buttons target-high))
    1.61 -            (step (buttons target-low)))
    1.62 +            (step (buttons jump-mode)))           ; Select JUMP mode.
    1.63          program-counters
    1.64          (capture-program-counter 
    1.65           post-jump
    1.66           10000)]
    1.67 -    (println program-counters)
    1.68      (assert (contains? (set program-counters) target-address))
    1.69 +    (println "jump test passed")
    1.70      post-jump))
    1.71 +
    1.72 +
    1.73 +(defn run-all-tests []
    1.74 +  (test-frame-metronome)
    1.75 +  (test-read-user-input)
    1.76 +  (test-set-H)
    1.77 +  (test-write-bytes)
    1.78 +  (test-jump))