about summary refs log tree commit diff stats
path: root/cpp/023jump
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-24 20:07:17 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-24 20:16:21 -0700
commitdcfca05e08744270b3145f7906c5cd46485a4b52 (patch)
tree673e8715688bdc3990bbfe9077158e764690ec01 /cpp/023jump
parent69e14325e3eaa3722766bb9706d7da5862b6ea26 (diff)
downloadmu-dcfca05e08744270b3145f7906c5cd46485a4b52.tar.gz
1171
Chip away at eliminating that 'pc' reference by first throwing out the
most common expression that uses it: instructions[pc].
Diffstat (limited to 'cpp/023jump')
-rw-r--r--cpp/023jump16
1 files changed, 8 insertions, 8 deletions
diff --git a/cpp/023jump b/cpp/023jump
index 2835e040..d4dd6094 100644
--- a/cpp/023jump
+++ b/cpp/023jump
@@ -6,8 +6,8 @@ JUMP,
 Recipe_number["jump"] = JUMP;
 :(before "End Primitive Recipe Implementations")
 case JUMP: {
-  trace("run") << "ingredient 0 is " << instructions[pc].ingredients[0].value;
-  pc += instructions[pc].ingredients[0].value;
+  trace("run") << "ingredient 0 is " << current_instruction().ingredients[0].value;
+  pc += current_instruction().ingredients[0].value;
   trace("run") << "jumping to instruction " << pc+1;
   break;
 }
@@ -39,15 +39,15 @@ JUMP_IF,
 Recipe_number["jump-if"] = JUMP_IF;
 :(before "End Primitive Recipe Implementations")
 case JUMP_IF: {
-  vector<int> arg0 = read_memory(instructions[pc].ingredients[0]);
+  vector<int> arg0 = read_memory(current_instruction().ingredients[0]);
   assert(arg0.size() == 1);
   trace("run") << "ingredient 0 is " << arg0[0];
   if (!arg0[0]) {
     trace("run") << "jump-if fell through";
     break;
   }
-  trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name;
-  pc += instructions[pc].ingredients[1].value;
+  trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name;
+  pc += current_instruction().ingredients[1].value;
   trace("run") << "jumping to instruction " << pc+1;
   break;
 }
@@ -79,15 +79,15 @@ JUMP_UNLESS,
 Recipe_number["jump-unless"] = JUMP_UNLESS;
 :(before "End Primitive Recipe Implementations")
 case JUMP_UNLESS: {
-  vector<int> arg0 = read_memory(instructions[pc].ingredients[0]);
+  vector<int> arg0 = read_memory(current_instruction().ingredients[0]);
   assert(arg0.size() == 1);
   trace("run") << "ingredient 0 is " << arg0[0];
   if (arg0[0]) {
     trace("run") << "jump-unless fell through";
     break;
   }
-  trace("run") << "ingredient 1 is " << instructions[pc].ingredients[1].name;
-  pc += instructions[pc].ingredients[1].value;
+  trace("run") << "ingredient 1 is " << current_instruction().ingredients[1].name;
+  pc += current_instruction().ingredients[1].value;
   trace("run") << "jumping to instruction " << pc+1;
   break;
 }