diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-05-22 14:04:36 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-06-12 13:38:05 +0200 |
| commit | 4f9a2c7a2d8464b04cc08075a7762c6d457090df (patch) | |
| tree | ae8fe229a3a5ba60d08b74299d0c1850685bda86 /src/op/memory | |
| parent | f25b015e5b668028c34974bbb22faa4105c26690 (diff) | |
| download | nanowasm-sync-4f9a2c7a2d8464b04cc08075a7762c6d457090df.tar.gz | |
WIP
Diffstat (limited to 'src/op/memory')
| -rw-r--r-- | src/op/memory/i32_load.c | 9 | ||||
| -rw-r--r-- | src/op/memory/i32_store.c | 5 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/op/memory/i32_load.c b/src/op/memory/i32_load.c index 04dbec7..ad5abe5 100644 --- a/src/op/memory/i32_load.c +++ b/src/op/memory/i32_load.c @@ -19,7 +19,7 @@ static int load(struct nw_interp *const i, const varuint32 flags, const varuint32 offset) { enum {ALIGN = 2}; - int32_t value; + int32_t value_le; if (flags != ALIGN) { @@ -28,12 +28,15 @@ static int load(struct nw_interp *const i, const varuint32 flags, i->exception = "unaligned access"; return -1; } - else if (interp_heap_load(i, offset, &value, sizeof value)) + else if (interp_heap_load(i, offset, &value_le, sizeof value_le)) { LOG("%s: interp_heap_load failed\n", __func__); return -1; } - else if (interp_stack_push(i, &value, sizeof value)) + + const int32_t value = ntohi32(value_le); + + if (interp_stack_push(i, &value, sizeof value)) { LOG("%s: interp_stack_push failed\n", __func__); return -1; diff --git a/src/op/memory/i32_store.c b/src/op/memory/i32_store.c index 212cd86..9f5351b 100644 --- a/src/op/memory/i32_store.c +++ b/src/op/memory/i32_store.c @@ -49,7 +49,10 @@ static int store(struct nw_interp *const i, const varuint32 flags, i->exception = exc; return -1; } - else if (interp_heap_store(i, offset + addr, &value, sizeof value)) + + const int32_t value_le = htoni32(value); + + if (interp_heap_store(i, offset + addr, &value_le, sizeof value_le)) { LOG("%s: interp_heap_store failed\n", __func__); return -1; |
