diff options
author | Wojciech Kosior <kwojtus@protonmail.com> | 2020-12-28 11:09:30 +0100 |
---|---|---|
committer | Wojciech Kosior <kwojtus@protonmail.com> | 2020-12-28 11:09:30 +0100 |
commit | ec9a0f72c6b7d74c9a7e2d4eaef44e26037eaca2 (patch) | |
tree | b6971abb7d5233e0b4b5c24c1983429ce3d49f30 /examples/example1a_blink_led_wasm/instructions.wat | |
parent | fac2f26447a0789a6142a690cefc7a3713f446bf (diff) | |
download | AGH-engineering-thesis-ec9a0f72c6b7d74c9a7e2d4eaef44e26037eaca2.tar.gz AGH-engineering-thesis-ec9a0f72c6b7d74c9a7e2d4eaef44e26037eaca2.zip |
also add a wasm version of example1 for comparison
Diffstat (limited to 'examples/example1a_blink_led_wasm/instructions.wat')
-rw-r--r-- | examples/example1a_blink_led_wasm/instructions.wat | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/examples/example1a_blink_led_wasm/instructions.wat b/examples/example1a_blink_led_wasm/instructions.wat new file mode 100644 index 0000000..f231c13 --- /dev/null +++ b/examples/example1a_blink_led_wasm/instructions.wat @@ -0,0 +1,35 @@ +;; Relevant addresses are lower half of timer reg (0x1BFC08) +;; and led2 reg (0x1BFC06). + +(module + (memory 0 2) + (func $main + ;; loop until timer exceeds 1500 + (loop $again + (br_if $again (i32.lt_u + (i32.load16_u offset=0x0 align=1 + (i32.const 0x1BFC08)) + (i32.const 1500)))) + + ;; now, light led2 + (i32.store16 offset=0x0 align=1 + (i32.const 0x1BFC06) (i32.const 0x1)) + + ;; loop until timer exceeds 3000 + (loop $again + (br_if $again (i32.lt_u + (i32.load16_u offset=0x0 align=1 + (i32.const 0x1BFC08)) + (i32.const 3000)))) + + ;; now, switch led2 off + (i32.store16 offset=0x0 align=1 + (i32.const 0x1BFC06) (i32.const 0x0)) + + ;; loop until timer exceeds 4500 + (loop $again + (br_if $again (i32.lt_u + (i32.load16_u offset=0x0 align=1 + (i32.const 0x1BFC08)) + (i32.const 4500))))) + (export "main" (func $main))) |