Nascom Newsletter |
Volume 3 · Numbers 5 & 6 · June 1984 |
Page 37 of 69 |
---|
This program adds several short routines to the straight print routine that I have been using with my printer, a Centronics 737.
The machine-dependent part of the routine has been put at the end, so that if you have some other printer you can replace the ‘PRINT’ subroutine with your own. The whole program is fully relocatable with the proviso that the two registers immediately precede it. The FNDSTR subroutine is only in the program to make it fully relocatable and a space has been left so that 0C82 to 0C84 can be replaced by 21 YY XX, where XXYY is the address of the first register.
If the FNDSTR subroutine is removed then all relative calls to the PRINT subroutine will nedd to be recalculated. For those of you not familiar with machine code, the Nas-Sys ‘A’ command can be used. For example, the new address of PRINT would be 0CED. To calculate the new RCAL2 enter ‘A 0C8D 0CED’. On the next line would appear ‘197A 0060 5E’. The last figure is the relative jump so 65H at 0C8E would be replaced by 5EH.
One minor fault with the relative call is that it is unconditional so two further bytes can be saved in lines 57 to 59 and 62 to 64 by replacing the two instructions with ‘CALL NZ,LFOUT’. The high nibble of the first register is used as a flag register with the low nibble as a store for the number of spaces to be printed in a margin.
The first flag (bit 4) is set after a CR. The Centronics printer uses a CR as a print instruction, with a LF being output only if there are other characters in the print buffer. If ther are consecutive CRs then the subsequent ones will be ignored by the printer and so the check is made of the flag and, if set, a LF followed by a CR is output. The CR is output in case the following line has 80 characters, in which case there would be an overflow of the buffer and the last character would be printed on the following line.
The second flag (bit 5) is checked after a CR to see if double spacing is required. If so, LF followed by a CR is output.
The third flag (bit 6) is also checked after each CR. If it is set then a margin of up to 15 spaces is printed, the number being stored in the lower nibble of the register. This is obtained in line 68 where the AND instruction is used to delete the high nibble. A check is made that a umber has been entered or the pointer will print a margin of 255 spaces wide. At this point the CR flag is reset as if would cause an extra LF to be
Page 37 of 69 |
---|