|
|
1.1 root 1: //////////
2: / i8086 C string library.
3: / strcmp()
4: / ANSI 4.11.4.2.
5: //////////
6:
7: //////////
8: / strcmp(String1, String2)
9: / char *String1, *String2;
10: /
11: / Compare String1 and String2 until mismatch or NUL seen.
12: //////////
13:
14: #include <larges.h>
15:
16: String1 = LEFTARG
17: String2 = String1+DPL
18:
19: Enter(strcmp_)
20: Lds si, String2(bp) / String2 address to DS:SI
21: Les di, String1(bp) / String1 address to ES:DI
22: mov cx, $0 / Result to CX
23: cld
24:
25: 1: lodsb / String2 character to AL
26: scasb / Compare to String1 character
27: jne 2f / Mismatch
28: orb al, al
29: jne 1b / Not done yet
30: jmp 4f / String1 == String2, return 0
31:
32: 2: ja 3f
33: inc cx / String1 > String2, return 1
34: jmp 4f
35:
36: 3: dec cx / String1 < String2, return -1
37:
38: 4: mov ax, cx / Result to AX
39: Leave
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.