From 3f02f778cdbec7d95e0a9d6f9368ce9cda0a6d03 Mon Sep 17 00:00:00 2001 From: Greg McGary Date: Fri, 9 Jun 2000 06:14:39 +0000 Subject: * sysdeps/i386/bp-asm.h: New file. * sysdeps/i386/__longjmp.S: Define & use symbolic argument stack offsets. Add ENTER/LEAVE macros for optionally maintaining frame-pointer chain when debugging. * sysdeps/i386/add_n.S: Likewise. * sysdeps/i386/addmul_1.S: Likewise. * sysdeps/i386/lshift.S: Likewise. * sysdeps/i386/memchr.S: Likewise. * sysdeps/i386/memcmp.S: Likewise. * sysdeps/i386/mul_1.S: Likewise. * sysdeps/i386/rawmemchr.S: Likewise. * sysdeps/i386/rshift.S: Likewise. * sysdeps/i386/stpcpy.S: Likewise. * sysdeps/i386/stpncpy.S: Likewise. * sysdeps/i386/strchr.S: Likewise. * sysdeps/i386/strchrnul.S: Likewise. * sysdeps/i386/strcspn.S: Likewise. * sysdeps/i386/strpbrk.S: Likewise. * sysdeps/i386/strrchr.S: Likewise. * sysdeps/i386/strspn.S: Likewise. * sysdeps/i386/strtok.S: Likewise. * sysdeps/i386/sub_n.S: Likewise. * sysdeps/i386/submul_1.S: Likewise. * sysdeps/i386/elf/setjmp.S: Likewise. * sysdeps/i386/i486/strcat.S: Likewise. * sysdeps/i386/i486/strlen.S: Likewise. * sysdeps/i386/i586/add_n.S: Likewise. * sysdeps/i386/i586/lshift.S: Likewise. * sysdeps/i386/i586/memcpy.S: Likewise. * sysdeps/i386/i586/memset.S: Likewise. * sysdeps/i386/i586/rshift.S: Likewise. * sysdeps/i386/i586/strchr.S: Likewise. * sysdeps/i386/i586/strcpy.S: Likewise. * sysdeps/i386/i586/strlen.S: Likewise. * sysdeps/i386/i586/sub_n.S: Likewise. * sysdeps/i386/i686/add_n.S: Likewise. * sysdeps/i386/i686/memcpy.S: Likewise. * sysdeps/i386/i686/mempcpy.S: Likewise. * sysdeps/i386/i686/memset.S: Likewise. * sysdeps/i386/i686/strcmp.S: Likewise. 2000-06-08 Greg McGary * sysdeps/i386/bp-asm.h: New file. * sysdeps/i386/__longjmp.S: Define & use symbolic argument stack offsets. Add ENTER/LEAVE macros for optionally maintaining frame-pointer chain when debugging. * sysdeps/i386/add_n.S: Likewise. * sysdeps/i386/addmul_1.S: Likewise. * sysdeps/i386/lshift.S: Likewise. * sysdeps/i386/memchr.S: Likewise. * sysdeps/i386/memcmp.S: Likewise. * sysdeps/i386/mul_1.S: Likewise. * sysdeps/i386/rawmemchr.S: Likewise. * sysdeps/i386/rshift.S: Likewise. * sysdeps/i386/stpcpy.S: Likewise. * sysdeps/i386/stpncpy.S: Likewise. * sysdeps/i386/strchr.S: Likewise. * sysdeps/i386/strchrnul.S: Likewise. * sysdeps/i386/strcspn.S: Likewise. * sysdeps/i386/strpbrk.S: Likewise. * sysdeps/i386/strrchr.S: Likewise. * sysdeps/i386/strspn.S: Likewise. * sysdeps/i386/strtok.S: Likewise. * sysdeps/i386/sub_n.S: Likewise. * sysdeps/i386/submul_1.S: Likewise. * sysdeps/i386/elf/setjmp.S: Likewise. * sysdeps/i386/i486/strcat.S: Likewise. * sysdeps/i386/i486/strlen.S: Likewise. * sysdeps/i386/i586/add_n.S: Likewise. * sysdeps/i386/i586/lshift.S: Likewise. * sysdeps/i386/i586/memcpy.S: Likewise. * sysdeps/i386/i586/memset.S: Likewise. * sysdeps/i386/i586/rshift.S: Likewise. * sysdeps/i386/i586/strchr.S: Likewise. * sysdeps/i386/i586/strcpy.S: Likewise. * sysdeps/i386/i586/strlen.S: Likewise. * sysdeps/i386/i586/sub_n.S: Likewise. * sysdeps/i386/i686/add_n.S: Likewise. * sysdeps/i386/i686/memcpy.S: Likewise. * sysdeps/i386/i686/mempcpy.S: Likewise. * sysdeps/i386/i686/memset.S: Likewise. * sysdeps/i386/i686/strcmp.S: Likewise. --- sysdeps/i386/__longjmp.S | 15 ++++- sysdeps/i386/add_n.S | 29 +++++---- sysdeps/i386/addmul_1.S | 25 ++++---- sysdeps/i386/bp-asm.h | 142 ++++++++++++++++++++++++++++++++++++++++++++ sysdeps/i386/elf/setjmp.S | 7 ++- sysdeps/i386/i486/strcat.S | 23 +++---- sysdeps/i386/i486/strlen.S | 16 ++--- sysdeps/i386/i586/add_n.S | 29 +++++---- sysdeps/i386/i586/lshift.S | 33 +++++----- sysdeps/i386/i586/memcpy.S | 39 ++++++++---- sysdeps/i386/i586/memset.S | 41 ++++++++----- sysdeps/i386/i586/rshift.S | 33 +++++----- sysdeps/i386/i586/strchr.S | 24 ++++---- sysdeps/i386/i586/strcpy.S | 23 ++++--- sysdeps/i386/i586/strlen.S | 17 +++--- sysdeps/i386/i586/sub_n.S | 29 +++++---- sysdeps/i386/i686/add_n.S | 27 +++++---- sysdeps/i386/i686/memcpy.S | 29 +++++---- sysdeps/i386/i686/mempcpy.S | 27 +++++---- sysdeps/i386/i686/memset.S | 47 +++++++++------ sysdeps/i386/i686/strcmp.S | 37 +++++++----- sysdeps/i386/lshift.S | 31 ++++++---- sysdeps/i386/memchr.S | 57 +++++++++--------- sysdeps/i386/memcmp.S | 22 +++---- sysdeps/i386/mul_1.S | 20 +++++-- sysdeps/i386/rawmemchr.S | 19 +++--- sysdeps/i386/rshift.S | 31 ++++++---- sysdeps/i386/stpcpy.S | 21 ++++--- sysdeps/i386/stpncpy.S | 24 ++++---- sysdeps/i386/strchr.S | 26 ++++---- sysdeps/i386/strchrnul.S | 53 +++++++++-------- sysdeps/i386/strcspn.S | 18 +++--- sysdeps/i386/strpbrk.S | 21 ++++--- sysdeps/i386/strrchr.S | 21 ++++--- sysdeps/i386/strspn.S | 18 +++--- sysdeps/i386/strtok.S | 21 +++++-- sysdeps/i386/sub_n.S | 29 +++++---- sysdeps/i386/submul_1.S | 28 +++++---- 38 files changed, 732 insertions(+), 420 deletions(-) create mode 100644 sysdeps/i386/bp-asm.h (limited to 'sysdeps') diff --git a/sysdeps/i386/__longjmp.S b/sysdeps/i386/__longjmp.S index a8049e9de3..54f31361be 100644 --- a/sysdeps/i386/__longjmp.S +++ b/sysdeps/i386/__longjmp.S @@ -1,5 +1,5 @@ /* longjmp for i386. - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -21,10 +21,19 @@ #define _ASM #define _SETJMP_H #include +#include + +#define PARMS LINKAGE /* no space for saved regs */ +#define JBUF PARMS +#define VAL JBUF+PTR_SIZE ENTRY (__longjmp) - movl 4(%esp), %ecx /* User's jmp_buf in %ecx. */ - movl 8(%esp), %eax /* Second argument is return value. */ + ENTER + + movl JBUF(%esp), %ecx /* User's jmp_buf in %ecx. */ + LEAVE + + movl VAL(%esp), %eax /* Second argument is return value. */ /* Save the return address now. */ movl (JB_PC*4)(%ecx), %edx /* Restore registers. */ diff --git a/sysdeps/i386/add_n.S b/sysdeps/i386/add_n.S index 8bf1512087..edd2e852fd 100644 --- a/sysdeps/i386/add_n.S +++ b/sysdeps/i386/add_n.S @@ -1,6 +1,6 @@ /* Add two limb vectors of the same length > 0 and store sum in a third limb vector. - Copyright (C) 1992, 94, 95, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1992, 94, 95, 97, 98, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -18,26 +18,27 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - s2_ptr (sp + 12) - size (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+8 /* space for 2 saved regs */ +#define RES PARMS +#define S1 RES+PTR_SIZE +#define S2 S1+PTR_SIZE +#define SIZE S2+PTR_SIZE .text ENTRY(__mpn_add_n) + ENTER + pushl %edi pushl %esi - movl 12(%esp),%edi /* res_ptr */ - movl 16(%esp),%esi /* s1_ptr */ - movl 20(%esp),%edx /* s2_ptr */ - movl 24(%esp),%ecx /* size */ + movl RES(%esp),%edi + movl S1(%esp),%esi + movl S2(%esp),%edx + movl SIZE(%esp),%ecx movl %ecx,%eax shrl $3,%ecx /* compute count for unrolled loop */ @@ -99,5 +100,7 @@ L(oop): movl (%esi),%eax popl %esi popl %edi + + LEAVE ret END(__mpn_add_n) diff --git a/sysdeps/i386/addmul_1.S b/sysdeps/i386/addmul_1.S index d7df5270c3..50151ea07d 100644 --- a/sysdeps/i386/addmul_1.S +++ b/sysdeps/i386/addmul_1.S @@ -1,6 +1,6 @@ /* i80386 __mpn_addmul_1 -- Multiply a limb vector with a limb and add the result to a second limb vector. - Copyright (C) 1992, 1994, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1992, 1994, 1997, 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -18,16 +18,15 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - sizeP (sp + 12) - s2_limb (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+16 /* space for 4 saved regs */ +#define RES PARMS +#define S1 RES+PTR_SIZE +#define SIZE S1+PTR_SIZE +#define S2LIMB SIZE+4 #define res_ptr edi #define s1_ptr esi @@ -42,10 +41,10 @@ ENTRY(__mpn_addmul_1) INSN1(push,l ,R(ebx)) INSN1(push,l ,R(ebp)) - INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20)) - INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24)) - INSN2(mov,l ,R(sizeP),MEM_DISP(esp,28)) - INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32)) + INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,RES)) + INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,S1)) + INSN2(mov,l ,R(sizeP),MEM_DISP(esp,SIZE)) + INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,S2LIMB)) INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,sizeP,4)) INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,sizeP,4)) diff --git a/sysdeps/i386/bp-asm.h b/sysdeps/i386/bp-asm.h new file mode 100644 index 0000000000..197c6da88c --- /dev/null +++ b/sysdeps/i386/bp-asm.h @@ -0,0 +1,142 @@ +/* Bounded-pointer definitions for x86 assembler. + Copyright (C) 2000 Free Software Foundation, Inc. + Contributed by Greg McGary + + This file is part of the GNU C Library. Its master source is NOT part of + the C library, however. The master source lives in the GNU MP Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _bp_asm_h_ +# define _bp_asm_h_ 1 + +# if __ASSEMBLER__ + +# if __BOUNDED_POINTERS__ + +/* Bounded pointers occupy three words. */ +# define PTR_SIZE 12 +/* Bounded pointer return values are passed back through a hidden + argument that points to caller-allocate space. The hidden arg + occupies one word on the stack. */ +# define RTN_SIZE 4 +/* Although the caller pushes the hidden arg, the callee is + responsible for popping it. */ +# define RET_PTR ret $RTN_SIZE +/* Maintain frame pointer chain in leaf assembler functions for the benefit + of debugging stack traces when bounds violations occur. */ +# define ENTER pushl %ebp; movl %esp, %ebp +# define LEAVE movl %ebp, %esp; popl %ebp +/* Stack space overhead of procedure-call linkage: return address and + frame pointer. */ +# define LINKAGE 8 + +/* Int 5 is the "bound range" exception also raised by the "bound" + instruction. */ +# define BOUNDS_VIOLATED int $5 + +# define CHECK_BOUNDS_LOW(VAL_REG, BP_MEM) \ + cmpl 4+BP_MEM, VAL_REG; \ + jae 0f; /* continue if value >= low */ \ + BOUNDS_VIOLATED; \ + 0: + +# define CHECK_BOUNDS_HIGH(VAL_REG, BP_MEM, Jcc) \ + cmpl 8+BP_MEM, VAL_REG; \ + Jcc 0f; /* continue if value < high */ \ + BOUNDS_VIOLATED; \ + 0: + +# define CHECK_BOUNDS_BOTH(VAL_REG, BP_MEM) \ + cmpl 4+BP_MEM, VAL_REG; \ + jb 1f; /* die if value < low */ \ + cmpl 8+BP_MEM, VAL_REG; \ + jb 0f; /* continue if value < high */ \ + 1: BOUNDS_VIOLATED; \ + 0: + +# define CHECK_BOUNDS_BOTH_WIDE(VAL_REG, BP_MEM, LENGTH) \ + CHECK_BOUNDS_LOW(VAL_REG, BP_MEM); \ + addl LENGTH, VAL_REG; \ + cmpl 8+BP_MEM, VAL_REG; \ + jbe 0f; /* continue if value <= high */ \ + BOUNDS_VIOLATED; \ + 0: subl LENGTH, VAL_REG /* restore value */ + +/* Take bounds from BP_MEM and affix them to the pointer + value in %eax, stuffing all into memory at RTN(%esp). + Use %ecx as a scratch register. */ + +# define RETURN_BOUNDED_POINTER(BP_MEM) \ + movl RTN(%esp), %ecx; \ + movl %eax, 0(%ecx); \ + movl 4+BP_MEM, %eax; \ + movl %eax, 4(%ecx); \ + movl 8+BP_MEM, %eax; \ + movl %eax, 8(%ecx) + +# define RETURN_NULL_BOUNDED_POINTER \ + movl RTN(%esp), %ecx; \ + movl %eax, 0(%ecx); \ + movl %eax, 4(%ecx); \ + movl %eax, 8(%ecx) + +/* The caller of __errno_location is responsible for allocating space + for the three-word BP return-value and passing pushing its address + as an implicit first argument. */ +# define PUSH_ERRNO_LOCATION_RETURN \ + subl $8, %esp; \ + subl $4, %esp; \ + pushl %esp + +/* __errno_location is responsible for popping the implicit first + argument, but we must pop the space for the BP itself. We also + dereference the return value in order to dig out the pointer value. */ +# define POP_ERRNO_LOCATION_RETURN \ + movl (%esp), %eax; \ + addl $4, %esp; \ + addl $8, %esp + +# else /* !__BOUNDED_POINTERS__ */ + +/* Unbounded pointers occupy one word. */ +# define PTR_SIZE 4 +/* Unbounded pointer return values are passed back in the register %eax. */ +# define RTN_SIZE 0 +/* Use simple return instruction for unbounded pointer values. */ +# define RET_PTR ret +/* Don't maintain frame pointer chain for leaf assembler functions. */ +# define ENTER +# define LEAVE +/* Stack space overhead of procedure-call linkage: return address only. */ +# define LINKAGE 4 + +# define CHECK_BOUNDS_LOW(VAL_REG, BP_MEM) +# define CHECK_BOUNDS_HIGH(VAL_REG, BP_MEM, Jcc) +# define CHECK_BOUNDS_BOTH(VAL_REG, BP_MEM) +# define CHECK_BOUNDS_BOTH_WIDE(VAL_REG, BP_MEM, LENGTH) +# define RETURN_BOUNDED_POINTER(BP_MEM) + +# define RETURN_NULL_BOUNDED_POINTER + +# define PUSH_ERRNO_LOCATION_RETURN +# define POP_ERRNO_LOCATION_RETURN + +# endif /* !__BOUNDED_POINTERS__ */ + +# endif /* __ASSEMBLER__ */ + +#endif /* _bp_asm_h_ */ diff --git a/sysdeps/i386/elf/setjmp.S b/sysdeps/i386/elf/setjmp.S index 40710be1ef..e734809bf8 100644 --- a/sysdeps/i386/elf/setjmp.S +++ b/sysdeps/i386/elf/setjmp.S @@ -21,6 +21,11 @@ #define _ASM #define _SETJMP_H #include +#include "bp-asm.h" + +#define PARMS LINKAGE /* no space for saved regs */ +#define JBUF PARMS +#define SGMSK JBUF+PRT_SIZE /* We include the BSD entry points here as well but we make them weak. */ @@ -55,7 +60,7 @@ ENTRY (__sigsetjmp) movl %esi, (JB_SI*4)(%eax) movl %edi, (JB_DI*4)(%eax) movl %ebp, (JB_BP*4)(%eax) - leal 4(%esp), %ecx /* Save SP as it will be after we return. */ + leal JBUF(%esp), %ecx /* Save SP as it will be after we return. */ movl %ecx, (JB_SP*4)(%eax) movl 0(%esp), %ecx /* Save PC we are returning to now. */ movl %ecx, (JB_PC*4)(%eax) diff --git a/sysdeps/i386/i486/strcat.S b/sysdeps/i386/i486/strcat.S index c3893315e7..c4ab170389 100644 --- a/sysdeps/i386/i486/strcat.S +++ b/sysdeps/i386/i486/strcat.S @@ -1,6 +1,6 @@ /* strcat(dest, src) -- Append SRC on the end of DEST. For Intel 80x86, x>=4. - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper . Optimised a little by Alan Modra @@ -22,19 +22,21 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - dest (sp + 4) - src (sp + 8) -*/ +#define PARMS LINKAGE+4 /* space for 1 saved reg */ +#define RTN PARMS +#define DEST RTN+RTN_SIZE +#define SRC DEST+PTR_SIZE .text ENTRY (strcat) + ENTER + pushl %edi /* Save callee-safe register. */ - movl 12(%esp), %ecx /* load source pointer */ - movl 8(%esp), %edx /* load destination pointer */ + movl DEST(%esp), %edx + movl SRC(%esp), %ecx testb $0xff, (%ecx) /* Is source string empty? */ jz L(8) /* yes => return */ @@ -254,8 +256,9 @@ L(9): movb %al, (%ecx,%edx) /* store first byte of last word */ movb %ah, 3(%ecx,%edx) /* store fourth byte of last word */ -L(8): movl 8(%esp), %eax /* start address of destination is result */ +L(8): movl DEST(%esp), %eax /* start address of destination is result */ popl %edi /* restore saved register */ - ret + LEAVE + RET_PTR END (strcat) diff --git a/sysdeps/i386/i486/strlen.S b/sysdeps/i386/i486/strlen.S index 4a25011016..d19a3457cf 100644 --- a/sysdeps/i386/i486/strlen.S +++ b/sysdeps/i386/i486/strlen.S @@ -1,6 +1,6 @@ /* strlen(str) -- determine the length of the string STR. Optimized for Intel 80x86, x>=4. - Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. + Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 2000 Free Software Foundation, Inc. Contributed by Ulrich Drepper . This file is part of the GNU C Library. @@ -21,15 +21,16 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define STR PARMS .text ENTRY (strlen) - movl 4(%esp), %ecx /* get string pointer */ + ENTER + + movl STR(%esp), %ecx movl %ecx, %eax /* duplicate it */ andl $3, %ecx /* mask alignment bits */ @@ -127,7 +128,8 @@ L(3): testb %cl, %cl /* is first byte NUL? */ jz L(2) /* yes => return pointer */ incl %eax /* increment pointer */ -L(2): subl 4(%esp), %eax /* compute difference to string start */ +L(2): subl STR(%esp), %eax /* compute difference to string start */ + LEAVE ret END (strlen) diff --git a/sysdeps/i386/i586/add_n.S b/sysdeps/i386/i586/add_n.S index 8b4130b415..9bea31b068 100644 --- a/sysdeps/i386/i586/add_n.S +++ b/sysdeps/i386/i586/add_n.S @@ -1,6 +1,6 @@ /* Pentium __mpn_add_n -- Add two limb vectors of the same length > 0 and store sum in a third limb vector. - Copyright (C) 1992, 94, 95, 96, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1992, 94, 95, 96, 97, 98, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -18,28 +18,29 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - s2_ptr (sp + 12) - size (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+16 /* space for 4 saved regs */ +#define RES PARMS +#define S1 RES+PTR_SIZE +#define S2 S1+PTR_SIZE +#define SIZE S2+PTR_SIZE .text ENTRY(__mpn_add_n) + ENTER + pushl %edi pushl %esi pushl %ebx pushl %ebp - movl 20(%esp),%edi /* res_ptr */ - movl 24(%esp),%esi /* s1_ptr */ - movl 28(%esp),%ebp /* s2_ptr */ - movl 32(%esp),%ecx /* size */ + movl RES(%esp),%edi + movl S1(%esp),%esi + movl S2(%esp),%ebp + movl SIZE(%esp),%ecx movl (%ebp),%ebx @@ -123,5 +124,7 @@ L(end2): popl %ebx popl %esi popl %edi + + LEAVE ret END(__mpn_add_n) diff --git a/sysdeps/i386/i586/lshift.S b/sysdeps/i386/i586/lshift.S index 22dc03ea65..d3f0da0062 100644 --- a/sysdeps/i386/i586/lshift.S +++ b/sysdeps/i386/i586/lshift.S @@ -1,5 +1,5 @@ /* Pentium optimized __mpn_lshift -- - Copyright (C) 1992, 94, 95, 96, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1992, 94, 95, 96, 97, 98, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify @@ -17,28 +17,29 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s_ptr (sp + 8) - size (sp + 12) - cnt (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+16 /* space for 4 saved regs */ +#define RES PARMS +#define S RES+PTR_SIZE +#define SIZE S+PTR_SIZE +#define CNT SIZE+4 -.text + .text ENTRY(__mpn_lshift) + ENTER + pushl %edi pushl %esi pushl %ebx pushl %ebp - movl 20(%esp),%edi /* res_ptr */ - movl 24(%esp),%esi /* s_ptr */ - movl 28(%esp),%ebp /* size */ - movl 32(%esp),%ecx /* cnt */ + movl RES(%esp),%edi + movl S(%esp),%esi + movl SIZE(%esp),%ebp + movl CNT(%esp),%ecx /* We can use faster code for shift-by-1 under certain conditions. */ cmp $1,%ecx @@ -127,6 +128,8 @@ L(end2): popl %ebx popl %esi popl %edi + + LEAVE ret /* We loop from least significant end of the arrays, which is only @@ -216,5 +219,7 @@ L(L1): movl %edx,(%edi) /* store last limb */ popl %ebx popl %esi popl %edi + + LEAVE ret END(__mpn_lshift) diff --git a/sysdeps/i386/i586/memcpy.S b/sysdeps/i386/i586/memcpy.S index 9116c8d741..82d5e79564 100644 --- a/sysdeps/i386/i586/memcpy.S +++ b/sysdeps/i386/i586/memcpy.S @@ -1,5 +1,5 @@ /* Highly optimized version for i586. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -20,23 +20,31 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - dst (sp + 4) - src (sp + 8) - len (sp + 12) -*/ +/* BEWARE: `#ifdef memset' means that memset is redefined as `bzero' */ +#define BCOPY_P (defined memcpy) +#define PARMS LINKAGE+8 /* space for 2 saved regs */ +#if BCOPY_P +# define DEST PARMS +#else +# define RTN PARMS +# define DEST RTN+RTN_SIZE +#endif +#define SRC DEST+PTR_SIZE +#define LEN SRC+PTR_SIZE .text ENTRY (memcpy) + ENTER + pushl %edi pushl %esi - movl 12(%esp), %edi /* dst */ - movl 16(%esp), %esi /* src */ - movl 20(%esp), %ecx /* len */ + movl DEST(%esp), %edi + movl SRC(%esp), %esi + movl LEN(%esp), %ecx movl %edi, %eax /* We need this in any case. */ @@ -91,18 +99,23 @@ L(3): movl 28(%edi), %edx /* Correct extra loop counter modification. */ L(2): addl $32, %ecx -#ifndef memcpy - movl 12(%esp), %eax /* dst */ +#if !BCOPY_P + movl DEST(%esp), %eax #endif L(1): rep; movsb -#ifdef memcpy +#if BCOPY_P movl %edi, %eax #endif popl %esi popl %edi + LEAVE +#if BCOPY_P ret +#else + RET_PTR +#endif END (memcpy) diff --git a/sysdeps/i386/i586/memset.S b/sysdeps/i386/i586/memset.S index 01bed35534..8b292e92fa 100644 --- a/sysdeps/i386/i586/memset.S +++ b/sysdeps/i386/i586/memset.S @@ -1,6 +1,6 @@ /* memset/bzero -- set memory area to CH/0 Highly optimized version for ix86, x>=5. - Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Torbjorn Granlund, @@ -21,27 +21,33 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - (memset) (bzero) - dst (sp + 4) dst (sp + 4) - ch (sp + 8) len (sp + 8) - len (sp + 12) -*/ +/* BEWARE: `#ifdef memset' means that memset is redefined as `bzero' */ +#define BZERO_P (defined memset) +#define PARMS LINKAGE+4 /* space for 1 saved reg */ +#define RTN PARMS +#define DEST RTN+RTN_SIZE +#if BZERO_P +# define LEN DEST+PTR_SIZE +#else +# define CHR DEST+PTR_SIZE +# define LEN CHR+4 +#endif .text ENTRY (memset) + ENTER + pushl %edi - movl 8(%esp), %edi /* destination pointer */ -#ifdef memset + movl DEST(%esp), %edi + movl LEN(%esp), %edx +#if BZERO_P xorl %eax, %eax /* we fill with 0 */ - movl 12(%esp), %edx /* size (in 8-bit words) */ #else - movb 12(%esp), %al /* use CH to fill */ - movl 16(%esp), %edx /* size (in 8-bit words) */ + movb CHR(%esp), %al movb %al, %ah movl %eax, %ecx @@ -93,11 +99,16 @@ L(2): shrl $2, %ecx /* convert byte count to longword count */ rep stosb +#if !BZERO_P /* Load result (only if used as memset). */ -#ifndef memset - movl 8(%esp), %eax + movl DEST(%esp), %eax #endif popl %edi + LEAVE +#if BZERO_P ret +#else + RET_PTR +#endif END (memset) diff --git a/sysdeps/i386/i586/rshift.S b/sysdeps/i386/i586/rshift.S index 64e4047642..2395446d1b 100644 --- a/sysdeps/i386/i586/rshift.S +++ b/sysdeps/i386/i586/rshift.S @@ -1,5 +1,5 @@ /* Pentium optimized __mpn_rshift -- - Copyright (C) 1992, 94, 95, 96, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1992, 94, 95, 96, 97, 98, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -17,28 +17,29 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s_ptr (sp + 8) - size (sp + 12) - cnt (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+16 /* space for 4 saved regs */ +#define RES PARMS +#define S RES+PTR_SIZE +#define SIZE S+PTR_SIZE +#define CNT SIZE+4 -.text + .text ENTRY(__mpn_rshift) + ENTER + pushl %edi pushl %esi pushl %ebx pushl %ebp - movl 20(%esp),%edi /* res_ptr */ - movl 24(%esp),%esi /* s_ptr */ - movl 28(%esp),%ebp /* size */ - movl 32(%esp),%ecx /* cnt */ + movl RES(%esp),%edi + movl S(%esp),%esi + movl SIZE(%esp),%ebp + movl CNT(%esp),%ecx /* We can use faster code for shift-by-1 under certain conditions. */ cmp $1,%ecx @@ -124,6 +125,8 @@ L(end2): popl %ebx popl %esi popl %edi + + LEAVE ret /* We loop from least significant end of the arrays, which is only @@ -216,5 +219,7 @@ L(L1): movl %edx,(%edi) /* store last limb */ popl %ebx popl %esi popl %edi + + LEAVE ret END(__mpn_rshift) diff --git a/sysdeps/i386/i586/strchr.S b/sysdeps/i386/i586/strchr.S index e351853231..bf351f605e 100644 --- a/sysdeps/i386/i586/strchr.S +++ b/sysdeps/i386/i586/strchr.S @@ -1,6 +1,6 @@ /* Find character CH in a NUL terminated string. Highly optimized version for ix85, x>=5. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper, . @@ -21,6 +21,7 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" /* This version is especially optimized for the i586 (and following?) processors. This is mainly done by using the two pipelines. The @@ -35,22 +36,23 @@ /* The magic value which is used throughout in the whole code. */ #define magic 0xfefefeff -/* - INPUT PARAMETERS: - str (sp + 4) - ch (sp + 8) -*/ +#define PARMS LINKAGE+16 /* space for 4 saved regs */ +#define RTN PARMS +#define STR RTN+RTN_SIZE +#define CHR STR+PTR_SIZE .text ENTRY (strchr) + ENTER + pushl %edi /* Save callee-safe registers. */ pushl %esi pushl %ebx pushl %ebp - movl 20(%esp), %eax /* get string pointer */ - movl 24(%esp), %edx /* get character we are looking for */ + movl STR(%esp), %eax + movl CHR(%esp), %edx movl %eax, %edi /* duplicate string pointer for later */ xorl %ecx, %ecx /* clear %ecx */ @@ -283,7 +285,8 @@ L(2): popl %ebp /* restore saved registers */ popl %esi popl %edi - ret + LEAVE + RET_PTR /* We know there is a NUL byte in the word. But we have to test whether there is an C byte before it in the word. */ @@ -326,7 +329,8 @@ L(3): xorl %eax, %eax /* set return value = NULL */ popl %esi popl %edi - ret + LEAVE + RET_PTR END (strchr) #undef index diff --git a/sysdeps/i386/i586/strcpy.S b/sysdeps/i386/i586/strcpy.S index 7f89a2c0f7..a48fbb68f8 100644 --- a/sysdeps/i386/i586/strcpy.S +++ b/sysdeps/i386/i586/strcpy.S @@ -1,5 +1,5 @@ /* strcpy/stpcpy implementation for i586. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -20,6 +20,12 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+12 /* space for 3 saved regs */ +#define RTN PARMS +#define DEST RTN+RTN_SIZE +#define SRC DEST+PTR_SIZE #ifndef USE_AS_STPCPY # define STRCPY strcpy @@ -29,12 +35,14 @@ .text ENTRY(STRCPY) + ENTER + pushl %edi pushl %esi pushl %ebx - movl 16(%esp), %edi - movl 20(%esp), %esi + movl DEST(%esp), %edi + movl SRC(%esp), %esi xorl %eax, %eax leal -1(%esi), %ecx @@ -136,12 +144,13 @@ L(end): movb %ah, (%edi) L(end2): #ifdef USE_AS_STPCPY movl %edi, %eax +#else + movl DEST(%esp), %eax #endif popl %ebx popl %esi popl %edi -#ifndef USE_AS_STPCPY - movl 4(%esp), %eax -#endif - ret + + LEAVE + RET_PTR END(STRCPY) diff --git a/sysdeps/i386/i586/strlen.S b/sysdeps/i386/i586/strlen.S index 2e6ea680ec..e2771268ed 100644 --- a/sysdeps/i386/i586/strlen.S +++ b/sysdeps/i386/i586/strlen.S @@ -1,6 +1,6 @@ /* strlen -- Compute length og NUL terminated string. Highly optimized version for ix86, x>=5. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper, . @@ -21,6 +21,7 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" /* This version is especially optimized for the i586 (and following?) processors. This is mainly done by using the two pipelines. The @@ -35,14 +36,14 @@ /* The magic value which is used throughout in the whole code. */ #define magic 0xfefefeff -/* - INPUT PARAMETERS: - str (sp + 4) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define STR PARMS .text ENTRY(strlen) - movl 4(%esp), %eax /* get string pointer */ + ENTER + + movl STR(%esp), %eax movl $3, %edx /* load mask (= 3) */ andl %eax, %edx /* separate last two bits of address */ @@ -176,9 +177,9 @@ L(3): subl $4, %eax /* correct too early pointer increment */ incl %eax /* increment pointer */ -L(2): subl 4(%esp), %eax /* now compute the length as difference +L(2): subl STR(%esp), %eax /* now compute the length as difference between start and terminating NUL character */ - + LEAVE ret END (strlen) diff --git a/sysdeps/i386/i586/sub_n.S b/sysdeps/i386/i586/sub_n.S index 03c85d9aa6..dbfb5d2865 100644 --- a/sysdeps/i386/i586/sub_n.S +++ b/sysdeps/i386/i586/sub_n.S @@ -1,6 +1,6 @@ /* Pentium __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and store difference in a third limb vector. - Copyright (C) 1992, 94, 95, 96, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1992, 94, 95, 96, 97, 98, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -18,28 +18,29 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - s2_ptr (sp + 12) - size (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+16 /* space for 4 saved regs */ +#define RES PARMS +#define S1 RES+PTR_SIZE +#define S2 S1+PTR_SIZE +#define SIZE S2+PTR_SIZE .text ENTRY(__mpn_sub_n) + ENTER + pushl %edi pushl %esi pushl %ebx pushl %ebp - movl 20(%esp),%edi /* res_ptr */ - movl 24(%esp),%esi /* s1_ptr */ - movl 28(%esp),%ebp /* s2_ptr */ - movl 32(%esp),%ecx /* size */ + movl RES(%esp),%edi + movl S1(%esp),%esi + movl S2(%esp),%ebp + movl SIZE(%esp),%ecx movl (%ebp),%ebx @@ -123,5 +124,7 @@ L(end2): popl %ebx popl %esi popl %edi + + LEAVE ret END(__mpn_sub_n) diff --git a/sysdeps/i386/i686/add_n.S b/sysdeps/i386/i686/add_n.S index 5a1339f9f8..45e1284b1b 100644 --- a/sysdeps/i386/i686/add_n.S +++ b/sysdeps/i386/i686/add_n.S @@ -18,16 +18,15 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - s2_ptr (sp + 12) - size (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+8 /* space for 2 saved regs */ +#define RES PARMS +#define S1 RES+PTR_SIZE +#define S2 S1+PTR_SIZE +#define SIZE S2+PTR_SIZE .text #ifdef PIC @@ -35,13 +34,15 @@ L(1): addl (%esp), %eax ret #endif ENTRY(__mpn_add_n) + ENTER + pushl %edi pushl %esi - movl 12(%esp),%edi /* res_ptr */ - movl 16(%esp),%esi /* s1_ptr */ - movl 20(%esp),%edx /* s2_ptr */ - movl 24(%esp),%ecx /* size */ + movl RES(%esp),%edi + movl S1(%esp),%esi + movl S2(%esp),%edx + movl SIZE(%esp),%ecx movl %ecx,%eax shrl $3,%ecx /* compute count for unrolled loop */ @@ -100,5 +101,7 @@ L(oop): movl (%esi),%eax popl %esi popl %edi + + LEAVE ret END(__mpn_add_n) diff --git a/sysdeps/i386/i686/memcpy.S b/sysdeps/i386/i686/memcpy.S index eab6855d57..8e8cc41fbc 100644 --- a/sysdeps/i386/i686/memcpy.S +++ b/sysdeps/i386/i686/memcpy.S @@ -1,7 +1,7 @@ /* Copy memory block and return pointer to beginning of destination block For Intel 80x86, x>=6. This file is part of the GNU C Library. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. Contributed by Ulrich Drepper , 1999. The GNU C Library is free software; you can redistribute it and/or @@ -21,20 +21,23 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* memcpy: - INPUT PARAMETER: - dest (sp + 4) - src (sp + 8) - len (sp + 12) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define RTN PARMS +#define DEST RTN+RTN_SIZE +#define SRC DEST+PTR_SIZE +#define LEN SRC+PTR_SIZE + .text ENTRY(memcpy) - movl 12(%esp), %ecx + ENTER + + movl LEN(%esp), %ecx movl %edi, %eax - movl 4(%esp), %edi + movl DEST(%esp), %edi movl %esi, %edx - movl 8(%esp), %esi + movl SRC(%esp), %esi cld shrl $1, %ecx jnc 1f @@ -46,6 +49,8 @@ ENTRY(memcpy) movsl movl %eax, %edi movl %edx, %esi - movl 4(%esp), %eax - ret + movl DEST(%esp), %eax + + LEAVE + RET_PTR END(memcpy) diff --git a/sysdeps/i386/i686/mempcpy.S b/sysdeps/i386/i686/mempcpy.S index 4fb14a3d14..c851d06d44 100644 --- a/sysdeps/i386/i686/mempcpy.S +++ b/sysdeps/i386/i686/mempcpy.S @@ -1,7 +1,7 @@ /* Copy memory block and return pointer to following byte. For Intel 80x86, x>=6. This file is part of the GNU C Library. - Copyright (C) 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. Contributed by Ulrich Drepper , 1998. The GNU C Library is free software; you can redistribute it and/or @@ -21,20 +21,23 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* mempcpy: - INPUT PARAMETER: - dest (sp + 4) - src (sp + 8) - len (sp + 12) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define RTN PARMS +#define DEST RTN+RTN_SIZE +#define SRC DEST+PTR_SIZE +#define LEN SRC+PTR_SIZE + .text ENTRY(__mempcpy) - movl 12(%esp), %ecx + ENTER + + movl LEN(%esp), %ecx movl %edi, %eax - movl 4(%esp), %edi + movl DEST(%esp), %edi movl %esi, %edx - movl 8(%esp), %esi + movl SRC(%esp), %esi cld shrl $1, %ecx jnc 1f @@ -46,6 +49,8 @@ ENTRY(__mempcpy) movsl xchgl %edi, %eax movl %edx, %esi - ret + + LEAVE + RET_PTR END(__mempcpy) weak_alias (__mempcpy, mempcpy) diff --git a/sysdeps/i386/i686/memset.S b/sysdeps/i386/i686/memset.S index 83f8c50484..74ce87bfc7 100644 --- a/sysdeps/i386/i686/memset.S +++ b/sysdeps/i386/i686/memset.S @@ -1,6 +1,6 @@ /* memset/bzero -- set memory area to CH/0 Highly optimized version for ix86, x>=6. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -21,27 +21,34 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - (memset) (bzero) - dst (sp + 4) dst (sp + 4) - ch (sp + 8) len (sp + 8) - len (sp + 12) -*/ +/* BEWARE: `#ifdef memset' means that memset is redefined as `bzero' */ +#define BZERO_P (defined memset) +#define PARMS LINKAGE+4 /* space for 1 saved reg */ +#if BZERO_P +# define DEST PARMS +# define LEN DEST+PTR_SIZE +#else +# define RTN PARMS +# define DEST RTN+RTN_SIZE +# define CHR DEST+PTR_SIZE +# define LEN CHR+4 +#endif .text ENTRY (memset) + ENTER + cld pushl %edi - movl 8(%esp), %edx -#ifdef memset - movl 12(%esp), %ecx - xorl %eax, %eax + movl DEST(%esp), %edx + movl LEN(%esp), %ecx +#if BZERO_P + xorl %eax, %eax /* fill with 0 */ #else - movzbl 12(%esp), %eax - movl 16(%esp), %ecx + movzbl CHR(%esp), %eax #endif jecxz 1f movl %edx, %edi @@ -61,7 +68,7 @@ ENTRY (memset) 2: movl %ecx, %edx shrl $2, %ecx andl $3, %edx -#ifndef memset +#if !BZERO_P imul $0x01010101, %eax #endif rep @@ -71,9 +78,15 @@ ENTRY (memset) stosb 1: -#ifndef memset - movl 8(%esp), %eax +#if !BZERO_P + movl DEST(%esp), %eax #endif popl %edi + + LEAVE +#if BZERO_P ret +#else + RET_PTR +#endif END (memset) diff --git a/sysdeps/i386/i686/strcmp.S b/sysdeps/i386/i686/strcmp.S index 8ffc5b0bb5..efda8515aa 100644 --- a/sysdeps/i386/i686/strcmp.S +++ b/sysdeps/i386/i686/strcmp.S @@ -1,5 +1,5 @@ /* Highly optimized version for ix86, x>=6. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -20,29 +20,34 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - s1 (sp + 4) - s2 (sp + 8) -*/ - +#define PARMS LINKAGE /* no space for saved regs */ +#define STR1 PARMS +#define STR2 STR1+PTR_SIZE .text ENTRY (strcmp) - movl 4(%esp), %ecx - movl 8(%esp), %edx -1: movb (%ecx), %al + ENTER + + movl STR1(%esp), %ecx + movl STR2(%esp), %edx + +L(oop): movb (%ecx), %al incl %ecx cmpb (%edx), %al - jne 2f + jne L(neq) incl %edx testb %al, %al - jnz 1b + jnz L(oop) + xorl %eax, %eax - jmp 3f -2: movl $1, %eax - ja 3f + jmp L(out) + +L(neq): movl $1, %eax + ja L(out) negl %eax -3: ret + +L(out): LEAVE + ret END (strcmp) diff --git a/sysdeps/i386/lshift.S b/sysdeps/i386/lshift.S index 737ce3ed2b..2e4c2ca3be 100644 --- a/sysdeps/i386/lshift.S +++ b/sysdeps/i386/lshift.S @@ -1,5 +1,5 @@ /* i80386 __mpn_lshift -- - Copyright (C) 1992, 1994, 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1992, 1994, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -17,27 +17,28 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s_ptr (sp + 8) - size (sp + 12) - cnt (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+12 /* space for 3 saved regs */ +#define RES PARMS +#define S RES+PTR_SIZE +#define SIZE S+PTR_SIZE +#define CNT SIZE+4 .text ENTRY(__mpn_lshift) + ENTER + pushl %edi pushl %esi pushl %ebx - movl 16(%esp),%edi /* res_ptr */ - movl 20(%esp),%esi /* s_ptr */ - movl 24(%esp),%edx /* size */ - movl 28(%esp),%ecx /* cnt */ + movl RES(%esp),%edi + movl S(%esp),%esi + movl SIZE(%esp),%edx + movl CNT(%esp),%ecx subl $4,%esi /* adjust s_ptr */ @@ -70,6 +71,8 @@ L(1): movl (%esi,%edx,4),%eax popl %ebx popl %esi popl %edi + + LEAVE ret L(end): shll %cl,%ebx /* compute least significant limb */ @@ -78,5 +81,7 @@ L(end): shll %cl,%ebx /* compute least significant limb */ popl %ebx popl %esi popl %edi + + LEAVE ret END(__mpn_lshift) diff --git a/sysdeps/i386/memchr.S b/sysdeps/i386/memchr.S index 1750aa8e26..80b210737b 100644 --- a/sysdeps/i386/memchr.S +++ b/sysdeps/i386/memchr.S @@ -1,7 +1,7 @@ -/* memchr (str, ch, n) -- Return pointer to first occurrence of CH in STR less - than N. +/* memchr (str, chr, len) -- Return pointer to first occurrence of CHR in STR less + than LEN. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper Optimised a little by Alan Modra @@ -32,32 +32,34 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) - c (sp + 8) - len (sp + 12) -*/ +#define PARMS LINKAGE+8 /* space for 2 saved regs */ +#define RTN PARMS +#define STR RTN+RTN_SIZE +#define CHR STR+PTR_SIZE +#define LEN CHR+4 .text ENTRY (memchr) + ENTER + /* Save callee-safe registers used in this function. */ pushl %esi pushl %edi /* Load parameters into registers. */ - movl 12(%esp), %eax /* str: pointer to memory block. */ - movl 16(%esp), %edx /* c: byte we are looking for. */ - movl 20(%esp), %esi /* len: length of memory block. */ + movl STR(%esp), %eax /* str: pointer to memory block. */ + movl CHR(%esp), %edx /* c: byte we are looking for. */ + movl LEN(%esp), %esi /* len: length of memory block. */ /* If my must not test more than three characters test them one by one. This is especially true for 0. */ cmpl $4, %esi jb L(3) - /* At the moment %edx contains C. What we need for the - algorithm is C in all bytes of the dword. Avoid + /* At the moment %edx contains CHR. What we need for the + algorithm is CHR in all bytes of the dword. Avoid operations on 16 bit words because these require an prefix byte (and one more cycle). */ movb %dl, %dh /* Now it is 0|0|c|c */ @@ -117,9 +119,9 @@ ENTRY (memchr) into bit 32 (=carry flag), so all of the hole bits will be changed. - 3) But wait! Aren't we looking for C, not zero? + 3) But wait! Aren't we looking for CHR, not zero? Good point. So what we do is XOR LONGWORD with a longword, - each of whose bytes is C. This turns each byte that is C + each of whose bytes is CHR. This turns each byte that is CHR into a zero. */ @@ -152,7 +154,7 @@ L(1): movl (%eax), %ecx /* get word (= 4 bytes) in question */ incl %edi /* add 1: if one carry bit was *not* set the addition will not result in 0. */ - /* If at least one byte of the word is C we don't get 0 in %edi. */ + /* If at least one byte of the word is CHR we don't get 0 in %edi. */ jnz L(8) /* found it => return pointer */ /* This process is unfolded four times for better performance. @@ -169,7 +171,7 @@ L(1): movl (%eax), %ecx /* get word (= 4 bytes) in question */ addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which is *not* 0 */ - jnc L(7) /* highest byte is C => return pointer */ + jnc L(7) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -183,7 +185,7 @@ L(1): movl (%eax), %ecx /* get word (= 4 bytes) in question */ addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which is *not* 0 */ - jnc L(6) /* highest byte is C => return pointer */ + jnc L(6) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -197,7 +199,7 @@ L(1): movl (%eax), %ecx /* get word (= 4 bytes) in question */ addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which is *not* 0 */ - jnc L(5) /* highest byte is C => return pointer */ + jnc L(5) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -220,7 +222,7 @@ L(2): subl $16, %esi addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which is *not* 0 */ - jnc L(8) /* highest byte is C => return pointer */ + jnc L(8) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -238,7 +240,7 @@ L(2): subl $16, %esi addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which is *not* 0 */ - jnc L(8) /* highest byte is C => return pointer */ + jnc L(8) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -256,7 +258,7 @@ L(2): subl $16, %esi addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which is *not* 0 */ - jnc L(8) /* highest byte is C => return pointer */ + jnc L(8) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -268,19 +270,19 @@ L(2): subl $16, %esi L(3): andl $3, %esi /* mask out uninteresting bytes */ jz L(4) /* no remaining bytes => return NULL */ - cmpb %dl, (%eax) /* compare byte with C */ + cmpb %dl, (%eax) /* compare byte with CHR */ je L(9) /* equal, than return pointer */ incl %eax /* increment source pointer */ decl %esi /* decrement length */ jz L(4) /* no remaining bytes => return NULL */ - cmpb %dl, (%eax) /* compare byte with C */ + cmpb %dl, (%eax) /* compare byte with CHR */ je L(9) /* equal, than return pointer */ incl %eax /* increment source pointer */ decl %esi /* decrement length */ jz L(4) /* no remaining bytes => return NULL */ - cmpb %dl, (%eax) /* compare byte with C */ + cmpb %dl, (%eax) /* compare byte with CHR */ je L(9) /* equal, than return pointer */ L(4): /* no byte found => return NULL */ @@ -312,5 +314,6 @@ L(8): testb %cl, %cl /* test first byte in dword */ L(9): popl %edi /* pop saved registers */ popl %esi - ret + LEAVE + RET_PTR END (memchr) diff --git a/sysdeps/i386/memcmp.S b/sysdeps/i386/memcmp.S index 723b5025ff..a1cbadb621 100644 --- a/sysdeps/i386/memcmp.S +++ b/sysdeps/i386/memcmp.S @@ -1,5 +1,5 @@ /* Compare two memory blocks for differences in the first COUNT bytes. - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -19,23 +19,24 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - block1 (sp + 4) - block2 (sp + 8) - len (sp + 12) -*/ +#define PARMS LINKAGE+4 /* space for 1 saved reg */ +#define BLK1 PARMS +#define BLK2 BLK1+PTR_SIZE +#define LEN BLK2+PTR_SIZE .text ENTRY (memcmp) + ENTER + pushl %esi /* Save callee-safe registers. */ movl %edi, %edx /* Note that %edx is not used and can so be used to save %edi. It's faster. */ - movl 8(%esp), %esi /* Load address of block #1. */ - movl 12(%esp), %edi /* Load address of block #2. */ - movl 16(%esp), %ecx /* Load maximal length of compare area. */ + movl BLK1(%esp), %esi + movl BLK2(%esp), %edi + movl LEN(%esp), %ecx cld /* Set direction of comparison. */ @@ -61,6 +62,7 @@ ENTRY (memcmp) L(1): popl %esi /* Restore registers. */ movl %edx, %edi + LEAVE ret END (memcmp) diff --git a/sysdeps/i386/mul_1.S b/sysdeps/i386/mul_1.S index 459f6239fb..9b125e7c7b 100644 --- a/sysdeps/i386/mul_1.S +++ b/sysdeps/i386/mul_1.S @@ -1,6 +1,6 @@ /* i80386 __mpn_mul_1 -- Multiply a limb vector with a limb and store the result in a second limb vector. - Copyright (C) 1992, 1994, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1992, 1994, 1997, 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -28,6 +28,13 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+16 /* space for 4 saved regs */ +#define RES PARMS +#define S1 RES+PTR_SIZE +#define SIZE S1+PTR_SIZE +#define S2LIMB SIZE+4 #define res_ptr edi #define s1_ptr esi @@ -36,16 +43,17 @@ .text ENTRY(__mpn_mul_1) + ENTER INSN1(push,l ,R(edi)) INSN1(push,l ,R(esi)) INSN1(push,l ,R(ebx)) INSN1(push,l ,R(ebp)) - INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20)) - INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24)) - INSN2(mov,l ,R(size),MEM_DISP(esp,28)) - INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32)) + INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,RES)) + INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,S1)) + INSN2(mov,l ,R(size),MEM_DISP(esp,SIZE)) + INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,S2LIMB)) INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4)) INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4)) @@ -68,6 +76,8 @@ L(oop): INSN1(pop,l ,R(ebx)) INSN1(pop,l ,R(esi)) INSN1(pop,l ,R(edi)) + + LEAVE ret #undef size END(__mpn_mul_1) diff --git a/sysdeps/i386/rawmemchr.S b/sysdeps/i386/rawmemchr.S index 83626e0473..89ba8d3857 100644 --- a/sysdeps/i386/rawmemchr.S +++ b/sysdeps/i386/rawmemchr.S @@ -1,6 +1,6 @@ /* rawmemchr (str, ch) -- Return pointer to first occurrence of CH in STR. For Intel 80x86, x>=3. - Copyright (C) 1994, 95, 96, 97, 98, 99 Free Software Foundation, Inc. + Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper Optimised a little by Alan Modra @@ -31,21 +31,23 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) - c (sp + 8) -*/ +#define PARMS LINKAGE+4 /* space for 1 saved reg */ +#define RTN PARMS +#define STR RTN+RTN_SIZE +#define CHR STR+PTR_SIZE .text ENTRY (__rawmemchr) + ENTER + /* Save callee-safe register used in this function. */ pushl %edi /* Load parameters into registers. */ - movl 8(%esp), %eax /* str: pointer to memory block. */ - movl 12(%esp), %edx /* c: byte we are looking for. */ + movl STR(%esp), %eax + movl CHR(%esp), %edx /* At the moment %edx contains C. What we need for the algorithm is C in all bytes of the dword. Avoid @@ -213,6 +215,7 @@ L(8): testb %cl, %cl /* test first byte in dword */ L(9): popl %edi /* pop saved register */ + LEAVE ret END (__rawmemchr) weak_alias (__rawmemchr, rawmemchr) diff --git a/sysdeps/i386/rshift.S b/sysdeps/i386/rshift.S index 0bb7288d31..c8a6a9feb0 100644 --- a/sysdeps/i386/rshift.S +++ b/sysdeps/i386/rshift.S @@ -1,5 +1,5 @@ /* i80386 __mpn_rshift -- - Copyright (C) 1992, 1994, 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1992, 1994, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -17,27 +17,28 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s_ptr (sp + 8) - size (sp + 12) - cnt (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+12 /* space for 3 saved regs */ +#define RES PARMS +#define S RES+PTR_SIZE +#define SIZE S+PTR_SIZE +#define CNT SIZE+4 .text ENTRY(__mpn_rshift) + ENTER + pushl %edi pushl %esi pushl %ebx - movl 16(%esp),%edi /* res_ptr */ - movl 20(%esp),%esi /* s_ptr */ - movl 24(%esp),%edx /* size */ - movl 28(%esp),%ecx /* cnt */ + movl RES(%esp),%edi + movl S(%esp),%esi + movl SIZE(%esp),%edx + movl CNT(%esp),%ecx leal -4(%edi,%edx,4),%edi leal (%esi,%edx,4),%esi @@ -72,6 +73,8 @@ L(1): movl (%esi,%edx,4),%eax popl %ebx popl %esi popl %edi + + LEAVE ret L(end): shrl %cl,%ebx /* compute most significant limb */ @@ -80,5 +83,7 @@ L(end): shrl %cl,%ebx /* compute most significant limb */ popl %ebx popl %esi popl %edi + + LEAVE ret END(__mpn_rshift) diff --git a/sysdeps/i386/stpcpy.S b/sysdeps/i386/stpcpy.S index 751e22c1c6..f8267c7d1e 100644 --- a/sysdeps/i386/stpcpy.S +++ b/sysdeps/i386/stpcpy.S @@ -1,6 +1,6 @@ /* Copy SRC to DEST returning the address of the terminating '\0' in DEST. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper (drepper@gnu.ai.mit.edu). @@ -24,18 +24,19 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - dest (sp + 4) - src (sp + 8) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define RTN PARMS +#define DEST RTN+RTN_SIZE +#define SRC DEST+PTR_SIZE .text ENTRY (__stpcpy) - movl 4(%esp), %eax /* load destination pointer */ - movl 8(%esp), %ecx /* load source pointer */ + ENTER + movl DEST(%esp), %eax + movl SRC(%esp), %ecx subl %eax, %ecx /* magic: reduce number of loop variants to one using addressing mode */ @@ -81,7 +82,9 @@ L(1): addl $4, %eax /* increment loop counter */ L(4): incl %eax L(3): incl %eax L(2): - ret + + LEAVE + RET_PTR END (__stpcpy) weak_alias (__stpcpy, stpcpy) diff --git a/sysdeps/i386/stpncpy.S b/sysdeps/i386/stpncpy.S index e0213082f8..cd1a84558f 100644 --- a/sysdeps/i386/stpncpy.S +++ b/sysdeps/i386/stpncpy.S @@ -1,7 +1,7 @@ /* copy no more then N bytes from SRC to DEST, returning the address of the terminating '\0' in DEST. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper Some bug fixes by Alan Modra @@ -26,22 +26,23 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - dest (sp + 4) - src (sp + 8) - maxlen (sp + 12) -*/ +#define PARMS LINKAGE+4 /* space for 1 saved reg */ +#define RTN PARMS +#define DEST RTN+RTN_SIZE +#define SRC DEST+PTR_SIZE +#define LEN SRC+PTR_SIZE .text ENTRY (__stpncpy) + ENTER pushl %esi - movl 8(%esp), %eax /* load destination pointer */ - movl 12(%esp), %esi /* load source pointer */ - movl 16(%esp), %ecx /* load maximal length */ + movl DEST(%esp), %eax + movl SRC(%esp), %esi + movl LEN(%esp), %ecx subl %eax, %esi /* magic: reduce number of loop variants to one using addressing mode */ @@ -138,7 +139,8 @@ L(3): decl %ecx /* all bytes written? */ L(9): popl %esi /* restore saved register content */ - ret + LEAVE + RET_PTR END (__stpncpy) weak_alias (__stpncpy, stpncpy) diff --git a/sysdeps/i386/strchr.S b/sysdeps/i386/strchr.S index 582c3d737a..0bb28bc9be 100644 --- a/sysdeps/i386/strchr.S +++ b/sysdeps/i386/strchr.S @@ -1,6 +1,6 @@ /* strchr (str, ch) -- Return pointer to first occurrence of CH in STR. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper Some optimisations by Alan Modra @@ -22,19 +22,20 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) - ch (sp + 8) -*/ +#define PARMS LINKAGE+4 /* space for 1 saved reg */ +#define RTN PARMS +#define STR RTN+RTN_SIZE +#define CHR STR+PTR_SIZE .text ENTRY (strchr) - pushl %edi /* Save callee-safe registers used here. */ + ENTER - movl 8(%esp), %eax /* get string pointer */ - movl 12(%esp), %edx /* get character we are looking for */ + pushl %edi /* Save callee-safe registers used here. */ + movl STR(%esp), %eax + movl CHR(%esp), %edx /* At the moment %edx contains C. What we need for the algorithm is C in all bytes of the dword. Avoid @@ -240,7 +241,9 @@ L(11): movl (%eax), %ecx /* get word (= 4 bytes) in question */ L(2): /* Return NULL. */ xorl %eax, %eax /* load NULL in return value register */ popl %edi /* restore saved register content */ - ret + + LEAVE + RET_PTR L(73): addl $4, %eax /* adjust pointer */ L(72): addl $4, %eax @@ -273,7 +276,8 @@ L(7): testb %cl, %cl /* is first byte C? */ L(6): popl %edi /* restore saved register content */ - ret + LEAVE + RET_PTR END (strchr) weak_alias (strchr, index) diff --git a/sysdeps/i386/strchrnul.S b/sysdeps/i386/strchrnul.S index f42a69728c..6860a11d7a 100644 --- a/sysdeps/i386/strchrnul.S +++ b/sysdeps/i386/strchrnul.S @@ -1,7 +1,7 @@ -/* strchrnul (str, ch) -- Return pointer to first occurrence of CH in STR +/* strchrnul (str, chr) -- Return pointer to first occurrence of CHR in STR or the final NUL byte. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper Some optimisations by Alan Modra @@ -23,22 +23,24 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) - ch (sp + 8) -*/ +#define PARMS LINKAGE+4 /* space for 1 saved reg */ +#define RTN PARMS +#define STR RTN+RTN_SIZE +#define CHR STR+PTR_SIZE .text ENTRY (__strchrnul) + ENTER + pushl %edi /* Save callee-safe registers used here. */ - movl 8(%esp), %eax /* get string pointer */ - movl 12(%esp), %edx /* get character we are looking for */ + movl STR(%esp), %eax + movl CHR(%esp), %edx - /* At the moment %edx contains C. What we need for the - algorithm is C in all bytes of the dword. Avoid + /* At the moment %edx contains CHR. What we need for the + algorithm is CHR in all bytes of the dword. Avoid operations on 16 bit words because these require an prefix byte (and one more cycle). */ movb %dl, %dh /* now it is 0|0|c|c */ @@ -108,9 +110,9 @@ ENTRY (__strchrnul) into bit 32 (=carry flag), so all of the hole bits will be changed. - 3) But wait! Aren't we looking for C, not zero? + 3) But wait! Aren't we looking for CHR, not zero? Good point. So what we do is XOR LONGWORD with a longword, - each of whose bytes is C. This turns each byte that is C + each of whose bytes is CHR. This turns each byte that is CHR into a zero. */ /* Each round the main loop processes 16 bytes. */ @@ -125,7 +127,7 @@ L(11): movl (%eax), %ecx /* get word (= 4 bytes) in question */ movl $0xfefefeff, %edi /* magic value */ addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which - is *not* C */ + is *not* CHR */ /* According to the algorithm we had to reverse the effect of the XOR first and then test the overflow bits. But because the @@ -144,7 +146,7 @@ L(11): movl (%eax), %ecx /* get word (= 4 bytes) in question */ incl %edi /* add 1: if one carry bit was *not* set the addition will not result in 0. */ - /* If at least one byte of the word is C we don't get 0 in %edi. */ + /* If at least one byte of the word is CHR we don't get 0 in %edi. */ jnz L(7) /* found it => return pointer */ /* Now we made sure the dword does not contain the character we are @@ -169,8 +171,8 @@ L(11): movl (%eax), %ecx /* get word (= 4 bytes) in question */ movl $0xfefefeff, %edi /* magic value */ addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which - is *not* C */ - jnc L(71) /* highest byte is C => return pointer */ + is *not* CHR */ + jnc L(71) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -194,8 +196,8 @@ L(11): movl (%eax), %ecx /* get word (= 4 bytes) in question */ movl $0xfefefeff, %edi /* magic value */ addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which - is *not* C */ - jnc L(72) /* highest byte is C => return pointer */ + is *not* CHR */ + jnc L(72) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -219,8 +221,8 @@ L(11): movl (%eax), %ecx /* get word (= 4 bytes) in question */ movl $0xfefefeff, %edi /* magic value */ addl %ecx, %edi /* add the magic value to the word. We get carry bits reported for each byte which - is *not* C */ - jnc L(73) /* highest byte is C => return pointer */ + is *not* CHR */ + jnc L(73) /* highest byte is CHR => return pointer */ xorl %ecx, %edi /* ((word^charmask)+magic)^(word^charmask) */ orl $0xfefefeff, %edi /* set all non-carry bits */ incl %edi /* add 1: if one carry bit was *not* set @@ -246,20 +248,20 @@ L(71): addl $4, %eax But we have to take care of the case that a NUL char is found before this in the dword. */ -L(7): testb %cl, %cl /* is first byte C? */ +L(7): testb %cl, %cl /* is first byte CHR? */ jz L(6) /* yes => return pointer */ cmpb %dl, %cl /* is first byte NUL? */ je L(6) /* yes => return NULL */ incl %eax /* it's not in the first byte */ - testb %ch, %ch /* is second byte C? */ + testb %ch, %ch /* is second byte CHR? */ jz L(6) /* yes => return pointer */ cmpb %dl, %ch /* is second byte NUL? */ je L(6) /* yes => return NULL? */ incl %eax /* it's not in the second byte */ shrl $16, %ecx /* make upper byte accessible */ - testb %cl, %cl /* is third byte C? */ + testb %cl, %cl /* is third byte CHR? */ jz L(6) /* yes => return pointer */ cmpb %dl, %cl /* is third byte NUL? */ je L(6) /* yes => return NULL */ @@ -269,7 +271,8 @@ L(7): testb %cl, %cl /* is first byte C? */ L(6): popl %edi /* restore saved register content */ - ret + LEAVE + RET_PTR END (__strchrnul) weak_alias (__strchrnul, strchrnul) diff --git a/sysdeps/i386/strcspn.S b/sysdeps/i386/strcspn.S index f2c53122b5..e7529a15c8 100644 --- a/sysdeps/i386/strcspn.S +++ b/sysdeps/i386/strcspn.S @@ -1,7 +1,7 @@ /* strcspn (str, ss) -- Return the length of the initial segment of STR which contains no characters from SS. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper Bug fixes by Alan Modra @@ -23,17 +23,18 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) - stopset (sp + 8) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define STR PARMS +#define STOP STR+PTR_SIZE .text ENTRY (strcspn) - movl 4(%esp), %edx /* get string pointer */ - movl 8(%esp), %eax /* get stopset pointer */ + ENTER + + movl STR(%esp), %edx + movl STOP(%esp), %eax /* First we create a table with flags for all possible characters. For the ASCII (7bit/8bit) or ISO-8859-X character sets which are @@ -173,5 +174,6 @@ L(4): subl %edx, %eax /* we have to return the number of valid non-valid character */ addl $256, %esp /* remove stopset */ + LEAVE ret END (strcspn) diff --git a/sysdeps/i386/strpbrk.S b/sysdeps/i386/strpbrk.S index ff0990272a..59d65540ab 100644 --- a/sysdeps/i386/strpbrk.S +++ b/sysdeps/i386/strpbrk.S @@ -1,7 +1,7 @@ /* strcspn (str, ss) -- Return the length of the initial segement of STR which contains no characters from SS. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. Contributed by Ulrich Drepper Bug fixes by Alan Modra This file is part of the GNU C Library. @@ -23,17 +23,19 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) - stopset (sp + 8) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define RTN PARMS +#define STR RTN+RTN_SIZE +#define STOP STR+PTR_SIZE .text ENTRY (strpbrk) - movl 4(%esp), %edx /* get string pointer */ - movl 8(%esp), %eax /* get stopset pointer */ + ENTER + + movl STR(%esp), %edx + movl STOP(%esp), %eax /* First we create a table with flags for all possible characters. For the ASCII (7bit/8bit) or ISO-8859-X character sets which are @@ -174,5 +176,6 @@ L(4): addl $256, %esp /* remove stopset */ jnz L(7) /* no => return pointer */ xorl %eax, %eax /* return NULL */ -L(7): ret +L(7): LEAVE + RET_PTR END (strpbrk) diff --git a/sysdeps/i386/strrchr.S b/sysdeps/i386/strrchr.S index 111f986dd8..328d8b0a09 100644 --- a/sysdeps/i386/strrchr.S +++ b/sysdeps/i386/strrchr.S @@ -1,6 +1,6 @@ /* strrchr (str, ch) -- Return pointer to last occurrence of CH in STR. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper Some optimisations by Alan Modra @@ -22,21 +22,23 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) - ch (sp + 8) -*/ +#define PARMS LINKAGE+8 /* space for 2 saved regs */ +#define RTN PARMS +#define STR RTN+RTN_SIZE +#define CHR STR+PTR_SIZE .text ENTRY (strrchr) + ENTER + pushl %edi /* Save callee-safe registers used here. */ pushl %esi xorl %eax, %eax - movl 12(%esp), %esi /* get string pointer */ - movl 16(%esp), %ecx /* get character we are looking for */ + movl STR(%esp), %esi + movl CHR(%esp), %ecx /* At the moment %ecx contains C. What we need for the algorithm is C in all bytes of the dword. Avoid @@ -320,7 +322,8 @@ L(26): testb %dl, %dl /* is third byte == NUL */ L(2): popl %esi /* restore saved register content */ popl %edi - ret + LEAVE + RET_PTR END (strrchr) weak_alias (strrchr, rindex) diff --git a/sysdeps/i386/strspn.S b/sysdeps/i386/strspn.S index 9f83adcc27..cfd11f0a9f 100644 --- a/sysdeps/i386/strspn.S +++ b/sysdeps/i386/strspn.S @@ -1,7 +1,7 @@ /* strcspn (str, ss) -- Return the length of the initial segment of STR which contains only characters from SS. For Intel 80x86, x>=3. - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper Bug fixes by Alan Modra @@ -23,17 +23,18 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" -/* - INPUT PARAMETERS: - str (sp + 4) - skipset (sp + 8) -*/ +#define PARMS LINKAGE /* no space for saved regs */ +#define STR PARMS +#define SKIP STR+PTR_SIZE .text ENTRY (strspn) - movl 4(%esp), %edx /* get string pointer */ - movl 8(%esp), %eax /* get skipset pointer */ + ENTER + + movl STR(%esp), %edx + movl SKIP(%esp), %eax /* First we create a table with flags for all possible characters. For the ASCII (7bit/8bit) or ISO-8859-X character sets which are @@ -173,5 +174,6 @@ L(4): subl %edx, %eax /* we have to return the number of valid non-valid character */ addl $256, %esp /* remove stopset */ + LEAVE ret END (strspn) diff --git a/sysdeps/i386/strtok.S b/sysdeps/i386/strtok.S index c6469e8ecf..6fa6cc2d0c 100644 --- a/sysdeps/i386/strtok.S +++ b/sysdeps/i386/strtok.S @@ -1,6 +1,6 @@ /* strtok (str, delim) -- Return next DELIM separated token from STR. For Intel 80x86, x>=3. - Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -21,6 +21,7 @@ #include #include "asm-syntax.h" +#include "bp-asm.h" /* This file can be used for three variants of the strtok function: @@ -48,12 +49,19 @@ save_ptr: #define FUNCTION strtok #endif +#define PARMS LINKAGE /* no space for saved regs */ +#define RTN PARMS +#define STR RTN+RTN_SIZE +#define DELIM STR+PTR_SIZE +#define SAVE DELIM+PTR_SIZE + .text ENTRY (FUNCTION) + ENTER - movl 4(%esp), %edx /* Get start of string. */ - movl 8(%esp), %eax /* Get start of delimiter set. */ + movl STR(%esp), %edx + movl DELIM(%esp), %eax #if !defined (USE_AS_STRTOK_R) && defined (PIC) pushl %ebx /* Save PIC register. */ @@ -70,7 +78,7 @@ L(here): #ifdef USE_AS_STRTOK_R /* The value is stored in the third argument. */ - movl 12(%esp), %edx + movl SAVE(%esp), %edx movl (%edx), %edx #else /* The value is in the local variable defined above. But @@ -257,7 +265,7 @@ L(11): L(return): /* Store the pointer to the next character. */ #ifdef USE_AS_STRTOK_R - movl 12(%esp), %ecx + movl SAVE(%esp), %ecx movl %edx, (%ecx) #else # ifndef PIC @@ -267,7 +275,8 @@ L(return): popl %ebx # endif #endif - ret + LEAVE + RET_PTR L(returnNULL): xorl %eax, %eax diff --git a/sysdeps/i386/sub_n.S b/sysdeps/i386/sub_n.S index ef9a8292e2..94cb070504 100644 --- a/sysdeps/i386/sub_n.S +++ b/sysdeps/i386/sub_n.S @@ -1,6 +1,6 @@ /* i80386 __mpn_sub_n -- Add two limb vectors of the same length > 0 and store sum in a third limb vector. - Copyright (C) 1992, 1994, 1995, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1992, 1994, 1995, 1997, 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -18,26 +18,27 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - s2_ptr (sp + 12) - size (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+8 /* space for 2 saved regs */ +#define RES PARMS +#define S1 RES+PTR_SIZE +#define S2 S1+PTR_SIZE +#define SIZE S2+PTR_SIZE .text ENTRY(__mpn_sub_n) + ENTER + pushl %edi pushl %esi - movl 12(%esp),%edi /* res_ptr */ - movl 16(%esp),%esi /* s1_ptr */ - movl 20(%esp),%edx /* s2_ptr */ - movl 24(%esp),%ecx /* size */ + movl RES(%esp),%edi + movl S1(%esp),%esi + movl S2(%esp),%edx + movl SIZE(%esp),%ecx movl %ecx,%eax shrl $3,%ecx /* compute count for unrolled loop */ @@ -99,5 +100,7 @@ L(oop): movl (%esi),%eax popl %esi popl %edi + + LEAVE ret END(__mpn_sub_n) diff --git a/sysdeps/i386/submul_1.S b/sysdeps/i386/submul_1.S index fc50585f86..99a1c81f2d 100644 --- a/sysdeps/i386/submul_1.S +++ b/sysdeps/i386/submul_1.S @@ -1,6 +1,6 @@ /* i80386 __mpn_submul_1 -- Multiply a limb vector with a limb and subtract the result from a second limb vector. - Copyright (C) 1992, 1994, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1992, 1994, 1997, 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -18,16 +18,15 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - sizeP (sp + 12) - s2_limb (sp + 16) -*/ - #include "sysdep.h" #include "asm-syntax.h" +#include "bp-asm.h" + +#define PARMS LINKAGE+16 /* space for 4 saved regs */ +#define RES PARMS +#define S1 RES+PTR_SIZE +#define SIZE S1+PTR_SIZE +#define S2LIMB SIZE+4 #define res_ptr edi #define s1_ptr esi @@ -36,16 +35,17 @@ .text ENTRY(__mpn_submul_1) + ENTER INSN1(push,l ,R(edi)) INSN1(push,l ,R(esi)) INSN1(push,l ,R(ebx)) INSN1(push,l ,R(ebp)) - INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20)) - INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24)) - INSN2(mov,l ,R(sizeP),MEM_DISP(esp,28)) - INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32)) + INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,RES)) + INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,S1)) + INSN2(mov,l ,R(sizeP),MEM_DISP(esp,SIZE)) + INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,S2LIMB)) INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,sizeP,4)) INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,sizeP,4)) @@ -69,5 +69,7 @@ L(oop): INSN1(pop,l ,R(ebx)) INSN1(pop,l ,R(esi)) INSN1(pop,l ,R(edi)) + + LEAVE ret END(__mpn_submul_1) -- cgit v1.2.3