Previous Next Contents Index
The error routines

THE 'DISCIPLE ERROR' ROUTINE
Whenever a DISCiPLE error is encountered this routine is executed to handle it. During
syntax checking the error is handled by the 'main' ROM error handler. Whenever an error
is found while executing a command code, a return is made with the Carry flag set and
the A register holding the error number. Only during runtime the error message is
printed.

3CBC D_ERROR    CALL #3B21,BORD_REST     Restore normal border colour.
3CBF            LD   (#1DED),DE          Track & sector with sector error.
3CC3            XOR  A
3CC4            LD   (#1ACF),A           Clear FLAGS3.
3CC7            POP  HL                  Fetch return address.
3CC8            LD   DE,(#0296)          Fetch (D_ERR_SP).
3CCC            LD   A,D
3CCD            OR   E
3CCE            LD   A,(HL)              Fetch error code.
3CCF            JR   Z,#3CD7,D_ERROR1    Jump if (D_ERR_SP) isn't used.

Whenever hook or command codes are being executed, errors are reported to the calling
routine by setting the carry flag. The A register holds the error code.

3CD1            LD   SP,(#0296)          Clear the machine stack.
3CD5            SCF                      Carry set to signal 'error'.
3CD6            RET

The routine continues here when an error message is to be printed.

3CD7 D_ERROR1   LD   (23610),A           Store error code into (ERR_NR).
3CDA            RES  5,(IY+1)            Signal 'ready for a new key'.
3CDE            LD   SP,(23613)          Clear machine stack by using (ERR_SP).
3CE2            RST  #30,SYNTAX_Z        Return via 'main' ROM 'SET_STK' routine
3CE3            LD   HL,#16C5,SET_STK    to the error handler during syntax
3CE6            JP   Z,#004F,UNPAGE_HL   checking.
3CE9            LD   HL,0
3CEC            LD   (IY+55),H           Clear FLAGX.
3CEF            LD   (IY+38),H           And X_PTR-hi.
3CF2            LD   (23563),HL          Clear DEFADD.
3CF5            INC  L                   Ensure that stream 0 points to channel
3CF6            LD   (23574),HL          'K'.
3CF9            RST  #10,CALBAS          Clear all the work areas and the
3CFA            DEFW #16B0,SET_MIN       calculator stack.
3CFC            LD   A,(23728)           A jump is made to the 'STMT_R_1' routine
3CFF            AND  A                   at #1B7D in the 'main' ROM, if error
3D00            JP   NZ,#0165,EXIT_STAT  messages are to be surpressed.
3D03            RES  5,(IY+55)           Signal 'EDIT mode' FLAGX.
3D07            RST  #10,CALBAS          Clear the lower screen.
3D08            DEFW #0D6E,CLS_LOWER
3D0A            SET  5,(IY+2)            Signal 'lower screen will require
                                         clearing'. (TV_FLAG)
3D0E            RES  3,(IY+2)            Signal 'mode is to be considered
                                         unchanged'.
3D12            LD   A,(23610)
3D15            CP   4
3D17            JR   NZ,#3D34,D_ERROR2   Jump if error isn't 'SECTOR error'.
3D19            PUSH AF
3D1A            LD   DE,(#1DED)          Fetch track and sector where error
3D1E            LD   H,0                 was signalled.
3D20            LD   L,D
3D21            PUSH DE
3D22            XOR  A                   Print the track number, no leading
3D23            CALL #3BE5,PRT_N100      characters.
3D26            LD   A,58                Print a comma.
3D28            CALL #3C2C,PRT_A
3D2B            POP  DE
3D2C            LD   H,0
3D2E            LD   L,E
3D2F            XOR  A                   Print the sector number, no leading
3D30            CALL #3BEB,PRT_N10       characters.
3D33            POP  AF

The routine now continues with the printing of the error message.

3D34 D_ERROR2   LD   HL,#3D51,ERR_MSGS   HL points to the error message table.
3D37            LD   BC,505              Length of error message table.
3D3A            CPIR                     Search for the message.
3D3C            CALL #3D47,PRT_MSG_HL    Print it.
3D3F            INC  SP                  Drop address of 'main' ROM error handler.
3D40            INC  SP
3D41            LD   HL,#1349,MAIN_5A    Print the line and statement number by
3D44            JP   #004F,UNPAGE_HL     jumping into the Spectrum error
                                         handler.

THE 'PRINT MESSAGE HL' SUBROUTINE
This subroutine prints the message pointed to by the HL register.

3D47 PRT_MSG_HL LD   A,(HL)              Fetch a character.
3D48            CP   32
3D4A            RET  C                   Exit if it isn't printable, message is
                                         finished.
3D4B            CALL #3C2C,PRT_A         Print the character.
3D4E            INC  HL
3D4F            JR   #3D47,PRT_MSG_HL    Continue until message end is reached.

THE 'ERROR MESSAGES' TABLE
The following table contains the DISCiPLE's error messages. Each message starts with
it's error number.

3D51 ERR_MSGS   DEFB #00
3D52            DEFM "Nonsense in GDOS"
3D62            DEFB #01
3D63            DEFM "Nonsense in GNOS"
3D73            DEFB #02
3D74            DEFB "Statement END error"
3D87            DEFB #03
3D88            DEFM "BREAK requested"
3D97            DEFB #04
3D98            DEFM ",SECTOR error"
3DA5            DEFB #05
3DA6            DEFM "FORMAT data lost"
3DB6            DEFB #06
3DB7            DEFM "NO DISC in drive"
3DC7            DEFB #07
3DC8            DEFM "No "SYSTEM" file"
3DD8            DEFB #08
3DD9            DEFM "Invalid FILE NAME"
3DEA            DEFB #09
3DEB            DEFM "Invalid STATION"
3DFA            DEFB #0A
3DFB            DEFM "Invalid DEVICE"
3E09            DEFB #0B
3E0A            DEFM "VARIABLE not found"
3E1C            DEFB #0C
3E1D            DEFM "VERIFY failed"
3E2A            DEFB #0D
3E2B            DEFM "Wrong FILE type"
3E3A            DEFB #0E
3E3B            DEFM "MERGE error"
3E46            DEFB #0F
3E47            DEFM "CODE error"
3E51            DEFB #10
3E52            DEFM "PUPIL set"
3E5B            DEFB #11
3E5C            DEFM "Invalid CODE"
3E68            DEFB #12
3E69            DEFM "Reading a WRITE file"
3E7D            DEFB #13
3E7E            DEFM "Writing a READ file"
3E91            DEFB #14
3E92            DEFM "O.K. GDOS 3"
3E9D            DEFB #15
3E9E            DEFM "Network OFF"
3EA9            DEFB #16
3EAA            DEFM "Wrong DRIVE"
3EB5            DEFB #17
3EB6            DEFM "Disc write PROTECTED"
3ECA            DEFB #18
3ECB            DEFM "Not enough SPACE on disc"
3EE3            DEFB #19
3EE4            DEFM "Directory FULL"
3EF2            DEFB #1A
3EF3            DEFM "File NOT FOUND"
3F01            DEFB #1B
3F02            DEFM "END of file"
3F0D            DEFB #1C
3F0E            DEFM "File NAME used"
3F1C            DEFB #1D
3F1D            DEFM "Not a MASTER station"
3F31            DEFB #1E
3F32            DEFM "STREAM used"
3F3D            DEFB #1F
3F4E            DEFM "CHANNEL used"

3F4A - 3FFF     Unused locations (all set to #00).
Previous Next Contents Index