A port of Enhanced 68k BASIC (originally for EASy68k simulator) to the Motorola MVME167-02 single-board computer with 167-Bug ROM monitor.
This is a working implementation of Lee Davison's Enhanced 6800 BASIC interpreter, adapted to run on real 68040 hardware. The interpreter runs entirely in RAM and uses the 167-Bug TRAP #15 interface for I/O.
- Motorola MVME167-02 (or compatible) single-board computer
- 68040 CPU (or 68030/68020 with modifications)
- 167-Bug ROM monitor firmware
- Serial terminal connection
- Code Load Address:
0x00401000 - Program Storage:
0x00500000-0x01FFFFFF(32MB BASIC program space) - Stack:
0x00500000(grows downward from program start)
vasmm68k_motassembler (vasm for Motorola syntax)- Standard Unix tools (make, rm, mkdir)
make # Build S-record file
make clean # Remove build artifactsOutput: build/enhanced_basic_ram.srec
- Connect to MVME167 via serial terminal
- Enter 167-Bug monitor
- Load the S-record:
167-Bug> lo 0 [Paste contents of build/enhanced_basic_ram.srec] - Start BASIC:
167-Bug> go 401000
- ✅ Interactive command line with prompt
- ✅ Line entry and editing
- ✅
LIST- Display program - ✅
RUN- Execute program - ✅
NEW- Clear program - ✅
PRINT- Output text and variables - ✅
FOR/NEXTloops (including nested loops) - ✅
IF/THENconditionals - ✅
GOTOandGOSUB/RETURN - ✅
DIM- Array declarations - ✅ Array operations (single and multi-dimensional)
- ✅ Arithmetic operations (+, -, *, /)
- ✅ Comparison operators (=, <, >, <=, >=, <>)
- ✅ Variable assignments
- ✅ Ctrl-C to exit to 167-Bug
⚠️ TI(timer) function returns 0 (not yet implemented)⚠️ INPUTstatement untested⚠️ String operations untested⚠️ File I/O not implemented (simulator-only feature)⚠️ Graphics commands not implemented
10 PRINT "HELLO WORLD"
RUN10 FOR I = 1 TO 10
20 PRINT "COUNT: "; I
30 NEXT I
RUNSee Sieve.BAS for a complete benchmark program.
The interpreter uses 167-Bug's TRAP #15 interface:
- $0020
.OUTCHR- Output character (stack-based) - $0000
.INCHR- Input character (stack-based) - $0001
.INSTAT- Check input status - $0063
.RETURN- Exit to 167-Bug
BASIC program lines are stored as:
[4-byte next pointer][2-byte line number][tokens...][0x00 terminator]
The 68040 is big-endian (MSB first). All multi-byte values are stored with the most significant byte at the lowest address.
- Ctrl-C Throttling: VEC_CC only checks for input every 64 BASIC statements to avoid TRAP storm
- Memory Alignment: Program storage forced to even addresses for 68040 compatibility
- Line Numbers: Changed from 32-bit to 16-bit storage
- I/O System: Replaced EASy68k TRAP #15 with 167-Bug TRAP #15
- Memory Alignment: Added EVEN directives and runtime checks for 68040
- GOTO Execution: Fixed execution flow to preserve FOR/NEXT stack
- Big-Endian Support: Corrected byte ordering for line number storage/retrieval
- Performance: Throttled Ctrl-C checking to prevent ROM monitor overload
- Fixed line number storage using wrong word in big-endian longword
- Fixed GOTO skipping incorrect number of bytes (was 2, needed 6)
- Fixed GOTO stack corruption when called from IF statement
- Fixed VEC_CC TRAP storm causing system crashes
- Fixed memory alignment issues causing odd-address faults
From Lee Davison's original documentation:
- Keywords must be in ALL UPPERCASE
- Variable names can be mixed case (first 3 letters determine uniqueness)
RND(0)generates random numbers (notRND(1)like Microsoft BASIC)- Arrays must be explicitly dimensioned with
DIM - Empty
INPUTresponses cause program break (by default) PRINTdoes not add spaces between items- Undefined variables generate errors (by default)
- Original BASIC: Lee Davison's Enhanced 6800 BASIC
- EASy68k Port: Original EASy68k simulator version
- MVME167 Port: John (2024)
- AI Assistant: Claude (Anthropic) - debugging and optimization
EhBASIC is copyright Lee Davison 2002-2012 and free for educational or personal use only. For commercial use please contact the original author.
Contributions welcome! Areas needing work:
- Implement proper TI timer function using 167-Bug
.TIME - Test and fix INPUT statement
- Test string operations
- Optimize floating-point math routines
- Add graphics support (Tektronix 4010, Sixel, or ASCII art)
Current Status: Working for integer arithmetic, loops, arrays, and control flow
Last Updated: December 2024