diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/014boolean | 28 |
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 |