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

Commit

Permalink
Merge pull request #215 from esteve/samples
Browse files Browse the repository at this point in the history
Added samples
  • Loading branch information
axic authored Mar 27, 2018
2 parents d4c8a3c + eef5219 commit 7fa0652
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
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)) )))
)

0 comments on commit 7fa0652

Please sign in to comment.