M4GNV5 / Geschwindigkeitsficken

Speedfuck - optimizing brainfuck compiler
12 stars 0 forks source link

Issue with pre-calculation #2

Open rdebath opened 4 years ago

rdebath commented 4 years ago

This BF program should print "Hello World! 255" with your interpreter. https://github.com/rdebath/Brainfuck/blob/master/bitwidth.b

Instead it prints the below and hangs.


WorlWo Hell

The first part of the issue is that the initial "Hello" is compiled as a literal string, however, the wrong literal string is printed!

Also this program should print 1.618033988749894848204586834365638117 not 1.6191514642.

M4GNV5 commented 4 years ago

Thanks for the report and especially for the brainfuck interpreter/compiler validation programs.

The first issue was an easy fix. Print "constant strings" statements were referencing wrong string constants when using the X64Assembly backend.

Now it prints Hello World and freezes, so not that much of an improvement. Disabling the constant folding optimization (-Oconstfold) yields Hello World! WTF! and exits. But according to you it should output 255 instead of WTF!? Do you have any insights what could be causing this? The WTF! string is not mentioned in your example code.

EDIT: My question seems to be somewhat related to https://github.com/rdebath/Brainfuck/issues/6

rdebath commented 4 years ago

My tests for that script are described in https://github.com/rdebath/Brainfuck/blob/broken-and-trivial/README I'm still "considering" how to put that together with the script itself :grin:

The one that looks closest is:

broken-bfL.c
    Mismatched (and incorrect) conditions on loops.
    Message: Hello World.. WTF!.

That particular broken interpreter has >0 for one loop condition rather than !=0, however, that doesn't seem to match your interpreter exactly. Though this kinda reminds me of another assembly interpreter that was using "movq" rather than "movb" to access the tape.

Edit: Nearly the right interpreter.