From eef52193690ff271f41fbed1d960a3d249e2af5c Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Tue, 27 Mar 2018 16:06:08 +0200 Subject: [PATCH] Added samples --- samples/sample.evm | Bin 0 -> 122 bytes samples/sample.evmhex | 1 + samples/sample.wasm | Bin 0 -> 160 bytes samples/sample.wast | 48 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 samples/sample.evm create mode 100644 samples/sample.evmhex create mode 100644 samples/sample.wasm create mode 100644 samples/sample.wast diff --git a/samples/sample.evm b/samples/sample.evm new file mode 100644 index 0000000000000000000000000000000000000000..25239b2f3eae733b5efaf2e80db12d2f40854562 GIT binary patch literal 122 zcmYdDNN@;BU@)y=WWWO^urwr>i!pr{NiYvjFb#`lh)xJeU}42R`&%lp#%MeNfh!o-mPEY<3{7OHCLn_gtRBS!dH|~~&-568bPkGY;Y04uBFe)5Keu!p!uriRMc>_}5eH#2SAVTQM=jTmKN~*mhTN kdElO${aiqta^gxkYUf$WidhMdlXmz`g*C)lTVsQi4_iALQUCw| literal 0 HcmV?d00001 diff --git a/samples/sample.wast b/samples/sample.wast new file mode 100644 index 00000000..325fac1c --- /dev/null +++ b/samples/sample.wast @@ -0,0 +1,48 @@ + +(module + (import "ethereum" "useGas" (func $useGas (param i64))) + (global $cb_dest (mut i32) (i32.const 0)) + (global $sp (mut i32) (i32.const -32)) + (global $init (mut i32) (i32.const 0)) + + ;; memory related global + (global $memstart i32 (i32.const 33832)) + ;; the number of 256 words stored in memory + (global $wordCount (mut i64) (i64.const 0)) + ;; what was charged for the last memory allocation + (global $prevMemCost (mut i64) (i64.const 0)) + + ;; TODO: memory should only be 1, but can't resize right now + (memory 500) + (export "memory" (memory 0)) + + + + + (func $main + (export "main") + (local $jump_dest i32) + (set_local $jump_dest (i32.const -1)) + + (block $done + (loop $loop + + (block $0 + (if + (i32.eqz (get_global $init)) + (then + (set_global $init (i32.const 1)) + (br $0)) + (else + ;; the callback dest can never be in the first block + (if (i32.eq (get_global $cb_dest) (i32.const 0)) + (then + (unreachable) + ) + (else + ;; return callback destination and zero out $cb_dest + get_global $cb_dest + (set_global $cb_dest (i32.const 0)) + (br_table $0 ) + )))))(call $useGas (i64.const 0)) ))) +) \ No newline at end of file