.TITLE NAMCAT V01 .enabl lc ; Breaks up a file name into parts and determines what ; characteristics it has. ; ; Call: ; NAMSTA = NAMCAT(FN, FN1) ; NAMSTA is set to indicate the status and is returned ; in register R0 ; FN1 is returned with the broken up file name. ; fn1(1, ... 6) - Name before the * ; FN1(7, ... 12)- Name after the * ; FN1(13, ...15)- Type before the * ; FN1(16, .. 18)- Type after the * ; Any parts not used are set to zero ; FN Contains the file name terminated with a null ; NAMSTA Bit values NAMFLG = 1 ;An * occurred in file name DOT = 2 ;A . occurred in the file name TYPFLG = 4 ;An * occurred in the file type NAMCHR = 8. ;There were characters in the file name TYPCHR = 16. ;There were characters in the file type NAMANY = 32. ;There were char surrounded by *'s in the name TYPANY = 64. ;There were char surrounded by *'s in the type ; Author: D. N. Tanner ; Livermore, Ca 94550 .GLOBL NAMCAT NAMSTA: .WORD 0 ;Status word NLOC: .WORD 0 ;Location of FN N1: .WORD 0 ;location of FN1 N2: .WORD 0 ;Location of FN1(7) T1: .WORD 0 ;Location of FN1(13) T2: .WORD 0 ;Location of FN1(16) NAMCAT: TST (R5)+ ;Bump argument pointer MOV (R5)+,NLOC ;Location of FN, the file name MOV (R5)+,R0 ;Location of FN1, the broken up file name MOV R0,N1 ;Store for later ADD #6,R0 ;Adjust the pointer, and store the rest of MOV R0,N2 ; the pointer values. ADD #6,R0 MOV R0,T1 ADD #4,R0 MOV R0,T2 MOV N1,R2 MOV #10.,R1 20$: CLR (R2)+ ;Clear FN1 array DEC R1 BGT 20$ MOV N1,R2 ;set output pointer to first part of FN1 MOV NLOC,R1 ;File name pointer CLR NAMSTA ;File name status 1$: MOVB (R1)+,R0 ;Get a character from the file name BEQ 10$ ;End on a null CMPB R0,#'* ;Is this a * BEQ 5$ ;Yes, record it CMPB R0,#'. ;A name, type separator BEQ 7$ ;Yes, record it BIT #DOT,NAMSTA ;Dot found yet? BNE 2$ ;Yes, doing file type part BIS #NAMCHR,NAMSTA ;Indicate that the name has letters MOVB R0,(R2)+ ;Store the letter in the correct place BR 1$ ;Next! 2$: BIS #TYPCHR,NAMSTA ;Flag a character in the file type. MOVB R0,(R2)+ ;Store the character BR 1$ ;Next character 5$: BIT #DOT,NAMSTA ;Has a dot been found? BNE 6$ ;Yes, must be doing file type part BIT #NAMFLG,NAMSTA ;Is this the second * with a letter BEQ 4$ ;No BIT #NAMCHR,NAMSTA BEQ 4$ BIS #NAMANY,NAMSTA ;Yes , set the any bit 4$: BIS #NAMFLG,NAMSTA ;Set wild name bit MOV N2,R2 ;Reset the pointer to 2nd name part BR 1$ ;Next character 6$: BIT #TYPFLG,NAMSTA ;Is this the second * with a letter BEQ 16$ ;NO BIT #TYPCHR,NAMSTA BEQ 16$ BIS #TYPANY,NAMSTA ;Yes set the any bit 16$: BIS #TYPFLG,NAMSTA ;Set wild type bit MOV T2,R2 ;Reset the output pointer to 2nd part of type BR 1$ ;Next character 7$: BIS #DOT,NAMSTA ;Flag a dot found MOV T1,R2 ;Set the output pointer to 1st part of type BR 1$ ;Next character 10$: MOV NAMSTA,R0 ;Return status BIT #DOT,R0 ;Was a . included? BNE 11$ ;Yes BIS #DOT!TYPFLG,R0 ;No, assume the .* was entered 11$: RTS PC ;bye bye .end