1 /* SPDX-License-Identifier: GPL-2.0 */
3 /*---------------------------------------------------------------------------+
6 | 64 bit right shift functions |
8 | Copyright (C) 1992,1995 |
9 | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, |
10 | Australia. E-mail billm@jacobi.maths.monash.edu.au |
13 | unsigned FPU_shrx(void *arg1, unsigned arg2) |
15 | unsigned FPU_shrxs(void *arg1, unsigned arg2) |
17 +---------------------------------------------------------------------------*/
22 /*---------------------------------------------------------------------------+
23 | unsigned FPU_shrx(void *arg1, unsigned arg2) |
25 | Extended shift right function. |
26 | Fastest for small shifts. |
27 | Shifts the 64 bit quantity pointed to by the first arg (arg1) |
28 | right by the number of bits specified by the second arg (arg2). |
29 | Forms a 96 bit quantity from the 64 bit arg and eax: |
30 | [ 64 bit arg ][ eax ] |
31 | shift right ---------> |
32 | The eax register is initialized to 0 before the shifting. |
33 | Results returned in the 64 bit arg and eax. |
34 +---------------------------------------------------------------------------*/
42 cmpl $32,%ecx /* shrd only works for 0..31 bits */
45 /* less than 32 bits */
47 movl (%esi),%ebx /* lsl */
48 movl 4(%esi),%edx /* msl */
49 xorl %eax,%eax /* extension */
65 movl (%esi),%eax /* lsl */
66 movl 4(%esi),%edx /* msl */
80 movl 4(%esi),%eax /* msl */
99 /*---------------------------------------------------------------------------+
100 | unsigned FPU_shrxs(void *arg1, unsigned arg2) |
102 | Extended shift right function (optimized for small floating point |
104 | Shifts the 64 bit quantity pointed to by the first arg (arg1) |
105 | right by the number of bits specified by the second arg (arg2). |
106 | Forms a 96 bit quantity from the 64 bit arg and eax: |
107 | [ 64 bit arg ][ eax ] |
108 | shift right ---------> |
109 | The eax register is initialized to 0 before the shifting. |
110 | The lower 8 bits of eax are lost and replaced by a flag which is |
111 | set (to 0x01) if any bit, apart from the first one, is set in the |
112 | part which has been shifted out of the arg. |
113 | Results returned in the 64 bit arg and eax. |
114 +---------------------------------------------------------------------------*/
122 cmpl $64,%ecx /* shrd only works for 0..31 bits */
125 cmpl $32,%ecx /* shrd only works for 0..31 bits */
128 /* We got here without jumps by assuming that the most common requirement
129 is for small integers */
130 /* Shift by [32..63] bits */
132 movl (%esi),%eax /* lsl */
133 movl 4(%esi),%edx /* msl */
138 orl %ebx,%ebx /* test these 32 bits */
140 test $0x7fffffff,%eax /* and 31 bits here */
142 orw %bx,%bx /* Any of the 63 bit set ? */
151 /* Shift by [0..31] bits */
153 movl (%esi),%ebx /* lsl */
154 movl 4(%esi),%edx /* msl */
155 xorl %eax,%eax /* extension */
159 test $0x7fffffff,%eax /* only need to look at eax here */
168 /* Shift by [64..95] bits */
174 movl (%esi),%ebx /* lsl */
175 movl 4(%esi),%eax /* msl */
176 xorl %edx,%edx /* extension */
182 test $0x7fffffff,%eax /* only need to look at eax here */
187 movl %edx,(%esi) /* set to zero */
188 movl %edx,4(%esi) /* set to zero */
195 /* Shift by [96..inf) bits */