Micro­power

  

Volume 1 · Number 3 · November 1981

Page 30 of 33

buffer? Wherever you put it, sooner or later you will want to load a program to that location. The only solution seems to be to use the screen RAM for temporary storage. The program therefore starts by clearing the screen; as it uses the margins as well as the ‘visible’ screen RAM, it also clears the screen at the end of the routine to restore the zeroes which the delineate the margins. A tally is kept on the screen of blocks which have been read correctly, and when all the blocks have been obtained the routine stops.

The revised Read incorporates the ‘load offset’ of Nas-Sys 3. A second argument can be used to force transfer of data from the buffer to memory, even when the checksum is wrong. This ensures that if you only have one copy of a program, and a persistent error on the tape, you don’t loose the whole block.

Because bad data is not written to memory, it is not necessary to use a separate verify command. To verify a tape you have just recorded you merely read it back with the R command – if the recording was faulty it will not corrupt the stored program. Therefore the routine does not test the value stored at ARGX (£0C2B), which is how the standard Nas-Sys routine distinguishes between Read and Verify. Consequently unless you change the address for the V command this will also read a tape into memory.

EF0C00READDEFB £EF £0C 00; CLEAR SCREEN
DF5FSCAL ZMFLP; TURN ON TAPE LED
DF77SCAL ZNNOM; RESET OUTPUT TABLE ADDRESS
E5PUSH HL; SAVE OLD ADDRESS ON STACK
DF78SCAL ZNNIM; RESET INPUT TABLE ADDRESS
E5PUSH HL; SAVE OLD ADDRESS ON STACK
0604R1LD B, 4; LOOK FOR 4 CHARS.
CFR2RST RIN; GET CHARACTER
3CJR NZ, R1;T44; IF NOT, KEEP LOOKING
10FADJNZ R2; HAVE WE GOT 4 YET?
CFRST RIN; NOW GET HEADER BYTES
6FLD L, A; FIRST BYTE INTO L REG.
CFRST RIN; SECOND BYTE
67LD H, A; INTO L REGISTER
CFRST RIN; THIRD BYTE
5FLD E, A; INTO E REGISTER
CFRST RIN; FOURTH BYTE
57LD D, A; INTO D REGISTER
EF1B00DEFB £EF £1B 00; PUT CURSOR BACK TO START
4FLD C, A; SET C TO ZERO
DF6CSCAL ZTX1; PRINT HL, DE: GET CHECKSUM
CFRST RIN; GET NEXT BYTE
B9CP C; COMPARE WITH CHECKSUM
20E6JR NZ, R1; IF WRONG, START AGAIN
48LD C, B; SET C TO ZERO
43LD B, E; PUT BLOCK LENGTH INTO B
E5PUSH HL; SAVE HL
21000ALD HL, £0A00; SET HL TO BUFFER START
CFR3RST RIN; GET DATA BYTES
77LD (HL) A; PUT INTO BUFFER
23INC HL; INCREMENT BUFFER ADDRESS
81ADD A, C; CHECKSUM CALCULATION
4FLD C, A; SAVE IN C
Page 30 of 33