diff --git a/404.html b/404.html index 4eb93ce49..58b9d4c1c 100644 --- a/404.html +++ b/404.html @@ -84,7 +84,7 @@ diff --git a/appendix/index.html b/appendix/index.html index 5a00fe254..f85f499f1 100644 --- a/appendix/index.html +++ b/appendix/index.html @@ -83,7 +83,7 @@ diff --git a/appendix/optimizations.html b/appendix/optimizations.html index 8f3fcdcff..c4d5d951c 100644 --- a/appendix/optimizations.html +++ b/appendix/optimizations.html @@ -83,7 +83,7 @@ diff --git a/benchmarks/fibonacci.html b/benchmarks/fibonacci.html index f8097ee09..9f6847309 100644 --- a/benchmarks/fibonacci.html +++ b/benchmarks/fibonacci.html @@ -83,7 +83,7 @@ diff --git a/benchmarks/index.html b/benchmarks/index.html index 842cdc711..71d5d5953 100644 --- a/benchmarks/index.html +++ b/benchmarks/index.html @@ -83,7 +83,7 @@ diff --git a/cli/elko.html b/cli/elko.html index 8a013258c..c1aed04b6 100644 --- a/cli/elko.html +++ b/cli/elko.html @@ -83,7 +83,7 @@ diff --git a/cli/index.html b/cli/index.html index 33d496c0e..5861bf577 100644 --- a/cli/index.html +++ b/cli/index.html @@ -83,7 +83,7 @@ diff --git a/cli/zinkc.html b/cli/zinkc.html index 293580b28..aa10995bb 100644 --- a/cli/zinkc.html +++ b/cli/zinkc.html @@ -83,7 +83,7 @@ diff --git a/compiler/arithmetic.html b/compiler/arithmetic.html index 1c43f4a39..f94c4d0dc 100644 --- a/compiler/arithmetic.html +++ b/compiler/arithmetic.html @@ -83,7 +83,7 @@ diff --git a/compiler/calls.html b/compiler/calls.html index 689444488..c06d2bac8 100644 --- a/compiler/calls.html +++ b/compiler/calls.html @@ -83,7 +83,7 @@ diff --git a/compiler/control-flow.html b/compiler/control-flow.html index a2609a001..ca97038a8 100644 --- a/compiler/control-flow.html +++ b/compiler/control-flow.html @@ -83,7 +83,7 @@ diff --git a/compiler/index.html b/compiler/index.html index 7970a449f..98a4e31a8 100644 --- a/compiler/index.html +++ b/compiler/index.html @@ -83,7 +83,7 @@ diff --git a/compiler/locals.html b/compiler/locals.html index 6b495a130..9be7d3137 100644 --- a/compiler/locals.html +++ b/compiler/locals.html @@ -83,7 +83,7 @@ diff --git a/compiler/recursion.html b/compiler/recursion.html index e38c58af3..60258c742 100644 --- a/compiler/recursion.html +++ b/compiler/recursion.html @@ -83,7 +83,7 @@ diff --git a/contributing/architecture.html b/contributing/architecture.html index dbdaeadf9..d52b87fa7 100644 --- a/contributing/architecture.html +++ b/contributing/architecture.html @@ -83,7 +83,7 @@ diff --git a/contributing/building.html b/contributing/building.html index cf82fa3bf..234235657 100644 --- a/contributing/building.html +++ b/contributing/building.html @@ -83,7 +83,7 @@ diff --git a/contributing/index.html b/contributing/index.html index 017a3a809..c44a2cdf9 100644 --- a/contributing/index.html +++ b/contributing/index.html @@ -83,7 +83,7 @@ diff --git a/contributing/testing.html b/contributing/testing.html index 9347edd3e..a67a5f4c6 100644 --- a/contributing/testing.html +++ b/contributing/testing.html @@ -83,7 +83,7 @@ diff --git a/examples/add-two.html b/examples/add-two.html index 875a0b502..fd3888ba3 100644 --- a/examples/add-two.html +++ b/examples/add-two.html @@ -83,7 +83,7 @@ @@ -182,6 +182,23 @@

AddTwo

pub extern "C" fn addition(x: u64, y: u64) -> u64 { x + y } +

A basic addition program in zink

+
(module
+    (func (param i32) (param i32) (result i32)
+    (local.get 0)
+    (local.get 1)
+    (i32.add)
+    )
+)
+
+

Requires:

+ +
6000356020350160005260206000f3
+
@@ -191,7 +208,7 @@

AddTwo

- @@ -205,7 +222,7 @@

AddTwo

- diff --git a/examples/fibonacci.html b/examples/fibonacci.html index 1f5899513..fb5701aed 100644 --- a/examples/fibonacci.html +++ b/examples/fibonacci.html @@ -83,7 +83,7 @@ @@ -192,12 +192,49 @@

Fibonacci

recursion(n - 1) + recursion(n - 2) } } +

A recursion example, complex in bytecode

+
(module
+  (type (;0;) (func (param i32) (result i32)))
+  (func (;0;) (type 0) (param i32) (result i32)
+    local.get 0
+    call 1)
+  (func (;1;) (type 0) (param i32) (result i32)
+    (local i32)
+    local.get 0
+    i32.const 2
+    i32.ge_u
+    if  ;; label = @1
+      loop  ;; label = @2
+        local.get 0    ;; 1
+        i32.const 1    ;; 2
+        i32.sub        ;; 1
+        call 1         ;; 1
+        local.get 1    ;; 2
+        i32.add        ;; 1
+        local.set 1    ;; 0
+        local.get 0    ;; 1
+        i32.const 2    ;; 2
+        i32.sub        ;; 1
+        local.tee 0    ;; 1
+        i32.const 1    ;; 2
+        i32.gt_u       ;; 1
+        br_if 0 (;@2;) ;; 2 -> 0
+      end
+    end
+    local.get 0
+    local.get 1
+    i32.add))
+
+

A more complex implementation of locals ( params + local variables) is introduced in this example, +control flow br_if and loop are compiled as well.

+
600035586010565b60005260206000f35b906000816002600190031015603d575b8160019003586010565b8101905081600290038092506001106020575b8181019150509060040156
+