File: strchr.S

package info (click to toggle)
avr-libc 20020203-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,448 kB
  • ctags: 6,562
  • sloc: ansic: 7,631; asm: 4,424; sh: 2,703; makefile: 338; pascal: 289
file content (36 lines) | stat: -rw-r--r-- 625 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

#include "macros.inc"

#define src_hi r25
#define src_lo r24
; #define val_hi r23
#define val_lo r22

#define ret_hi r25
#define ret_lo r24

; char *strchr(const char *src, int val)

	.text
	.global	_U(strchr)
	.type	_U(strchr), @function
_U(strchr):
	LOAD_Z(src_lo, src_hi)
.strchr_loop:
	ld	__tmp_reg__, Z+
	cp	__tmp_reg__, val_lo
	breq	.strchr_found
	tst	__tmp_reg__
	brne	.strchr_loop
; not found, return NULL pointer
	clr	ret_lo
	clr	ret_hi
	ret
.strchr_found:
	sbiw	ZL, 1		; undo post-increment
	mov	ret_lo, ZL	; XXX use movw if available
	mov	ret_hi, ZH
	ret
.strchr_end:
	.size	_U(strchr), .strchr_end - _U(strchr)