Giter Site home page Giter Site logo

mnnbfsl's Introduction

MNNBFSL

Mada Namae no Nai BrainFuck fu Stack Language

Stack

MNNBFSL interpreter has 2 stacks, a data stack and a return stack.

Commands

There are 9 commands and 1 debug command.

character meaning
" duplicate a value on the top of the data stack
+ increment a value on the top of the data stack
- decrement a value on the top of the data stack
> pop a value from the data stack and push the value to the return stack
< pop a value from the return stack and push the value to the data stack
[ push a program counter to the return stack
] pop a value from the data stack, if the value is 0, pop a value from the return stack; otherwise, pop a value from the return stack and set the value to the program counter
. pop a value from the data stack and write to stdout
, read 1 byte from stdin, push the byte to the data stack, and push 1 to the data stack. if the end of stdin, push 0 to the data stack
s print the data stack and the return stack to stderr (for debugging)
others no operations

mnnbfsl's People

Contributors

yshl avatar

Stargazers

Mtv Europe avatar Kobayasi, Hiroaki avatar

Watchers

 avatar James Cloos avatar

mnnbfsl's Issues

GOTO & Turing Completeness

Hi,

I added labels (:label) and 'get label address' (!label) and then wrote in chicken scheme an assembler compiles them into pure MNNBFSL:

https://gist.github.com/orchid-hybrid/29cd05db345d17f80de5

label addresses are computed in binary:

#;5> (begin (push-binary 4) (newline))
[<[-"]"+[->+<"]+[-"][]"[->+<"]+[-"][]"[->+<"]+[-"][]
#;6> (begin (push-binary 5) (newline))
[<[-"]"+[->+<"]+[-"][]"[->+<"]+[-"][]"+[->+<"]+[-"][]
#;7> (begin (push-binary 6) (newline))
[<[-"]"+[->+<"]+[-"][]"+[->+<"]+[-"][]"[->+<"]+[-"][]
#;8> (begin (push-binary 7) (newline))
[<[-"]"+[->+<"]+[-"][]"+[->+<"]+[-"][]"+[->+<"]+[-"][]

The assembler must be careful to allocate enough space for printing out binary codes when calculating addresses.


Given that we have stack operations, +, *, swap and goto as well as conditionals it shouldn't be hard to build a simulator for a Turing complete language.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.