File: strcmp.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 (33 lines) | stat: -rw-r--r-- 691 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
30
31
32
33
;
; Ullrich von Bassewitz, 31.05.1998
;
; int strcmp (const char* s1, const char* s2);
;

        .export         _strcmp
        .import         popptr1
        .importzp       ptr1, ptr2

_strcmp:
        sta     ptr2            ; Save s2
        stx     ptr2+1
        jsr     popptr1         ; Get s1
        ;ldy     #0             ; Y=0 guaranteed by popptr1

loop:   lda     (ptr1),y
        cmp     (ptr2),y
        bne     L1
        tax                     ; end of strings?
        beq     L3
        iny
        bne     loop
        inc     ptr1+1
        inc     ptr2+1
        bne     loop

L1:     bcs     L2
        ldx     #$FF
        rts

L2:     ldx     #$01
L3:     rts