.title minlib .sbttl chcopy ; ; this routine implements the following fortran interface ; ; call chcopy(c, out, j) ; ; after the copy, j is incremented and an EOS is placed in out(j) ; ap=%5 c=2 out=4 j=6 .psect $r.roi,con,ro,rel,lcl,i .enabl lsb chcopy:: mov out(ap),r0 ; address of out(1) in r0 mov @j(ap),r1 ; value of j in r1 dec r1 ; j-1 in r1 add r1,r0 ; address of out(j) in r0 movb @c(ap),(r0)+ ; copy character clrb (r0) ; write EOS(0) in next location inc @j(ap) ; increment j return .page .sbttl equal ; ; this routine implements the following fortran interface ; ; status = equal(a, b) ; ; where a and b are EOS-terminated strings. If they are equal, ; status is returnes as YES(1), otherwise NO(0) ; ap=%5 a=2 b=4 yes=1 no=0 .psect $r.roi,con,ro,rel,lcl,i .enabl lsb equal:: mov a(ap),r1 ; address of a(1) in r1 mov b(ap),r2 ; address of b(1) in r2 mov #no,r0 ; initialize return value to NO 10$: cmpb (r1)+,(r2) ; compare the next character bne 20$ ; if !=, then return tstb (r2)+ ; see if this character is EOS(0) bne 10$ ; not EOS, try next character mov #yes,r0 ; all characters equal, return YES 20$: return .page .sbttl fold ; ; this routine implements the following fortran interface ; ; call fold(buf) ; ; where buf is an EOS-terminated string ; ; fold crunches all characters in the range A-Z into lower case ; ap=%5 buf=2 BIGA=101 BIGZ=132 LETA=141 LETZ=172 DIF=LETA-BIGA MASK=177 .psect $r.roi,con,ro,rel,lcl,i .enabl lsb fold:: mov buf(ap),r1 ; address of buf(1) in r1 10$: movb (r1),r0 ; next character into r0 beq 20$ ; if == 0, then done cmpb r0,#BIGA&MASK ; see if >= A blt 30$ ; if <, then copy character back cmpb r0,#BIGZ&MASK ; see if <= Z bgt 30$ ; if >, then copy character back add #DIF,r0 ; add 40(8) to character 30$: movb r0,(r1)+ ; copy byte back into string br 10$ 20$: return .page .sbttl gtftok ;+ ; integer function gtftok(buf, i, token) ;- ap=%5 buf=2 i=4 token=6 .psect $r.roi,con,ro,rel,lcl,i .enabl lsb gtftok:: mov buf(ap),r1 ; address of buf(1) mov i(ap),r3 ; address of i dec (r3) ; i = i - 1 add (r3),r1 ; address of buf(i) mov token(ap),r2 ; destination address clr r0 ; initialize return count inc (r3) ; i = i + 1 cmpb (r1),#'/ ; buf(i) == SLASH? bne 10$ ; NO inc (r3) ; i = i + 1 inc r1 ; address of buf(i) 10$: movb (r1)+,(r2) ; copy character beq 30$ ; if == 0, done cmpb (r2),#'/ ; SLASH? beq 20$ ; YES inc r0 ; increment count inc (r3) ; i = i + 1 cmpb (r2)+,#'\ ; BACKSLASH? bne 10$ ; NO, do next character 20$: clrb (r2) ; terminate with EOS 30$: return .page .sbttl index ; ; this routine provides the following fortran interface ; ; i = index(buf, char) ; ; where buf is an EOS terminated string and the value of the function ; is its position in the string if found, and 0 if not ; ap=%5 buf=2 char=4 .psect $r.roi,con,ro,rel,lcl,i .enabl lsb index:: mov buf(ap),r1 ; buffer address in r1 movb @char(ap),r2 ; character to find in r2 clr r0 ; initialize character position 10$: inc r0 ; increment to current char position tstb (r1) ; see if at EOS(0) beq 20$ ; if == 0, return value of 0 cmpb (r1)+,r2 ; see if current byte matches beq 30$ ; if so, r0 contains position br 10$ ; try next byte 20$: clr r0 ; return 0 since char not found 30$: return .page .sbttl length ; ; ; this routine implements the following fortran interface ; ; n = length(buf) ; ; where buf is a byte array and the string is terminated by a ; 0-byte. The length returned does not include the 0-byte. ; ap=%5 buf=2 .psect $r.roi,con,ro,rel,lcl,i .enabl lsb length:: mov buf(ap),r1 ; address of buf in r1 clr r0 ; initialize length to 0 10$: tstb (r1)+ ; see if this byte is 0(EOS) beq 20$ ; if so, return inc r0 ; increment length by 1 br 10$ 20$: return .page .sbttl stcopy ; ; this routine provides the following fortran interface ; ; call stcopy(in, i, out, j) ; ; where in is an EOS-terminated string; j is incremented, also ; ap=%5 in=2 i=4 out=6 j=10 .psect $r.roi,con,ro,rel,lcl,i .enabl lsb stcopy:: mov in(ap),r0 ; address of in(1) in r0 mov @i(ap),r1 ; value of i in r1 dec r1 ; now value of i-1 add r1,r0 ; r0 now has address of in(i) mov out(ap),r1 ; address of out(1) in r1 mov j(ap),r2 ; address of j in r2 dec (r2) ; j has been decremented add (r2),r1 ; r1 now has address of out(j) 10$: inc (r2) ; j now points to location copied to movb (r0)+,(r1)+ ; copy next byte bne 10$ ; if != 0, then do next byte return .page .sbttl strcpy ;+ ; call strcpy(in, out) ;- ap=%5 in=2 out=4 .psect $r.roi,con,ro,rel,lcl,i .enabl lsb strcpy:: mov in(ap),r0 ; starting address of source mov out(ap),r1 ; starting address of destination 10$: movb (r0)+,(r1)+ ; copy character bne 10$ ; if not EOS, do again return .page .sbttl type ;+ ; integer function type(c) ;- ap=%5 c=2 letter=1 digit=2 .psect $r.roi,con,ro,rel,lcl,i .enabl lsb type:: movb @c(ap),r0 ; fetch character cmp r0,#'0 ; digit? blt 20$ ; NO, too small cmp r0,#'9 ; digit? bgt 10$ ; NO, too large mov #digit,r0 ; return(DIGIT) br 30$ 10$: bic #40,r0 ; make upper case cmp #'A,r0 ; see if letter bgt 20$ ; NO cmp #'Z,r0 ; other bound blt 20$ ; NO mov #letter,r0 ; return(LETTER) br 30$ 20$: movb @c(ap),r0 ; return(c) 30$: return .end