diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-02-19 17:47:20 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-02-19 17:47:20 -0800 |
commit | 8039a98d3b4b978a4aa2d8486c35596165981c3d (patch) | |
tree | 6d55bf74cbdbdfa29ba2a8d05b4699fef86de26a /test/wasm_backend/unaligned.cpp | |
parent | c2a7d79c3a44c8064f5e5099e7b14a12423b0d77 (diff) | |
parent | 5fa252b63c29121ea4e240f5ccccb32f0a7327c8 (diff) | |
download | binaryen-8039a98d3b4b978a4aa2d8486c35596165981c3d.tar.gz binaryen-8039a98d3b4b978a4aa2d8486c35596165981c3d.tar.bz2 binaryen-8039a98d3b4b978a4aa2d8486c35596165981c3d.zip |
Merge pull request #203 from WebAssembly/wasm.js-improvements
Wasm.js improvements
Diffstat (limited to 'test/wasm_backend/unaligned.cpp')
-rw-r--r-- | test/wasm_backend/unaligned.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/test/wasm_backend/unaligned.cpp b/test/wasm_backend/unaligned.cpp new file mode 100644 index 000000000..75f8b419b --- /dev/null +++ b/test/wasm_backend/unaligned.cpp @@ -0,0 +1,70 @@ +#include <stdint.h> +#include <emscripten.h> + +void print(int v) { + int *x = (int*)8; + *x = v; + EM_ASM({ + Module.print("print: " + HEAP32[8>>2]); + }); +} + +char buffer[8]; + +int main() { + { + volatile int16_t* x; + x = (int16_t*)&buffer[0]; + *x = 0x1234; + print(*x); + x = (int16_t*)&buffer[1]; + *x = 0x2345; + print(*x); + } + { + volatile int32_t* x; + x = (int32_t*)&buffer[0]; + *x = 0x12345678; + print(*x); + x = (int32_t*)&buffer[1]; + *x = 0x23456789; + print(*x); + x = (int32_t*)&buffer[2]; + *x = 0x3456789a; + print(*x); + x = (int32_t*)&buffer[3]; + *x = 0x456789ab; + print(*x); + } + { + volatile float* x; + x = (float*)&buffer[0]; + *x = -0x12345678; + print(*x); + x = (float*)&buffer[1]; + *x = -0x12345678; + print(*x); + x = (float*)&buffer[2]; + *x = -0x12345678; + print(*x); + x = (float*)&buffer[3]; + *x = -0x12345678; + print(*x); + } + { + volatile double* x; + x = (double*)&buffer[0]; + *x = -1; + print(*x); + x = (double*)&buffer[1]; + *x = -2; + print(*x); + x = (double*)&buffer[2]; + *x = -3; + print(*x); + x = (double*)&buffer[3]; + *x = -4; + print(*x); + } +} + |