about summary refs log tree commit diff stats
path: root/cpp
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-02-22 00:44:30 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-02-22 00:44:30 -0800
commit79f4349c785a644ed9494804495cb31a6d15bbc6 (patch)
treeac402980e71b069dbc56066a8667930c69c8d161 /cpp
parentde63f02eac2bfc14b1fa9ee979f03eeeb5f35250 (diff)
downloadmu-79f4349c785a644ed9494804495cb31a6d15bbc6.tar.gz
820 - bugfix in get-address
Diffstat (limited to 'cpp')
-rw-r--r--cpp/017record5
-rw-r--r--cpp/018address5
2 files changed, 8 insertions, 2 deletions
diff --git a/cpp/017record b/cpp/017record
index 89516672..42fda587 100644
--- a/cpp/017record
+++ b/cpp/017record
@@ -116,7 +116,10 @@ case GET_ADDRESS: {
   assert(instructions[pc].ingredients[1].types.size() == 1);
   assert(instructions[pc].ingredients[1].types[0] == 0);  // must be literal
   size_t offset = to_int(instructions[pc].ingredients[1].name);
-  int src = base_address+offset;
+  int src = base_address;
+  for (size_t i = 0; i < offset; ++i) {
+    src += size_of(reagent(Type[base_type].elements[i][0]));
+  }
   trace("run") << "address to copy is " << src;
   vector<int> result;
   result.push_back(src);
diff --git a/cpp/018address b/cpp/018address
index 91954ec8..19650e84 100644
--- a/cpp/018address
+++ b/cpp/018address
@@ -161,7 +161,10 @@ case GET_ADDRESS: {
   assert(instructions[pc].ingredients[1].types.size() == 1);
   assert(instructions[pc].ingredients[1].types[0] == 0);  // must be literal
   size_t offset = to_int(instructions[pc].ingredients[1].name);
-  int src = base_address+offset;
+  int src = base_address;
+  for (size_t i = 0; i < offset; ++i) {
+    src += size_of(reagent(Type[base_type].elements[i][0]));
+  }
   trace("run") << "address to copy is " << src;
   vector<int> result;
   result.push_back(src);