Backport of fix from asynchvfs branch for PM-LOG-VFS-PM deadlock that resulted in...
[minix3-old.git] / lib / i86 / string / bcmp.s
blobc6be9db23af9813064670c663cfdd3c4e501990c
1 ! bcmp() Author: Kees J. Bot
2 ! 27 Jan 1994
3 .sect .text; .sect .rom; .sect .data; .sect .bss
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.)
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