rdos/kernel/string.asm

32 lines
437 B
NASM
Raw Normal View History

2019-09-28 14:37:16 +02:00
; IN DS:SI offset of needle
; ES:DI offset to haystack table
; OUT ES:DI found offset in table
; ZF zero flag set if match
string_search_token:
push bp
push cx
.loop:
cmp BYTE [es:di], 0
je .fail
push si
push di
mov bp, di
xor ch, ch
mov cl, [es:di]
inc di
add bp, cx
inc bp
repe cmpsb
pop di
pop si
je .end
mov di, bp
jmp .loop
.fail:
stc
.end:
pop cx
pop cx
ret