\ SEARCH.SEQ String search routine. by Roger Bird comment: This file may be removed, but it is used by WORDS.SEQ, and ENVIRON.SEQ, which is itself used by EXEC.SEQ. The String manipulation primitives include string comparison and searching. The string search implemented is used in the editor to find the desired string. The only unusual thing about it is the presence of a variable called CAPS, which determines whether or not to ignore the case of the subject and pattern strings. If case is ignored then A-Z = a-z. The default is ignore case. Much thanks to Roger Bird for this improved impilmentation of SEARCH, it is about 20 % faster than my previous improved version, and is 10 times faster in the case where the string being searched for starts with a space. It is also 140 bytes smaller than the old implimentation. comment; hex CODE SEARCH ( sadr slen dadr dcnt -- offset found? ) pop cx pop di pop bx pop ax push di push es mov es, sseg push si push bp mov si, ax dec bx mov dx, bx cmp caps # 0 0= if mov bp, # 0 else mov bp, # $2020 then begin cmp bx, cx <= while begin mov al, 0 [si+bx] mov ah, es: 0 [di+bx] or ax, bp cmp ah, al 0= while dec bx 0< if pop bp pop si pop es pop dx sub di, dx push di mov ax, # $FFFF 1push then repeat inc di dec cx mov bx, dx repeat pop bp pop si pop es pop dx sub di, dx push di sub ax, ax 1push end-code decimal comment: : DELETE ( buffer size count -- ) OVER MIN >R R@ - ( left over ) DUP 0> IF 2DUP SWAP DUP R@ + -ROT SWAP CMOVE THEN + R> BLANK ; : INSERT ( string length buffer size -- ) ROT OVER MIN >R R@ - ( left over ) OVER DUP R@ + ROT CMOVE> R> CMOVE ; : REPLACE ( string length buffer size -- ) ROT MIN CMOVE ; comment;