?? strstr.s
字號:
; char *strstr(char *str, char *substr)
; ja 2003-02-24
;
; uses R0,R1,R16,R17,R18,R19,R26,R27,R30,R31
;
; note: strstr will not find an empty substr
;
_strstr::
strstr1:
mov R30,R18 ; (re)load
mov R31,R19 ; substr pointer
mov R26,R16 ; and
mov R27,R17 ; str pointer
strstr2:
ld R0,Z ; get substr char
tst R0 ; end of substr?
breq strstr3 ; yes = found ...
adiw R30,1 ; inc substr pointer
ld R1,X+ ; get str char
tst R1 ; end of str?
breq strstr4 ; yes = not found ...
cp R1,R0 ; chars are equal?
breq strstr2 ; go next substr char ...
subi R16,0xFF ; else
sbci R17,0xFF ; inc str pointer
rjmp strstr1 ; go next str char ...
;
strstr3: ; end of substr:
cp R30,R18 ; substr must not
cpc R31,R19 ; be emptfy
brne strstr99 ; ...
strstr4: ; substr not found:
ldi R16,0 ;
ldi R17,0 ; return NULL pointer
strstr99:
ret
;
;eof;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -