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

📄 cstrstr.s

📁 ICCAVR中所有的库函数源码
💻 S
字号:
; char *cstrstr(char *ramstr, const char *romstr)
; ja 2003-02-21
;
; uses R0,R1,R16,R17,R18,R19,R26,R27,R30,R31
;
; note: cstrstr will not find an empty romstr
;
_cstrstr::
cstrstr1:
	mov	R30,R18	; (re)load
	mov 	R31,R19	; rom pointer
	mov 	R26,R16	; and
	mov 	R27,R17	; ram pointer
cstrstr2:
	lpm			; get rom char
	tst	R0		; end of romstr?
	 breq	cstrstr3	; yes = found ...
	adiw	R30,1		; inc rom pointer
	ld	R1,X+ 	; get ram char
	tst	R1		; end of ramstr?
	 breq	cstrstr4	; yes = not found ...
	cp	R1,R0		; chars are equal?
	 breq	cstrstr2	; go next rom char ...
	subi	R16,0xFF	; else
	sbci	R17,0xFF	; inc ram pointer
	rjmp	cstrstr1	; go next ram char ...
;
cstrstr3:			; end of romstr:
	cp	R30,R18	; romstr must not
	cpc	R31,R19	; be emptfy
	 brne	cstrstr99	; ...
cstrstr4:	     		; romstr not found:
	ldi	R16,0		;
	ldi	R17,0		; return NULL pointer
cstrstr99:
	ret
;
;eof;

⌨️ 快捷键说明

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