2024-02-29 10:50:53 +00:00
|
|
|
# Brainfuck support for r2
|
2011-10-07 01:10:44 +00:00
|
|
|
|
|
|
|
Plugins for brainfuck:
|
2024-02-29 10:50:53 +00:00
|
|
|
|
|
|
|
* `debug.bf` - debugger using bfvm
|
|
|
|
* `arch.bf` - code analysis for brainfuck
|
|
|
|
* `bp.bf` - breakpoints support (experimental)
|
2011-10-07 01:10:44 +00:00
|
|
|
|
2011-10-09 02:41:53 +00:00
|
|
|
To debug a brainfuck program:
|
2011-10-07 01:10:44 +00:00
|
|
|
|
2024-02-29 10:50:53 +00:00
|
|
|
```sh
|
|
|
|
r2 -D bf bfdbg:///tmp/bf
|
2011-10-07 01:10:44 +00:00
|
|
|
|
2024-02-29 10:50:53 +00:00
|
|
|
> dc # continue
|
|
|
|
> x@scr # show screen buffer contents
|
|
|
|
```
|
2011-10-09 03:24:15 +00:00
|
|
|
|
2011-10-07 01:10:44 +00:00
|
|
|
The debugger creates virtual sections for code, data, screen and input.
|
|
|
|
|
2024-02-29 10:50:53 +00:00
|
|
|
## TODO
|
2011-10-07 01:10:44 +00:00
|
|
|
|
2024-02-29 10:50:53 +00:00
|
|
|
* add support for comments, ignore invalid instructions as nops
|
|
|
|
* enhance io and debugger plugins to generate sections and set arch opts
|
2018-02-27 09:54:54 +00:00
|
|
|
|
2024-02-29 10:50:53 +00:00
|
|
|
## Hello World
|
|
|
|
|
|
|
|
```brainfuck
|
2011-10-07 01:10:44 +00:00
|
|
|
>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]
|
|
|
|
>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++
|
|
|
|
.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.
|
2018-02-27 09:54:54 +00:00
|
|
|
```
|
2011-10-07 01:10:44 +00:00
|
|
|
|
2024-02-29 10:50:53 +00:00
|
|
|
```sh
|
2011-10-07 01:10:44 +00:00
|
|
|
$ cat << EOF
|
|
|
|
>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.
|
|
|
|
EOF
|
2018-02-27 09:54:54 +00:00
|
|
|
```
|