2 /*---------------------------------------------------------------------------+
5 | 64 bit right shift functions |
7 | Copyright (C) 1992,1995 |
8 | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, |
9 | Australia. E-mail billm@jacobi.maths.monash.edu.au |
12 | unsigned FPU_shrx(void *arg1, unsigned arg2) |
14 | unsigned FPU_shrxs(void *arg1, unsigned arg2) |
16 +---------------------------------------------------------------------------*/
21 /*---------------------------------------------------------------------------+
22 | unsigned FPU_shrx(void *arg1, unsigned arg2) |
24 | Extended shift right function. |
25 | Fastest for small shifts. |
26 | Shifts the 64 bit quantity pointed to by the first arg (arg1) |
27 | right by the number of bits specified by the second arg (arg2). |
28 | Forms a 96 bit quantity from the 64 bit arg and eax: |
29 | [ 64 bit arg ][ eax ] |
30 | shift right ---------> |
31 | The eax register is initialized to 0 before the shifting. |
32 | Results returned in the 64 bit arg and eax. |
33 +---------------------------------------------------------------------------*/
41 cmpl $32,%ecx /* shrd only works for 0..31 bits */
44 /* less than 32 bits */
46 movl (%esi),%ebx /* lsl */
47 movl 4(%esi),%edx /* msl */
48 xorl %eax,%eax /* extension */
64 movl (%esi),%eax /* lsl */
65 movl 4(%esi),%edx /* msl */
79 movl 4(%esi),%eax /* msl */
97 /*---------------------------------------------------------------------------+
98 | unsigned FPU_shrxs(void *arg1, unsigned arg2) |
100 | Extended shift right function (optimized for small floating point |
102 | Shifts the 64 bit quantity pointed to by the first arg (arg1) |
103 | right by the number of bits specified by the second arg (arg2). |
104 | Forms a 96 bit quantity from the 64 bit arg and eax: |
105 | [ 64 bit arg ][ eax ] |
106 | shift right ---------> |
107 | The eax register is initialized to 0 before the shifting. |
108 | The lower 8 bits of eax are lost and replaced by a flag which is |
109 | set (to 0x01) if any bit, apart from the first one, is set in the |
110 | part which has been shifted out of the arg. |
111 | Results returned in the 64 bit arg and eax. |
112 +---------------------------------------------------------------------------*/
120 cmpl $64,%ecx /* shrd only works for 0..31 bits */
123 cmpl $32,%ecx /* shrd only works for 0..31 bits */
126 /* We got here without jumps by assuming that the most common requirement
127 is for small integers */
128 /* Shift by [32..63] bits */
130 movl (%esi),%eax /* lsl */
131 movl 4(%esi),%edx /* msl */
136 orl %ebx,%ebx /* test these 32 bits */
138 test $0x7fffffff,%eax /* and 31 bits here */
140 orw %bx,%bx /* Any of the 63 bit set ? */
149 /* Shift by [0..31] bits */
151 movl (%esi),%ebx /* lsl */
152 movl 4(%esi),%edx /* msl */
153 xorl %eax,%eax /* extension */
157 test $0x7fffffff,%eax /* only need to look at eax here */
166 /* Shift by [64..95] bits */
172 movl (%esi),%ebx /* lsl */
173 movl 4(%esi),%eax /* msl */
174 xorl %edx,%edx /* extension */
180 test $0x7fffffff,%eax /* only need to look at eax here */
185 movl %edx,(%esi) /* set to zero */
186 movl %edx,4(%esi) /* set to zero */
193 /* Shift by [96..inf) bits */