1/* libgcc routines for the FR30.
2   Copyright (C) 1998-2013 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 3, or (at your option) any
9later version.
10
11This file is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14General Public License for more details.
15
16Under Section 7 of GPL version 3, you are granted additional
17permissions described in the GCC Runtime Library Exception, version
183.1, as published by the Free Software Foundation.
19
20You should have received a copy of the GNU General Public License and
21a copy of the GCC Runtime Library Exception along with this program;
22see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23<http://www.gnu.org/licenses/>.  */
24
25	.macro FUNC_START name
26	.text
27	.globl __\name
28	.type  __\name, @function
29__\name:
30	.endm
31
32	.macro FUNC_END name
33	.size  __\name, . - __\name
34	.endm
35
36	.macro DIV_BODY reg number
37	.if \number
38	DIV_BODY  \reg, "\number - 1"
39	div1	\reg
40	.endif
41	.endm
42
43#ifdef L_udivsi3
44FUNC_START udivsi3
45	;; Perform an unsiged division of r4 / r5 and place the result in r4.
46	;; Does not handle overflow yet...
47	mov	r4, mdl
48	div0u	r5
49	DIV_BODY r5 32
50	mov	mdl, r4
51	ret
52FUNC_END udivsi3
53#endif /* L_udivsi3 */
54
55#ifdef L_divsi3
56FUNC_START divsi3
57	;; Perform a siged division of r4 / r5 and place the result in r4.
58	;; Does not handle overflow yet...
59	mov	r4, mdl
60	div0s	r5
61	DIV_BODY r5 32
62	div2    r5
63	div3
64	div4s
65	mov	mdl, r4
66	ret
67FUNC_END divsi3
68#endif /* L_divsi3 */
69
70#ifdef L_umodsi3
71FUNC_START umodsi3
72	;; Perform an unsiged division of r4 / r5 and places the remainder in r4.
73	;; Does not handle overflow yet...
74	mov	r4, mdl
75	div0u	r5
76	DIV_BODY r5 32
77	mov	mdh, r4
78	ret
79FUNC_END umodsi3
80#endif /* L_umodsi3 */
81
82#ifdef L_modsi3
83FUNC_START modsi3
84	;; Perform a siged division of r4 / r5 and place the remainder in r4.
85	;; Does not handle overflow yet...
86	mov	r4, mdl
87	div0s	r5
88	DIV_BODY r5 32
89	div2    r5
90	div3
91	div4s
92	mov	mdh, r4
93	ret
94FUNC_END modsi3
95#endif /* L_modsi3 */
96
97#ifdef L_negsi2
98FUNC_START negsi2
99	ldi:8	#0, r0
100	sub	r4, r0
101	mov	r0, r4
102	ret
103FUNC_END negsi2
104#endif /* L_negsi2 */
105
106#ifdef L_one_cmplsi2
107FUNC_START one_cmplsi2
108	ldi:8	#0xff, r0
109	extsb	r0
110	eor	r0, r4
111	ret
112FUNC_END one_cmplsi2
113#endif /* L_one_cmplsi2 */
114
115
116