	TITLE INDEX
;FIND INDEX IN STRING IN ARG 1 OF CHAR IN ARG 2
; I=INDEX(STRING,CHR)
_DATA	SEGMENT PUBLIC 'DATA'
I3B	DW 0
I	DW 0
_DATA	ENDS
DGROUP	GROUP _DATA
CODE	SEGMENT 'CODE'
	ASSUME CS:CODE,DS:DGROUP,SS:DGROUP
PUBLIC INDEX
INDEX  PROC  FAR
L10:
    PUSH      BP
    MOV       BP,SP
    push  si
    MOV       I3B,0000H
L11:
    MOV       I,0001H
    JMP       I2
I3:	;LOOP START
L12:
    MOV       SI,I
    DEC       SI
    LES       BX,DWORD PTR [BP].0AH
    MOV       AX,ES:[BX][SI]
    CMP       I3B,00H
    JLE       V02A4	;SKIP ANYTHING IF INSIDE VBL
    DEC       I3B	;(EVEN SKIP NULLS...)
    JMP       U0234
V02A4:
    AND       AL,AL	;SEE IF CHAR WAS NULL.
    JNE       U026C
I4:
L16:
    MOV       AX,I
L17:
    JMP       KK1	;IF NULL, EXIT NOW
L18:
U026C:
L19:
;    MOV       SI,I
;    DEC       SI
;    LES       BX,DWORD PTR [BP].0AH
;    MOV       AX,ES:[BX][SI]
    XOR       AH,AH
; IF START OF CELL ADDRESS SAVE COUNTER 3 TO SKIP OVER...
    CMP       AX,00FFH
    JNE       I5
    MOV       I3B,0003H
I5:
L20:
    CMP       I3B,00H
    JLE       U02A4
I6:
L22:
    DEC       I3B
L23:
    JMP       U0234
L24:
U02A4:
L25:
;    MOV       SI,I
;    DEC       SI
;    LES       BX,DWORD PTR [BP].0AH
;    MOV       AX,ES:[BX][SI]
; AL STILL HAS CHARACTER
    LES       BX,DWORD PTR [BP].06H
    MOV       CX,ES:[BX]
    CMP       AL,CL
    JNE       U02DC
I7:
L26:
    MOV       AX,I
L27:
    JMP       I1
L28:
U02DC:
L29:
U0314:
L31:
U0234:
    INC       I
I2:
    CMP       I,0100H
    JLE       I3
L32:
	MOV AX,0FFH
; FFH IF WE FAILED TO FIND CHAR WITHIN 256 OF START...
U034C:
L33:
I1:
KK1:
    pop  si
    MOV       SP,BP
    POP       BP
    RET      0008H
INDEX ENDP
CODE ENDS
	END


