_strcmp.s (839B)
1 .module strcmp 2 3 .area _HOME 4 5; int strcmp(const char *s1, const char *s2) 6_strcmp:: 7 lda hl,2(sp) 8 ld a,(hl+) 9 ld e, a 10 ld a,(hl+) 11 ld d, a 12 ld a,(hl+) 13 ld h,(hl) 14 ld l,a 151$: 16 ld a,(de) 17 sub (hl) ; s1[i]==s2[i]? 18 jr nz, 2$ ; -> Different 19 ;; A == 0 20 cp (hl) ; s1[i]==s2[i]==0? 21 22 inc de 23 inc hl 24 jr nz, 1$ ; ^ Didn't reach a null character. Loop. 25 26 ; Yes. return 0; 27 ld d, a ; Since a == 0 this is faster than a 16 bit immediate load. 28 ld e, a 29 ret 302$: 31 ld de,#-1 32 ret c 33 34 ld de,#1 35 ret