/ PROGRAM strs SETLAB st. ;- ; compare two smp type strings i.e. compare str1(i1) to str2(i2) ; ; ;+ FUNCTION cmpstr[Str1,i1,str2,i2] LET r2 = fndstr[str1(r5),i1(r5)] LET r3 = fndstr[str2(r5),i2(r5)] IFB (r2) NE (r3) 20$: RET #-1 ELSE movb (r2)+,r4 IF EQ clr r0 RET FI inc r3 30$: ; cmpb (r2)+,(r3)+ ;the below now does this caselessly movb (r2)+,r0 movb (r3)+,r1 cmp r0,#141 blo 5$ cmp r0,#172 bhi 5$ sub #40,r0 5$: cmp r1,#141 blo 10$ cmp r1,#172 bhi 10$ sub #40,r1 10$: cmp r0,r1 bne 20$ sob r4,30$ clr r0 RET FI ;- ; move an smp string (with multiple strings therein) into an ; smp type string which will then only be used as a single string smp ; type string. (just for speed) This allows the output smp to not ; worry about shifting up/down other strings (e.g. 2..n) ; but it can no longer be used as a multiple string smp type. ; a kludge for sure. ;+ FUNCTION mvstr[dest,source,i] LET r0 = fndstr[source(r5),i(r5)] mov dest(r5),r1 add #12.,r1 movb (r0)+,r2 bic #177400,r2 movb r2,(r1)+ ble 20$ 10$: movb (r0)+,(r1)+ sob r2,10$ 20$: RET ;- ; find a pointer to a string (an smp type string) it returns an address ; of a location within an smp string. the address is of the count byte ; which precedes the ascii part (count/text,count/text...) ;+ FUNCTION fndstr[str,i] mov str(r5),r0 add #12.,r0 mov i(r5),r2 ble 30$ br 20$ 10$: movb (r0)+,r1 bic #177400,r1 add r1,r0 20$: sob r2,10$ 30$: RET ;- ; search an smp string array for a given string (caselessly). n is the ; size of ary (an n element smp type string). str is a pointer to a ; string of the count/text type. i.e. it is usually a pointer to a ; string inside an smp type string array. it is usually called as follows: ; let answer = ifnstr[n,array,fndstr[smp,n2]] ;+ AUTO i,sr4 FUNCTION ifnstr[n,ary,str] mov str(r5),r4 ;r4=str addr IF r4 = #0 clr r3 ELSE movb (r4)+,r3 ;r3=len FI mov ary(r5),r0 add #12.,r0 ;r0=addr of 1st/next str in array LOOP for i(r5) = #1 TO n(r5) movb (r0)+,r1 bic #177400,r1 mov r0,r2 add r1,r0 IF r1 = r3 IF r1 = #0 jmp equal FI mov r4,sr4(r5) 30$: ; cmpb (r2)+,(r4)+ ;now do it caselessly movb (r2)+,-(sp) movb (r4)+,-(sp) cmpb (sp),#141 blo 5$ cmpb (sp),#172 bhi 5$ sub #40,(sp) 5$: cmpb 2(sp),#141 blo 10$ cmpb 2(sp),#172 bhi 10$ sub #40,2(sp) 10$: cmpb (sp)+,(sp)+ bne 20$ sob r1,30$ jmp equal 20$: mov sr4(r5),r4 FI NEXT i(r5) clr r0 RET equal: RET i(r5) .end