-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
untested code probably wrong, just a lead
Adding a simple error reporting system.
Currently, when errors occur (like stack underflow or heap overflow),
MINT just silently continues or resets.
why useful:
- Helps users understand what went wrong
- Makes debugging user programs much easier
- Prevents silent failures
- Helps learning the system
could be done compactly:
; Add to error constants section
ERR_STACK: EQU 'S' ; Stack error
ERR_HEAP: EQU 'H' ; Heap overflow
ERR_SYNTAX: EQU 'X' ; Syntax error
; Error reporting routine - about 15 bytes
REPORT_ERROR:
LD A,'?' ; Error marker
CALL putchar
LD A,C ; Error code in C
CALL putchar
JP ETX ; Return to prompt
; Then modify existing error points like:
ETX1:
LD C,ERR_STACK ; Stack underflow
JP REPORT_ERROR ; Instead of silent continue
This would:
- Add only about 25 bytes total
- Provide immediate feedback
- Make MINT much more user-friendly
- Keep the minimal philosophy
- Help users learn from mistakes
This enhancement:
-
Adds error reporting for:
- Stack underflow/overflow
- Heap overflow
- Division by zero
-
Changes to error handling:
Before: After: ETX1: ETX1: JP interpret LD C,ERR_STACK JP REPORT_ERROR -
Error output format:
- Shows "?" followed by error code
- Example: "?S" for stack error
- Then returns to MINT prompt
-
Total size impact:
- About 60 bytes total
- Fits easily within our 2048-byte constraint
To test try:
1 0 / ; Should show ?D (division error)
) ; Should show ?X (syntax error)
. . . ; Should show ?S (stack underflow)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels