summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <hallo@tomsmeding.nl>2015-08-22 09:58:20 +0200
committertomsmeding <hallo@tomsmeding.nl>2015-08-22 10:00:28 +0200
commit37173a7008807f133c92d64109b079ec209a34a2 (patch)
tree576bba58f92787eb8771bd3d0d1ab40aa292f8f4
parent9ff0f95e1863b299bcf22da175cf7cbcf9a1d23a (diff)
Better testing material for bf.prn
-rw-r--r--fibonacci.bf9
-rw-r--r--kerstboom.bf94
-rw-r--r--test.bf3
3 files changed, 106 insertions, 0 deletions
diff --git a/fibonacci.bf b/fibonacci.bf
new file mode 100644
index 0000000..1b61292
--- /dev/null
+++ b/fibonacci.bf
@@ -0,0 +1,9 @@
+>++++++++++>+>+[
+ [+++++[>++++++++<-]>.<++++++[>--------<-]+<<<]>.>>[
+ [-]<[>+<-]>>[<<+>+>-]<[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-
+ [>+<-[>+<-[>+<-[>[-]>+>+<<<-[>+<-]]]]]]]]]]]+>>>
+ ]<<<
+]
+This program doesn't terminate; you will have to kill it.
+Daniel B Cristofani (cristofdathevanetdotcom)
+http://www.hevanet.com/cristofd/brainfuck/ \ No newline at end of file
diff --git a/kerstboom.bf b/kerstboom.bf
new file mode 100644
index 0000000..1db1e22
--- /dev/null
+++ b/kerstboom.bf
@@ -0,0 +1,94 @@
+Read in two digit number:
+0 1 2 3 4
+N0 N N0cp 10 N1
+
+,------------------------------------------------[>+>+<<-]>>[<<+>>-]>>,+[-<<<[-]>>>------------------------------------------------<++++++++++ [<<<[->+>+<<]>>[-<<+>>]>-] >[-<<<+>>>] ]<<<<
+#
+Now at 0
+
+[-] (Clear N0)
+>[<+>-]<
+
+
+Layout now: N in 0
+
+
+Place 'minus' in 1:
+>+++++++++++++++++++++++++++++++++++++++++++++<
+
+Place 'star' in 2:
+>>++++++++++++++++++++++++++++++++++++++++++<<
+
+
+Set line counter in 7:
+>>>>>>>+<<<<<<<
+
+Move N from 0 to 9 and 10:
+[>>>>>>>>>+>+<<<<<<<<<<-]
+Move N from 9 to 0 (leaving N in 10):
+>>>>>>>>>[<<<<<<<<<+>>>>>>>>>-]<<<<<<<<<
+
+Loop on (decreasing) N in 10:
+>>>>>>>>>>[<<<<<<<<<<
+
+
+
+ Move decreasing N from 10 to 3 4 and 5:
+ >>>>>>>>>>[<<<<<+<+<+>>>>>>>-]<<<<<<<<<<
+ Move N from 5 to 10:
+ >>>>>[>>>>>+<<<<<-]<<<<<
+
+ Set 3 and 4 to decreasing N minus 1:
+ >>>->-<<<<
+
+ Print 'minus' (in 1) times in 3 (which is N minus 1) while zeroing 3:
+ >>>[<<.>>-]<<<
+
+
+ Move line counter from 7 to 8 and 9:
+ >>>>>>>[>+>+<<-]<<<<<<<
+
+ Add line counter from 9 onto 7 and 8:
+ >>>>>>>>>[<+<+>>-]<<<<<<<<<
+
+ Now 7 holds line counter and 8 holds 2*line counter
+
+ Subtract 1 from 8 to let it hold 2*line counter minus 1:
+ >>>>>>>>-<<<<<<<<
+
+ Print 'star' (in 2) times in 8 (which is 2*line counter minus 1) while zeroing 8:
+ >>>>>>>>[<<<<<<.>>>>>>-]<<<<<<<<
+
+ Print 'minus' (in 1) times in 4 (which is N minus 1) while zeroing 4:
+ >>>>[<<<.>>>-]<<<<
+
+
+ Add 1 to line counter (in 7):
+ >>>>>>>+<<<<<<<
+
+ Subtract 1 from decreasing N in 10:
+ >>>>>>>>>>-<<<<<<<<<<
+
+ >>>++++++++++.[-]<<<
+
+
+
+Loop on (decreasing) N in 10
+>>>>>>>>>>]<<<<<<<<<<
+
+Move N from 0 to 3 and 4:
+[>>>+>+<<<<-]
+
+Subtract 1 from 3 and 4 to let them contain N minus 1:
+>>>->-<<<<
+
+Print 'minus' (in 1) times in 3 (which is N minus 1) while zeroing 3:
+>>>[<<.>>-]<<<
+
+Print 'star' (in 2) one time:
+>>.<<
+
+Print 'minus' (in 1) times in 4 (which is N minus 1) while zeroing 4:
+>>>>[<<<.>>>-]<<<<
+
+++++++++++.
diff --git a/test.bf b/test.bf
index cb6719f..4a1dd26 100644
--- a/test.bf
+++ b/test.bf
@@ -1 +1,4 @@
++++++++++[>++++++++++++<-]>----.<+++[>-----<-]>.<++[>+++++++<-]>.+.<++++++++++.
+[-]>[-]<
++++++++++++>+++++++
+<#[->[->+>+<<]>>[-<<+>>]<<<#]