From: utzoo!decvax!duke!mcnc!idis!dan Newsgroups: net.unix-wizards Title: Re: Speedup to bcopy() Article-I.D.: idis.126 Posted: Tue Jul 13 21:53:48 1982 Received: Thu Jul 15 04:14:24 1982 Several years ago (when v7 was just a rumor) I got excited about cpu time spent in bcopy() and rewrote it in assembler to reduce loop control overhead by a factor of 8. Some time after I did this, I took a good look at how the kernel actually used bcopy() and decided that I had probably been wasting my time. If you are into shaving microseconds, this is one way to do it. Notice that the length argument is in words. More modern systems may use byte counts here. This code is for pdp11s. VAXen should (and do) use the movc3 instruction. .globl _bcopy /call: bcopy(from,to,wordcount); _bcopy: mov sp,r0 mov r2,-(sp) mov r3,-(sp) tst (r0)+ mov (r0)+,r2 /par#1 - from pointer mov (r0)+,r3 /par#2 - to pointer mov *r0,r1 /par#3 - word count clr r0 div $8,r0 inc r0 asl r1 neg r1 jmp 2f(r1) 1: mov (r2)+,(r3)+ mov (r2)+,(r3)+ mov (r2)+,(r3)+ mov (r2)+,(r3)+ mov (r2)+,(r3)+ mov (r2)+,(r3)+ mov (r2)+,(r3)+ mov (r2)+,(r3)+ 2: sob r0,1b mov (sp)+,r3 mov (sp)+,r2 rts pc