An ASM-like language that compiles to BrainFuck
·
Report Bug
·
Request Feature
java -jar Cow-1.0-all.jar
-verbose <true|false> Verbosity (optional, default false)
-input <file> Input file
-output <file> Output file (optional, default output.bf)
The following types are available:
Code
; syntax:
{
<commands>
}
where a command is either a macro or an unsafe call.
Register
; There are 20 registers, 10 being function registers (like%eax
in assembly), which can be referenced using%n
where n is between0
and9
(inclusive). The remaining 10 registers are internal registers, referenced using&n
for n between0
and9
(inclusive). These internal registers should not be used (by you), just like internal macros.Address
; an address pointing to a memory cell. The syntax for this is a hex value, e.g.0x3
would reference the4
th memory cell._translateAddress(0x0) == 0y20
.@AnyAddress
; an address pointing to a brainfuck cell. The syntax is similar to that of an address, the only difference being that thex
is replaced with ay
.0y0
is the first cell on the tape. This should not be used (by you).BFCode
; syntax:
!{
<brainfuck code>
}
note that this type is not available as a macro parameter.
Calling a macro:
<macro name> <args separated by spaces>;
Optionally, parenthesis can be placed.
A macro argument can be one of the following:
- Direct type: an address, an anyaddress, a code block, or a register.
- Indirect type: an argument from the current macro (see below).
- Unsafe call: the return values of the
_translateRegister
and_translateAddress
unsafes.
Macros beginning with @
are not meant to be used (by you), as they tinker with the brainfuck cells themselves. They are considered internal.
Defining a macro:
def <macro name> {
...
}
or
def <macro name>(type1, type2, type3) {
...
}
Inside a macro body, the arguments supplied by the caller can be referenced using $n
where n
is any natural number (starting at 0).
Unsafes are like macros. The only difference is that they are evaluated at compile-time.
The following unsafes are available:
_bf(BFCode)
: write$0
into the current spot._sub(Code)
: substitute$0
into the current spot._ptrelt(@AnyAddress)
: move$0
many cells to the right on the tape._ptrelb(@AnyAddress)
: move$0
many cells to the left on the tape._translateAddress(Address)
: get the any address of$0
. Can be used as a macro argument._translateRegister(Register)
: get the any address of$0
. Can be used as a macro argument._unsafe
: allow unsafe calls._internal
: allow internal macro calls.
Unsafe calls, just like macro calls, have to end in a semicolon.
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.