.title kilc .ident "v1.0" .nlist bex,me,cnd .sbttl "Author's credits ; Author: Henry R. Tumblin ; Date: February 18,1979 ; Version: 1.0 ; Module Name: KILC ; For: Systems/Utility Subroutines ; Residence: DB1:[1,20]KILC.MAC ; Machine/System: PDP-11/70 IAS V2.0 ; Type/Language: Subroutine/Assembler ; Abstract: This subroutine removes all leading ; spaces and control characters, all ; internal control characters, all trailing ; spaces, and compresses all blank strings. ; Edits: ; Date By Reason ; --------- ----- ------------------------------------------------ ;+01 25-Mar-79 HRT Fixed length problem in dropping a character .sbttl Operation ; This subroutine is used by different command ; processors to help to reduce a command line. ; The basic function of this module is to compress ; a command line in place. It is fully FORTRAN-IV ; compatable in its call and destroys no registers. ; The calling site is: ; CALL KILC ( STRING , LENGTH , MASK ) ; Where : ; STRING - Is the ASCIZ character string to compress ; LENGTH - Is the length of the string to compress. ; Note that this must be a variable and not ; an explicit number because the compressed ; line length will be returned in this variable. ; MASK - Describes the type of compression to perform. ; The values for MASK are : ; ; 1 - Remove all leading blanks and control ; characters. ; 2 - Replace all control characters with ; a blank. ; 4 - Reduce all blank strings to a single ; blank. ; ; Examples: ; ; Example #1. ; ; CALL KILC(INSTRG,ILEN,4) ; ; This will reduce all multiple blank strings to ; a single blank and return the new line length ; in ILEN. ; Example #2. ; ; CALL KILC(INSTRG,ILEN,4+2+1) ; ; This will remove all leading spaces and control ; characters, convert all control characters to ; blanks, and reduce all blank strings to a single blank. .sbttl Start code section .enabl lsb .PSECT KILC,I,RW,REL ; Produce R/W psect ; .PSECT KILC,I,RO,REL ; Produce R/O psect KILC:: CALL $SAVAL ; Save our registers MOV 2(R5),R3 ; Point to the input string ADD @4(R5),R3 ; Point to the end of the string DEC R3 ; Point to last character -> R3 .sbttl 1) Remove all leading spaces ; This section removes all leading blanks and control ; characters from the input line and left justifies the ; line, and updates the line length to reflect any changes. BIT #1,@6(R5) ; Do they want to remove leading? BEQ 10$ ; No, check next conversion MOV 2(R5),R0 ; Point to the input string -> R0 MOV @4(R5),R1 ; Set string length -> R1 CB: CMPB #40,(R0) ; Is it a blank? BLT 10$ ; No - check control characters DEC R1 ; Decrement character count BLE 10$ ; EQ - check other types MOV R1,R2 ; Leave in R2 1$: MOVB 1(R0),(R0)+ ; Move into place SOB R1,1$ ; Loop till thru CLRB (R3) ; Make it an ASCIZ string MOV R2,R1 ; Restore R1 MOV 2(R5),R0 ; Restore R0 BR CB ; Go check next character 10$: MOV R1,@4(R5) ; Store new line length BLE 40$ ; EQ - then null line .sbttl 2) Remove all control characters ; This section scans the input line for control characters ; and replaces them with blanks. BIT #2,@6(R5) ; Do they want to remove control. BEQ 30$ ; No, check next conversion MOV 2(R5),R0 ; Point to the input string -> R0 MOV @4(R5),R1 ; Initialize string length -> R1 CT: CMPB #40,(R0)+ ; Is it a control character BLT 4$ ; LT - Check next character MOVB #40,-1(R0) ; Else replace it with a blank 4$: SOB R1,CT ; Loop till thru .sbttl 3) Reduce all multiple blank strings ; This section scans for multiple blanks ; and will reduce them to a single blank. 30$: BIT #4,@6(R5) ; Do they want to remove leading? BEQ 40$ ; No, check next conversion MOV 2(R5),R0 ; Point to the input string -> R0 MOV @4(R5),R1 ; Get the string length -> R1 RB: CMPB #40,(R0) ; Is it a blank? BNE 24$ ; NE - no, check next character CMPB #40,1(R0) ; How about the next one BNE 24$ ; No, check next character MOV R1,R2 ; Save current count MOV R0,R4 ; And pointer 22$: MOVB 1(R0),(R0)+ ; Move into place SOB R1,22$ ; Loop till thru CLRB (R3) ; Make it an ASCIZ string MOV R2,R1 ; Restore pointer DEC @4(R5) ; -1 from total length MOV R4,R0 ; Restore pointer 20$: SOB R1,RB ; Loop until thru BR 40$ ; All through, go home 24$: INC R0 ; Point to next character in buffer BR 20$ ; Go check next character 40$: RETURN ; Return to whoever called us .END