1dnl mc68020 mpn_addmul_1, mpn_submul_1 -- add or subtract mpn multiple. 2 3dnl Copyright 1992, 1994, 1996, 1999-2002, 2011 Free Software Foundation, Inc. 4 5dnl This file is part of the GNU MP Library. 6dnl 7dnl The GNU MP Library is free software; you can redistribute it and/or modify 8dnl it under the terms of either: 9dnl 10dnl * the GNU Lesser General Public License as published by the Free 11dnl Software Foundation; either version 3 of the License, or (at your 12dnl option) any later version. 13dnl 14dnl or 15dnl 16dnl * the GNU General Public License as published by the Free Software 17dnl Foundation; either version 2 of the License, or (at your option) any 18dnl later version. 19dnl 20dnl or both in parallel, as here. 21dnl 22dnl The GNU MP Library is distributed in the hope that it will be useful, but 23dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 24dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 25dnl for more details. 26dnl 27dnl You should have received copies of the GNU General Public License and the 28dnl GNU Lesser General Public License along with the GNU MP Library. If not, 29dnl see https://www.gnu.org/licenses/. 30 31include(`../config.m4') 32 33C cycles/limb 34C 68040: 25 35 36ifdef(`OPERATION_addmul_1',` 37 define(M4_inst, addl) 38 define(M4_function_1, mpn_addmul_1) 39',`ifdef(`OPERATION_submul_1',` 40 define(M4_inst, subl) 41 define(M4_function_1, mpn_submul_1) 42', 43`m4_error(`Need OPERATION_addmul_1 or OPERATION_submul_1 44')')') 45 46 47C INPUT PARAMETERS 48C res_ptr (sp + 4) 49C s1_ptr (sp + 8) 50C s1_size (sp + 12) 51C s2_limb (sp + 16) 52 53define(res_ptr, `a0') 54define(s1_ptr, `a1') 55define(s1_size, `d2') 56define(s2_limb, `d4') 57 58MULFUNC_PROLOGUE(mpn_addmul_1 mpn_submul_1) 59 60PROLOGUE(M4_function_1) 61 62C Save used registers on the stack. 63 moveml d2-d5, M(-,sp) 64 65C Copy the arguments to registers. Better use movem? 66 movel M(sp,20), res_ptr 67 movel M(sp,24), s1_ptr 68 movel M(sp,28), s1_size 69 movel M(sp,32), s2_limb 70 71 eorw #1, s1_size 72 clrl d1 73 clrl d5 74 lsrl #1, s1_size 75 bcc L(L1) 76 subql #1, s1_size 77 subl d0, d0 C (d0,cy) <= (0,0) 78 79L(Loop): 80 movel M(s1_ptr,+), d3 81 mulul s2_limb, d1:d3 82 addxl d0, d3 83 addxl d5, d1 84 M4_inst d3, M(res_ptr,+) 85L(L1): movel M(s1_ptr,+), d3 86 mulul s2_limb, d0:d3 87 addxl d1, d3 88 addxl d5, d0 89 M4_inst d3, M(res_ptr,+) 90 91 dbf s1_size, L(Loop) 92 addxl d5, d0 93 subl #0x10000, s1_size 94 bcc L(Loop) 95 96C Restore used registers from stack frame. 97 moveml M(sp,+), d2-d5 98 99 rts 100 101EPILOGUE(M4_function_1) 102