diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-02-19 17:12:55 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-02-19 17:12:55 -0800 |
commit | c7c822b27aac56de1e44555c9c2366ac6bbf13f2 (patch) | |
tree | cf921bd1677aa8121f6185678bc78a7e7a74e4e1 /cpp/013arithmetic | |
parent | d7e112371c97b8d9e7b4ea4451071f8914b9b57f (diff) | |
download | mu-c7c822b27aac56de1e44555c9c2366ac6bbf13f2.tar.gz |
793
Diffstat (limited to 'cpp/013arithmetic')
-rw-r--r-- | cpp/013arithmetic | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/cpp/013arithmetic b/cpp/013arithmetic index 47d14b2c..1f12b474 100644 --- a/cpp/013arithmetic +++ b/cpp/013arithmetic @@ -6,16 +6,16 @@ Recipe_number["add"] = ADD; Next_recipe_number++; :(before "End Primitive Recipe Implementations") case ADD: { - trace("run") << "ingredient 0 is " << p->ingredients[0].name; - vector<int> arg0 = read_memory(p->ingredients[0]); + trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].name; + vector<int> arg0 = read_memory(instructions[pc].ingredients[0]); assert(arg0.size() == 1); - trace("run") << "ingredient 1 is " << p->ingredients[1].name; - vector<int> arg1 = read_memory(p->ingredients[1]); + trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name; + vector<int> arg1 = read_memory(instructions[pc].ingredients[1]); assert(arg1.size() == 1); vector<int> result; result.push_back(arg0[0] + arg1[0]); trace("run") << "product 0 is " << result[0]; - write_memory(p->products[0], result); + write_memory(instructions[pc].products[0], result); break; } @@ -50,16 +50,16 @@ Recipe_number["subtract"] = SUBTRACT; Next_recipe_number++; :(before "End Primitive Recipe Implementations") case SUBTRACT: { - trace("run") << "ingredient 0 is " << p->ingredients[0].name; - vector<int> arg0 = read_memory(p->ingredients[0]); + trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].name; + vector<int> arg0 = read_memory(instructions[pc].ingredients[0]); assert(arg0.size() == 1); - trace("run") << "ingredient 1 is " << p->ingredients[1].name; - vector<int> arg1 = read_memory(p->ingredients[1]); + trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name; + vector<int> arg1 = read_memory(instructions[pc].ingredients[1]); assert(arg1.size() == 1); vector<int> result; result.push_back(arg0[0] - arg1[0]); trace("run") << "product 0 is " << result[0]; - write_memory(p->products[0], result); + write_memory(instructions[pc].products[0], result); break; } @@ -94,17 +94,17 @@ Recipe_number["multiply"] = MULTIPLY; Next_recipe_number++; :(before "End Primitive Recipe Implementations") case MULTIPLY: { - trace("run") << "ingredient 0 is " << p->ingredients[0].name; - vector<int> arg0 = read_memory(p->ingredients[0]); + trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].name; + vector<int> arg0 = read_memory(instructions[pc].ingredients[0]); assert(arg0.size() == 1); - trace("run") << "ingredient 1 is " << p->ingredients[1].name; - vector<int> arg1 = read_memory(p->ingredients[1]); + trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name; + vector<int> arg1 = read_memory(instructions[pc].ingredients[1]); assert(arg1.size() == 1); trace("run") << "ingredient 1 is " << arg1[0]; vector<int> result; result.push_back(arg0[0] * arg1[0]); trace("run") << "product 0 is " << result[0]; - write_memory(p->products[0], result); + write_memory(instructions[pc].products[0], result); break; } @@ -139,17 +139,17 @@ Recipe_number["divide"] = DIVIDE; Next_recipe_number++; :(before "End Primitive Recipe Implementations") case DIVIDE: { - trace("run") << "ingredient 0 is " << p->ingredients[0].name; - vector<int> arg0 = read_memory(p->ingredients[0]); + trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].name; + vector<int> arg0 = read_memory(instructions[pc].ingredients[0]); assert(arg0.size() == 1); - trace("run") << "ingredient 1 is " << p->ingredients[1].name; - vector<int> arg1 = read_memory(p->ingredients[1]); + trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name; + vector<int> arg1 = read_memory(instructions[pc].ingredients[1]); assert(arg1.size() == 1); trace("run") << "ingredient 1 is " << arg1[0]; vector<int> result; result.push_back(arg0[0] / arg1[0]); trace("run") << "product 0 is " << result[0]; - write_memory(p->products[0], result); + write_memory(instructions[pc].products[0], result); break; } @@ -184,20 +184,20 @@ Recipe_number["divide_with_remainder"] = DIVIDE_WITH_REMAINDER; Next_recipe_number++; :(before "End Primitive Recipe Implementations") case DIVIDE_WITH_REMAINDER: { - trace("run") << "ingredient 0 is " << p->ingredients[0].name; - vector<int> arg0 = read_memory(p->ingredients[0]); + trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].name; + vector<int> arg0 = read_memory(instructions[pc].ingredients[0]); assert(arg0.size() == 1); - trace("run") << "ingredient 1 is " << p->ingredients[1].name; - vector<int> arg1 = read_memory(p->ingredients[1]); + trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name; + vector<int> arg1 = read_memory(instructions[pc].ingredients[1]); assert(arg1.size() == 1); vector<int> result0; result0.push_back(arg0[0] / arg1[0]); trace("run") << "product 0 is " << result0[0]; - write_memory(p->products[0], result0); + write_memory(instructions[pc].products[0], result0); vector<int> result1; result1.push_back(arg0[0] % arg1[0]); trace("run") << "product 1 is " << result1[0]; - write_memory(p->products[1], result1); + write_memory(instructions[pc].products[1], result1); break; } |