This repository has been archived by the owner on Jan 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #215 from esteve/samples
Added samples
- Loading branch information
Showing
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0x60606040526000357c010000000000000000000000000000000000000000000000000000000090048063771602F7146037576035565b005b60546004808035906020019091908035906020019091905050606A565b6040518082815260200191505060405180910390f35b6000818301905080505b9291505056 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) ))) | ||
) |