]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgcc/config/msp430/slli.S
MSP430: Implement 64-bit shifts in assembly code
[thirdparty/gcc.git] / libgcc / config / msp430 / slli.S
1 ; Copyright (C) 2012-2019 Free Software Foundation, Inc.
2 ; Contributed by Red Hat.
3 ;
4 ; This file is free software; you can redistribute it and/or modify it
5 ; under the terms of the GNU General Public License as published by the
6 ; Free Software Foundation; either version 3, or (at your option) any
7 ; later version.
8 ;
9 ; This file is distributed in the hope that it will be useful, but
10 ; WITHOUT ANY WARRANTY; without even the implied warranty of
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ; General Public License for more details.
13 ;
14 ; Under Section 7 of GPL version 3, you are granted additional
15 ; permissions described in the GCC Runtime Library Exception, version
16 ; 3.1, as published by the Free Software Foundation.
17 ;
18 ; You should have received a copy of the GNU General Public License and
19 ; a copy of the GCC Runtime Library Exception along with this program;
20 ; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
21 ; <http://www.gnu.org/licenses/>.
22
23 .text
24
25 /* Logical Left Shift - R12 -> R12. */
26
27 .section .text.__mspabi_slli_n
28 .macro _slli n
29 .global __mspabi_slli_\n
30 __mspabi_slli_\n:
31 ADD.W R12,R12
32 .endm
33
34 _slli 15
35 _slli 14
36 _slli 13
37 _slli 12
38 _slli 11
39 _slli 10
40 _slli 9
41 _slli 8
42 _slli 7
43 _slli 6
44 _slli 5
45 _slli 4
46 _slli 3
47 _slli 2
48 _slli 1
49 #ifdef __MSP430X_LARGE__
50 RETA
51 #else
52 RET
53 #endif
54
55 .section .text.__mspabi_slli
56 1: ADD.W #-1,R13
57 ADD.W R12,R12
58 .global __mspabi_slli
59 __mspabi_slli:
60 CMP #0,R13
61 JNZ 1b
62 #ifdef __MSP430X_LARGE__
63 RETA
64 #else
65 RET
66 #endif
67
68 /* Logical Left Shift - R12:R13 -> R12:R13. */
69
70 .section .text.__mspabi_slll_n
71 .macro _slll n
72 .global __mspabi_slll_\n
73 __mspabi_slll_\n:
74 ADD.W R12,R12
75 ADDC.W R13,R13
76 .endm
77
78 _slll 15
79 _slll 14
80 _slll 13
81 _slll 12
82 _slll 11
83 _slll 10
84 _slll 9
85 _slll 8
86 _slll 7
87 _slll 6
88 _slll 5
89 _slll 4
90 _slll 3
91 _slll 2
92 _slll 1
93 #ifdef __MSP430X_LARGE__
94 RETA
95 #else
96 RET
97 #endif
98
99 .section .text.__mspabi_slll
100 1: ADD.W #-1,R14
101 ADD.W R12,R12
102 ADDC.W R13,R13
103 .global __mspabi_slll
104 __mspabi_slll:
105 CMP #0,R14
106 JNZ 1b
107 #ifdef __MSP430X_LARGE__
108 RETA
109 #else
110 RET
111 #endif
112
113 /* Logical Left Shift - R8:R11 -> R12:R15
114 A 64-bit argument would normally be passed in R12:R15, but __mspabi_sllll has
115 special conventions, so the 64-bit value to shift is passed in R8:R11.
116 According to the MSPABI, the shift amount is a 64-bit value in R12:R15, but
117 we only use the low word in R12. */
118
119 .section .text.__mspabi_sllll
120 .global __mspabi_sllll
121 __mspabi_sllll:
122 MOV R11, R15 ; Free up R11 first
123 MOV R12, R11 ; Save the shift amount in R11
124 MOV R10, R14
125 MOV R9, R13
126 MOV R8, R12
127 CMP #0,R11
128 JNZ 1f
129 #ifdef __MSP430X_LARGE__
130 RETA
131 #else
132 RET
133 #endif
134 1:
135 RLA R12
136 RLC R13
137 RLC R14
138 RLC R15
139 ADD #-1,R11
140 JNZ 1b
141 #ifdef __MSP430X_LARGE__
142 RETA
143 #else
144 RET
145 #endif