Trailing-Edge
-
PDP-10 Archives
-
decuslib20-04
-
decus/20-0114/fprint.mac
There are 2 other files named fprint.mac in the archive. Click here to see a list.
TITLE FPRINT ---ROUTINE TO HANDLE COBOL LINE PRINTER FILES BCF JUNE 75
;
DEFINE WRITE (A)
< OUTSTR [ASCIZ/? /]
OUTSTR MESS1
OUTSTR [ASCIZ /A/]
CALLI 12 >
;
;
;
; AC'S
;
RPTR=0
CONCHR=1
TMP=2
CHR=3
CHN=2
CNTR=2
LINE=1
BIN=4
INDEX=5
;
IO.EOF=1B22
CR=15 ;CARRIAGE RETURN
LF=12 ;LINE FEED
VT=13 ;VERT TAB
FF=14 ;FORM FEED
DLE=20
DC1=21
DC2=22
DC3=23
DC4=24
;
;
EXTERN FUNCT.
INTERN FPRINT,FPSET
;
;
;
SUBTTLE INITILAIZATION ENTRY POINT
PAGE
;
;
; ENTRY POINT TO INITIALIZE THE PRINTER FILE
;
; ARGUEMENTS:
; CONTAB: CONTROL TAPE INDEX <0 THEN NONE>
; PAGSZE: # OF LINES PER PAGE <0 THEN DEFAULT 60>
; FILNEM: SIXBIT FILENAME AND EXTENTION FOR LPT FILE
; OVFLOW: ADDRESS TO SET TOP OF FORM INDICATOR
; BEFORE: FLAG FOR ADVANCING BEFORE/AFTER PRINTING
;
;
;
FPSET: DMOVEM 0,SAVE
DMOVEM 2,SAVE+2
DMOVEM 4,SAVE+4
HRRZ TMP,(16)
MOVE TMP,(TMP) ;GET TAPE CONTROL CHARACTER
MOVEM TMP,CONTAP ;SAVE IT
HRRZ TMP,2(16) ;GET ADDRESS OFFILENAME
DMOVE TMP,@(TMP) ;GET THE FILENAME AND EXT
MOVEM TMP,FILNME ;AND STORE
HLLZM TMP+1,FILNME+1
MOVE TMP,3(16)
HRRZM TMP,OVFLOW ;GET ADDRESS OFOVERFLOW FLAG
MOVE TMP,4(16) ;GET ADRESS OF ADVANCING FLAG
HRRZM TMP,ADVANC ;AND STORE
MOVE TMP,(TMP) ;GET ADVANCE FLAG
MOVEM TMP,BEFORE ;AND SET BEFOREFLAG
MOVE TMP,1(16)
SKIPN TMP,(TMP) ;LINE COUNT DEFAULT??
MOVEI TMP,^D56 ;YES--SET IT UP
MOVEM TMP,PAGSZE ;SET UP PAGE SIZE
SKIPL BEFORE
SOJ TMP,
MOVEM TMP,LNECNT
SKIPL CHN,CHANEL ;BEEN THROUGH BEFORE??
JRST GOTCHN ;YES THEN ALREADY HAVE CHANNEL
MOVEI 16,ARGBLK ;SET UP ARGUMENT LIST
PUSHJ 17,FUNCT. ;GO GET UNUSED CHANEL
SKIPE ERROR ;GOT ONE??
JRST CHNERR ;NOPE--ALL USED
MOVE CHN,ARG1 ;GET CHANNEL #
DPB CHN,[POINT 4,OPENI,12] ;PUT IT IN OPEN UUO
DPB CHN,[POINT 4,OUTI,12] ;AND OUT UUO
DPB CHN,[POINT 4,CLOSEI,12] ;AND CLOSE UUO
DPB CHN,[POINT 4,ENTI,12] ;AND ENTER UUO
MOVEM CHN,CHANEL
GOTCHN: XCT CLOSEI ;CLEAN THE CHANNEL
SKIPE CONTAP ;CARRAIGE CONTROL TAPE???
PUSHJ 17,TABSET ;YUP--GO SET IT UP
XCT OPENI ;OPEN IT
JRST OPERR
XCT ENTI ;DO AN ENTER ON THE FILENAME
JRST ENTERR
XCT OUTI ;DUMMY OUTPUT
JRST FFNSH
JRST OUTERR
;
;
FFNSH: DMOVE 0,SAVE
DMOVE 2,SAVE+2
DMOVE 4,SAVE+4
POPJ 17,
SUBTTL WRITE ENTRY POINT
PAGE
;
;
; ROUTINE TABSET: READS IN CARRAIGE CONTOL FILE
; AND SETS UP THE LINKED LIST
; TABLE OF CHANNEL SKIPS.
;
;
TABSET: DPB CHN,[POINT 4,INI,12] ;PUT CHANNEL NUMBER IN INPUT
DPB CHN,[POINT 4,LOOKI,12]
DPB CHN,[POINT 4,CHKEOF,12] ;AND IN STATUS
XCT OPENI ;OPEN THE CHANNEL
JRST OPERR
MOVE TMP,@CONTAP ;GET THE ADDRESS
MOVEM TMP,TCNFLE ;AND RESET
XCT LOOKI ;LOOKUP THE FILE
JRST LOOKER
SETZM FFREE
MOVE TMP,[XWD FFREE,SKPTAB] ;ZERO THE CHANNEL TABLE
BLT TMP,SKPTAB+11
ANLINE: PUSHJ 17,GETCHR ;GET A CHARACTER
JUMPL CHR,EOFFLE ;END OF FILE
PUSHJ 17,CONVR2 ;GO AND CONVERT
JUMPGE BIN,LINEOK ;FINE--GOT LINE NUMBER
ANLIN1: PUSHJ 17,CONVRT ;GET A CHANNEL NUMBER
JUMPL BIN,.-1 ;ERROR
LINEOK: MOVEI LINE,(BIN)
ANCHN: PUSHJ 17,CONVRT
JUMPL BIN,ANLINE ;END OF LINE
CAILE BIN,^D12 ;CHANNEL VALUE OK?
JRST SPCERR
HRRZ INDEX,SKPTAB(BIN) ;GET POINTER TO LINKED LIST
JUMPE INDEX,FTIME ;IF 0 FIRST TIME
DUNLST: HRRZ TMP,LLIST(INDEX) ;GET LINK
JUMPE TMP,ENDLST ;LAST ENTRY
MOVEI INDEX,(TMP) ;SET INDEX
JRST DUNLST ;AND BACK
ENDLST: AOS TMP,FFREE ;GET NEXT POINTER
HRLZM LINE,LLIST(TMP) ;SET LINE VALUE
HRRM TMP,LLIST(INDEX) ;AND POINTER
JRST ANCHN
FTIME: AOS INDEX,FFREE ;COUNT AND GET NEW POINTER
HRLZM LINE,LLIST(INDEX) ;SET LINE
HRRM INDEX,SKPTAB(BIN) ;SET POINTER INTO LINKED LIST
JRST ANCHN
;
EOFFL1: POP 17,
EOFFLE: XCT CLOSEI
POPJ 17,
;
PAGE
;
;
;
; ENTRY POINT FOR WRITING A RECORD
;
; ONE ARGUMENT --- 133 CHARACTER RECORD
; 1ST CHARACTER IS CARRAIGE CONTROL
; 132 CHARACTERS ARE PRINTER LINE
;
;;
;
;
FPRINT: DMOVEM 0,SAVE
DMOVEM 2,SAVE+2
DMOVEM 4,SAVE+4
HRRZ RPTR,(16)
MOVE RPTR,@RPTR ;GET POINTER TO OUTPUT STRING
SETZM @OVFLOW
SKIPE CONTAP ;ARE WE USING CARRIAGE CONTROL TAPE??
JRST TCNTRL ;YES INDEED
SKIPL @ADVANC ;ADVANCE BEFORE??
PUSHJ 17,ACNTRL ;YUP YUP!!
ILDB CONCHR,RPTR
TLNN RPTR,100 ;SIXBIT?
MOVEI CONCHR,40(CONCHR) ;CONVERT TO ASCII
SKIPL BEFORE
PUSHJ 17,CCNTRL
HRLZI CNTR,^D-132 ;GET CHARACTER COUNT
OUTIT: ILDB CHR,RPTR ;AND PICK UP A CHRACTER
TLNN RPTR,100 ; IS IT ASCII?
MOVEI CHR,40(CHR) ;NOPE -SIBIT SO CONVERT
PUSHJ 17,PUTCHR ;STUFF IT
AOBJN CNTR,OUTIT ;MORE??
SKIPGE @ADVANC ;ADVANCE AFTER??
PUSHJ 17,ACNTRL ;YUP
SKIPGE BEFORE
PUSHJ 17,CCNTRL
FPRET: MOVE TMP,BEFORE ;GET INITIAL VALUE
MOVEM TMP,@ADVANC ;AND RESET
JRST FFNSH
;
;
SUBTTL DEFAULT CARRAIGE CONTROL ROUTINES
PAGE
;
;
; HERE WE LOOK AFTER DEFAULT CARRIAGE CONTROL
;
;
CCNTRL: CAIN CONCHR,40 ;BLANK???
JRST SSPACE ;SINGLE SPACING
MOVEI CONCHR,-52(CONCHR) ;GET AS INDEX
CAILE CONCHR,11 ;TOO BIG??
JRST CONERR ;YES INDEED
JUMPL CONCHR,CONERR ;TOO SMALL??
MOVEI CHR,CR ;GET A CARRAIGE RETURN
PUSHJ 17,PUTCHR ;ZAP IT OUT
XCNTRL: XCT CTAB(CONCHR) ;AND GET LINE CONTROL CCHARRACTER
;
;
; TABLE FOR VARIOUSR LINE CONTROL CHARACTERS
;
;
CTAB: JRST SSPACE ;* ----SKIP TO NEXT LINE(NO FORM)
POPJ 17, ;+ ----LINE SURPRESS
JRST DSPACE ; ----DOUBLE SPACE
JRST TSPACE ;- ----TRIPLE SPACE
JRST TSPACE ;. ----TRIPL;E SPACE
JRST SIXTH ;/ ----1/6TH OF PAGE
JRST DSPACE ;0 ----DOUBLE SPACE
JRST RESET1 ;1 ----TOP OF FORM
JRST HALF ;2 ----SKIP 1/2 OF PAGE
JRST THIRD ;3 ----SKIP 1/3RD OF PAGE
;
;
; LOOK AFTER ADVANCE
;
;
ACNTRL: MOVM TMP,@ADVANC ;GET MAG OF FLAG
CAIG TMP,1 ;> THAN 1 ??
POPJ 17,
MOVEI CHR,DC3
ADVLFS: PUSHJ 17,PUTCHR ;DUMP A LINE FEED
SOSG LNECNT ;OVERPAGE??
PUSHJ 17,RESET1
SOJG TMP,ADVLFS ;MORE??
POPJ 17,
PAGE
;
;
; ROUTINES TO HANDLE SINGLE,DOUBLE & TRIPLE SPACE
;
;
;
;
;
;
TSPACE: MOVEI CHR,DC3
PUSHJ 17,PUTCHR ;PUT IN ONE LINE FEED
SOSG LNECNT ;OVER PAGE??
SETOM @OVFLOW
DSPACE: MOVEI CHR,DC3
PUSHJ 17,PUTCHR
SOSG LNECNT
SETOM @OVFLOW
SSPACE: MOVEI CHR,DC3
PUSHJ 17,PUTCHR
SOSG LNECNT
SETOM @OVFLOW
POPJ 17,
;
;
;
RESET1: MOVEI CHR,FF
PUSHJ 17,PUTCHR
RESETT: MOVE TMP,PAGSZE
SKIPL BEFORE ;ADVANCE BEFORE??
SOJ TMP, ;YES---THEN ONE LESS
MOVEM TMP,LNECNT ;RESET LINE COUNT
SETZ TMP, ;FOR ADVANCE STUFF
POPJ 17,
PAGE
;
;
; ROUTINES TO HANDLE SKIP 1/2 1/3 & 1/6 PAGES
;
;
;
;
;
SIXTH: MOVE TMP,PAGSZE ;GET PAGE SIZE
IDIVI TMP,6 ;AND CLACULATE A SXTH
TESTPG: SUBM TMP,LNECNT ;SUBTRACT 1/6 OF PAGE
SKIPG LNECNT ;FINISHED PAGE??
JRST RESET1 ;YES RESET
MOVEI CHR,DC3 ;GET A LINEFEED
SOJG TMP,.-2 ;START DUMPING LINE FEEDS
POPJ 17,
;
;
HALF: MOVE TMP,PAGSZE
LSH TMP,-1
JRST TESTPG
;
;
THIRD: MOVE TMP,PAGSZE
IDIVI TMP,3
JRST TESTPG
;
;
CONERR: OUTSTR MESS1
OUTSTR MESS2
MOVEI CONCHR,52(CONCHR)
OUTCHR CONCHR
OUTSTR MESS3
JRST SSPACE
PAGE
;
;
;
PUTCHR: SOSG OBUF+2
JRST EMPTY ;GO EMPTY THE BUFFER
IDPB CHR,OBUF+1 ;STUFF IN OUTPUT BUFFER
POPJ 17,
;
EMPTY: XCT OUTI
JRST PUTCHR
JRST OUTERR
;
;
;
;
SUBTTL ROUTINES TO HANDLE CARRAIGE CONTROL TAPES
PAGE
;
;
; MAIN ROUTINE FOR CARRAIGE CONTROL
;
;
TCNTRL: SKIPL @ADVANC ;ADVANCE NECESSARY??
PUSHJ 17,TACNTL ;GO DO ATHE ADVA
ILDB CONCHR,RPTR
TLNN RPTR,100 ;SIXBIT?
MOVEI CONCHR,40(CONCHR) ;YUP--CONVERT
SKIPL BEFORE
PUSHJ 17,TCCNTL
HRLZI BIN,^D-132 ;COUNTER FOR CHARACTERS
OUTCHR: ILDB CHR,RPTR ;GET A CHARACTER
TLNN RPTR,100 ;SIXBIT??
MOVEI CHR,40(CHR) ;YUP -- CONVERT TO ASCII
PUSHJ 17,PUTCHR ;SND STUFF IT
AOBJN BIN,OUTCHR ;FINISHED??
SKIPGE @ADVANCE ;ADVANCE AFTER??
PUSHJ 17,TACNTL
SKIPGE BEFORE ;CC AFTER??
PUSHJ 17,TCCNTL
JRST FPRET ;AND RETURN
PAGE
;
;
; ROUTINE TACNTL: DOES ADVANCE CONTROL
;
;
;
TACNTL: MOVM TMP,@ADVANCE
CAIG TMP,1
POPJ 17, ;LESS OR = 1 FORGET IT
MOVEI CHR,DC3
ADVDC3: PUSHJ 17,PUTCHR ;DUMP A LINE FEED
SOSG LNECNT ;AND DECRE LINECOUNT
PUSHJ 17,TRESTT ;TOP OF FORM
SOJG TMP,ADVDC3 ;FINSIHED COUNT?
POPJ 17, ;YUP
;
;
;
;
;
TCCNTL: CAIN CONCHR,40 ;IS IT A SPACE
JRST TSSPCE ;YES INDEED
MOVEI CONCHR,-52(CONCHR) ;STRIP IT
JUMPL CONCHR,TCNERR ;-VE!! NASTY!
CAILE CONCHR,32
JRST TCNERR ;TOO LARGE!!
MOVEI CHR,CR ;GET A CARRAIGE RETURN
PUSHJ 17,PUTCHR ;AND BLATZ IT OUT
XCT TCTAB(CONCHR) ;DO APPROPRIATE THING
JRST CHNSKP ;WAS CHANNEL CONTRAOL
;
;
PAGE
;
;
; TABLE FOR CHANNEL CONTROL ON CARRAIGE CONTOL TAPES
;
;
;
TCTAB: JRST TSSPCE ;* --SINGLE
POPJ 17, ;+ --LINE SURPRESS
JRST TDSPCE ;, --DOUBLE
JRST TTSPCE ;- --TRIPLE
JRST TTSPCE ;. --TRIPLE
JRST TSIXTH ;/ --1/6TH OF A PAGER
JRST TDSPCE ;0 --DOUBLE SPACE
MOVEI CONCHR,1 ;CHANNEL 1
MOVEI CONCHR,2 ;2
MOVEI CONCHR,3 ;3
MOVEI CONCHR,4 ;4
MOVEI CONCHR,5 ;5
MOVEI CONCHR,6 ;6
MOVEI CONCHR,7 ;7
MOVEI CONCHR,10 ;8
MOVEI CONCHR,11 ;9
REPEAT 7, <
JRST TCNERR ;ERROR---ILLEGAL>
MOVEI CONCHR,12 ;10
MOVEI CONCHR,13 ;11
MOVEI CONCHR,14 ;12
;
;
TCNERR: OUTSTR MESS1
OUTSTR MESS2
MOVEI CONCHR,52(CONCHR)
OUTCHR CONCHR
OUTSTR MESS3
JRST TSSPCE
PAGE
;
;
TTSPCE: MOVEI CHR,DC3
PUSHJ 17,PUTCHR ;PUT IN ONE LINE FEED
SOSG LNECNT ;OVER PAGE??
SETOM @OVFLOW
TDSPCE: MOVEI CHR,DC3
PUSHJ 17,PUTCHR
SOSG LNECNT
SETOM @OVFLOW
TSSPCE: MOVEI CHR,DC3
PUSHJ 17,PUTCHR
SOSG LNECNT
SETOM @OVFLOW
POPJ 17,
TRESTT: MOVEI CHR,DC3
PUSHJ 17,PUTCHR
SOSLE LNECNT
JRST .-2
TRE2: MOVE TMP,PAGSZE
SKIPL BEFORE
SOJ TMP,
MOVEM TMP,LNECNT ;TRESET LINE COUNT
SETZ TMP, ;FOR ADVANCE STUFF
POPJ 17,
;
;
;
TSIXTH: MOVE TMP,PAGSZE ;GET PAGE SIZE
IDIVI TMP,6 ;AND CLACULATE A SXTH
SUBM TMP,LNECNT ;SUBTRACT 1/6 OF PAGE
SKIPG LNECNT ;FINISHED PAGE??
JRST TRESTT ;YES RESET
MOVEI CHR,DC3 ;GET A LINEFEED
SOJG TMP,.-2 ;START DUMPING LINE FEEDS
POPJ 17,
PAGE
;
;
;
; ROUTINE TO HANDLE CHANNEL CONROL SKIPS
;
;
;
CHNSKP: HRRZ INDEX,SKPTAB(CONCHR) ;GET POINTER FROM CHANNEL TABLE
JUMPE INDEX,ILLCHN ;IF NO LINE COUNTS ERROR!!!!
AGAIN: HLRZ TMP,LLIST(INDEX) ;GET FIRST LINE VALUE
MOVE LINE,PAGSZE ;GET PAGE SIZE
SUB LINE,LNECNT ;CALCULATE POSITION
CAILE TMP,(LINE) ;LESS THAN CURRENT LINE COUNT??
JRST GOTSKP ;GOT A SKIP!!
HRRZ INDEX,LLIST(INDEX) ;GET ADDR OF NEXT ONE
JUMPE INDEX,TRESTT ;NONE? THEN TOPOF FORM
JRST AGAIN ;TRY AGAIN
GOTSKP: MOVEI CHR,DC3
SUBI TMP,1(LINE) ;NUMBER OF <DC3>'S
SOS LNECNT ;COUNT ONE LINE
PUSHJ 17,PUTCHR ;AND OUT IT GOES
SOJG TMP,.-2
POPJ 17,
PAGE
;
;
; ROUTINE CONVRT ----COVerTS DECIAMAL ASCII TO BINARY
;
;
;
CONVRT: PUSHJ 17,GETCHR ;GET A CHARACTER
JUMPL CHR,EOFFL1 ;END OF FILE
CONVR2: CAIE CHR," " ;BLANK?
CAIN CHR,"," ;COMMA??
JRST .-3 ;PASS OVER THEM
CAIG CHR,"9"
CAIGE CHR,"0" ;DIGIT???
JRST SPCHR ;NOPE!!
SETZ BIN,
CONVR1: IMULI BIN,12
MOVEI CHR,-60(CHR)
ADDI BIN,(CHR)
PUSHJ 17,GETCHR ;GET ANOTHE R CHARACTER
CAIG CHR,"9"
CAIGE CHR,"0"
POPJ 17,
JRST CONVR1
;
SPCHR: CAIG CHR,15
CAIGE CHR,12 ;CARRIGE CONTROL??
JRST SPCERR
SETO BIN, ;FLAG END OF LINE
POPJ 17,
;
;
;
GETCHR: SOSGE IBUF+2
JRST PFILL ;NEED MORE INPUT
ILDB CHR,IBUF+1 ;GET A CHARACTER
JUMPE CHR,GETCHR ;IGNORE NULLS
POPJ 17,
;
PFILL: XCT INI
JRST GETCHR ;OK!!
XCT CHKEOF ;SEE IF EOF
JRST [SETO CHR,
POPJ 17, ] ;FLAG END OF FILE
JRST PARERR
SUBTTL ERROR MESSAGES
PAGE
;
;
LOOKER: WRITE (LOOKUP FAILED ON TAPE CONTROL FILE)
OPERR:: WRITE(CANNOT OPEN CHANNEL FOR LPT FILE.)
PARERR: WRITE(PARITY ERROR ON READ OF CARRAIGE CONTROL FILE.)
ENTERR: WRITE(ENTER ERROR ON LPT FILE.)
CHNERR: WRITE(NO CHANNELS AVAILABLE FOR LPT FILE.)
ILLCHN: OUTSTR MESS1
OUTSTR [ASCIZ /ILLEGAL SKIP CHANNEL SPECIFICATION FOR CARRAIGECONTROL---> /]
MOVEI CONCHR,60(CONCHR)
OUTCHR CONCHR
OUTSTR MESS3
JRST TSSPCE
OUTERR: WRITE(OUTPUT ERROR ON LPT FILE.)
SPCERR: WRITE(ILLEGAL CHARACTER IN CARRAIGE CONTROL FILE.)
SUBTTL DATA AREAS
PAGE
;
CHKEOF: STATZ Z,IO.EOF
;
INI: IN Z,Z
;
;
LOOKI: LOOKUP Z,TCNFLE
;
TCNFLE: CONTAP: SIXBIT/TAPCNT/
SIXBIT/TAP/
Z
Z
OPENI: OPEN Z,FILESP
;
FILESP: Z
SIXBIT /DSK/
XWD OBUF,IBUF
;
IBUF: BLOCK 3
OBUF: BLOCK 3
;
;
ENTI: ENTER Z,FILNME
;
FILNME: Z
Z
Z
Z
;
;
CLOSEI: CLOSE Z,Z
;
;
OUTI: OUT Z,Z
;
;
;
XWD -1,0
ARGBLK: XWD 100,FUNCTN
XWD 100,ERROR
XWD 100,STAT
XWD 100,ARG1
;
;
SAVE: BLOCK 6
FUNCTN: 4
ERROR: Z
STAT: Z
ARG1: Z
;
;
FFREE: Z
LLIST: BLOCK ^D100
SKPTAB: BLOCK ^D12
;
ADVANC: Z
BEFORE: Z
LNECNT: Z
OVFLOW: Z
PAGSZE: Z
CHANEL: -1
;
;
;
MESS1: ASCIZ /ERROR IN FPRINT/
MESS2: ASCIZ /ILLEGAL CARRAIGE CONTROL CHARACTER---> /
MESS3: ASCIZ /DEFAULT TO A BLANK AS CONTROL CHARACTER/
END
.$.