4917 microprocess is an 4-bit cpu designed for University of New South Wales (UNSW) COMP1917.
This emulator is written by both clojure and clojurescript, I use the Clojure 1.7 new feature Reader Conditionals to reduce code complexity, you can build and running this emulator on JVM or Node.js.
For those interesting how to write 4917 emulator, I write a tutorial here:
使用 Clojure 打造 4917 微處理器的模擬器 (Chinese)
I will update the tutorial in English later.
To execute this emulator on JVM, you can use lein
lein run -- examples/countdown.bin
or compile this application to jar and execute
lein uberjar java -jar target/emulator-4917-0.1.0-SNAPSHOT-standalone.jar examples/countdown.bin
To execute on node.js, one muse compile clojurescript to javascript first
lein cljsbuild once
This project use none
optimization by default, you can use run.js
to execute
the application
node run.js examples/countdown.bin
or you also can modify the project.clj
for advanced optimization
:optimizations :advanced
:pretty-print false
rebuild to javascript again and start application by node
lein cljsbuild once
node target/emulator-4917.js examples/countdown.bin
There are four examples in examples folder: (in binary format)
file name | desription |
---|---|
countdown.bin | countdown from 5 to 1 |
countup.bin | countup from 0 |
bell.bin | ring bell three times |
calculate_6+3+1.bin | calculate 6 + 3 + 1 |
Copyright © 2015 Yen-Chin, Lee <coldnew.tw@gmail.com>
Distributed under the Eclipse Public License either version 1.0 or any later version.