CP75 -- Cassette to Printer Direct tansfer of HP-75 TEXT file using an HP-41 by Michael Markov Required : HP-41 with HP-IL module & HP-IL Development (DEVIL) ROM. Description : HP-41 users now can access HP-75 TEXT files on mass storage and either view such files, or produce printed listing on HP-IL 80 column printers. CP75 is very similar to another program called CPDEVIL, that allows HP-41 users to access LIF1 type text files, to include HP-41 AS(CII), HP-71 TEXT, HP71 S(ecured) TEXT and HP-75 LIF1 files. The main difference is in the output routine, with changes that reflect the slightly different structure of HP-75 Text files. User instructions are identical for all CP programs, please refer to CPDOC and CPDEVDOC for such instructions. HP-75 mass storage Text file Structure : The first eighteen bytes are a copy of the HP-75 RAM catalog entry. This is standard for all HP-75 files, excepting LIF1 Interchange files. The sixth byte is the file type identifier, "T", for Text. The catalog entry is followed by a 10 byte Program Control Block, or PCB. This is all nulls, and should be ignored. Thereafter, we see the text file lines, beginning with a two byte BCD coded line number. This is followed by a SINGLE byte that gives the lenght of the text that follows, in bytes. This is repeated until you reach end-of-file. End-of-file is "99 A9 02 8A 0E". Since the "99 A9" is found in the line number field, and since the maximum line number is "99 99", recognition is easy enough. Notice the clear implication of the 1 byte length of Text specifier: The absolute maximum length HP-75 text file is 255 bytes + 4 byte line number. This corresponds fairly closely with HP-41 internal format. However, the HP-75 is more limited than that, 96 character lines is the most you can handle. NOTE: Jan G. Buitenhuis wrote an HP-71 routine that does the same job. The HP-41 routine here presented was developed much later. Thanks for the idea, Jan! The CP75 routine is much slower than any other CP routine. It could be greatly speeded-up with an MCODE QR(Quotend-Remainder) function. This would make the line number decoding process much easier. The method here used was not optimized, the sole intent was developing something that works without using functions not available in an HP-41C + HP-IL + DEVIL. HP-75 owners should still try to provide swapdisk files in LIF1 format, since any improvement in CP75 is bound to be still slower than CPDEVIL. Please? For detailed comments, see CPDEVDOC. Comments included in this file address the code used to handle HP-75 Text files. LBL "CP75" . STO 00 STO 01 STO 02 MANIO CF33 E AAU AAD E - E3 / SIGN ST+ L LBL 00 LASTX UNT TAD SAI UNT 64 X<=Y? GTO 01 RDN 48 X<=Y? GTO 02 RDN 32 X<=Y? GTO 03 RDN 16 X=Y? GTO 04 LBL 01 ISG L GTO 00 GTO 05 LBL 02 LASTX X<> 02 X0? X<> 02 GTO 01 LBL 03 LASTX X<> 01 X0? X<> 01 GTO 01 LBL 04 LASTX X<> 00 X0? X<> 00 GTO 01 LBL 14 error exit if not an HP-75 Text file "NOT T-75" GTO 13 here error exit automatically restore normal I/O operations LBL 99 "NO OUT. DEV" LBL 13 AVIEW BEEP GTO 15 LBL 05 RCL 02 FS? 21 RCL 01 X=0? GTO 99 RCL 00 X=0? AUTOIO X=0? DIR SELECT LAD SDC UNL TAD 2 DDT DDT 256 BSIZEX MIPT " " LBL 09 0 PT= LBL 10 32 INBUFX 10 A=BUFX? GTO 11 GTO 10 LBL 11 10 PT= 2 BUF-XB X=0? GTO 09 14 PT= UNT RCL 00 LAD 4 DDL 2 OUTBUFX LBL 08 INSTAT FS? 05 GTO 08 UNL RCL 00 TAD 2 DDT 0 PT= 10 CLA BUF-AX 28 we start by copying the catalog entry and PCB into the buffer, INBUFX (28 byte of junk) 5 check to make sure type byte in catalog is "T" - buffer pointer PT= is zero based 1 get value of byte in X BUF-XB 84 decimal value for "T" XY? not equal? GTO 14 sorry, we only do T-75 files. go to error exit LBL 06 the mass storage to output device loop UNL RCL 00 TAD 0 DDT PT= SF33 0 ENTER^ 193 WREG CF33 3 get BCD coded line number and line length byte INBUFX (3 byte line header) 2 get line number value BUF-XB 39337 is it equal to start of End-of-file value? X=Y? GTO 15 yes, we are done, go clean-up the act & END RDN now, we start decoding the line number. In BASIC, we would do 240 HEX$(REV$(A$[1,2])) - both HP-75 & HP-71. Here, we basically get AND the value of each nibble (0-9, since BCD), add 48 to convert 16 each nibble to an ASCII character "0" to "9". We build the line / number in buffer from PT=4 to PT=7. 48 "abcd" becomes "CDAB", where C(byte)=c(nibble)+48, ect. + just finished getting "C" 4 PT= RDN X-BUF store "C" in buffer 1 PT= now, we go after the "d" nibble BUF-XB 16 MOD X reg. now holds "d" 48 + convert to "D" 5 and store it in buffer PT= RDN X-BUF 0 now, we go get & convert "a" to "A" PT= 1 BUF-XB 16 / 48 + 6 PT= RDN X-BUF store "A" in buffer 0 and, finally, we process "b" PT= 1 BUF-XB 16 MOD 48 + convert to "B" 7 PT= RDN X-BUF and we have finally built our line number UNT so, we set-up to send it out to the output device(s) FS? 21 RCL 01 FC? 21 RCL 02 LAD 4 and send them out, having converted two bytes into four PT= OUTBUFX RCL 00 now, we set-up the direct transfer for the text of the line TAD 0 DDT 2 PT= position of third byte, the Length-of-Text byte in the buffer 1 and into X. BUF-XB INBUFX does the direct transfer UNT 3338 and we send CR;LF; to the output device OUTBIN GTO 06 that all there is to it! Easy, no? LBL 15 UNL UNT 0 BSIZEX AUTOIO CF33 END