Micro­power

  

Volume 1 · Number 4 · December 1981

Page 30 of 33

WRITE W xxxx yyyy

The write routine first switches on the cassette LED; it then waits for approximately one second, which allows the cassette recorder speed to stabilise if you are using the LED signal to control your recorder. The output table pointer is then reset to its normal value, so that output is sent only to screen. This ensures that a user routine will not interfere with the operation of the write routine. The address stored at £0C73 is saved on the stack, and restored at the end of the write routine.

After 256 nulls have been output to the serial port the data is output in blocks of 256 bytes, preceded by a null and four ‘FF’s, a header which gives the start address of the block, the length and number of the block, and a checksum for the header data. The start address and the length and number of the block are printed on the screen, but all other bytes are output only to the serial port; output through this port is by direct call to the serial routine, and does not use the output table and its pointer. The block of data is then output, followed by ten nulls. The purpose of all these nulls is to ensure that if several bytes of data are missed when the tape is read, the start of the next block header, marked by four ‘FF’s, will not be missed. If there were no nulls the READ routine would continue until it detected the correct number of bytes, accepting one or more of the ‘FF’s, and it would then miss the following block and only start reading again when the next block start was detected.

When all the data has been written the routine jumps to the end of the READ routine, using the same code to reset the output pointer. If you wish to make several copies of the same data, which is always advisable, you do not need to re-enter the arguments – just enter W and the previous arguments, which are still at 0C0C and 0C0E, will be used again. If you are too lazy to do even this, a simple modification to the WRITE routine will make it unnecessary. Instead of jumping to the end of READ, first execute the following code:–

21 10 0CLD HL, £0C10; Point HL to ARG3
35 DEC (HL) ; Decrement ARG3
C2 XX XXJP NZ, REWRT ; Continue if non-zero
C3 YY YYJP RDEND ; Jump to end of READ

For Nas-Sys 1 the address XXXX is £04EF; for Nas-Sys 3 it is £502. Address YYYY is the end of the READ routine, where the table pointer is reset. If you use the modified READ routine given in the last article, you will find that there is room for extra WRITE code at the end, and the final jump can be a relative one. Incidentally, there is a misprint in the listing on page 30 of the last issue; from line 32 it should read:–

CF R2RST RIN ; GET CHARACTER
3C INC A ; IS IT FF?
20FA JR NZ, R1; IF NOT, KEEP LOOKING

–       –       –       –       –       –       –       –       –       –       –       –       –

Page 30 of 33