[6604] in Athena Bugs
RT bcmp()
daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Mon Dec 17 02:17:05 1990
To: bugs@ATHENA.MIT.EDU
Date: Mon, 17 Dec 90 02:16:53 EST
From: John Carr <jfc@ATHENA.MIT.EDU>
This is an assembly version of bcmp() for the RT. It is faster than the C
version being used. It should go in /source/bsd-4.3/rt/lib/libc/gen/bcmp.s.
This version comes from the kernel (/source/bsd-4.3/rt/sys/ca/loutil.s).
----------------------------------------------------------------
#include "LINKG.h"
.text
.align 2
ENTRY(bcmp)
cis r4,0
#ifdef PROF
jl 0f
#else
bl 0f # return 0 if length is 0
#endif
cas r4,r2,r4 # calculate end = s1 + len
# 2: should be aligned on a 4-byte boundary
# to take advantage of loop mode on an APC
2:
lcs r0,0(r2) # first character (*s1)
lcs r5,0(r3) # second character (*s2)
inc r2,1 # s1++
inc r3,1 # s2++
c r0,r5 # compare (*s1) == (*s2)
jne 1f # not the same
c r2,r4 # if (s1 < end)
jl 2b # goto 2b;
0:
brx r15
lis r2,0 # return 0 (same)
1:
brx r15
lis r2,1 # return 1 (different)
TTNOFRM
----------------------------------------------------------------