User Tools

Site Tools


sd-8516_stellar_basic_v1.0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sd-8516_stellar_basic_v1.0 [2026/01/22 03:27] appledogsd-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 'real' program? If you remove the original text you can't necessarily LIST your code. Therefore, tokenization was settled on as a standard.
  
-== Core features+Therefore, when it came time to compile the IL into a program we instead chose a C64 style tokenization, and added $99 as PRINT as a subtle homage to the adventure, the love, and the magic of the C64 era.
  
 +== Core features
 * Line-numbered programs * Line-numbered programs
 * ''LET'' (often optional) * ''LET'' (often optional)
Line 59: Line 60:
  
 == Appendix I: Pao Alto Tiny Basic == Appendix I: Pao Alto Tiny Basic
-Stellar Basic is based on Pao Alto Tiny Basic, written by Dennis Allison in 1975. I implemented it in this order:+Stellar Basic is based on Pao Alto Tiny Basic, written by Dennis Allison in 1975. 
 + 
 +=== Implementation 
 +Please see: https://www.helloneo.ca/wiki/doku.php?id=vc-3_system_interrupt_table#int_05h_-_pao_alto_tiny_basic 
 + 
 +I implemented it in this order:
  
 * Phase 1: Variable management (3 functions: get, set, clear_all) * Phase 1: Variable management (3 functions: get, set, clear_all)
Line 78: Line 84:
 * Phase 4: IL Interpreter Core; * Phase 4: IL Interpreter Core;
 * Design IL bytecode table (~30-40 IL opcodes) * Design IL bytecode table (~30-40 IL opcodes)
 +* Command tokenizer (major hurdles to pass -- this was hard)
 * IL fetch/decode/execute loop * IL fetch/decode/execute loop
 * Expression evaluation using the stack * Expression evaluation using the stack
 * Control flow (GOTO, GOSUB, IF/THEN, FOR/NEXT) * Control flow (GOTO, GOSUB, IF/THEN, FOR/NEXT)
  
-* Phase 5: BASIC Commands (~15-20%)+* Phase 5: BASIC Commands
 * PRINT, INPUT, LET * PRINT, INPUT, LET
 * RUN, LIST, NEW, CLEAR * RUN, LIST, NEW, CLEAR
 * Integrate with term.ts to highlight a "Boot-to-basic" experience. * Integrate with term.ts to highlight a "Boot-to-basic" experience.
  
-* Phase 6: Testing & Polish (~5%)+* Phase 6: Testing & Polish
 * End-to-end BASIC program tests * End-to-end BASIC program tests
 * Error handling and status messages * Error handling and status messages
 * Bug fixes * Bug fixes
 * Performance tuning * Performance tuning
 +
 +=== Stack-based design
 +Everything in PATB is stack-based. This is a core design principle. There are three stacks:
 +
 +# **Expression Stack** - Arithmetic evaluation
 +** "5 + 3 * 2" is "push 5", "push 3", "push 2", "multiply" (pop 2 values, push result), "add" (pop 2 values, push result).
 +# **GOSUB Stack** - Subroutine calls
 +** "GOSUB 1000" -- push current line number, jump to 1000
 +** "RETURN" -- pop line number, jump back
 +# **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.
 +
 +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!
 +
 +* ;   AH=$70: STR_COMPARE    - Compare strings for keyword matching
 +* ;   AH=$71: STR_TO_UPPER   - Convert string to uppercase
 +* ;   AH=$72: STR_SKIP_SPACE - Skip whitespace in ELM string
 +* ;   AH=$73: STR_IS_DIGIT   - Check if character is digit
 +* ;   AH=$74: STR_IS_ALPHA   - Check if character is letter
 +* ;   AH=$75: STR_LENGTH     - Get string length
 +* ;   AH=$76: STR_COPY       - Copy string from src to dst
 +* ;   AH=$77: STR_CONCAT     - Concatenate two strings
 +* ;   AH=$78: STR_LEFT       - Extract left N characters (LEFT$)
 +* ;   AH=$79: STR_RIGHT      - Extract right N characters (RIGHT$)
 +* ;   AH=$7A: STR_MID        - Extract middle substring (MID$)
 +* ;   AH=$7B: STR_CHR        - Convert byte to character (CHR$)
 +* ;   AH=$7C: STR_ASC        - Convert character to byte (ASC)
 +* ;   AH=$7D: STR_VAL        - Convert string to number (VAL)
 +* ;   AH=$7E: STR_STR        - Convert number to string (STR$)
 +* ;   AH=$7F: STR_FIND       - Find substring within string (INSTR)
 +* ;   AH=$80: STR_LTRIM      - Trim leading whitespace
 +* ;   AH=$81: STR_RTRIM      - Trim trailing whitespace
 +* ;   AH=$82: STR_TRIM       - Trim both leading and trailing whitespace
 +* ;   AH=$83: STR_REVERSE    - Reverse a string
 +* ;   AH=$84: STR_REPEAT     - Repeat character N times (STRING$)
 +* ;   AH=$85: STR_SPLIT      - Split string at delimiter
 +* ;   AH=$86: STR_REPLACE    - Replace substring with another
 +
  
  
sd-8516_stellar_basic_v1.0.1769052477.txt.gz · Last modified: by appledog

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki