aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor <pashev.igor@gmail.com>2010-01-19 17:54:14 +0300
committerIgor <pashev.igor@gmail.com>2010-01-19 17:54:14 +0300
commit5e88c2b8496a3f1b46b80fe64354461a0cfb74cf (patch)
tree2fadf132801c071d82d665ab0c4724696262a977
parent63802befc2e9e8dd6272f1b273fa7c99df1821ce (diff)
downloadbrainfuck-5e88c2b8496a3f1b46b80fe64354461a0cfb74cf.tar.gz
More examples
-rw-r--r--README7
-rw-r--r--brainfuck.c6
2 files changed, 9 insertions, 4 deletions
diff --git a/README b/README
index b627bfd..f7de6a6 100644
--- a/README
+++ b/README
@@ -9,7 +9,7 @@ All data cells are zeros initially
Options (defaults are in brackets):
-s num stack size (128)
-d num data size (30000)
- -t trace execution for debug
+ -t trace execution for debugging
Formats for operators '.' and ',' (output and input):
-c, -i, -u, -o, -x char, signed int, unsigned int, octal, hexadecimal
@@ -28,8 +28,11 @@ Extensions:
; - end of code (useful when reading stdin)
# - comment to the end of line (useful when reading files)
-Example:
+Examples:
echo '+++[.-]' | ./brainfuck # count down from 3 to 1
echo ',+++.;5' | ./brainfuck # shows 8
echo ',>,<[->+<]>.;4 5' | ./brainfuck # shows 4+5=9
echo 'c,u.;h' | ./brainfuck # shows 104 (ASCII code for 'h')
+ echo ', [-[->+<]>];4' | ./brainfuck -t # move data pointer by 4
+ echo ',>,< [> [->+<] < -[->+<]> ]; 3 7' | ./brainfuck -t # move '7' by 3
+
diff --git a/brainfuck.c b/brainfuck.c
index d23ae52..47bc60e 100644
--- a/brainfuck.c
+++ b/brainfuck.c
@@ -249,7 +249,7 @@ void usage(char * self)
printf("Options (defaults are in brackets):\n");
printf(" -s num stack size (%u)\n", stack_size);
printf(" -d num data size (%u)\n", data_size);
- printf(" -t trace execution for debug\n");
+ printf(" -t trace execution for debugging\n");
printf("\n");
printf("Formats for operators '.' and ',' (output and input):\n");
printf(" -c, -i, -u, -o, -x char, signed int, unsigned int, octal, hexadecimal\n");
@@ -268,11 +268,13 @@ void usage(char * self)
printf(" ; - end of code (useful when reading stdin)\n");
printf(" # - comment to the end of line (useful when reading files)\n");
printf("\n");
- printf("Example:\n");
+ printf("Examples:\n");
printf(" echo '+++[.-]' | %s # count down from 3 to 1\n", self);
printf(" echo ',+++.;5' | %s # shows 8\n", self);
printf(" echo ',>,<[->+<]>.;4 5' | %s # shows 4+5=9\n", self);
printf(" echo 'c,u.;h' | %s # shows 104 (ASCII code for 'h')\n", self);
+ printf(" echo ', [-[->+<]>];4' | %s -t # move data pointer by 4 \n", self);
+ printf(" echo ',>,< [> [->+<] < -[->+<]> ]; 3 7' | %s -t # move '7' by 3 \n\n", self);
exit(EXIT_SUCCESS);
}