File: strlen.s

package info (click to toggle)
cc65 2.19-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,268 kB
  • sloc: ansic: 117,151; asm: 66,339; pascal: 4,248; makefile: 1,009; perl: 607
file content (29 lines) | stat: -rw-r--r-- 672 bytes parent folder | download | duplicates (2)
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
;
; Ullrich von Bassewitz, 31.05.1998
;
; Note: strspn & strcspn call internally this function and rely on
; the usage of only ptr2 here! Keep in mind when appling changes
; and check the other implementations too!
;
; int strlen (const char* s);
;

        .export         _strlen
        .importzp       ptr2

_strlen:
        sta     ptr2            ; Save s
        stx     ptr2+1
        ldx     #0              ; YX used as counter
        ldy     #0

L1:     lda     (ptr2),y
        beq     L9
        iny
        bne     L1
        inc     ptr2+1
        inx
        bne     L1

L9:     tya                     ; get low byte of counter, hi's all set
        rts