Commit | Line | Data |
---|---|---|
3d8a65a3 | 1 | /* strcmp.s 4.3 84/11/14 */ |
1e9489b5 SL |
2 | |
3 | /* | |
4 | * Compare string s1 lexicographically to string s2. | |
5 | * Return: | |
6 | * 0 s1 == s2 | |
7 | * > 0 s1 > s2 | |
8 | * < 0 s2 < s2 | |
9 | * | |
10 | * strcmp(s1, s2) | |
11 | * char *s1, *s2; | |
12 | */ | |
dadab5a2 | 13 | #include "DEFS.h" |
1e9489b5 | 14 | |
dadab5a2 | 15 | ENTRY(strcmp, 0) |
3d8a65a3 KM |
16 | movl 4(ap),r1 # r1 = s1 |
17 | movl 8(ap),r3 # r3 = s2 | |
1e9489b5 | 18 | 1: |
3d8a65a3 | 19 | cmpc3 $32,(r1),(r3) # compare strings |
1e9489b5 | 20 | bneq 2f |
3d8a65a3 KM |
21 | locc $0,$32,-32(r1) # check if contain null |
22 | beql 1b | |
23 | mnegb -32(r0)[r3],r0 # r0 = $0 - *s2 | |
24 | cvtbl r0,r0 | |
25 | ret | |
1e9489b5 | 26 | 2: |
3d8a65a3 KM |
27 | subl3 r0,$32,r0 # check for null in matching string |
28 | subl2 r0,r1 | |
29 | locc $0,r0,(r1) | |
1e9489b5 | 30 | bneq 3f |
3d8a65a3 | 31 | subb3 (r3),-(r1),r0 # r0 = *s1 - *s2 |
1e9489b5 SL |
32 | cvtbl r0,r0 |
33 | ret | |
3d8a65a3 KM |
34 | 3: |
35 | clrl r0 # both the same to null | |
36 | ret |