⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 strstr.s

📁 ICCAVR中所有的库函数源码
💻 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;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -