1/* libgcc routines for the FR30.
2   Copyright (C) 1998, 1999 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 2, or (at your option) any
9later version.
10
11In addition to the permissions in the GNU General Public License, the
12Free Software Foundation gives you unlimited permission to link the
13compiled version of this file into combinations with other programs,
14and to distribute those combinations without any restriction coming
15from the use of this file.  (The General Public License restrictions
16do apply in other respects; for example, they cover modification of
17the file, and distribution when not linked into a combine
18executable.)
19
20This file is distributed in the hope that it will be useful, but
21WITHOUT ANY WARRANTY; without even the implied warranty of
22MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23General Public License for more details.
24
25You should have received a copy of the GNU General Public License
26along with this program; see the file COPYING.  If not, write to
27the Free Software Foundation, 59 Temple Place - Suite 330,
28Boston, MA 02111-1307, USA.  */
29
30	.macro FUNC_START name
31	.text
32	.globl __\name
33	.type  __\name, @function
34__\name:
35	.endm
36
37	.macro FUNC_END name
38	.size  __\name, . - __\name
39	.endm
40
41	.macro DIV_BODY reg number
42	.if \number
43	DIV_BODY  \reg, "\number - 1"
44	div1	\reg
45	.endif
46	.endm
47
48#ifdef L_udivsi3
49FUNC_START udivsi3
50	;; Perform an unsiged division of r4 / r5 and place the result in r4.
51	;; Does not handle overflow yet...
52	mov	r4, mdl
53	div0u	r5
54	DIV_BODY r5 32
55	mov	mdl, r4
56	ret
57FUNC_END udivsi3
58#endif /* L_udivsi3 */
59
60#ifdef L_divsi3
61FUNC_START divsi3
62	;; Perform a siged division of r4 / r5 and place the result in r4.
63	;; Does not handle overflow yet...
64	mov	r4, mdl
65	div0s	r5
66	DIV_BODY r5 32
67	div2    r5
68	div3
69	div4s
70	mov	mdl, r4
71	ret
72FUNC_END divsi3
73#endif /* L_divsi3 */
74
75#ifdef L_umodsi3
76FUNC_START umodsi3
77	;; Perform an unsiged division of r4 / r5 and places the remainder in r4.
78	;; Does not handle overflow yet...
79	mov	r4, mdl
80	div0u	r5
81	DIV_BODY r5 32
82	mov	mdh, r4
83	ret
84FUNC_END umodsi3
85#endif /* L_umodsi3 */
86
87#ifdef L_modsi3
88FUNC_START modsi3
89	;; Perform a siged division of r4 / r5 and place the remainder in r4.
90	;; Does not handle overflow yet...
91	mov	r4, mdl
92	div0s	r5
93	DIV_BODY r5 32
94	div2    r5
95	div3
96	div4s
97	mov	mdh, r4
98	ret
99FUNC_END modsi3
100#endif /* L_modsi3 */
101
102#ifdef L_negsi2
103FUNC_START negsi2
104	ldi:8	#0, r0
105	sub	r4, r0
106	mov	r0, r4
107	ret
108FUNC_END negsi2
109#endif /* L_negsi2 */
110
111#ifdef L_one_cmplsi2
112FUNC_START one_cmplsi2
113	ldi:8	#0xff, r0
114	extsb	r0
115	eor	r0, r4
116	ret
117FUNC_END one_cmplsi2
118#endif /* L_one_cmplsi2 */
119
120
121