Repository navigation
tinybasic: clear pend at start - #3
Open
enjoy-digital wants to merge 1 commit into
Open
enjoy-digital wants to merge 1 commit into
enjoy-digital wants to merge 1 commit into
Conversation
pend (the end of the program text) is a register variable in S4. It was set only by NEW, so the interpreter worked only when the CPU starts with S4 = 0. After a boot loader that leaves other values in the registers (found with the LiteX BIOS on VexRiscv) the first statement gives "Syntax error" or writes outside the program memory. The RAM variables are cleared by the startup code, the registers are not. Tested in rbsim with all registers set to 0xDEADBEEF before the start: without the change the first PRINT fails, with it PRINT, a stored program and LIST work. Written by an AI agent (Claude Code), supervised by Florent Kermarrec. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This was referenced Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In
examples/lib/tinybasic.bas,pend(the end of the program text) is a register variable inS4. It is set only byNEW, so the interpreter works only when the CPU starts withS4 = 0. The startup code clears the RAM variables, not the registers.When a boot loader runs first and leaves other values in the registers, the first statement fails:
PRINT 2+3*4gives? Syntax error, or the interpreter writes outside the program memory. Found with the LiteX BIOS on VexRiscv, which loads the program and jumps to it.Fix
One line:
pend = 0before the banner.Tested
In
rbsim, with all registers set to0xDEADBEEFbefore the start (RV32I, UART0 of the test simulator):PRINT 2+3*4fails with a store to an unmapped address;PRINT 2+3*4gives 14, a stored FOR / NEXT program andLISTwork.tests/run_tests.py: all tests passed. Not run on the Sapphire SoC (no board here).Written by an AI agent (Claude Code), supervised by Florent Kermarrec.
🤖 Generated with Claude Code