Previous Next Contents Index
Miscalleneous routines

After the syntax of the 'new' commands has been checked, a jump is made here to confirm
that the statement is finished. An error is given when it isn't finished. A return to
the calling routine is made only during runtime, otherwise the control returns to the
'main' ROM interpreter.

2155 ST_END_ROM CALL #002C,GET_C_ROM     Get the current character.
2158            CP   13
215A            JR   Z,#2161,TEST_RET    Jump if the statement ends with ENTER.
215C            CP   ":"                 Give an error if statement doesn't end
215E            JP   NZ,#2924,REP_2      with a colon.
2162            RET  NZ                  Return during runtime.
2163            JR   #2169,END1

The control is returned to the BASIC interpreter for interpretation of the next

2165 END        CALL #0403,TEST_SERV
2168            RET  NZ                  Exit if serving the network.
2169 END1       LD   SP,(23613)          Clear machine stack (ERR_SP).
216D            LD   (IY+0),#FF          Clear error code (ERR_NR).
2171            LD   HL,#1BF4,STMT_NEXT  Return address in 'main' ROM is
2174            RST  #30,SYNTAX_Z        'STMT_NEXT' during syntax checking.
2175            JP   Z,#004F,UNPAGE_HL
2178            LD   HL,#1B7D,STMT_R_1   Return address during runtime is
217B            CALL #0181,TST_BREAK     But first test for BREAK.
217E            JP   #004F,UNPAGE_HL     No BREAK so jump to Spectrum ROM.

Test for BREAK key and jump to error routine if pressed.

2181 TST_BREAK  LD   A,#7F
2183            IN   A,(254)
2185            RRA
2186            RET  C                   Return if SPACE wasn't pressed.
2187            LD   A,#FE
2189            IN   A,(254)
218B            RRA
218C            RET  C                   Return if CAPS wasn't pressed.
218D            JP   #2926,REP_3

This routine calls the required 'main' ROM routine.

2190 CALBAS_2   LD   (#1AC5),DE          Free DE and HL.
2194            LD   (#1AC8),HL
2197            POP  HL                  Get return address, points to address
2198            LD   E,(HL)              of 'main' ROM routine to be called.
2199            INC  HL                  Fetch address of routine to be called.
219A            LD   D,(HL)
219B            INC  HL
219C            PUSH HL                  Push the new return address.
219D            LD   HL,#1DE5
21A0            LD   (HL),#47            Signal 'CALBAS executing'.
21A2            LD   HL,#0066            Return address to DISCiPLE system is
21A5            PUSH HL                  'NMI_ROM'.
21A6            PUSH DE                  Push address of routine to be called.
21A7            LD   HL,(#1AC8)          Restore callers HL and DE.
21AA            LD   DE,(#1AC5)
21AE            JP   #0050,UNPAGE_1      Do the CALBAS.

The following 11 bytes form the file description (directory description and filename)
of a System-file.

21B1            DEFB 4
21B2            DEFM "SYS*      "

The RUN command loads the system file, this routine is only reached when the DISCiPLE
isn't initialized as a PUPIL station.

21BC RUN        RST  #30,SYNTAX_Z        Exit immediately if syntax is being
21BD            JP   Z,#0165,END         checked.
21C0            LD   IX,#1AC3
21C4            LD   A,1                 Signal 'drive 1 is being used'.
21C6            LD   (IX+11),A
21C9            LD   A,%00010001         Set drive 1 and DISCiPLE on.
21CB            LD   (#1DDA),A           Store it in the control port state.
21CE            OUT  (31),A              Activate.
21D0            CALL #3030,REST          Move drive head to track 0.
21D3            LD   HL,#01B1            Copy the file description to UFIA1.
21D6            LD   DE,#1E05
21D9            LD   BC,11
21DC            LDIR
21DE            LD   A,8                 Signal 'matching name and directory
                                         description have to be found'.
21E0            CALL #335B,SCAN_CAT      Search for the file.
21E3            JP   NZ,#292E,REP_7      Give 'No "SYSTEM" file' error when file
                                         not found.
21E6            RST  #10,CALBAS          Clear the whole screen.
21E7            DEFW #0DAF,CL_ALL
21E9            CALL #3C38,MESG_0        Print the 'SYSTEM LOADING' message.
21EC            CALL #35C2,LOAD_1ST      Copy the file description (directory
                                         description and filename) to UFIA2 and
                                         load the first sector of the file into
                                         the disk buffer.
21EF            LD   HL,#1BD6            Copy the file header (the 9 bytes
21F2            LD   DE,#1E29            consisting of filetype, length, etc.)
21F5            LD   BC,9                to UFIA2.
21F8            LDIR
21FA            LD   (IX+13),9           Update the buffer pointer for the bytes
21FE            LD   HL,#020C,LOAD_SYS   read.
2201            LD   DE,#1E3D            Because the current routine is executed
2204            LD   BC,13               in RAM (see #028E and further) and that
2207            LDIR                     is where the system-file will be
                                         LOADed, all this will be overwritten.
                                         So copy the next routine to a safe
2209            JP   #1E3D,LOAD_SYS      place and jump to it. (Was it not
                                         possible to PUSH the #0013 and jump to
                                         #3145 ?)
220C LOAD_SYS   LD   DE,(#1E2A)          Fetch the systemfile's length.
2210            LD   HL,#0000            Loadaddress is #0000.
2213            CALL #3145,LOAD_FILE     Load the system.
2216            JP   #0013,INIT_SYS      Exit via 'INIT_SYS'.
2219            DEFB #00                 Unused location.
Previous Next Contents Index