yshl / MNNBFSL

Mada Namae no Nai BrainFuck fu Stack Language
The Unlicense
2 stars 0 forks source link

GOTO & Turing Completeness #1

Open orchid-hybrid opened 9 years ago

orchid-hybrid commented 9 years ago

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.

AndoDaan commented 9 years ago

Hey, I just wanted to say great work with coding the labels. It helped me get a better handle on MNNBFSL. I was working on something similar towards proving it's TC-ness, but eventually I opted to implement a Bitwise Cycle Tag interpreter. Thanks.