NAME
baffle - An extension of brainfuck language
SYNOPSIS
baffle [-f, --file <file> ] [-i, --input <file> ] [-o, --output <file> ] [-t, --type <type> ] [-d, --debug ] [-h, --help ] [-v, --version ]
DESCRIPTION
baffle Is an extension to BF language (https://esolangs.org/wiki/brain‐
fuck), which itself in turn is a extension of Turing machine. baffle
extends Bf by adding a stack, support for procedures, adding more
arithmetic instructions, and a register. baffle can run original BF
programs, and while it's not the fastest implementation of BF, but it's
written in such a way that makes it easier to replace the instruction
set, and to write similar languages.
Every cell is a single byte, and the tape wraps.
Code size is set to be maximum of 8192 bytes.
Tape size is set to be 16384 bytes.
Stack size is 2048, and procedure stack size is 1024 bytes.
INSTRUCTIONS
baffle adds a register (R) with a default value of 1, which makes it
run plain BF instructions as long as the register is set to 1. Carry
flag is actualy a byte, which can be used to impelement multi-byte mul‐
tiplication.
Here are the instructions:
BF insturctions:
+ : current_cell = current_cell + R
- : current_cell = current_cell - R
> : current_cell_ptr = current_cell_ptr + 1
< : current_cell_ptr = current_cell_ptr - 1
[ : if current_cell == 0 go down to ]
] : if current_cell != 0 go up to [
, : read current_cell
= : R = current_cell
T : Back up the current_cell_ptr
G : Restore the current_cell_ptr
Z : current_cell_ptr = 0 (Rewind)
* : current_cell *= R
/ : current_cell /= R
% : current_cell %= R
^ : current_cell ^= R
& : current_cell &= R
| : current_cell |= R
~ : One's complement of current_cell
L : current_cell <<= 1
R : current_cell >>= 1
! : R = Carry flag
$ : R = Sign flag
\ : clear flags
X : Swap current_cell and R
? : Skip over the next instruction if current_cell is zero
K : label
) : Jump to the label in lower address
( : go to the label in the higher address
: : push current_cell
; : pop current_cell
# : comment (ignore the rest of the line)
" : Put following characters into the tape
V : Print current_cell as a signed number
U : Print current_cell as an unsigned number
H : Print current_cell as HEX
I : Read a byte (a number betwen 0 to 255) and put it in cur‐
rent_cell
P : Print null terminating string starting from current_cell_ptr
S : Read string and insert it cells starting at current_cell_ptr
0-9,A-F : Store HEX number into current_cell
{ : Beginning of a procedure
} : Return from the procedure
@ : Call the Nth procedure where N is current_cell
Q : Quit
axbf is a subset of baffle instructions were symbols only contain alpha
numeric characters.
A : +
S : -
R : >
L : <
W : [
B : ]
P : .
I : ,
E : =
T : T
G : G
Z : Z
M : *
D : /
Y : ?
K : @
F : {
J : }
C : !
N : $
X : X
V : :
U : ;
H : H
Q : Q
0-9 : Store decimal number (0-255) in current_cell
options
-f, --file <file>
File containing the code, if missing STDIN is used
-i, --input <file>
Input file, if missing STDIN is used
-o, --output <file>
Output file, if missing STDOUT is used
-t, --type <type>
Code type is either 'baffle', or 'axbf' default is 'baffle'
-d, --debug
Debug mode
-h, --help
Displays this
-v, --version
Displays the version number
baffle without any parameters reads and executes the code from
STDIN.
DEBUGGING
Passing -d puts baffle in interactive debugging mode. While in this
mode, these commands can be used:
s : Step through
n : same as 's' for now
b<number> : Sets the breakpoint (only one for now)
c : clears the breakpoint
g : Go (runs until reaches breakpoing or program ends)
a<secs> : Autostep, step through every <secs> (can be a fraction)
q : quit
AVAILABILITY
baffle is tested on many different variations of Linux, Cygwin, and
FreeBSD.
Please feel free to send us your patches to get tgc working on other
platforms.
COPYRIGHT AND LEGAL ISSUES
Copyright (c) 2018, Faraz.V (faraz@fzv.ca)
Redistribution and use in source and binary forms, with or without mod‐
ification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of the author nor the names of its contributors
may be used to endorse or promote products derived from THIS
SOFTWARE without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTIC‐
ULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POS‐
SIBILITY OF SUCH DAMAGE.
AUTHOR
baffle is written by Faraz.V (faraz@fzv.ca)