Created
May 29, 2009 06:25
-
-
Save durka/119813 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; First example: | |
Clojure=> (subleq 3 4 [5 8 12 0 0 42 0 0 144 1 2 3 4 5 6 7] {:ip 0}) ; here x = 42 and y = 144 | |
[[5 8 12 0 0 42 0 0 102 1 2 3 4 5 6 7] {:out false, :in false, :ip 3}] | |
; Mem[A] has been subtracted from Mem[B], but Mem[B] is 102 so we do not jump to C | |
Clojure=> (subleq 3 4 [5 8 12 0 0 144 0 0 42 1 2 3 4 5 6 7] {:ip 0}) ; now switch Mem[A] and Mem[B] | |
[[5 8 12 0 0 144 0 0 -102 1 2 3 4 5 6 7] {:out false, :in false, :ip 12}] | |
;; Second example, with a negative operand: | |
Clojure=> (subleq 3 4 [5 8 -12 0 0 42 0 0 144 1 2 3 14 5 6 7] {:ip 0}) | |
[[5 8 -12 0 0 42 0 0 102 1 2 3 14 5 6 7] {:out false, :in false, :ip 3}] | |
Clojure=> (subleq 3 4 [5 8 -12 0 0 144 0 0 42 1 2 3 14 5 6 7] {:ip 0}) | |
[[5 8 -12 0 0 144 0 0 -102 1 2 3 14 5 6 7] {:out false, :in false, :ip 14}] | |
; Note that the program jumps to address 14 (which happens to have a 6 in it), which comes from cell 12, named by C |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment