diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-03-26 17:14:55 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-03-26 17:14:55 -0700 |
commit | fae7033152eebfa7d860146afbfd58f1fb2e7556 (patch) | |
tree | 85ce0dcc54af11105730dc2ab2aa0bd7b5c44c71 /cpp | |
parent | bb12a2dec2900c5e578cd2b10db7806165dbedf1 (diff) | |
download | mu-fae7033152eebfa7d860146afbfd58f1fb2e7556.tar.gz |
975
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/013run | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cpp/013run b/cpp/013run index 1b37f205..ef608cb6 100644 --- a/cpp/013run +++ b/cpp/013run @@ -124,7 +124,8 @@ vector<int> read_memory(reagent x) { return result; } int base = x.value; - for (size_t offset = 0; offset < Type[x.types[0]].size; ++offset) { + size_t size = size_of(x); + for (size_t offset = 0; offset < size; ++offset) { int val = Memory[base+offset]; trace("mem") << "location " << base+offset << " is " << val; result.push_back(val); @@ -136,9 +137,9 @@ vector<int> read_memory(reagent x) { void write_memory(reagent x, vector<int> data) { if (is_dummy(x)) return; int base = x.value; - size_t size = size_of(x); - if (size != data.size()) raise << "size mismatch in storing to " << x.to_string(); - for (size_t offset = 0; offset < size; ++offset) { + if (size_of(x) != data.size()) + raise << "size mismatch in storing to " << x.to_string(); + for (size_t offset = 0; offset < data.size(); ++offset) { trace("mem") << "storing " << data[offset] << " in location " << base+offset; Memory[base+offset] = data[offset]; } |