206 questions
-1
votes
0
answers
82
views
Why does my Brainfuck interpreter read user input instead of outputting a char? [closed]
I am making a Brainfuck clone and my interpreter isn't working:
// _ dicrement the instruction pointer by 3 if the current cell value is 0
// <, >, +, -, ,, . are the same as in bf
.global ...
3
votes
2
answers
146
views
my brainfuck code wrap from 0 to 255 in the cells when I decrement values and make an error when the input is minor than 5
when I decrement a value in a check cell by 5 to determine if the value the user entered is greater or less than 5, two situations occur: 1) when the input is greater or equal than 5, the result is ...
0
votes
1
answer
67
views
Moving over variable number of NULL cells in Brainfuck (non-NULL terminated loops)
In Brainfuck loops continue until they finish an iteration on a NULL cell.
This means it is easy to move over a variable number of cells as long as there is a NULL cell to end on, for example a NULL ...
0
votes
1
answer
167
views
I need help understanding a brainfuck code
>, >, <<
convert from ascii
+++++ +++[>----- ->----- -<<-] (a)
multiply
>[>[->+>+<<]>[-<+>]<<-] (b)
separate numbers
>[-]>+> >...
1
vote
1
answer
542
views
Brainfuck Compiler in javascript
I wrote a BrainFuck compiler in JavaScript and it works fine with this input:
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++.....
1
vote
2
answers
200
views
Interpreter in C++ for Brainfuck printing the wrong results
I written a Interpreter in C++ for Brainfuck und it works fine with "Hello World" Brainfuck Code to give me the right output. Now I'm trying a different Brainfuck Code, that generates the ...
0
votes
0
answers
95
views
ifstream stuck on `\n` when trying to read the previous character
I'm writing a brainfuck interpreter in C++. One of its language features is that in a loop if the current byte != 0 then go back to the beginning of the loop until it's == 0. My approach is reading a ...
1
vote
2
answers
112
views
Copy byte value from an address to the specified address
I have this bf code:
> ++++ ++ @1=6
How do I copy current value (6) in address @1 to the specified address for example address @8
I can do it with this:
> ++++ ++ @1=6
[
>>>> >&...
1
vote
1
answer
139
views
Why does this interpreter results in a segmentation fault?
I am trying to write a brainf*ck Interpreter in C.
The current pointer, the array and the length of the array are given in a struct.
The interpreter method receives pointers to the array struct and ...
0
votes
1
answer
127
views
How to have text before the input in Brainfuck?
How do I make it so that the question is asked before the input in Brainfuck?
What I want:
What is your number:
3
What I get:
3
What is your number:
So the input executes before the text is printed ...
0
votes
0
answers
153
views
Unexpected "10" when converting a string to ascii code in rust
I am trying to covert a string to an ascii code in rust to turn the string into BrainFuck code:
(The variable "input" is the string "hello" and this snippet starts at line 12)
for ...
1
vote
2
answers
272
views
Prints '+' to the screen 20 times using a loop and arithmetic operators
I have a simple Brainfuck program called "PuraPuraNanya", which prints the character + to the screen 20 times using a loop and arithmetic operators.
++++++++++[>+>+++>++++>+++++&...
1
vote
1
answer
316
views
Is there a way to print out the value at the pointer an a number in brainfuck?
I was wondering how I could print this value as a number NOT as a character an example would be that the pointer is on (125)
(0)(0)(125)(0)(0)
In this case when this snippet of would start, the ...
0
votes
0
answers
126
views
How to access the whole screen in x64 assembly, without BIOS or C
I'm currently working on an operating system. I have written an interpreter (which is also a compiler, oddly enough, but that's not the point). I basically did everything; I just need to build a GUI. ...
2
votes
1
answer
545
views
How do you use the comma command in Brainfuck?
I've been experimenting with the BF esolang today, as I graduated from hello world to an addition program, (which requires the data take in command), I could not for the life of me figure out how this ...
0
votes
0
answers
132
views
How to fix "borrowed value does not live long enough" issue in rust
I have been writing a brainf*ck interpreter in rust, and was stupid enough to not use a lexer.
I use recursion to tackle loops.
let mut ret = exec(i, file, tape, ptr);
i = &(ret.0);
file = &...
0
votes
2
answers
261
views
How can i add a+b in brainfuck?
How can i sum a and b without removing them?
Example we have [A,B] and i want [A,B,A+B] and not [A+B,0]?
;>;
<
[->>+>+<<<]
>
[->+>>+<<<]
>>
[<&...
1
vote
1
answer
335
views
Unoptimized Brainfuck code runs faster than optimized Brainfuck code
I am currently trying to program a Brainfuck interpreter in Java. I try to optimize the Brainfuck code by removing comments and code that is redundant (I use regex for this). However, my unoptimized ...
0
votes
2
answers
270
views
How can I check if user input is equal to a value in brainfuck?
I am trying to write a program (which I'm sure has been done before, just trying to challenge myself) that takes two user inputs per loop, one for the letter/number, and one to check if the user is ...
4
votes
2
answers
326
views
Is brainfuck still Turing complete if opening brackets do nothing
I am working on a physical breadboard 8bit CPU that directly interpret brainfuck.
The language specification indicates that both opening and closing brackets have logic :
[ => Jump to matching ] ...
0
votes
1
answer
109
views
Why does this end up as 72 in Brainfuck?
so I started looking into Brainfuck and I found this line as a part of a "Hello World" Program:
-[>+<-------]>-.
This line produces the output "H". If I understood it ...
2
votes
2
answers
144
views
Brainfuck: Why does this happen?
I have this pretty simple program:
+[----->+++<]>.
+[----->+++<]>.
Trying to log two g's
however the output is gØ
how can i make a newline break the code? operator? Not possible?
0
votes
1
answer
86
views
How can you check if brainf*ck program is in an loop more than 5 seconds in python?
I am making a program that makes a random Brainf*ck program in python and runs it. I have an interpreter and I need it to check for long loops (more than 5 seconds).
The interpreter is:
while i < ...
0
votes
2
answers
83
views
My BF program worked yesterday but doesn't today
I know that may seem silly, but yesterday, I found out about Brainfuck, and had fun with it.
I made some programs and had a lot of fun.
Though, today, when I try the same program, it simply prints ...
3
votes
2
answers
184
views
How do I make a program in Brainfuck that will add two digits?
I'm trying to make a program in Brainfuck which I think is also called "Brainflake", that will add two single digit decimal integers input with ASCII numeric characters and display the sum ...
-1
votes
1
answer
192
views
How is Brainfuck interpereting loops that makes this code work?
This might sound stupid, but i need help with brainfuck.
so im writing an interpreter in c#, and I tried to use my interpreter on a real piece of code (+[----->+++<]>+.+.) which should print ...
2
votes
2
answers
263
views
Absolute of number in brainfuck
How would you go about getting the absolute of a number in brainfuck?
I originally thought squaring the number ([->+>+<<]>>[-<<+>>]<<[>[->+>+<<]>&...
3
votes
2
answers
761
views
How do I implement the looping functionality in my BrainFuck Interpreter?
There's multiple questions here already, but I'll still proceed. This is a simple BrainFuck interpreter. I figured out all the other symbols, but I can't figure out how to implement loops. Can anyone ...
3
votes
1
answer
152
views
Can anyone explain why this brainfuck if/else code doesn't work?
// if x = y then {if_code}; else then {else_code}
,>,< / empty memory
[->-<]> / (x)'y
[>->]< / 0'(y-x)
+[
{if_code}
->>
]< / {if x=y then} (0)'0; {else then} 0'...
1
vote
1
answer
240
views
How to optimize brainf*ck instructions
I'm trying to write an optimisation feature for my brainf*ck interpreter.
It basically combines same instructions into 1 instruction.
I wrote this function but It doesn't work properly:
pub fn ...
0
votes
1
answer
63
views
Does the new location have to be zero for the loop to end in brainf*uck
I was wondering abt bf loops then it just got much more complicated.
when you open the loop([) at the pointer location 0, then go forward(>) in the loop([>). Does the new location have to be ...
2
votes
1
answer
293
views
how to set an array with the size of n to a specific number in brainfuck
I want to set an array of n elements to a predefined value (which isn't copying from a cell but setting a value from the code itself). How could I do that? without changing other cells as I went ...
0
votes
1
answer
266
views
Why does every brainf*ck interpreter (except the web ones) show these characters? (♀♂)
So I tried doing my own Brainf*ck interpreter in C++, and everything was going fine until I tried this program:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[.-]
It just goes to ...
1
vote
1
answer
387
views
implementing loops in a c brainfuck interpreter
I have written a simple brainfuck interpreter in c. all the commands work fine, except for loops. currently, I am handeling them like this:
I have a function to find the matching square bracket:
int ...
-1
votes
2
answers
566
views
How should I handle possible negatives in my BrainF**k interpreter?
I'm building my first interpreter to learn Rust better, and I'm sort of stuck on this problem, because me tape/memory is a vector of unsigned 8-bit integers, but loops sometimes result on negatives.
I'...
1
vote
1
answer
224
views
Exit condition loop BrainF*ck
I've used the BrainFuck Visualizer to check out this small piece of code but I don't understand how the exit conditions work on the loops starting with -. It suddenly just stops and jumps to the next ...
3
votes
0
answers
45
views
Are BrainF*ck tape spots overflowing? [duplicate]
Can I assume that if you do - on a tape spot with 0, that it loops around to 255?
Otherwise I don't understand how you can start a loop with - without first incrementing?
e.g:
+[----->+++<]>+....
-1
votes
1
answer
106
views
List has no items to pop however there was something there?
Trying to make a brainfuck interpreter in python from scratch just for fun, I'm almost done with the code however this small error is coming up whenever I try interpreting ",[>++++<]" ...
-1
votes
1
answer
170
views
My Brainf*** interpreter Does Not Work With Common Hellow World Program
I am trying to make a brainf*** interpreter in c++. when I test it with the Esolang hello world example:
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-...
4
votes
1
answer
233
views
How do I print “What happened on the 4th of June 1989?” in BrainFuck?
I need to learn how to display this text in BrainFuck among other programming languages, BrainFuck included.
1
vote
0
answers
329
views
Brainfuck interpreter has peculiar problems with loops
I am writing a cpp program to execute live inputs of Brainfuck code,
like how you can use python live in a terminal.
Everything works fine, except when nested loops come into play:
This nested loop ...
1
vote
1
answer
273
views
Moving the pointer by a given amount in brainfuck
My array looks like this at the moment, data pointer at the [n]. The code will give a number from 2-10
0 10 45 45 45 45 45 45 45 45 45 0 [n] 0
I need to move the pointer to the left by n spaces ...
0
votes
1
answer
83
views
How to add Brainfuck into Atom
I know nothing about grammars or that type of stuff and i don't know how to make brainfuck work in
Atom. I have installed script and brainfuck, but if I try to run it just prints the error "...
0
votes
1
answer
682
views
BrainF*ck interpreter in x86 32-bit Assembly
I started to write a BrainF*ck interpreter for my OS in 32-bit x86 assembly. I have already written one in C that just works and tried to implement it in assembly but the one written in assembly doesn'...
3
votes
2
answers
187
views
Optimized cell increasing in brainfuck
So my aim:
put the value n into a cell with smallest amount of instructions.
I could do + twenty times for the value 20.
But a shorter way is for example to do >++++[<+++++>-]<.
How could ...
1
vote
1
answer
472
views
Is this possible to write a Quine in ook
According to this comment from the general question Is it possible to create a quine in every turing-complete language? it seems like it is said that it's possible.
However I didn't find any Ook! ...
-4
votes
1
answer
158
views
Why the brainfuck interpreter in C may not work when executing a program with loops?
I decided to write another one BF interpreter in order of personal development, and despite the fact that this is his second version written from scratch, one way or another it doesn't work correctly ...
2
votes
1
answer
150
views
Brain**** implementation in C
I'm trying to run a hello world program with the brainfuck implementation that I made this week but I'm getting a strange output.
This is the hello world file that I'm trying to run.
++++++++[>++++[...
0
votes
0
answers
79
views
Why is this assertion failing for my Scheme-based Brainfuck interpreter?
I am writing a Brainfuck interpreter in Scheme (Chez Scheme). It seems like no matter which Brainfuck program I throw at it, it never works, and I cannot figure out why. I figured that I would try it ...
0
votes
1
answer
89
views
What is causing the abort trap in the output C file for my Brainfuck transpiler?
I am working on a C to Brainfuck transpiler, based on the translation described in Brainfuck's Wikipedia page. Each program that I have tested works perfectly, until the end. In the beginning, I ...