.TITLE SHTUTL - SHT Utility Routines .IDENT /1.0/ .ENABL LC ;+ ; ; Free software BY ; Project Software & Development, Inc. ; ; This software is furnished for free and may be used and copied as ; desired. This software or any other copies thereof may be provided or ; otherwise made available to any other person. No title to and ; ownership of the software is hereby transferred or allowed. ; ; The information in this software is subject to change without notice ; and should not be construed as a commitment by PROJECT SOFTWARE ; AND DEVELOPMENT, INC. ; ; PROJECT SOFTWARE assumes no responsibility for the use or reliability ; of this software on any equipment whatsoever. ; ; Project Software & Development, Inc. ; 14 Story St. ; Cambridge, Ma. 02138 ; 617-661-1444 ; ; ; Title: SHTUTL.MAC ; Author: Robin Miller ; Date: January 4, 1985 ; ; Description: ; ; Utility routines for the show terminal program. ; ; Modification History: ; ;- .ENABL AMA .NLIST BEX .MCALL DIR$, QIOW$S .SBTTL CVTDEC - Convert binary to decimal ASCII. ;+ ; ; CVTDEC - Convert binary to decimal ASCII. ; ; Inputs: ; R0 = The output buffer address. ; R1 = The binary value to convert. ; FLDSIZ = The current field size. ; ; Outputs: ; R0 = The updated output buffer. ; FLDSIZ = The updated field size. ; ; All other registers are preserved. ; ;- CVTDEC::JSR R5,.SAVR1 ; Save R1 - R5. MOV R0,-(SP) ; Save current buffer address. CLR R2 ; Set for zero suppression. CALL $CBDMG ; Convert it to decimal. MOV R0,R3 ; Copy the buffer address. SUB (SP)+,R3 ; Calculate the byte count. ADD R3,FLDSIZ ; Adjust the current field size. RETURN .SBTTL CVTOCT - Convert binary to octal ASCII. ;+ ; ; CVTOCT - Convert binary to octal ASCII. ; ; Inputs: ; R0 = The output buffer address. ; R1 = The binary value to convert. ; FLDSIZ = The current field size. ; ; Outputs: ; R0 = The updated output buffer. ; FLDSIZ = The updated field size. ; ; All other registers are preserved. ; ;- CVTOCT::JSR R5,.SAVR1 ; Save R1 - R5. MOV R0,-(SP) ; Save current buffer address. CLR R2 ; Set for zero supression. CALL $CBTMG ; Convert it to octal. MOV R0,R3 ; Copy the buffer address. SUB (SP)+,R3 ; Calculate the byte count. ADD R3,FLDSIZ ; Adjust the current field size. RETURN .SBTTL CVTUIC - Convert Binary UIC To ASCII ;+ ; ; CVTUIC - Convert binary UIC to ASCII. ; ; Inputs: ; R0 = The output buffer address. ; R3 = The binary UIC to convert. ; FLDSIZ = The current field size. ; ; Outputs: ; R0 = The updated buffer address. ; FLDSIZ = The updated field size. ; ; All other registers are preserved. ; ;- CVTUIC::JSR R5,.SAVR1 ; Save R1 - R5. MOV R0,R2 ; Copy the output buffer address. MOV R0,R1 ; Save for later calculation. CLR R4 ; Suppress zeros/insert separators. CALL .PPASC ; Convert UIC to ASCII string. MOV R2,R0 ; Restore the buffer address. CLRB (R0) ; Terminate string with a null. SUB R1,R2 ; Calculate the string length. ADD R2,FLDSIZ ; Adjust the field size. RETURN .SBTTL MISC - Misc. Subroutines. ;+ ; ; MOVE - Move an ASCIZ message to the output buffer. ; ; INPUTS: ; R1 = Address of ASCIZ string to move. ; R0 = Address of output buffer. ; ; OUTPUTS: ; R0 = Updated (ready for next character). ; ;- MOVE:: INC FLDSIZ ; Bump the current field size. MOVB (R1)+,(R0)+ ; Copy the first/next byte. BNE MOVE ; If NE, more to copy. DEC R0 ; Point to the null byte. DEC FLDSIZ ; Adjust the field size. RETURN ; ; Append to buffer pointed to by R0. ; NEWLIN::MOVB #CR,(R0)+ ; MOVE IN CR MOVB #LF,(R0)+ ; AND LF CLF ; Reset the field size. RETURN ; ; Move ASCII "No " to buffer pointed to by R0. ; MOVENO::JSR R5,.SAVR1 ; Save R1 - R5. MVS RETURN ; ; Move ASCII prefix string to buffer pointed to by R0. ; MOVPRE::MVS < > CLF ; Reset the field size. RETURN ; ; Skip past leading spaces in buffer pointed to by R1. ; STRSPC::CMPB (R1)+,#SPACE ; SPACE CHARACTER ? BEQ STRSPC ; IF EQ, YES DEC R1 ; POINT TO LAST CHAR RETURN .SBTTL PADFLD - Pad the field with spaces. ;+ ; ; PADFLD - Pad the field with spaces. ; ; Inputs: ; R0 The output buffer address. ; FLDSIZ The current field size. ; FLDMAX The maximum field size. ; ; Outputs: ; R0 The updated buffer address. ; FLDSIZ Reinitialized to zero. ; ;- PADFLD::CMP FLDSIZ,FLDMAX ; Have we reached the maximum size ? BHIS 100$ ; If HIS, yes. MOVB #SPACE,(R0)+ ; No, append a space. INC FLDSIZ ; Adjust the field size. BR PADFLD ; And check against maximum again. 100$: CLF ; Reset the field size. RETURN .SBTTL PARSE - PARSE COMMAND LINE PARAMETERS ;+ ; ; PARSE - Parse command line for input parameters. ; ; This routine will parse the command line for input parameters ; and create entries in the parameter table to point to them. ; Each parameter will be terminated with a NULL. Parameters ; may be separated by either a space, tab, or a comma. ; ; Inputs: ; R0 = Address of the command line ; (terminated by CR, ESC, or NULL). ; ; Outputs: ; All registers are preserved. ; ;- PARSE:: CALL $SAVAL ; SAVE ALL REGISTERS MOV #PRMTBL,R1 ; POINT TO PARAMETER TABLE 10$: TSTB (R0) ; END OF COMMAND LINE ? BEQ 100$ ; IF EQ, YES CMPB (R0),#CR ; END OF COMMAND LINE ? BEQ 100$ ; IF EQ, YES CMPB (R0),#ESC ; END OF COMMAND LINE ? BEQ 100$ ; IF EQ, YES CMPB (R0),#SPACE ; VALID DELIMETER ? BEQ 20$ ; IF EQ, YES CMPB (R0),#HT ; HORIZONAL TAB ? BEQ 20$ ; IF EQ, YES (VALID) CMPB (R0),#COMMA ; VALID DELIMETER ? BEQ 20$ ; IF EQ, YES INC R0 ; POINT TO NEXT BYTE BR 10$ ; AND LOOP 20$: CLRB (R0)+ ; CLEAR THE DELEMITER TSTB (R0) ; END OF COMMAND LINE ? BEQ 100$ ; IF EQ, YES CMPB (R0),#CR ; END OF COMMAND LINE ? BEQ 100$ ; IF EQ, YES CMPB (R0),#ESC ; END OF COMMAND LINE ? BEQ 100$ ; IF EQ, YES CMPB (R0),#SPACE ; ANOTHER DELIMETER ? BEQ 20$ ; IF EQ, YES CMPB (R0),#COMMA ; ANOTHER DELIMETER ? BEQ 20$ ; IF EQ, YES CMPB (R0),#HT ; ANOTHER DELIMETER ? BEQ 20$ ; IF EQ, YES MOV R0,(R1)+ ; SAVE THE POINTER INC R0 ; POINT PAST PARAMETER BR 10$ ; AND LOOP FOR NEXT 100$: CLR (R1) ; END OF PARAMETERS RETURN .SBTTL WRITE - WRITE A MESSAGE TO THE TERMINAL ;+ ; ; WRITE - Write a message to the terminal. ; ; This routine is used to write a message to the terminal. ; ; Inputs: ; R0 = Address of buffer to print. ; ; Outputs: ; All registers are preserved. ; ;- WRITE:: CALL $SAVAL ; SAVE R0 - R5 MOV R0,R1 ; COPY START OF BUFFER CLRB STOP ; CLEAR STOPPED STATUS DIR$ #GETTI ; GET CONTROL/O STATUS BITB #2,STOP ; STOP OUTPUT REQUESTED ? BEQ 10$ ; IF EQ, NO JMP EXISUC ; ELSE, EXIT 10$: TSTB (R1)+ ; COPY THE MESSAGE BNE 10$ ; IF NE, NO DEC R1 ; POINT AT NULL SUB R0,R1 ; CALCULATE BYTE COUNT QIOW$S #IO.WVB,#TOLUN,#TOEFN,,#TOSB,, BCC 30$ ; IF CC, OK MOV $DSW,R0 ; ELSE SET EXIT STATUS JMP EXST ; AND EXIT WITH IT 30$: CMPB TOSB,#IS.SUC ; SUCCESSFUL WRITE ? BEQ 40$ ; IF EQ, YES MOVB TOSB,R0 ; ELSE SET EXIT STATUS JMP EXST ; END EXIT WITH IT 40$: RETURN ; ALL DONE .END