BASIC: RENUM [start[,step]] renumbers lines and their references

Fixes the numbers after GOTO, GOSUB, THEN, RUN and ON ... GOTO/GOSUB;
missing targets, quotes, REM and DATA are left alone. The new program is
built above the old one and copied down at the end, so a step of 0,
numbers past 65535, an over-long line or lack of memory change nothing.

To make room without giving up --opt-code-speed: one decimal formatter
(fmt_ul) shared by LIST, RENUM and number printing; fmt_num's output
branches merged (same text for ~2M test values); parse_num reads the
whole part and decimals in one loop. Works around an SDCC 4.5 bug that
turned a 0-trip loop into a 256-trip djnz. Adds basic/test-renum.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
brad ArantandClaude Opus 5.5 committed 2026-11-30 13:24:56 -08:00
1 parent c553824df0
commit 8f098b5502
7 files changed
+10302 -10089

No files matched your search

+1 -1
View File
@@ -188,7 +188,7 @@ typed can be edited with the cursor keys, Home, End, Backspace, Delete and
Ctrl-U, and Up brings back the last line. Type a line number and press Right
to copy that program line one character at a time, or End to copy all of it.
- **Commands**: `RUN [line]`, `LIST [a][-b]`, `NEW` (also `SCRATCH`).
- **Commands**: `RUN [line]`, `LIST [a][-b]`, `RENUM [start[,step]]`, `NEW` (also `SCRATCH`).
- **Files in flash**: `SAVE "NAME"`, `LOAD "NAME"`, `RUN "NAME"`, `DIR`,
`DEL "NAME"`; data files with `OPEN "NAME" FOR INPUT|OUTPUT|APPEND AS #n`,
`PRINT #n`, `INPUT #n`, `LINE INPUT #n`, `EOF(n)`, `CLOSE [#n]`; memory