~ubuntu-branches/ubuntu/breezy/avr-libc/breezy

« back to all changes in this revision

Viewing changes to libc/string/strlen.S

  • Committer: Bazaar Package Importer
  • Author(s): Hakan Ardo
  • Date: 2002-04-15 14:53:38 UTC
  • Revision ID: james.westby@ubuntu.com-20020415145338-c8hi0tn5bx74w7o3
Tags: upstream-20020203
ImportĀ upstreamĀ versionĀ 20020203

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#include "macros.inc"
 
3
 
 
4
#define src_hi r25
 
5
#define src_lo r24
 
6
 
 
7
; size_t strlen(const char *src)
 
8
; 10 words, (14 + strlen(src) * 5) cycles
 
9
 
 
10
        .text
 
11
        .global _U(strlen)
 
12
        .type   _U(strlen), @function
 
13
_U(strlen):
 
14
        LOAD_Z(src_lo, src_hi)
 
15
.strlen_loop:
 
16
        ld      __tmp_reg__, Z+
 
17
        tst     __tmp_reg__
 
18
        brne    .strlen_loop
 
19
; Z points one character past the terminating NUL
 
20
; return Z - 1 - src = (-1 - src) + Z = ~src + Z
 
21
        com     src_lo
 
22
        com     src_hi
 
23
        add     src_lo, ZL
 
24
        adc     src_hi, ZH
 
25
        ret
 
26
.strlen_end:
 
27
        .size   _U(strlen), .strlen_end - _U(strlen)
 
28