1dnl mc68020 mpn_add_n, mpn_sub_n -- add or subtract limb vectors 2 3dnl Copyright 1992, 1994, 1996, 1999, 2000, 2001, 2002, 2003, 2005 Free 4dnl Software 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: 6 25 26ifdef(`OPERATION_add_n',` 27 define(M4_inst, addxl) 28 define(M4_function_n, mpn_add_n) 29',`ifdef(`OPERATION_sub_n',` 30 define(M4_inst, subxl) 31 define(M4_function_n, mpn_sub_n) 32', 33`m4_error(`Need OPERATION_add_n or OPERATION_sub_n 34')')') 35 36MULFUNC_PROLOGUE(mpn_add_n mpn_sub_n) 37 38 39C INPUT PARAMETERS 40C res_ptr (sp + 4) 41C s1_ptr (sp + 8) 42C s2_ptr (sp + 12) 43C size (sp + 16) 44 45 46PROLOGUE(M4_function_n) 47 48C Save used registers on the stack. 49 movel d2, M(-,sp) 50 movel a2, M(-,sp) 51 52C Copy the arguments to registers. Better use movem? 53 movel M(sp,12), a2 54 movel M(sp,16), a0 55 movel M(sp,20), a1 56 movel M(sp,24), d2 57 58 eorw #1, d2 59 lsrl #1, d2 60 bcc L(L1) 61 subql #1, d2 C clears cy as side effect 62 63L(Loop): 64 movel M(a0,+), d0 65 movel M(a1,+), d1 66 M4_inst d1, d0 67 movel d0, M(a2,+) 68L(L1): movel M(a0,+), d0 69 movel M(a1,+), d1 70 M4_inst d1, d0 71 movel d0, M(a2,+) 72 73 dbf d2, L(Loop) C loop until 16 lsb of %4 == -1 74 subxl d0, d0 C d0 <= -cy; save cy as 0 or -1 in d0 75 subl #0x10000, d2 76 bcs L(L2) 77 addl d0, d0 C restore cy 78 bra L(Loop) 79 80L(L2): 81 negl d0 82 83C Restore used registers from stack frame. 84 movel M(sp,+), a2 85 movel M(sp,+), d2 86 87 rts 88 89EPILOGUE(M4_function_n) 90