.TITLE AUXUTL - AUX 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: AUXUTL.MAC ; Author: Robin Miller ; Date: July 23, 1985 ; ; Description: ; ; This module contains the utility routines for the AUX program. ; ;- .ENABL AMA .NLIST BEX .MCALL MRKT$S, WTSE$S, IOERR$ IOERR$ ; Define I/O error codes. .psect code,ro,i,lcl,rel,con ; Local equates: TICKS = 1 ; TIME UNITS FOR MARKTIME SECNDS = 2 ; MINUTE = 3 ; HOURS = 4 ; .SBTTL CUPPER - Convert string to upper case. ;+ ; ; CUPPER - Convert string to upper case. ; CUCHAR - Convert single character to upper case. ; ; This routine is used to convert a string of characters to uppercase. ; ; Inputs: ; R0 = The string address (terminated by NULL). ; ; Outputs: ; All registers are preserved. ; ;- CUPPER::JSR R2,$SAVVR ; Save R0 - R2. 10$: CALL CUCHAR ; Convert character to uppercase. TSTB (R0)+ ; End of the string ? BNE 10$ ; If NE, no - more to go. RETURN ; Convert a single character to upper case. CUCHAR::CMPB (R0),#'a ; Possible lowercase ? BLO 10$ ; If LO, no. CMPB (R0),#'z ; Is it really lowercase ? BHI 10$ ; If HI, no. BICB #40,(R0) ; Yes, convert it to uppercase. 10$: RETURN .SBTTL CVTDEC - Convert Binary Number To Decimal ASCII ;+ ; ; CVTDEC - Convert binary number to Decimal ASCII. ; ; Inputs: ; R0 = the output buffer address. ; R1 = the binary number to convert. ; ; Outputs: ; R0 = the updated output buffer address. ; ; All other registers are preserved. ; ;- CVTDEC::JSR R5,.SAVR1 ; Save R1 - R5 MOV #030012,R2 ; WIDTH=6 ! ZERO-SUPPRESS ! DECIMAL CALL $CBTA ; Convert it to decimal ASCII. RETURN .SBTTL CVTOCT - Convert Binary Number To Octal ASCII ;+ ; ; CVTOCT - Convert binary number to octal ASCII. ; ; Inputs: ; R0 = the output buffer address. ; R1 = the binary number to convert. ; ; Outputs: ; R0 = the updated output buffer address. ; ; All other registers are preserved. ; ;- CVTOCT::JSR R5,.SAVR1 ; Save R1 - R5 MOV #030010,R2 ; WIDTH=6 ! ZERO-SUPPRESS ! OCTAL CALL $CBTA ; Convert it to octal ASCII. RETURN .SBTTL DELAY - Wait Specified Time Interval ;+ ; ; DELAY - Wait specified time interval. ; ; Inputs: ; R0 = the time interval magnitude. ; R1 = the time interval unit (i.e., TICKS). ; ; Outputs: ; Carry clear/set = success/failure. ; ; All registers are preserved. ; ;- DELAY:: MRKT$S #MRKEFN,R0,R1 ; ISSUE THE MARK TIME CALL CHKDIR ; Check fir directive status. BCS 100$ ; If CS, the directive failed. WTSE$S #MRKEFN ; ELSE WAIT FOR MARKTIME 100$: RETURN .SBTTL FCSERR - Report an FCS error message. ;+ ; ; FCSERR - Report an FCS error message. ; ; This routine is used to report an FCS error message without appending ; the file name to the error message. It doesn't check for the severity ; of the error either (may want to change this later). If the error is ; "End of file", the error message is not reported (expected error). ; ; Inputs: ; R0 = The FDB address. ; ; Outputs: ; All registers are preserved. ; ;- FCSERR::JSR R2,$SAVVR ; Save R0 - R2. MOV F.ERR(R0),R0 ; Copy the FCS error code. CMPB #IE.EOF,R0 ; Is the error "End of file" ? BEQ 10$ ; If EQ, yes (don't report). CALL WRTERR ; Write the error message text. 10$: SEC ; Show we had an error. RETURN .SBTTL FILERR - Report file error with name. ;+ ; ; FILERR - Report a file error with name. ; ; This routine is used to report an FCS error with the file name appended ; to the error messsage. In addition, it checks for non-fatal errors and ; returns the C-bit clear/set appropriatly. ; ; ; Inputs: ; R5 = The file table entry address. ; ; Outputs: ; C bit clear/set = non-fatal/fatal error. ; ; All registers are preserved. ; ;- FILERR::JSR R2,$SAVVR ; Save R0 - R2 BIS #B.FERR,STATUS ; Show we had a file error. MOV O.FDB(R5),R0 ; Copy the FDB address. MOV F.ERR(R0),R0 ; Copy the FCS error code. CALL WRTERR ; Write the error message text. BIC #B.FERR,STATUS ; The file error was reported. SEC ; Show we've had an error. RETURN .SBTTL GETLEN - Get the length of a string. ;+ ; ; GETLEN - Get the length of a string. ; ; This routine is used to calculate the length of a string which is ; terminated by a NULL byte. ; ; Inputs: ; R0 = The string address (terminated by NULL). ; ; Outputs: ; R0 = The string address. ; R1 = The string length. ; ; All other registers are preserved. ; ;- GETLEN::MOV R0,R1 ; Copy the string address. 10$: TSTB (R1)+ ; Is this the NULL byte ? BNE 10$ ; If NE, no (loop). DEC R1 ; Adjust for the NULL byte. SUB R0,R1 ; Now calculate the length. RETURN .SBTTL MOVEC - Move a character string. ;+ ; ; MOVEC - Move a character string. ; ; Inputs: ; R0 = The output buffer address. ; R1 = The character string to copy (terminated by NULL). ; ; Outputs: ; R0 = The updated buffer address. ; R1 = The number of characters copied. ; ;- MOVEC:: MOV R0,-(SP) ; Save the starting address. 10$: MOVB (R1)+,(R0)+ ; Copy the next character. BNE 10$ ; If NE, more to copy. DEC R0 ; Point to the null byte. MOV R0,R1 ; Copy the ending address. SUB (SP)+,R1 ; Calculate characters copied. RETURN .END