sd-8516_stellar_basic_v1.0
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| sd-8516_stellar_basic_v1.0 [2026/01/09 03:08] – appledog | sd-8516_stellar_basic_v1.0 [2026/01/28 16:08] (current) – appledog | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| Dennis Allison’s 1975 article in Dr. Dobb’s Journal was a key moment in the history of Computer Science. It contained a formal specification of Tiny BASIC, a BASIC that could be implemented in less than 4 KB. | Dennis Allison’s 1975 article in Dr. Dobb’s Journal was a key moment in the history of Computer Science. It contained a formal specification of Tiny BASIC, a BASIC that could be implemented in less than 4 KB. | ||
| - | Stellar BASIC is very much in the same vein as Tiny BASIC, and is intended to evolve over time. | + | Stellar BASIC is very much in the same vein as Tiny BASIC, and is intended to evolve over time. However, Tiny BASIC itself is only a specification. One way is to compile a list of IL (intermediate language) statements. Once you have the IL interpretation you compile it and interpret it from there. On a machine with limited ram this approach can require up to 50% of the memory of a standard BASIC program. This is problematic. So machines like the C64 tokenized the statements on entry and executed them that way. The other issue with IL is that you have this compiled version and you also have the text lying around. That's two copies of the program. Which one is the ' |
| - | == Core features | + | Therefore, when it came time to compile the IL into a program we instead chose a C64 style tokenization, |
| + | == Core features | ||
| * Line-numbered programs | * Line-numbered programs | ||
| * '' | * '' | ||
| - | * `PRINT` | + | * '' |
| - | * `INPUT` | + | * '' |
| - | * `IF … THEN` | + | * '' |
| - | * `GOTO` | + | * '' |
| - | * `GOSUB` / `RETURN` | + | * '' |
| - | * `FOR` / `NEXT` | + | * '' |
| - | * Integer arithmetic | + | * Usually |
| - | * Single-letter variables (`A`–`Z`) | + | * Single letter variables (ex. '' |
| - | + | ||
| - | ### What’s usually removed | + | |
| * No floating-point math | * No floating-point math | ||
| - | * No strings (or very limited strings) | + | * Very limited strings |
| - | * No arrays | + | * No arrays |
| * No file I/O | * No file I/O | ||
| * Minimal error messages | * Minimal error messages | ||
| * Very limited editing commands | * Very limited editing commands | ||
| - | Some versions | + | Some versions |
| - | --- | + | == Example BASIC program |
| - | ## Size | + | <Code:Basic> |
| - | + | ||
| - | Typical Tiny BASIC interpreters: | + | |
| - | + | ||
| - | * **1–4 KB total** | + | |
| - | * Some famous versions were under **2 KB** | + | |
| - | * A few extreme versions fit in **less than 1 KB** | + | |
| - | + | ||
| - | This was achieved through: | + | |
| - | + | ||
| - | * Hand-written assembly | + | |
| - | * Tokenization | + | |
| - | * Shared code paths | + | |
| - | * Aggressive simplification of syntax | + | |
| - | + | ||
| - | --- | + | |
| - | + | ||
| - | ## Example: Tiny BASIC program | + | |
| - | + | ||
| - | ```basic | + | |
| 10 LET A = 1 | 10 LET A = 1 | ||
| 20 PRINT A | 20 PRINT A | ||
| Line 56: | Line 36: | ||
| 40 IF A <= 10 THEN GOTO 20 | 40 IF A <= 10 THEN GOTO 20 | ||
| 50 END | 50 END | ||
| - | ``` | + | </ |
| - | Many Tiny BASICs would allow this even shorter form: | + | Stellar BASIC will allow this even shorter form: |
| - | ```basic | + | < |
| 10 A=1 | 10 A=1 | ||
| 20 ?A | 20 ?A | ||
| 30 A=A+1 | 30 A=A+1 | ||
| 40 IF A<=10 GOTO 20 | 40 IF A<=10 GOTO 20 | ||
| - | ``` | + | </ |
| - | (`?` was often shorthand for `PRINT`.) | + | ('' |
| - | --- | + | == More Information |
| - | + | Notable Tiny BASIC implementations | |
| - | ## Notable Tiny BASIC implementations | + | |
| * **Palo Alto Tiny BASIC** (Dennis Allison) | * **Palo Alto Tiny BASIC** (Dennis Allison) | ||
| Line 80: | Line 59: | ||
| * **Micro-Soft 8080 BASIC** (larger, but influenced by Tiny BASIC work) | * **Micro-Soft 8080 BASIC** (larger, but influenced by Tiny BASIC work) | ||
| - | Each one differed slightly, but all followed the “tiny, usable, interactive” idea. | + | == Appendix I: Pao Alto Tiny Basic |
| + | Stellar Basic is based on Pao Alto Tiny Basic, written by Dennis Allison in 1975. | ||
| + | |||
| + | === Implementation | ||
| + | Please see: https:// | ||
| + | |||
| + | I implemented it in this order: | ||
| + | |||
| + | * Phase 1: Variable management (3 functions: get, set, clear_all) | ||
| + | * Expression stack (4 functions: push, pop, peek, clear) | ||
| + | * I/O & String Helpers (ex. IO_GETNUM) | ||
| + | * String comparison, number parsing (ex. STR_SKIP_SPACE) | ||
| + | |||
| + | * Phase 2: Stack Operations | ||
| + | * GOSUB/ | ||
| + | * FOR/NEXT stack (4 functions) | ||
| + | |||
| + | * Phase 3: Program Line Management | ||
| + | * Find line by number | ||
| + | * Insert/ | ||
| + | * Navigate through program (first line, next line) | ||
| + | * Program storage with line markers (opcode 251) | ||
| - | --- | + | * Phase 4: IL Interpreter Core; |
| + | * Design IL bytecode table (~30-40 IL opcodes) | ||
| + | * Command tokenizer (major hurdles to pass -- this was hard) | ||
| + | * IL fetch/ | ||
| + | * Expression evaluation using the stack | ||
| + | * Control flow (GOTO, GOSUB, IF/THEN, FOR/NEXT) | ||
| - | ## Why Tiny BASIC matters | + | * Phase 5: BASIC Commands |
| + | * PRINT, INPUT, LET | ||
| + | * RUN, LIST, NEW, CLEAR | ||
| + | * Integrate with term.ts to highlight a " | ||
| - | Tiny BASIC is important because it: | + | * Phase 6: Testing & Polish |
| + | * End-to-end BASIC program tests | ||
| + | * Error handling and status messages | ||
| + | * Bug fixes | ||
| + | * Performance tuning | ||
| - | * Made programming accessible on the *cheapest possible hardware* | + | === Stack-based design |
| - | * Helped bootstrap the early microcomputer software ecosystem | + | Everything in PATB is stack-based. This is a core design principle. There are three stacks: |
| - | * Demonstrated how interpreters could be **designed under extreme constraints** | + | |
| - | * Influenced later minimal languages and embedded scripting systems | + | |
| - | It’s often cited as an early example of **open, shared language design**, since many implementations were published openly in magazines. | + | # **Expression Stack** - Arithmetic evaluation |
| + | ** "5 + 3 * 2" is "push 5", "push 3", "push 2", " | ||
| + | # **GOSUB Stack** - Subroutine calls | ||
| + | ** "GOSUB 1000" -- push current line number, jump to 1000 | ||
| + | ** " | ||
| + | # **FOR Stack** - Loop context | ||
| + | ** "FOR I=1 TO 10" -- push (I, 10, 1) | ||
| + | ** "NEXT I" -- peek stack, increment I, check if done, pop if finished | ||
| - | --- | + | === Immediate Modifications to PATB 1.0 |
| + | During the implementation phase I made several by-the-way changes to PATB in order to support a more advanced integration with the SD-8516. I added LINE_FIND_REVERSE and LINE_PREV as well as LINE_MAKE_SPACE and LINE_REMOVE_SPACE for line management. I am not sure how PATB does those things. I worked from example code and the specs but I did not really understand what I was doing. After the tests for the IL implementation passed I added string helpers. Some of these are in PATB (about 4 or 5 of them IIRC) but I added enough to support proper string handling, as it is the first thing I plan to add. After the basic port, of course. | ||
| - | ## In one sentence | + | I'm really excited to start working on these because I feel I understand them and they will be easy. LINE_INSERT is not easy It is long and hard. I do not understand it... YET! |
| - | > **Tiny BASIC is a deliberately minimal BASIC interpreter, | + | * ; |
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| + | * ; | ||
| - | If you’d like, I can: | ||
| - | * Show a **formal Tiny BASIC grammar** | ||
| - | * Compare Tiny BASIC vs Microsoft BASIC | ||
| - | * Explain how a Tiny BASIC interpreter works internally | ||
| - | * Show how to write your own Tiny BASIC in C or assembly | ||
sd-8516_stellar_basic_v1.0.1767928125.txt.gz · Last modified: by appledog
