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