2 ; Ullrich von Bassewitz, 25.05.2000
4 ; int strncmp (const char* s1, const char* s2, unsigned n);
9 .importzp ptr1, ptr2, ptr3
14 ; Convert the given counter value in a/x from a downward counter into an
15 ; upward counter, so we can increment the counter in the loop below instead
16 ; of decrementing it. This adds some overhead now, but is cheaper than
17 ; executing a more complex test in each iteration of the loop. We do also
18 ; correct the value by one, so we can do the test on top of the loop.
26 ; Get the remaining arguments
39 ; Start of compare loop. Check the counter.
42 beq IncHi ; Increment high byte
44 ; Compare a byte from the strings
48 bne NotEqual ; Jump if strings different
50 beq Equal1 ; Jump if EOS reached, a/x == 0
52 ; Increment the pointers
58 bne Loop ; Branch always
63 bne Comp ; Jump if counter not zero
65 ; Exit code if strings are equal. a/x not set
71 ; Exit code if strings not equal
75 ldx #$FF ; Make result negative
78 L1: ldx #$01 ; Make result positive