1;   Copyright (C) 2012-2015 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	.macro	_srli n
26	.global __mspabi_srli_\n
27__mspabi_srli_\n:
28	CLRC
29	RRC.W	R12
30	.endm
31
32/* Logical Right Shift - R12 -> R12 */
33	_srli	15
34	_srli	14
35	_srli	13
36	_srli	12
37	_srli	11
38	_srli	10
39	_srli	9
40	_srli	8
41	_srli	7
42	_srli	6
43	_srli	5
44	_srli	4
45	_srli	3
46	_srli	2
47	_srli	1
48#ifdef __MSP430X_LARGE__
49	RETA
50#else
51	RET
52#endif
53
541:	ADD.W	#-1,R13
55	CLRC
56	RRC.W	R12,R12
57	.global	__mspabi_srli
58__mspabi_srli:
59	CMP	#0,R13
60	JNZ	1b
61#ifdef __MSP430X_LARGE__
62	RETA
63#else
64	RET
65#endif
66
67/* Logical Right Shift - R12:R13 -> R12:R13 */
68
69	.macro	_srll	n
70	.global	__mspabi_srll_\n
71__mspabi_srll_\n:
72	CLRC
73	RRC.W	R13
74	RRC.W	R12
75	.endm
76
77	_srll	15
78	_srll	14
79	_srll	13
80	_srll	12
81	_srll	11
82	_srll	10
83	_srll	9
84	_srll	8
85	_srll	7
86	_srll	6
87	_srll	5
88	_srll	4
89	_srll	3
90	_srll	2
91	_srll	1
92#ifdef __MSP430X_LARGE__
93	RETA
94#else
95	RET
96#endif
97
981:	ADD.W	#-1,R14
99	CLRC
100	RRC.W	R13
101	RRC.W	R12
102	.global	__mspabi_srll
103__mspabi_srll:
104	CMP	#0,R14
105	JNZ	1b
106#ifdef __MSP430X_LARGE__
107	RETA
108#else
109	RET
110#endif
111