1 1.1 mrg ; mc88100 mpn_sub_n -- Subtract two limb vectors of the same length > 0 and 2 1.1 mrg ; store difference in a third limb vector. 3 1.1 mrg 4 1.1 mrg ; Copyright 1992, 1994, 1996, 2000 Free Software Foundation, Inc. 5 1.1 mrg 6 1.1.1.2 mrg ; This file is part of the GNU MP Library. 7 1.1.1.2 mrg ; 8 1.1.1.2 mrg ; The GNU MP Library is free software; you can redistribute it and/or modify 9 1.1.1.2 mrg ; it under the terms of either: 10 1.1.1.2 mrg ; 11 1.1.1.2 mrg ; * the GNU Lesser General Public License as published by the Free 12 1.1.1.2 mrg ; Software Foundation; either version 3 of the License, or (at your 13 1.1.1.2 mrg ; option) any later version. 14 1.1.1.2 mrg ; 15 1.1.1.2 mrg ; or 16 1.1.1.2 mrg ; 17 1.1.1.2 mrg ; * the GNU General Public License as published by the Free Software 18 1.1.1.2 mrg ; Foundation; either version 2 of the License, or (at your option) any 19 1.1.1.2 mrg ; later version. 20 1.1.1.2 mrg ; 21 1.1.1.2 mrg ; or both in parallel, as here. 22 1.1.1.2 mrg ; 23 1.1.1.2 mrg ; The GNU MP Library is distributed in the hope that it will be useful, but 24 1.1.1.2 mrg ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 25 1.1.1.2 mrg ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 26 1.1.1.2 mrg ; for more details. 27 1.1.1.2 mrg ; 28 1.1.1.2 mrg ; You should have received copies of the GNU General Public License and the 29 1.1.1.2 mrg ; GNU Lesser General Public License along with the GNU MP Library. If not, 30 1.1.1.2 mrg ; see https://www.gnu.org/licenses/. 31 1.1 mrg 32 1.1 mrg 33 1.1 mrg ; INPUT PARAMETERS 34 1.1 mrg ; res_ptr r2 35 1.1 mrg ; s1_ptr r3 36 1.1 mrg ; s2_ptr r4 37 1.1 mrg ; size r5 38 1.1 mrg 39 1.1 mrg ; This code has been optimized to run one instruction per clock, avoiding 40 1.1 mrg ; load stalls and writeback contention. As a result, the instruction 41 1.1 mrg ; order is not always natural. 42 1.1 mrg 43 1.1 mrg ; The speed is about 4.6 clocks/limb + 18 clocks/limb-vector on an 88100, 44 1.1 mrg ; but on the 88110, it seems to run much slower, 6.6 clocks/limb. 45 1.1 mrg 46 1.1 mrg text 47 1.1 mrg align 16 48 1.1 mrg global ___gmpn_sub_n 49 1.1 mrg ___gmpn_sub_n: 50 1.1 mrg ld r6,r3,0 ; read first limb from s1_ptr 51 1.1 mrg extu r10,r5,3 52 1.1 mrg ld r7,r4,0 ; read first limb from s2_ptr 53 1.1 mrg 54 1.1 mrg subu r5,r0,r5 55 1.1 mrg mak r5,r5,3<4> 56 1.1 mrg bcnd.n eq0,r5,Lzero 57 1.1 mrg subu.co r0,r0,r0 ; initialize carry 58 1.1 mrg 59 1.1 mrg or r12,r0,lo16(Lbase) 60 1.1 mrg or.u r12,r12,hi16(Lbase) 61 1.1 mrg addu r12,r12,r5 ; r12 is address for entering in loop 62 1.1 mrg 63 1.1 mrg extu r5,r5,2 ; divide by 4 64 1.1 mrg subu r2,r2,r5 ; adjust res_ptr 65 1.1 mrg subu r3,r3,r5 ; adjust s1_ptr 66 1.1 mrg subu r4,r4,r5 ; adjust s2_ptr 67 1.1 mrg 68 1.1 mrg or r8,r6,r0 69 1.1 mrg 70 1.1 mrg jmp.n r12 71 1.1 mrg or r9,r7,r0 72 1.1 mrg 73 1.1 mrg Loop: addu r3,r3,32 74 1.1 mrg st r8,r2,28 75 1.1 mrg addu r4,r4,32 76 1.1 mrg ld r6,r3,0 77 1.1 mrg addu r2,r2,32 78 1.1 mrg ld r7,r4,0 79 1.1 mrg Lzero: subu r10,r10,1 ; subtract 0 + 8r limbs (adj loop cnt) 80 1.1 mrg Lbase: ld r8,r3,4 81 1.1 mrg subu.cio r6,r6,r7 82 1.1 mrg ld r9,r4,4 83 1.1 mrg st r6,r2,0 84 1.1 mrg ld r6,r3,8 ; subtract 7 + 8r limbs 85 1.1 mrg subu.cio r8,r8,r9 86 1.1 mrg ld r7,r4,8 87 1.1 mrg st r8,r2,4 88 1.1 mrg ld r8,r3,12 ; subtract 6 + 8r limbs 89 1.1 mrg subu.cio r6,r6,r7 90 1.1 mrg ld r9,r4,12 91 1.1 mrg st r6,r2,8 92 1.1 mrg ld r6,r3,16 ; subtract 5 + 8r limbs 93 1.1 mrg subu.cio r8,r8,r9 94 1.1 mrg ld r7,r4,16 95 1.1 mrg st r8,r2,12 96 1.1 mrg ld r8,r3,20 ; subtract 4 + 8r limbs 97 1.1 mrg subu.cio r6,r6,r7 98 1.1 mrg ld r9,r4,20 99 1.1 mrg st r6,r2,16 100 1.1 mrg ld r6,r3,24 ; subtract 3 + 8r limbs 101 1.1 mrg subu.cio r8,r8,r9 102 1.1 mrg ld r7,r4,24 103 1.1 mrg st r8,r2,20 104 1.1 mrg ld r8,r3,28 ; subtract 2 + 8r limbs 105 1.1 mrg subu.cio r6,r6,r7 106 1.1 mrg ld r9,r4,28 107 1.1 mrg st r6,r2,24 108 1.1 mrg bcnd.n ne0,r10,Loop ; subtract 1 + 8r limbs 109 1.1 mrg subu.cio r8,r8,r9 110 1.1 mrg 111 1.1 mrg st r8,r2,28 ; store most significant limb 112 1.1 mrg 113 1.1 mrg addu.ci r2,r0,r0 ; return carry-out from most sign. limb 114 1.1 mrg jmp.n r1 115 1.1 mrg xor r2,r2,1 116