home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug034.arc
/
PRINTPRN.ASM
< prev
next >
Wrap
Assembly Source File
|
1979-12-31
|
5KB
|
159 lines
*****************************************
* *
* PRINTER PROGRAM FOR CROWE PRN FILES *
* EXPANDS TAB WITH NO COL RESET ON LF *
* PRN.COM by Dennis E Baker 8/8/82 *
* *
*****************************************
CPMENT EQU 5 ;CP/M ENTRY POINT
KBSTAT EQU 11 ;KEYBOARD STATUS
OPNFIL EQU 15 ;OPEN FILE FUNCTION#
PRNCHR EQU 5 ;PRINTER FUNCTION
RDSEQ EQU 20 ;SEQUENTIAL READ FUNCTION
SETDMA EQU 26 ;SET ADDRESS FOR READ
T EQU 255 ;TERMINATOR
ORG 100H
START: LXI H,FCB+12 ;INIT FILE CONTROL BLOCK
MVI B,28! SUB A
CLR1: MOV M,A! INX H ;CLEAR REMAINDER
DCR B! JNZ CLR1
CALL CLRBUF ;RESET BUFFER TO SPACES
MVI A,9
STA IGNOR
LDA 83H! CPI ':' ;TEST DRIVE SPEC
LXI D,82H! JNZ NAME
LDA 82H! ANI 5FH ;GET DRIVE SPEC UPPER CASE
CPI 'A'! RM ;A-D OK
CPI 'E'! RP
SUI 64! STA FCB ;SET DRIVE
INX D! INX D
NAME: MVI B,8! LXI H,FCB+1
NMLP: LDAX D! ORA A
JZ OPEN
MOV M,A
INX D! INX H
DCR B! JNZ NMLP
OPEN: LXI D,FCB
MVI C,OPNFIL
CALL CPMENT ;OPEN THE FILE
CPI T! RZ
LDA FCB+15 ;NO. OF BLOCKS
ORA A! RZ
STA SECT ;SAVE
PLOOP: MVI A,64 ;64*128 = 8K BUFFER
STA CNTR
LDA SECT
CPI 9! JP OVER
ANA A! RAL ;X8
RAL! RAL
STA CNTR
JMP PRINT
OVER: SUI 8! STA SECT ;ADJUST
CALL PRINT
JMP PLOOP
PRINT: LXI H,BUFFER ;READ & PRINT BUFFER
SHLD PNTR
RDLOOP: LHLD PNTR! XCHG ;GET 128 BLOCK
LXI H,128! DAD D
SHLD PNTR
MVI C,SETDMA ;SET ADDRESS
CALL CPMENT
LXI D,FCB ;NOW READ SEQUENTIAL
MVI C,RDSEQ
CALL CPMENT
LXI H,CNTR! DCR M ;CNTR-1
JNZ RDLOOP
LXI H,BUFFER ;SET FOR PRINTOUT
SHLD PNTR
LXI H,8192 ;BUFFER LENGTH
PRLOOP: SHLD BUFCNT ;SET COUNTER
MOV A,H! ORA L! RZ
LHLD PNTR
MOV A,M! INX H
SHLD PNTR
CPI 13! JZ CR ;CAR RET
CPI 9! JZ TAB ;TAB
CPI 10! JZ LF ;LINE FEED
CPI 12! JZ CHRBAK ;FORM FEED
CPI 26! JZ ENDOUT ;END ON 26
MOV B,A ;SAVE
LXI H,TABCNT
MOV E,M! INR M
MVI D,0
LXI H,PBUFER
DAD D! MOV M,B ;PLACE CHARACTER
CHRBAK: LHLD BUFCNT! DCX H ;CNTR-1
JMP PRLOOP
TAB: LXI H,TABCNT! INR M
MOV A,M! ANI 7 ;TEST TAB END
JNZ TAB
JMP CHRBAK
CR: SUB A! STA TABCNT ;CARR RETURN
JMP CHRBAK
LF: CALL PRNTBF ;LINE FEED
JMP CHRBAK
ENDOUT: CALL PRNTBF
JMP 0
PRNTBF: LDA IGNOR
ORA A
JZ CONT
DCR A
STA IGNOR
RET
CONT: LXI H,PBUFER+130 ;TERM & PRINT BUFFER
MVI B,131
PRNT1: MOV A,M! DCX H
CPI ' '! JNZ PRNT2
DCR B! JNZ PRNT1
PRNT2: INX H! INX H! MVI M,T
LDA PBUFER+6
CPI 'Z'! CZ CRLF ;EXTRA LINE BEFORE CROWE HEADING
LXI H,PBUFER
SHLD PRPNTR
LINLOP: LHLD PRPNTR ;CHAR LOOP
MOV A,M! INX H
SHLD PRPNTR
CPI T! JZ ENDLIN
CALL CHROUT
JMP LINLOP
ENDLIN: CALL CRLF
MVI C,KBSTAT ;CHECK KEYBOARD
CALL CPMENT
DCR A! JZ 0 ;EXIT ON ANY KEY
CLRBUF: LXI H,PBUFER+131 ;CLEAR BUFFER
MVI M,T! DCX H
MVI B,131! MVI A,' '
CLR2: MOV M,A! DCX H
DCR B! JNZ CLR2
RET
CRLF: MVI A,13 ;CARR RET
CALL CHROUT
MVI A,10
CHROUT: MOV E,A ;CHARACTER OUT
MVI C,PRNCHR
JMP CPMENT
SECT: DB 0 ;NUMBER OF SECTORS
CNTR: DB 0 ;SECT COUNTER
IGNOR: DB 0 ;IGNOR COUNTER
TABCNT: DB 0 ;COL COUNTER
PNTR: DW 0 ;BUFF POINTER
BUFCNT: DW 0 ;BUFF CHAR COUNT
PRPNTR: DW 0 ;PRINTER COL POINTER
PBUFER: DS 132 ;PRINTER BUFFER
FCB: DB 0,' PRN' ;FILE CONTROL BLOCK
DS 28
BUFFER: DB 0 ;START OF 4096 CHAR BUFF
END