Factor out string token search
This commit is contained in:
parent
7f9820bace
commit
cc28b42897
@ -8,37 +8,6 @@ config_tokens:
|
||||
.none:
|
||||
db 0
|
||||
|
||||
; IN SI offset of needle
|
||||
; DI offset to haystack table
|
||||
; OUT DI found offset in table
|
||||
; ZF zero flag set if match
|
||||
config_search_token:
|
||||
push bp
|
||||
push cx
|
||||
.loop:
|
||||
cmp BYTE [di], 0
|
||||
je .fail
|
||||
push si
|
||||
push di
|
||||
mov bp, di
|
||||
xor ch, ch
|
||||
mov cl, [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
|
||||
|
||||
config_parse_int:
|
||||
ret
|
||||
|
||||
@ -46,6 +15,6 @@ config_parse_int:
|
||||
config_first_run:
|
||||
mov si, bx
|
||||
mov di, config_tokens
|
||||
call config_search_token
|
||||
call string_search_token
|
||||
int3
|
||||
ret
|
||||
|
@ -58,6 +58,7 @@ init:
|
||||
hlt
|
||||
jmp .halt
|
||||
|
||||
%include "string.asm"
|
||||
%include "config.asm"
|
||||
|
||||
kernel_end:
|
||||
|
31
kernel/string.asm
Normal file
31
kernel/string.asm
Normal file
@ -0,0 +1,31 @@
|
||||
; 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
|
Loading…
Reference in New Issue
Block a user