.MCALL .MODULE .MODULE SLPSUB,VERSION=02,COMMENT=,IDENT=NO ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. ; Edit History: ; ; 001 08-Aug-80 02:51 PM Kent, Jeff [240,94] ; Redefine W level user error traps for slp. ; (001) ; 002 12-Nov-80 03:41 PM Kent, Jeff [240,94] ; Create [1,23]SLP-W-Audit trail overwrites existing audit trail ; (002) ; 003 02-Feb-81 10:32 AM Jeff Kent [240,94] ; Fix "[1,23]SLP-F-Audit trail overwites line". ; (003) ; ;- ; ; Jonathan M. Taylor 26-Apr-78 ; .SBTTL $SAVRG Register Save and Restore Co-routine $SAVRG:: MOV R4, -(SP) MOV R3, -(SP) JSR PC, (R5) ; co-routine back to caller MOV (SP)+, R3 MOV (SP)+, R4 MOV (SP)+, R5 RTS PC ; to the caller of the caller .SBTTL $PADLN Pad the Line ; Pad a line with blanks or tabs to the right margin. ; ; INPUTS: ; R0 -> next byte in line buffer ; R1 = horizontal position of next byte in line buffer ; R3 -> flag word ; ; OUTPUTS: ; R0 -> next byte in line buffer ; R1 = $PDLGH (horizontal position of audit trail) ; $PADLN:: MOV $PDLGH, R2 ; R2 = margin position CMP R1, R2 ; line already bigger than margin? BLOS 46$ ; No -- branch outa here ;002 MOV R0,-(SP) ; Save R0 ;002 MOV R1,-(SP) ; Save R1 ;002 MOV $LNADR,R0 ; Reset R0 to point at front of ;002 CLR R1 ; R1 is going to count the posit;002 41$: CMPB (R0)+,#11 ; ? ;002 BNE 42$ ; No -- don't do count it as suc;002 BIS #7,R1 ; Yes -- count it as such ;002 42$: INC R1 ; Bump character count ;002 CMP R1,R2 ; Have we reached audit trail st;002 BLO 41$ ; Nope -- keep on counting! ;002 CMPB @R0,#73 ; Yep -- are we looking at semic;002 BEQ 44$ ; Yes -- branch around return ;002 MOV (SP)+,R1 ; No -- fatal error time ;002 MOV (SP)+,R0 ; Restore R0 and R1 ;002 BR 46$ ; And get outa here! ;002 44$: CMPB 3(R0),#55 ; Now, is this the **-n audit tr;002 BEQ 45$ ; Yes -- don't worry about it ;002 MOV R0,-(SP) ; Otherwise save R0 ;002 MOV $LNADR,R0 ; Reset R0 to beginning of line ;002 WARN E$ATAT ; And warn the user ;002 MOV (SP)+,R0 ; Bring R0 back ;002 45$: TST (SP)+ ; Clean up the stack ;002 TST (SP)+ ; And we're all done ;002 46$: CMP R1,R2 ; Back where we started ->line=m;002 BHIS 20$ ; branch if no padding to do ;003 BIT #BL$NK, $SWTCH ; blank fill? ;**-1 BNE 10$ ; branch if yes BIC #7, R1 ; tab pad, compute position after tab 5$: ADD #10, R1 MOVB #11, (R0)+ ; and move in the tab CMP R1, R2 ; up to margin yet? BNE 5$ ; branch if not RETURN 10$: INC R1 ; increment horizontal position MOVB #' , (R0)+ ; insert a blank CMP R1, R2 ; up to margin yet? BNE 10$ ; branch if not 70$: RETURN 20$: BEQ 70$ ; branch if no padding to do MOV $LNADR, R0 ; find address of margin FATAL E$ATOL ; warning: audit trail overwrite;001 CLR R1 ; by finding when column = $PDLG 25$: CMP R1, R2 ; is column = $PDLGH? BEQ 70$ ; branch if so CMPB (R0)+, #11 ; get next byte. TAB? BNE 30$ ; branch if not BIC #7, R1 ; compute next tab stop ADD #7, R1 ; in R1 30$: INC R1 BR 25$ ; and continue .SBTTL $GTCFL Get Source Line and Strip ; $GETCFL calls $GETLN to get a line from the source file. ; $GTCFL:: BIT #SR$CO, $SWTCH ; if no source file BEQ 70$ ; error MOV #$SBUF, R0 ; R0 -> source buffer descriptor CALL $GETLN ; get next line INC $CFNMB ; update source line number RETURN 70$: CLR R0 ; no optional error message FATAL E$SNSP ; source file not specified .SBTTL $CMPRS Compress Source Line ; LOCAL MACROS ; ; JUMP ON NO DIGIT ; ; JOND ADDR ; ; ADDR=ADDRESS TO JUMP TO IF NO DIGIT ; ; .MACRO JOND ADDR MOVB (R1)+,R5 CMPB R3,R5 BGT ADDR CMPB R4,R5 BLT ADDR .ENDM ; ; JUMP ON NO LETTER ; ; JONL ADDR ; ; ADDR=ADDRESS TO JUMP TO IF NO MATCH ; .MACRO JONL ADDR MOVB (R1)+,R5 CMPB (R4)+,R5 BNE ADDR .ENDM ; ; LOCAL DATA ; CNTRL: .BYTE 0,11,' ,';,'*,'*,'-,'E,'W,'*,'*; .EVEN ;+ ; **-$CMPRS-COMPRESS LINE ; ; THIS ROUTINE COMPRESSES THE LINE IN $LNBUF AND APPENDS ";**-DDDD" IF ; APPROPRIATE. THE LINE IS SCANNED AND TRAILING BLANKS, HORIZONAL TABS, ; AND ";**NEW**" OR ";**-DDDD" ARE DELETED. IF A LINE DELETION (I.E. ; -N,M) HAS NOT YET BEEN EDITED ($LNDEL NONZERO), THEN THE LINE IS ; PADDED TO THE RIGHT MARGIN AND ";**-" IS APPENDED. $LNDEL IS CONVERTED ; TO ASCII AND APPENDED IMMEDIATELY FOLLOWING THE "-". ; ; INPUTS: ; ; LINE IN $LNBUF. ; ; OUTPUTS: ; ; THE LINE IN $LNBUF IS COMPRESSED AND $LNDEL IS SET TO ZERO. ;- $CMPRS:: SAVRG ;SAVE NONVOLITILE REGISTERS MOV $LNADR,R1 ;GET ADDRESS OF LINE BUFFER 1$: MOV R1,R0 ;SAVE ADDRESS OF NEXT BYTE 2$: MOVB (R1)+,R5 ;GET NEXT BYTE 3$: MOV #CNTRL,R4 ;GET ADDRESS OF CONTROL BYTE STRING JOL 8$ ;0? JOL 2$ ;HT? JOL 2$ ;SPACE? CMPB (R4)+,R5 ;";"? BNE 1$ ;IF NE NO JONL 7$ ;"*"? JONL 7$ ;"*"? JONL 4$ ;"-"? MOV #'0,R3 ;SET LOW LIMIT MOV #'9,R4 ;SET HIGH LIMIT JOND 7$ ;DIGIT? JOND 6$ ;DIGIT? JOND 6$ ;DIGIT? JOND 6$ ;DIGIT? BR 5$ ; 4$: CMPB #'N,R5 ;"N"? BNE 7$ ;IF NE NO JONL 7$ ;"E"? JONL 7$ ;"W"? JONL 7$ ;"*"? JONL 7$ ;"*"? 5$: MOVB (R1)+,R5 ;GET NEXT BYTE 6$: TSTB R5 ;ZERO BYTE? BEQ 8$ ;IF EQ YES 7$: TSTB -(R1) ;BACK UP BYTE ADDRESS BR 1$ ;GO AGAIN 8$: TST $LNDEL ;ANYTHING TO DELETE? BEQ 12$ ;IF EQ NO CLR R1 ;CLEAR HORIZONAL POSITION MOV $LNADR,R2 ;GET ADDRESS OF LINE BUFFER 9$: CMP R2,R0 ;ANY MORE TO SCAN? BHIS 11$ ;IF HIS NO CMPB (R2)+,#11 ;HORIZONAL TAB? BNE 10$ ;IF NE NO BIC #7,R1 ;CLEAR EXCESS BITS ADD #7,R1 ;CALCULATE NEXT TAB STOP 10$: INC R1 ;INCREMENT HORIZONAL POSITION BR 9$ ; 11$: CALL $PADLN ;PAD LINE TO RIGHT MARGIN MOV #CNTRL+3,R4 ;APPEND PART OF SUFFIX .REPT 4 MOVB (R4)+,(R0)+ ; .ENDR MOV $LNDEL,R1 ;GET NUMBER OF LINES DELETED CALL $CBDMG ;CONVERT TO DECIMAL CLR $LNDEL ;ZERO NUMBER OF LINES DELETED 12$: CLRB (R0) ;SET ZERO SENTINEL BYTE RETURN ; .SBTTL $CBDMG Convert Binary to ASCII ; Convert binary in R1 to ASCII and store (R0). ; Suppress leading zeroes. ; $CBDMG:: SAVRG MOV R0, R5 ; R5 -> ASCII buffer MOV #$10TAB, R2 ; R2 -> powers of 10. table 5$: MOV (R2)+, R4 ; R4 = next power of 10. BEQ DONE CLR R3 ; clear counter 10$: INC R3 SUB R4, R1 BGE 10$ ADD R4, R1 ; adjust back up one DEC R3 ; adjust counter BNE 15$ ; branch if not zero CMP R0, R5 ; if still at beginning BEQ 5$ ; don't put out the '0' 15$: ADD #'0, R3 ; make R3 ASCII MOVB R3, (R0)+ BR 5$ DONE: RETURN $10TAB::10000. 1000. 100. 10. 1. 0. .END