Line | |
---|
1 | ! bcmp() Author: Kees J. Bot
|
---|
2 | ! 27 Jan 1994
|
---|
3 | .sect .text; .sect .rom; .sect .data; .sect .bss
|
---|
4 |
|
---|
5 | ! int bcmp(const void *s1, const void *s2, size_t n)
|
---|
6 | ! Compare two chunks of memory.
|
---|
7 | ! This is a BSD routine that escaped from the kernel. Don't use.
|
---|
8 | ! (Alas it is not without some use, it reports the number of bytes
|
---|
9 | ! after the bytes that are equal. So it can't be simply replaced.)
|
---|
10 | !
|
---|
11 | .sect .text
|
---|
12 | .define _bcmp
|
---|
13 | _bcmp:
|
---|
14 | push bp
|
---|
15 | mov bp, sp
|
---|
16 | push 8(bp)
|
---|
17 | push 6(bp)
|
---|
18 | push 4(bp)
|
---|
19 | call _memcmp ! Let memcmp do the work
|
---|
20 | mov sp, bp
|
---|
21 | test ax, ax
|
---|
22 | jz equal
|
---|
23 | sub dx, 4(bp) ! Memcmp was nice enough to leave "si" in dx
|
---|
24 | dec dx ! Number of bytes that are equal
|
---|
25 | mov ax, 8(bp)
|
---|
26 | sub ax, dx ! Number of bytes that are unequal
|
---|
27 | equal: pop bp
|
---|
28 | ret
|
---|
Note:
See
TracBrowser
for help on using the repository browser.