aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/while.sil19
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/while.sil b/examples/while.sil
new file mode 100644
index 0000000..2b531d6
--- /dev/null
+++ b/examples/while.sil
@@ -0,0 +1,19 @@
+Int print(Int n) {
+ |~ push_a 0
+ |~.d 1 0
+ |~ jsr _print_graph
+ |~.o 0 0
+ return n;
+}
+
+Int loop(Int start, Int end) {
+ while (!(start == end)) {
+ start := print(start);
+ start := start + 1;
+ }
+ return start;
+}
+
+Int main() {
+ return loop(1, 5);
+}