Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ahorn/bf-interpreter

BF virtual machine written in C
https://github.com/ahorn/bf-interpreter

Last synced: 2 months ago
JSON representation

BF virtual machine written in C

Awesome Lists containing this project

README

        

License: GPL
Author: A. Horn
Description: BF virtual machine written in C
Installation: sudo make install

BF commands:

> increment the data pointer (to point to the next cell to the right).
< decrement the data pointer (to point to the next cell to the left).
+ increment (increase by one) the byte at the data pointer.
- decrement (decrease by one) the byte at the data pointer.
. output the value of the byte at the data pointer.
, accept one byte of input, storing its value in the byte at the data pointer.
[ if the byte at the data pointer is zero, then instead of moving the instruction
pointer forward to the next command, jump it forward to the command after
the matching ] command*.
] if the byte at the data pointer is nonzero, then instead of moving the instruction
pointer forward to the next command, jump it back to the command after the
matching [ command*.

Example:

+++++ +++++ // initialize counter (cell #0) to 10
[ // use loop to set the next four cells to 70/100/30/10
> +++++ ++ // add 7 to cell #1
> +++++ +++++ // add 10 to cell #2
> +++ // add 3 to cell #3
> + // add 1 to cell #4
<<<< - // decrement counter (cell #0)
] //
> ++ . // print 'H'
> + . // print 'e'
+++++ ++ . // print 'l'
. // print 'l'
+++ . // print 'o'
> ++ . // print ' '
<< +++++ +++++ +++++ . // print 'W'
> . // print 'o'
+++ . // print 'r'
----- - . // print 'l'
----- --- . // print 'd'
> + . // print '!'
> . // print '\n'