about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-02-19 17:02:20 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-02-19 17:02:20 -0800
commitd7e112371c97b8d9e7b4ea4451071f8914b9b57f (patch)
tree7aebbf6dc45e853ea077db7b1721352b19bc85fe
parente2d57bfec90a578d6545dff0059cc6050d21c573 (diff)
downloadmu-d7e112371c97b8d9e7b4ea4451071f8914b9b57f.tar.gz
792
-rw-r--r--cpp/014boolean28
1 files changed, 28 insertions, 0 deletions
diff --git a/cpp/014boolean b/cpp/014boolean
index 66499b7f..87ea6e2f 100644
--- a/cpp/014boolean
+++ b/cpp/014boolean
@@ -66,3 +66,31 @@ recipe main [
 +mem: location 2 is 0
 +run: product 0 is 1
 +mem: storing in location 3
+
+:(before "End Globals")
+const int NOT = 9;
+:(before "End Primitive Recipe Numbers")
+Recipe_number["not"] = NOT;
+Next_recipe_number++;
+:(before "End Primitive Recipe Implementations")
+case NOT: {
+  trace("run") << "ingredient 0 is " << p->ingredients[0].name;
+  vector<int> arg0 = read_memory(p->ingredients[0]);
+  assert(arg0.size() == 1);
+  vector<int> result;
+  result.push_back(!arg0[0]);
+  trace("run") << "product 0 is " << result[0];
+  write_memory(p->products[0], result);
+  break;
+}
+
+:(scenario "not")
+recipe main [
+  1:integer <- copy 1:literal
+  2:integer <- not 1:integer
+]
++run: instruction 1
++run: ingredient 0 is 1
++mem: location 1 is 1
++run: product 0 is 0
++mem: storing in location 2