File: strlen.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 (28 lines) | stat: -rw-r--r-- 519 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

#include "macros.inc"

#define src_hi r25
#define src_lo r24

; size_t strlen(const char *src)
; 10 words, (14 + strlen(src) * 5) cycles

	.text
	.global	_U(strlen)
	.type	_U(strlen), @function
_U(strlen):
	LOAD_Z(src_lo, src_hi)
.strlen_loop:
	ld	__tmp_reg__, Z+
	tst	__tmp_reg__
	brne	.strlen_loop
; Z points one character past the terminating NUL
; return Z - 1 - src = (-1 - src) + Z = ~src + Z
	com	src_lo
	com	src_hi
	add	src_lo, ZL
	adc	src_hi, ZH
	ret
.strlen_end:
	.size	_U(strlen), .strlen_end - _U(strlen)