aboutsummaryrefslogtreecommitdiff
path: root/arch/parisc/lib/milli/remU.S
blob: c0a2d6e247c3ca096eee3401f49746f1c48d9d85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* 32 and 64-bit millicode, original author Hewlett-Packard
   adapted for gcc by Paul Bame <bame@debian.org>
   and Alan Modra <alan@linuxcare.com.au>.

   Copyright 2001, 2002, 2003 Free Software Foundation, Inc.

   This file is part of GCC and is released under the terms of
   of the GNU General Public License as published by the Free Software
   Foundation; either version 2, or (at your option) any later version.
   See the file COPYING in the top-level GCC source directory for a copy
   of the license.  */

#include "milli.h"

#ifdef L_remU
/* ROUTINE:	$$remU
   .	Single precision divide for remainder with unsigned binary integers.
   .
   .	The remainder must be dividend-(dividend/divisor)*divisor.
   .	Divide by zero is trapped.

   INPUT REGISTERS:
   .	arg0 ==	dividend
   .	arg1 == divisor
   .	mrp  == return pc
   .	sr0  == return space when called externally

   OUTPUT REGISTERS:
   .	arg0 =	undefined
   .	arg1 =	undefined
   .	ret1 =	remainder

   OTHER REGISTERS AFFECTED:
   .	r1   =	undefined

   SIDE EFFECTS:
   .	Causes a trap under the following conditions:  DIVIDE BY ZERO
   .	Changes memory at the following places:  NONE

   PERMISSIBLE CONTEXT:
   .	Unwindable.
   .	Does not create a stack frame.
   .	Suitable for internal or external millicode.
   .	Assumes the special millicode register conventions.

   DISCUSSION:
   .	Calls other millicode routines using mrp: NONE
   .	Calls other millicode routines: NONE  */


RDEFINE(temp,r1)
RDEFINE(rmndr,ret1)	/*  r29 */
	SUBSPA_MILLI
	ATTR_MILLI
	.export $$remU,millicode
	.proc
	.callinfo	millicode
	.entry
GSYM($$remU)
	ldo	-1(arg1),temp		/*  is there at most one bit set ? */
	and,=	arg1,temp,r0		/*  if not, don't use power of 2 */
	b	LREF(regular_seq)
	addit,=	0,arg1,r0		/*  trap on div by zero */
	and	arg0,temp,rmndr		/*  get the result for power of 2 */
	MILLIRETN
LSYM(regular_seq)
	comib,>=,n  0,arg1,LREF(special_case)
	subi	0,arg1,rmndr		/*  clear carry, negate the divisor */
	ds	r0,rmndr,r0		/*  set V-bit to 1 */
	add	arg0,arg0,temp		/*  shift msb bit into carry */
	ds	r0,arg1,rmndr		/*  1st divide step, if no carry */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  2nd divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  3rd divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  4th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  5th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  6th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  7th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  8th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  9th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  10th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  11th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  12th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  13th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  14th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  15th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  16th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  17th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  18th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  19th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  20th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  21st divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  22nd divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  23rd divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  24th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  25th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  26th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  27th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  28th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  29th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  30th divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  31st divide step */
	addc	temp,temp,temp		/*  shift temp with/into carry */
	ds	rmndr,arg1,rmndr		/*  32nd divide step, */
	comiclr,<= 0,rmndr,r0
	  add	rmndr,arg1,rmndr	/*  correction */
	MILLIRETN
	nop

/* Putting >= on the last DS and deleting COMICLR does not work!  */
LSYM(special_case)
	sub,>>=	arg0,arg1,rmndr
	  copy	arg0,rmndr
	MILLIRETN
	nop
	.exit
	.procend
	.end
#endif