diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/.traces/store_indirect | 13 | ||||
-rw-r--r-- | cpp/018address | 11 |
2 files changed, 24 insertions, 0 deletions
diff --git a/cpp/.traces/store_indirect b/cpp/.traces/store_indirect new file mode 100644 index 00000000..259685d1 --- /dev/null +++ b/cpp/.traces/store_indirect @@ -0,0 +1,13 @@ +parse/0: instruction: 1 +parse/0: ingredient: {name: "2", type: 0} +parse/0: product: {name: "1", type: 2-1} +parse/0: instruction: 1 +parse/0: ingredient: {name: "34", type: 0} +parse/0: product: {name: "1", type: 2-1, property: deref:} +run/0: instruction 0 +run/0: ingredient 0 is 2 +mem/0: storing in location 1 +run/0: instruction 1 +run/0: ingredient 0 is 34 +mem/0: location 1 is 2 +mem/0: storing in location 2 diff --git a/cpp/018address b/cpp/018address index 4a5bcd51..33f62fc9 100644 --- a/cpp/018address +++ b/cpp/018address @@ -28,8 +28,19 @@ vector<int> read_memory(reagent x) { return result; } +:(scenario "store_indirect") +# similarly, write to addresses pointing at other locations using the 'deref' property +recipe main [ + 1:address:integer <- copy 2:literal + 1:address:integer/deref <- copy 34:literal +] ++run: instruction 1 ++mem: location 1 is 2 ++mem: storing in location 2 + :(replace{} "void write_memory(reagent x, vector<int> data)") void write_memory(reagent x, vector<int> data) { + x = canonize(x); int base = to_int(x.name); size_t size = size_of(x.types[0]); if (size != data.size()) raise << "size mismatch in storing to " << x.to_string(); |