Skip to content

Error Handling #49

Description

@SteveJustin1963

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:

  1. Helps users understand what went wrong
  2. Makes debugging user programs much easier
  3. Prevents silent failures
  4. 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:

  1. Add only about 25 bytes total
  2. Provide immediate feedback
  3. Make MINT much more user-friendly
  4. Keep the minimal philosophy
  5. Help users learn from mistakes

This enhancement:

  1. Adds error reporting for:

    • Stack underflow/overflow
    • Heap overflow
    • Division by zero
  2. Changes to error handling:

    Before:        After:
    ETX1:          ETX1:
    JP interpret   LD  C,ERR_STACK
                  JP  REPORT_ERROR
    
  3. Error output format:

    • Shows "?" followed by error code
    • Example: "?S" for stack error
    • Then returns to MINT prompt
  4. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions