1/* i80586 sub_n -- Sub two limb vectors of the same length > 0 and store 2 * sum in a third limb vector. 3 * 4 * Copyright (C) 1992, 1994, 1995, 1998, 5 * 2001, 2002 Free Software Foundation, Inc. 6 * 7 * This file is part of Libgcrypt. 8 * 9 * Libgcrypt is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU Lesser General Public License as 11 * published by the Free Software Foundation; either version 2.1 of 12 * the License, or (at your option) any later version. 13 * 14 * Libgcrypt is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this program; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 22 * 23 * Note: This code is heavily based on the GNU MP Library. 24 * Actually it's the same code with only minor changes in the 25 * way the data is stored; this is to support the abstraction 26 * of an optional secure memory allocation which may be used 27 * to avoid revealing of sensitive data due to paging etc. 28 */ 29 30 31#include "sysdep.h" 32#include "asm-syntax.h" 33 34 35/******************* 36 * mpi_limb_t 37 * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (sp + 4) 38 * mpi_ptr_t s1_ptr, (sp + 8) 39 * mpi_ptr_t s2_ptr, (sp + 12) 40 * mpi_size_t size) (sp + 16) 41 */ 42 43 44.text 45 ALIGN (3) 46 .globl C_SYMBOL_NAME(_gcry_mpih_sub_n) 47C_SYMBOL_NAME(_gcry_mpih_sub_n:) 48 49 pushl %edi 50 pushl %esi 51 pushl %ebx 52 pushl %ebp 53 54 movl 20(%esp),%edi /* res_ptr */ 55 movl 24(%esp),%esi /* s1_ptr */ 56 movl 28(%esp),%ebp /* s2_ptr */ 57 movl 32(%esp),%ecx /* size */ 58 59 movl (%ebp),%ebx 60 61 decl %ecx 62 movl %ecx,%edx 63 shrl $3,%ecx 64 andl $7,%edx 65 testl %ecx,%ecx /* zero carry flag */ 66 jz Lend 67 pushl %edx 68 69 ALIGN (3) 70Loop: movl 28(%edi),%eax /* fetch destination cache line */ 71 leal 32(%edi),%edi 72 73L1: movl (%esi),%eax 74 movl 4(%esi),%edx 75 sbbl %ebx,%eax 76 movl 4(%ebp),%ebx 77 sbbl %ebx,%edx 78 movl 8(%ebp),%ebx 79 movl %eax,-32(%edi) 80 movl %edx,-28(%edi) 81 82L2: movl 8(%esi),%eax 83 movl 12(%esi),%edx 84 sbbl %ebx,%eax 85 movl 12(%ebp),%ebx 86 sbbl %ebx,%edx 87 movl 16(%ebp),%ebx 88 movl %eax,-24(%edi) 89 movl %edx,-20(%edi) 90 91L3: movl 16(%esi),%eax 92 movl 20(%esi),%edx 93 sbbl %ebx,%eax 94 movl 20(%ebp),%ebx 95 sbbl %ebx,%edx 96 movl 24(%ebp),%ebx 97 movl %eax,-16(%edi) 98 movl %edx,-12(%edi) 99 100L4: movl 24(%esi),%eax 101 movl 28(%esi),%edx 102 sbbl %ebx,%eax 103 movl 28(%ebp),%ebx 104 sbbl %ebx,%edx 105 movl 32(%ebp),%ebx 106 movl %eax,-8(%edi) 107 movl %edx,-4(%edi) 108 109 leal 32(%esi),%esi 110 leal 32(%ebp),%ebp 111 decl %ecx 112 jnz Loop 113 114 popl %edx 115Lend: 116 decl %edx /* test %edx w/o clobbering carry */ 117 js Lend2 118 incl %edx 119Loop2: 120 leal 4(%edi),%edi 121 movl (%esi),%eax 122 sbbl %ebx,%eax 123 movl 4(%ebp),%ebx 124 movl %eax,-4(%edi) 125 leal 4(%esi),%esi 126 leal 4(%ebp),%ebp 127 decl %edx 128 jnz Loop2 129Lend2: 130 movl (%esi),%eax 131 sbbl %ebx,%eax 132 movl %eax,(%edi) 133 134 sbbl %eax,%eax 135 negl %eax 136 137 popl %ebp 138 popl %ebx 139 popl %esi 140 popl %edi 141 ret 142 143