Skip to content
This repository was archived by the owner on Jan 5, 2019. It is now read-only.

Added samples #215

Merged
merged 1 commit into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added samples/sample.evm
Binary file not shown.
1 change: 1 addition & 0 deletions samples/sample.evmhex
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0x60606040526000357c010000000000000000000000000000000000000000000000000000000090048063771602F7146037576035565b005b60546004808035906020019091908035906020019091905050606A565b6040518082815260200191505060405180910390f35b6000818301905080505b9291505056
Binary file added samples/sample.wasm
Binary file not shown.
48 changes: 48 additions & 0 deletions samples/sample.wast
Original file line number Diff line number Diff line change
@@ -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)) )))
)