-
Notifications
You must be signed in to change notification settings - Fork 397
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
feat: add p/demo/bf (brainfuck vm) #885
Conversation
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Just gotta make it run https://github.com/matslina/awib to see Gno compile BF to i386 binaries :) |
Next step: EVM. |
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
// Jump forward past the matching ']' if the byte at the memory pointer is zero | ||
if memory[pointer] == 0 { | ||
braceCount := 1 | ||
for braceCount > 0 { | ||
i++ | ||
if code[i] == '[' { | ||
braceCount++ | ||
} else if code[i] == ']' { | ||
braceCount-- | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could make this use a stack of open brackets, popped each time we go out of a loop, probably better for memory/efficiency... but if you don't want to do it it's fine :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's keep this for when we'll have better benchmarking tools as a good example of runtime and gas optimization.
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Signed-off-by: Manfred Touron 94029+moul@users.noreply.github.com
Description
Please provide a detailed description of the changes made in this pull request.
Contributors Checklist
BREAKING CHANGE: xxx
message was included in the descriptionMaintainers Checklist
CONTRIBUTING.md
BREAKING CHANGE:
in the body)