|
Packit |
6c4009 |
/* MIPS __mpn_addmul_1 -- Multiply a limb vector with a single limb and
|
|
Packit |
6c4009 |
add the product to a second limb vector.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Copyright (C) 1995-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
This file is part of the GNU MP Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU MP Library is free software; you can redistribute it and/or modify
|
|
Packit |
6c4009 |
it under the terms of the GNU Lesser General Public License as published by
|
|
Packit |
6c4009 |
the Free Software Foundation; either version 2.1 of the License, or (at your
|
|
Packit |
6c4009 |
option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU MP Library is distributed in the hope that it will be useful, but
|
|
Packit |
6c4009 |
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
Packit |
6c4009 |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
Packit |
6c4009 |
License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public License
|
|
Packit |
6c4009 |
along with the GNU MP Library. If not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <sysdep.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* INPUT PARAMETERS
|
|
Packit |
6c4009 |
res_ptr $4
|
|
Packit |
6c4009 |
s1_ptr $5
|
|
Packit |
6c4009 |
size $6
|
|
Packit |
6c4009 |
s2_limb $7
|
|
Packit |
6c4009 |
*/
|
|
Packit |
6c4009 |
#ifdef __PIC__
|
|
Packit |
6c4009 |
.option pic2
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
ENTRY (__mpn_addmul_1)
|
|
Packit |
6c4009 |
.set noreorder
|
|
Packit |
6c4009 |
#ifdef __PIC__
|
|
Packit |
6c4009 |
.cpload t9
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
.set nomacro
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* warm up phase 0 */
|
|
Packit |
6c4009 |
lw $8,0($5)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* warm up phase 1 */
|
|
Packit |
6c4009 |
addiu $5,$5,4
|
|
Packit |
6c4009 |
#if __mips_isa_rev < 6
|
|
Packit |
6c4009 |
multu $8,$7
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
mulu $11,$8,$7
|
|
Packit |
6c4009 |
muhu $12,$8,$7
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
addiu $6,$6,-1
|
|
Packit |
6c4009 |
beq $6,$0,L(LC0)
|
|
Packit |
6c4009 |
move $2,$0 /* zero cy2 */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
addiu $6,$6,-1
|
|
Packit |
6c4009 |
beq $6,$0,L(LC1)
|
|
Packit |
6c4009 |
lw $8,0($5) /* load new s1 limb as early as possible */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
L(Loop): lw $10,0($4)
|
|
Packit |
6c4009 |
#if __mips_isa_rev < 6
|
|
Packit |
6c4009 |
mflo $3
|
|
Packit |
6c4009 |
mfhi $9
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
move $3,$11
|
|
Packit |
6c4009 |
move $9,$12
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
addiu $5,$5,4
|
|
Packit |
6c4009 |
addu $3,$3,$2 /* add old carry limb to low product limb */
|
|
Packit |
6c4009 |
#if __mips_isa_rev < 6
|
|
Packit |
6c4009 |
multu $8,$7
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
mulu $11,$8,$7
|
|
Packit |
6c4009 |
muhu $12,$8,$7
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
lw $8,0($5) /* load new s1 limb as early as possible */
|
|
Packit |
6c4009 |
addiu $6,$6,-1 /* decrement loop counter */
|
|
Packit |
6c4009 |
sltu $2,$3,$2 /* carry from previous addition -> $2 */
|
|
Packit |
6c4009 |
addu $3,$10,$3
|
|
Packit |
6c4009 |
sltu $10,$3,$10
|
|
Packit |
6c4009 |
addu $2,$2,$10
|
|
Packit |
6c4009 |
sw $3,0($4)
|
|
Packit |
6c4009 |
addiu $4,$4,4
|
|
Packit |
6c4009 |
bne $6,$0,L(Loop) /* should be "bnel" */
|
|
Packit |
6c4009 |
addu $2,$9,$2 /* add high product limb and carry from addition */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* cool down phase 1 */
|
|
Packit |
6c4009 |
L(LC1): lw $10,0($4)
|
|
Packit |
6c4009 |
#if __mips_isa_rev < 6
|
|
Packit |
6c4009 |
mflo $3
|
|
Packit |
6c4009 |
mfhi $9
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
move $3,$11
|
|
Packit |
6c4009 |
move $9,$12
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
addu $3,$3,$2
|
|
Packit |
6c4009 |
sltu $2,$3,$2
|
|
Packit |
6c4009 |
#if __mips_isa_rev < 6
|
|
Packit |
6c4009 |
multu $8,$7
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
mulu $11,$8,$7
|
|
Packit |
6c4009 |
muhu $12,$8,$7
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
addu $3,$10,$3
|
|
Packit |
6c4009 |
sltu $10,$3,$10
|
|
Packit |
6c4009 |
addu $2,$2,$10
|
|
Packit |
6c4009 |
sw $3,0($4)
|
|
Packit |
6c4009 |
addiu $4,$4,4
|
|
Packit |
6c4009 |
addu $2,$9,$2 /* add high product limb and carry from addition */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* cool down phase 0 */
|
|
Packit |
6c4009 |
L(LC0): lw $10,0($4)
|
|
Packit |
6c4009 |
#if __mips_isa_rev < 6
|
|
Packit |
6c4009 |
mflo $3
|
|
Packit |
6c4009 |
mfhi $9
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
move $3,$11
|
|
Packit |
6c4009 |
move $9,$12
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
addu $3,$3,$2
|
|
Packit |
6c4009 |
sltu $2,$3,$2
|
|
Packit |
6c4009 |
addu $3,$10,$3
|
|
Packit |
6c4009 |
sltu $10,$3,$10
|
|
Packit |
6c4009 |
addu $2,$2,$10
|
|
Packit |
6c4009 |
sw $3,0($4)
|
|
Packit |
6c4009 |
j $31
|
|
Packit |
6c4009 |
addu $2,$9,$2 /* add high product limb and carry from addition */
|
|
Packit |
6c4009 |
END (__mpn_addmul_1)
|