Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with pre-calculation #2

Open
rdebath opened this issue Oct 31, 2020 · 2 comments
Open

Issue with pre-calculation #2

rdebath opened this issue Oct 31, 2020 · 2 comments

Comments

@rdebath
Copy link

rdebath commented Oct 31, 2020

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
Copy link
Owner

M4GNV5 commented Oct 31, 2020

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 rdebath/Brainfuck#6

M4GNV5 added a commit that referenced this issue Oct 31, 2020
@rdebath
Copy link
Author

rdebath commented Nov 1, 2020

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 😁

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants