Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Changed the SP to start at 0. Fixes #2

  • Loading branch information...
commit 5dc860033630f75e51444d5a63b6ddd3333c44ed 1 parent eb17b6c
Josh Comer jjcomer authored
2  src/clj_dcpu16/core.clj
@@ -262,6 +262,6 @@
262 262 (change-memory :pc pc)
263 263 (run!))
264 264 ([]
265   - (change-memory :sp 0xFFFF)
  265 + (change-memory :sp 0x0000)
266 266 (while true
267 267 (execute (follow-memory :pc)))))
8 test/clj_dcpu16/core_test.clj
@@ -3,7 +3,7 @@
3 3 clj-dcpu16.core))
4 4
5 5 (defn- clear-memory []
6   - (dosync (alter memory (fn [old] {:pc 0x0000 :sp 0xFFFF}))))
  6 + (dosync (alter memory (fn [old] {:pc 0x0000 :sp 0x0000}))))
7 7
8 8 (defn- force-memory [address value]
9 9 (dosync (alter memory #(assoc % address value))))
@@ -55,10 +55,10 @@
55 55 (testing "Push"
56 56 (clear-memory)
57 57 (change-memory :push 0x1234)
58   - (is (= 0xFFFE (get-memory :sp)))
  58 + (is (= 0xFFFF (get-memory :sp)))
59 59 (is (= 0x1234 (get-memory :peek)))
60 60 (change-memory :push 0x4321)
61   - (is (= 0xFFFD (get-memory :sp)))
  61 + (is (= 0xFFFE (get-memory :sp)))
62 62 (is (= 0x4321 (get-memory :peek)))))
63 63 (testing "Inc memory"
64 64 (clear-memory)
@@ -111,10 +111,12 @@
111 111 (testing "Peek"
112 112 (clear-memory)
113 113 (force-memory 0xFFFF 0x1234)
  114 + (force-memory :sp 0xFFFF)
114 115 (is (= [0x1234 0xFFFF] (get-address-and-value 0x19))))
115 116 (testing "Push"
116 117 (clear-memory)
117 118 (force-memory 0xFFFF 0x1234)
  119 + (force-memory :sp 0xFFFF)
118 120 (is (= [0x1234 :push] (get-address-and-value 0x1A))))
119 121 (testing "De-reference next word"
120 122 (clear-memory)

0 comments on commit 5dc8600

Please sign in to comment.
Something went wrong with that request. Please try again.