1/* sparc lshift 2 * 3 * Copyright (C) 1995, 1996, 1998, 4 * 2001, 2002 Free Software Foundation, Inc. 5 * 6 * This file is part of Libgcrypt. 7 * 8 * Libgcrypt is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU Lesser General Public License as 10 * published by the Free Software Foundation; either version 2.1 of 11 * the License, or (at your option) any later version. 12 * 13 * Libgcrypt is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this program; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 21 */ 22 23 24! INPUT PARAMETERS 25! res_ptr %o0 26! src_ptr %o1 27! size %o2 28! cnt %o3 29 30#include "sysdep.h" 31 32 .text 33 .align 4 34 .global C_SYMBOL_NAME(_gcry_mpih_lshift) 35C_SYMBOL_NAME(_gcry_mpih_lshift): 36 sll %o2,2,%g1 37 add %o1,%g1,%o1 ! make %o1 point at end of src 38 ld [%o1-4],%g2 ! load first limb 39 sub %g0,%o3,%o5 ! negate shift count 40 add %o0,%g1,%o0 ! make %o0 point at end of res 41 add %o2,-1,%o2 42 andcc %o2,4-1,%g4 ! number of limbs in first loop 43 srl %g2,%o5,%g1 ! compute function result 44 be L0 ! if multiple of 4 limbs, skip first loop 45 st %g1,[%sp+80] 46 47 sub %o2,%g4,%o2 ! adjust count for main loop 48 49Loop0: ld [%o1-8],%g3 50 add %o0,-4,%o0 51 add %o1,-4,%o1 52 addcc %g4,-1,%g4 53 sll %g2,%o3,%o4 54 srl %g3,%o5,%g1 55 mov %g3,%g2 56 or %o4,%g1,%o4 57 bne Loop0 58 st %o4,[%o0+0] 59 60L0: tst %o2 61 be Lend 62 nop 63 64Loop: ld [%o1-8],%g3 65 add %o0,-16,%o0 66 addcc %o2,-4,%o2 67 sll %g2,%o3,%o4 68 srl %g3,%o5,%g1 69 70 ld [%o1-12],%g2 71 sll %g3,%o3,%g4 72 or %o4,%g1,%o4 73 st %o4,[%o0+12] 74 srl %g2,%o5,%g1 75 76 ld [%o1-16],%g3 77 sll %g2,%o3,%o4 78 or %g4,%g1,%g4 79 st %g4,[%o0+8] 80 srl %g3,%o5,%g1 81 82 ld [%o1-20],%g2 83 sll %g3,%o3,%g4 84 or %o4,%g1,%o4 85 st %o4,[%o0+4] 86 srl %g2,%o5,%g1 87 88 add %o1,-16,%o1 89 or %g4,%g1,%g4 90 bne Loop 91 st %g4,[%o0+0] 92 93Lend: sll %g2,%o3,%g2 94 st %g2,[%o0-4] 95 retl 96 ld [%sp+80],%o0 97 98