Upload Tizen:Base source
[external/gmp.git] / mpn / mips32 / lshift.asm
1 dnl  MIPS32 mpn_lshift -- Left shift.
2
3 dnl  Copyright 1995, 2000, 2002 Free Software Foundation, Inc.
4
5 dnl  This file is part of the GNU MP Library.
6
7 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl  it under the terms of the GNU Lesser General Public License as published
9 dnl  by the Free Software Foundation; either version 3 of the License, or (at
10 dnl  your option) any later version.
11
12 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
13 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15 dnl  License for more details.
16
17 dnl  You should have received a copy of the GNU Lesser General Public License
18 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
20 include(`../config.m4')
21
22 C INPUT PARAMETERS
23 C res_ptr       $4
24 C src_ptr       $5
25 C size          $6
26 C cnt           $7
27
28 ASM_START()
29 PROLOGUE(mpn_lshift)
30         sll     $2,$6,2
31         addu    $5,$5,$2        C make r5 point at end of src
32         lw      $10,-4($5)      C load first limb
33         subu    $13,$0,$7
34         addu    $4,$4,$2        C make r4 point at end of res
35         addiu   $6,$6,-1
36         and     $9,$6,4-1       C number of limbs in first loop
37         beq     $9,$0,.L0       C if multiple of 4 limbs, skip first loop
38          srl    $2,$10,$13      C compute function result
39
40         subu    $6,$6,$9
41
42 .Loop0: lw      $3,-8($5)
43         addiu   $4,$4,-4
44         addiu   $5,$5,-4
45         addiu   $9,$9,-1
46         sll     $11,$10,$7
47         srl     $12,$3,$13
48         move    $10,$3
49         or      $8,$11,$12
50         bne     $9,$0,.Loop0
51          sw     $8,0($4)
52
53 .L0:    beq     $6,$0,.Lend
54          nop
55
56 .Loop:  lw      $3,-8($5)
57         addiu   $4,$4,-16
58         addiu   $6,$6,-4
59         sll     $11,$10,$7
60         srl     $12,$3,$13
61
62         lw      $10,-12($5)
63         sll     $14,$3,$7
64         or      $8,$11,$12
65         sw      $8,12($4)
66         srl     $9,$10,$13
67
68         lw      $3,-16($5)
69         sll     $11,$10,$7
70         or      $8,$14,$9
71         sw      $8,8($4)
72         srl     $12,$3,$13
73
74         lw      $10,-20($5)
75         sll     $14,$3,$7
76         or      $8,$11,$12
77         sw      $8,4($4)
78         srl     $9,$10,$13
79
80         addiu   $5,$5,-16
81         or      $8,$14,$9
82         bgtz    $6,.Loop
83          sw     $8,0($4)
84
85 .Lend:  sll     $8,$10,$7
86         j       $31
87         sw      $8,-4($4)
88 EPILOGUE(mpn_lshift)