aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/example1a_blink_led_wasm/Makefile (renamed from examples/example1_blink_led/Makefile)0
-rw-r--r--examples/example1a_blink_led_wasm/instructions.wat35
l---------examples/example1b_blink_led_tclasm/Makefile1
-rw-r--r--examples/example1b_blink_led_tclasm/instructions.s.tcl (renamed from examples/example1_blink_led/instructions.s.tcl)12
4 files changed, 42 insertions, 6 deletions
diff --git a/examples/example1_blink_led/Makefile b/examples/example1a_blink_led_wasm/Makefile
index 9755f33..9755f33 100644
--- a/examples/example1_blink_led/Makefile
+++ b/examples/example1a_blink_led_wasm/Makefile
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)))
diff --git a/examples/example1b_blink_led_tclasm/Makefile b/examples/example1b_blink_led_tclasm/Makefile
new file mode 120000
index 0000000..c11f6e5
--- /dev/null
+++ b/examples/example1b_blink_led_tclasm/Makefile
@@ -0,0 +1 @@
+../example1a_blink_led_wasm/Makefile \ No newline at end of file
diff --git a/examples/example1_blink_led/instructions.s.tcl b/examples/example1b_blink_led_tclasm/instructions.s.tcl
index 13c51e2..3a69c7b 100644
--- a/examples/example1_blink_led/instructions.s.tcl
+++ b/examples/example1b_blink_led_tclasm/instructions.s.tcl
@@ -11,9 +11,9 @@ set_sp h100000
# this will translate to 2 16-bit instructions
loadwzx h1C0008
-## loop until timer exceeds 500
+## loop until timer exceeds 1500
# this will translate to 2 16-bit instructions
-const 500
+const 1500
# this will translate to 1 16-bit instruction
lt
# this will translate to 1 16-bit instruction
@@ -30,9 +30,9 @@ storew h1C0006
# this will translate to 2 16-bit instructions
loadwzx h1C0008
-## loop until timer exceeds 1000
+## loop until timer exceeds 3000
# this will translate to 2 16-bit instructions
-const 1000
+const 3000
# this will translate to 1 16-bit instruction
lt
# this will translate to 1 16-bit instruction
@@ -48,8 +48,8 @@ storew h1C0006
## this is address 40 we later jump to
loadwzx h1C0008
-## loop until timer exceeds 1500
-const 1500
+## loop until timer exceeds 4500
+const 4500
lt
cond_jump 40