From d7e112371c97b8d9e7b4ea4451071f8914b9b57f Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 19 Feb 2015 17:02:20 -0800 Subject: 792 --- cpp/014boolean | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'cpp/014boolean') 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 arg0 = read_memory(p->ingredients[0]); + assert(arg0.size() == 1); + vector 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 -- cgit 1.4.1-2-gfad0