openblt

a hobby OS from the late 90s
git clone http://frotz.net/git/openblt.git
Log | Files | Refs | LICENSE

strcpy.S (1076B)


      1 /* $Id: //depot/blt/lib/strcpy.S#1 $ */
      2 
      3 /*	$OpenBSD: strcpy.S,v 1.2 1996/09/27 06:47:50 mickey Exp $	*/
      4 
      5 /*
      6  * Written by J.T. Conklin <jtc@netbsd.org>.
      7  * Public domain.
      8  */
      9 
     10 /*
     11  * NOTE: I've unrolled the loop eight times: large enough to make a
     12  * significant difference, and small enough not to totally trash the
     13  * cache.
     14  */
     15 
     16 #include <i386/asm.h>
     17 
     18 FUNCTION (strcpy)
     19 	movl	4(%esp),%ecx		/* dst address */
     20 	movl	8(%esp),%edx		/* src address */
     21 	pushl	%ecx			/* push dst address */
     22 
     23 	.align 2,0x90
     24 L1:	movb	(%edx),%al		/* unroll loop, but not too much */
     25 	movb	%al,(%ecx)
     26 	testb	%al,%al
     27 	jz	L2
     28 	movb	1(%edx),%al
     29 	movb	%al,1(%ecx)
     30 	testb	%al,%al
     31 	jz	L2
     32 	movb	2(%edx),%al
     33 	movb	%al,2(%ecx)
     34 	testb	%al,%al
     35 	jz	L2
     36 	movb	3(%edx),%al
     37 	movb	%al,3(%ecx)
     38 	testb	%al,%al
     39 	jz	L2
     40 	movb	4(%edx),%al
     41 	movb	%al,4(%ecx)
     42 	testb	%al,%al
     43 	jz	L2
     44 	movb	5(%edx),%al
     45 	movb	%al,5(%ecx)
     46 	testb	%al,%al
     47 	jz	L2
     48 	movb	6(%edx),%al
     49 	movb	%al,6(%ecx)
     50 	testb	%al,%al
     51 	jz	L2
     52 	movb	7(%edx),%al
     53 	movb	%al,7(%ecx)
     54 	addl	$8,%edx
     55 	addl	$8,%ecx
     56 	testb	%al,%al
     57 	jnz	L1
     58 L2:	popl	%eax			/* pop dst address */
     59 	ret