Im Magazin „Microcomputing" wurde im Februar 1981 der folgende Artikel abgedruckt.
Ein kurzes Programm zum Ausdrucken von Textdateien mit Formatierung.
|
|
A Print Utility for CP/M
By Ken Barbier
If only I had a dollar for every time I have entered
PIP LST: = FILENAME.PRN
and gotten a garbage printout of an assembly-language program listing because I forgot to include [T8] on the end of the command line!
The peripheral interchange program (PIP) supplied with the CP/M operating system can perform a host of functions, including formatting of output to a line printer, but it insists that you teil it to expand the tabs.
Forget the [T8], and your listing will be all jammed together.
And I always forget.
In addition to amnesia, I also suffer from laziness.
Every unnecessary keystroke on a computer terminal is an insult to humanity (I dare you to ask me what I think of Pascal).
Since I can't remember all the magic words required by PIP, I wrote the Print program shown in
Listing 1.
Operating Print
Now when I want a printout of a file named (in this example) FILENAME.PRN, I simply have to enter
PRINT FILENAME
and out comes a listing, with tabs expanded to eight spaces, and with form feeds for each page and for the end of the listing.
Lacking one of the exotic word processors, I often use the ED program of CP/M to write letters, notes, operating instructions, product data sheets and similar examples of short texts.
I usually need more than one copy of such items and use a PRINT command to produce multiple copies (up to 255).
Simply enter
PRINT FILENAME 5
and out come five copies of FILENAME.PRN.
If the file to be printed has a file type other than PRN, it can be specified in the usual manner:
PRINT FILENAME.TYP
where .TYP agrees with the file type specification in the disk directory.
Print Program Features
The program is most useful on a single disk drive CP/M system but is fully compatible with multi-drivc systems.
When loaded, the program will pause and prompt the operator to place the read disk in the drive.
This lets you print a file that is not on the same disk as the PRINT.COM file.
After printing is complete, the program again pauses, allowing another swap of disks before reloading the CP/M operating system.
These pauses make life with a single disk drive system a little easier, but can be patched out of the program if not needed.
The minimum size of any file on a CP/M system is 1K bytes, and PRINT fits easily within 1K.
This lets you include operator prompts and error messages that are fully spelled out and easily understood.
For example, if a read checksum error is encountered when the file to be printed is being loaded into the computer memory, the program displays
READ ERROR! ENTER X TO ABORT
CR TO IGNORE_
and pauses, giving you the option of entering "X" to return to the operating system or entering a carriage return to ignore the error and print the data as read.
Other types of errors which are not recoverable are also flagged on the console, and a pause lets you swap disks before returning to the operating system.
If the file to be printed is larger than the available memory in the computer, it will be read into memory and printed in segments.
Multiple copies are still possible with large files, since the file is rewound at the end of each printout.
All disk operations and I/O are handled through the CP/M standard BDOS call, which is vectored through a jump instruction at memory location 5, so the program as listed should be compatible with any version of CP/M.
Add a Program and Gain 5K
In "CP/M for Single-Drive Systems" (Kilobaud Microcomputing, September 1980, p.94), I listed a Filecopy program for use on single disk drive CP/M Systems.
With such a system - typically consisting of a computer, one terminal, one printer and a single disk drive - there is little need for most of the features provided by PIP.
Adding Filecopy and Print to your Systems disk can eliminate the need for PIP, which takes up 7K bytes of disk space.
Each of the new programs fits in 1K, so erasing PIP results in a net gain of 5K bytes.
On a single-density minifloppy system, this provides an increase of more than 10 percent in the available user workspace!
Ken Barbier, Borrego Engineering, PO Box 1253,
Borrego Springs, CA 92004.
[Hier als 8080-Assembler Programm
und hier als Z80-Assembler Programm]
Eingescanned von
Werner Cirsovius
August 2002
© Microcomputing