80-Bus News

  

July–August 1984 · Volume 3 · Issue 4

Page 14 of 43

A Pascal Print Routine

by P. A. Forrester

Dr. Dark has frequently extolled the virtues of Pascal as a programming language and I admit to sharing his enthusiasm; however, the programs which have been published in 80-BUS News so far have been mainly for illustrative purposes rather than to achieve anything useful. The following program is offered in the hope that it may be useful to members experimenting with BLS Pascal. The excellent editor provided with this compiler is slightly flawed by there being no simple method of printing the contents of the source buffer on a serial printer equivalent to that offered by the ZEAP U command. The recommended way is to mark the beginning and end of the buffer with control symbols and then direct the output to a user-defined print program. I think that a better solution is to use a separate program which gives a more complete control of the print process. My solution is to keep a copy of the compiled code generated by the following program at the top end of the memory and call it whenever I wish to print the source code of a new program.

The program assumes that the source code starts at 4000H and uses the pointer at 0C82H to locate the end. When called, the printer BUSY line, which is connected to bit 7 of Port 0, is checked to ensure that it is ready to receive a character. The edit buffer only uses 0DH for carriage-return (CR), so the program has to add an 0AH to produce a line feed (LF). It also counts the number of CRs transmitted and when this equals the value held in ‘lines.page’, a number of CRLFs is sent which is determined by the value stored in ‘spaces’; this gives automatic pagination. The values can be set at the start of the program or the default values of 60 and 8 used. Printing can be stopped temporarily by pressing the space-bar or aborted by ESC. As the text is transmitted, the procedure ‘Writewindow’ displays the next 32 characters in a ticker-tape fashion in the centre of the screen and gives a good indication that all is progressing well. The procedure produces a slight delay to the print rate of an Epson FX-80 run at full speed when written in Pascal. This can be overcome by using a machine-code version called as a CODE routine; the ZEAP segment shows how this works. I hope the workings of the program can be followed from the source code. A further refinement would be to provide a means of printing only part of the source buffer, either by asking for start and finish addresses, or by inserting markers into the text. However, the program then starts to become quite complex by the time you have devised a means of entering numbers in hex or a suitable means of coping with markers which stray into the negative integer region.

Page 14 of 43