aboutsummaryrefslogtreecommitdiff
path: root/examples/simple-adder.bf
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-12-03 00:02:12 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-12-03 00:02:12 +0000
commit623b3acc1f8b719b15523982ff5ed04eb85b19d5 (patch)
tree5aee01714fd4bcf60971356889f1192f797c5690 /examples/simple-adder.bf
parentc2a4eb3985de412b548a713ed72ee752f4ee8e3b (diff)
downloadobf-623b3acc1f8b719b15523982ff5ed04eb85b19d5.tar.gz
obf-623b3acc1f8b719b15523982ff5ed04eb85b19d5.tar.bz2
obf-623b3acc1f8b719b15523982ff5ed04eb85b19d5.zip
Added some examples to test the interpreter
Diffstat (limited to 'examples/simple-adder.bf')
-rw-r--r--examples/simple-adder.bf20
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/simple-adder.bf b/examples/simple-adder.bf
new file mode 100644
index 0000000..3f5f2ee
--- /dev/null
+++ b/examples/simple-adder.bf
@@ -0,0 +1,20 @@
+++ Cell c0 = 2
+> +++++ Cell c1 = 5
+
+[ Start your loops with your cell pointer on the loop counter (c1 in our case)
+< + Add 1 to c0
+> - Subtract 1 from c1
+] End your loops with the cell pointer on the loop counter
+
+At this point our program has added 5 to 2 leaving 7 in c0 and 0 in c1
+but we cannot output this value to the terminal since it is not ASCII encoded
+
+To display the ASCII character "7" we must add 48 to the value 7
+We use a loop to compute 48 = 6 * 8
+
+++++ ++++ c1 = 8 and this will be our loop counter again
+[
+< +++ +++ Add 6 to c0
+> - Subtract 1 from c1
+]
+< . Print out c0 which has the value 55 which translates to "7"! \ No newline at end of file