.TITLE FNCVRT FILE NAME CONVERT .IDENT /C01/ .ENABL GBL,LC ; AUTHOR: Bradford Castalia ; DATE: OCT/86 ; CHANGES: ; This module was modified for C-language interface ; from its equivalent used with FORTRAN. ; MODULE FUNCTION: ; FNA2R (ANAME, RNAME) ; Or FNR2A (RNAME, ANAME) ; ANAME - Address of ASCII form of file name (null terminated) ; RNAME - Address of RAD50 form of file name ; The RAD50 form of the filename, whether as source (1st arg) or ; target (2nd arg), must always be 6 words long - ; Word Contents ; ----------------------------------------------------------------------- ; 1 Device and unit (defaults to LB0 for target) ; 2 UIC member, group (defaults to word 7 from GTSK$ for target) ; NOTE: This word is an exception to the RAD50 format ; The low byte is the member value (binary) ; The high byte is the group value (binary) ; 3 - 5 Filename of up to 9 characters ; 6 Extension of up to 3 characters ; If the conversion is successful, the target address is returned in R0, ; otherwise 0 is returned in R0. .LIST TTM ; TERMINAL LISTING MODE .NLIST BEX ; SUPPRESS BIN EXTENSION .MCALL GTSK$S ; SYMBOL DEFINITIONS: COLON = 72 ; : LFTBRC = 133 ; [ RTBRC = 135 ; ] PERIOD = 56 ; . COMMA = 54 ; , SEMIC = 73 ; ; SPACE = 40 ; DEVICE = ^RLB0 ; Default device name (RAD50) ; Automatic variables: .IF DF C$AUTO AUTO$$ = C$AUTO .IFF AUTO$$ = -6 .ENDC TSKBUF = AUTO$$ - 32. ; 16 word buffer for GTSK$ info UICW = 14. ; Offset to UIC word in buffer STACK = 36. ; SP adjustment amount .PSECT C$CODE,I .PAGE .SBTTL FNA2R - Convert ASCII filename string to 6 RAD50 words ; FUNCTION DETAILS: ; The input ASCII filename string must be null terminated. A version number, ; if present, is ignored. If no device name and unit are present, LB0 is ; used by default. If no UIC is present, word 7 from the GTSK$ directive ; is used by default. Missing filename and/or extension default to spaces. ; >>> WARNING <<< The filename MUST be uppercase. ; Function arguments: .IF DF C$PMTR ARGS$$ = C$PMTR .IFF ARGS$$ = 4 .ENDC ANAME = ARGS$$+0 ; ASCII Filename RNAME = ARGS$$+2 ; RAD50 Filename FNA2R:: JSR R5,CSV$ ; Establish the environment SUB #STACK,SP ; Move the stack pointer ; Get the device name and unit number <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< DEV: MOV ANAME(R5),R3 ; R3 <- #ANAME MOV RNAME(R5),R4 ; R4 <- #RNAME MOV #4,R0 ; Only search 1st 4 chars for colon 1$: CMPB #COLON,(R3)+ ; Device delimiter found? BEQ DEV1 ; Yes TSTB -1(R3) ; End of filename? BEQ DEFDEV ; Yes SOB R0,1$ ; No, try again ; Use default device DEFDEV: MOV #DEVICE,(R4)+ ; Save the device name and unit number MOV ANAME(R5),R3 ; Start again with 1st char BR UIC ; Device delimiter found DEV1: CMP #2,R0 ; Colon found in 1st 2 chars? BLE FAIL ; Yes, this is an error MOV ANAME(R5),R0 ; R0 <- #ANAME CLR R1 ; Period will terminate CALL $CAT5 ; Convert MOV R1,(R4)+ ; Stash the dev/unit word BCS 2$ ; 2 chars converted? ; Confirm that the third char is a digit CMPB R2,#60 ; Low end is 0 BMI FAIL ; Below low CMPB #67,R2 ; High end is 7 BMI FAIL BR UIC 2$: CMPB #COLON,R2 ; Conversion terminated with colon? BNE FAIL ; Whoops! bad character in there ; Get the UIC value <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< UIC: MOV R3,R0 ; R0 <- begin search here CMPB #LFTBRC,(R0)+ ; Left brace found? BEQ 1$ ; Yes ; Use default UIC MOV R5,R1 ADD #TSKBUF,R1 ; R1 <- Task buffer addr GTSK$S R1 ; Get the task's default UIC MOV UICW(R1),(R4)+ ; Save the UIC DEC R0 ; Reset the search pointer BR FILNAM ; Left brace found 1$: CALL $COTB ; Convert octal to binary MOVB R1,1(R4) ; Stash the group value BEQ FAIL ; Null? CMPB #COMMA,R2 ; Conversion terminated with comma? BNE FAIL ; Whoops! bad character in there CALL $COTB MOVB R1,(R4) ; Stash the member value BEQ FAIL ; Null? CMPB #RTBRC,R2 ; Conversion terminated with "]"? BNE FAIL ; No TST (R4)+ ; Point to next RNAME word ; Get the filename <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< FILNAM: MOV #3,R3 ; Max of 3 conversion cycles (9 chars) 1$: CLR R1 ; Terminate on period CALL $CAT5 ; Convert ASCII to RAD50 MOV R1,(R4)+ ; Stash the RAD50 word BCS 3$ ; Conversion terminated? 2$: SOB R3,1$ ; Next 3 chars MOVB (R0)+,R2 ; Check the next character BR 4$ 31$: CLR (R4)+ ; Pad extra words with blanks 3$: SOB R3,31$ 4$: TSTB R2 ; End of filename? BEQ DEFEXT ; Yes CMPB #PERIOD,R2 ; Terminated on period? BNE FAIL ; No, Bad char found ; Get the file extension <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EXT: CLR R1 CALL $CAT5 MOV R1,(R4) BR OK ; Use default blank extension DEFEXT: CLR (R4) ; Success! OK: MOV RNAME(R5),R0 ; Return the target address JMP CRET$ ; Failed FAIL: CLR R0 JMP CRET$ .PAGE .SBTTL FNR2A - Convert 6 word RAD50 filename to ASCII string ; FUNCTION DETAILS: ; The first argument, RNAME, contains 6 words representing a filename ; (see MODULE FUNCTION) which is to be stored in the second argument, ; ANAME, as an ASCII character string. The ANAME array must be at least ; 16 words long. The resultant string will have all embedded blanks ; removed, and will be null terminated. ; Function arguments: RNAME = ARGS$$+0 ; RAD50 Filename ANAME = ARGS$$+2 ; ASCII Filename FNR2A:: JSR R5,CSV$ ; Establish environment SUB #STACK,SP ; Reset the stack pointer ; Convert the device/unit word 1$: MOV ANAME(R5),R0 ; R0 <- #ANAME MOV RNAME(R5),R4 ; R4 <- #RNAME MOV (R4)+,R1 ; R1<- value to be converted CALL $C5TA ; Convert RAD50 to ASCII MOVB #COLON,(R0)+ ; Add the device delimiter ; Convert the UIC word MOVB #LFTBRC,(R0)+ ; Add the left brace for UIC MOVB 1(R4),R1 CLR R2 ; Suppress leading zeros CALL $CBTMG ; Covert binary byte to octal mag MOVB #COMMA,(R0)+ ; Add the separating comma MOVB (R4),R1 CLR R2 CALL $CBTMG MOVB #RTBRC,(R0)+ ; Add the closing right brace TST (R4)+ ; Point to next RNAME word ; Convert the filename words MOV #3,R3 ; Convert the next 3 words 2$: MOV (R4)+,R1 CALL $C5TA SOB R3,2$ MOVB #PERIOD,(R0)+ ; Add the period delimiter ; Convert the extension word MOV (R4),R1 ; Null? BEQ 3$ ; Yes, all spaces CALL $C5TA ; Compress out embedded blanks 3$: CLRB (R0) ; Trailing null MOV ANAME(R5),R0 ; R0 <- #ANAME CALL CMPRS$ ; Compress out the blanks JMP CRET$ .END