![]() |
Routines |
Prev: 02050 | Up: Map |
Used by the routine at SAVE_ETC.
This routine controls the LOADing of a BASIC program, and its variables, or an array.
|
|||||||||||
LD_CONTRL | 02056 | LD E,(IX+11) | Fetch the 'number of bytes' as given in the 'new header'. | ||||||||
02059 | LD D,(IX+12) | ||||||||||
02062 | PUSH HL | Save the 'destination pointer'. | |||||||||
02063 | LD A,H | Jump forward unless trying to LOAD a previously undeclared array. | |||||||||
02064 | OR L | ||||||||||
02065 | JR NZ,LD_CONT_1 | ||||||||||
02067 | INC DE | Add three bytes to the length - for the name, the low length and the high length of a new variable. | |||||||||
02068 | INC DE | ||||||||||
02069 | INC DE | ||||||||||
02070 | EX DE,HL | ||||||||||
02071 | JR LD_CONT_2 | Jump forward. | |||||||||
Consider now if there is enough room in memory for the new data block.
|
|||||||||||
LD_CONT_1 | 02073 | LD L,(IX-6) | Fetch the size of the existing 'program+variables or array'. | ||||||||
02076 | LD H,(IX-5) | ||||||||||
02079 | EX DE,HL | ||||||||||
02080 | SCF | Jump forward if no extra room will be required (taking into account the reclaiming of the presently used memory). | |||||||||
02081 | SBC HL,DE | ||||||||||
02083 | JR C,LD_DATA | ||||||||||
Make the actual test for room.
|
|||||||||||
LD_CONT_2 | 02085 | LD DE,5 | Allow an overhead of five bytes. | ||||||||
02088 | ADD HL,DE | ||||||||||
02089 | LD B,H | Move the result to the BC register pair and make the test. | |||||||||
02090 | LD C,L | ||||||||||
02091 | CALL TEST_ROOM | ||||||||||
Now deal with the LOADing of arrays.
|
|||||||||||
LD_DATA | 02094 | POP HL | Fetch the 'pointer' anew. | ||||||||
02095 | LD A,(IX+0) | Jump forward if LOADing a BASIC program. | |||||||||
02098 | AND A | ||||||||||
02099 | JR Z,LD_PROG | ||||||||||
02101 | LD A,H | Jump forward if LOADing a new array. | |||||||||
02102 | OR L | ||||||||||
02103 | JR Z,LD_DATA_1 | ||||||||||
02105 | DEC HL | Fetch the 'length' of the existing array by collecting the length bytes from the variables area. | |||||||||
02106 | LD B,(HL) | ||||||||||
02107 | DEC HL | ||||||||||
02108 | LD C,(HL) | ||||||||||
02109 | DEC HL | Point to its old name. | |||||||||
02110 | INC BC | Add three bytes to the length - one for the name and two for the 'length'. | |||||||||
02111 | INC BC | ||||||||||
02112 | INC BC | ||||||||||
02113 | LD (23647),IX | Save the IX register pair temporarily (in X-PTR) whilst the old array is reclaimed. | |||||||||
02117 | CALL RECLAIM_2 | ||||||||||
02120 | LD IX,(23647) | ||||||||||
Space is now made available for the new array - at the end of the present variables area.
|
|||||||||||
LD_DATA_1 | 02124 | LD HL,(23641) | Find the pointer to the end-marker of the variables area - the '128-byte' (E-LINE). | ||||||||
02127 | DEC HL | ||||||||||
02128 | LD C,(IX+11) | Fetch the 'length' of the new array. | |||||||||
02131 | LD B,(IX+12) | ||||||||||
02134 | PUSH BC | Save this 'length'. | |||||||||
02135 | INC BC | Add three bytes - one for the name and two for the 'length'. | |||||||||
02136 | INC BC | ||||||||||
02137 | INC BC | ||||||||||
02138 | LD A,(IX-3) | 'IX+0E' of the old header gives the name of the array. | |||||||||
02141 | PUSH AF | The name is saved whilst the appropriate amount of room is made available. In effect BC spaces before the 'new 128-byte'. | |||||||||
02142 | CALL MAKE_ROOM | ||||||||||
02145 | INC HL | ||||||||||
02146 | POP AF | ||||||||||
02147 | LD (HL),A | The name is entered. | |||||||||
02148 | POP DE | The 'length' is fetched and its two bytes are also entered. | |||||||||
02149 | INC HL | ||||||||||
02150 | LD (HL),E | ||||||||||
02151 | INC HL | ||||||||||
02152 | LD (HL),D | ||||||||||
02153 | INC HL | HL now points to the first location that is to be filled with data from the tape. | |||||||||
02154 | PUSH HL | This address is moved to the IX register pair; the carry flag set; 'data block' is signalled; and the block LOADed. | |||||||||
02155 | POP IX | ||||||||||
02157 | SCF | ||||||||||
02158 | LD A,255 | ||||||||||
02160 | JP LD_BLOCK | ||||||||||
Now deal with the LOADing of a BASIC program and its variables.
|
|||||||||||
LD_PROG | 02163 | EX DE,HL | Save the 'destination pointer'. | ||||||||
02164 | LD HL,(23641) | Find the address of the end marker of the current variables area - the '128-byte' (E-LINE). | |||||||||
02167 | DEC HL | ||||||||||
02168 | LD (23647),IX | Save IX temporarily (in X-PTR). | |||||||||
02172 | LD C,(IX+11) | Fetch the 'length' of the new data block. | |||||||||
02175 | LD B,(IX+12) | ||||||||||
02178 | PUSH BC | Keep a copy of the 'length' whilst the present program and variables areas are reclaimed. | |||||||||
02179 | CALL RECLAIM_1 | ||||||||||
02182 | POP BC | ||||||||||
02183 | PUSH HL | Save the pointer to the program area and the length of the new data block. | |||||||||
02184 | PUSH BC | ||||||||||
02185 | CALL MAKE_ROOM | Make sufficient room available for the new program and its variables. | |||||||||
02188 | LD IX,(23647) | Restore the IX register pair from X-PTR. | |||||||||
02192 | INC HL | The system variable VARS has also to be set for the new program. | |||||||||
02193 | LD C,(IX+15) | ||||||||||
02196 | LD B,(IX+16) | ||||||||||
02199 | ADD HL,BC | ||||||||||
02200 | LD (23627),HL | ||||||||||
02203 | LD H,(IX+14) | If a line number was specified then it too has to be considered. | |||||||||
02206 | LD A,H | ||||||||||
02207 | AND 192 | ||||||||||
02209 | JR NZ,LD_PROG_1 | Jump if 'no number'; otherwise set NEWPPC and NSPPC. | |||||||||
02211 | LD L,(IX+13) | ||||||||||
02214 | LD (23618),HL | ||||||||||
02217 | LD (IY+10),0 | ||||||||||
The data block can now be LOADed.
|
|||||||||||
LD_PROG_1 | 02221 | POP DE | Fetch the 'length'. | ||||||||
02222 | POP IX | Fetch the 'start'. | |||||||||
02224 | SCF | Signal 'LOAD'. | |||||||||
02225 | LD A,255 | Signal 'data block' only. | |||||||||
02227 | JP LD_BLOCK | Now LOAD it. |
Prev: 02050 | Up: Map |