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

📄 cstrstrx.s

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

⌨️ 快捷键说明

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