4 * Fixed point arithmetic polynomial evaluation.
7 * void polynomial(unsigned accum[], unsigned x[], unsigned terms[][2],
11 * terms[0] + (terms[1] + (terms[2] + ... + (terms[n-1]*x)*x)*x)*x) ... )*x
12 * The result is returned in accum.
15 * Copyright (C) 1992,1993,1994
16 * W. Metzenthen, 22 Parker St, Ormond, Vic 3163,
17 * Australia. E-mail billm@vaxc.cc.monash.edu.au
18 * All rights reserved.
20 * This copyright notice covers the redistribution and use of the
21 * FPU emulator developed by W. Metzenthen. It covers only its use
22 * in the 386BSD, FreeBSD and NetBSD operating systems. Any other
23 * use is not permitted under this copyright.
25 * Redistribution and use in source and binary forms, with or without
26 * modification, are permitted provided that the following conditions
28 * 1. Redistributions of source code must retain the above copyright
29 * notice, this list of conditions and the following disclaimer.
30 * 2. Redistributions in binary form must include information specifying
31 * that source code for the emulator is freely available and include
33 * a) an offer to provide the source code for a nominal distribution
35 * b) list at least two alternative methods whereby the source
36 * can be obtained, e.g. a publically accessible bulletin board
37 * and an anonymous ftp site from which the software can be
39 * 3. All advertising materials specifically mentioning features or use of
40 * this emulator must acknowledge that it was developed by W. Metzenthen.
41 * 4. The name of W. Metzenthen may not be used to endorse or promote
42 * products derived from this software without specific prior written
45 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
46 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
47 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
48 * W. METZENTHEN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
49 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
50 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
51 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
52 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
53 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
54 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 * The purpose of this copyright, based upon the Berkeley copyright, is to
58 * ensure that the covered software remains freely available to everyone.
60 * The software (with necessary differences) is also available, but under
61 * the terms of the GNU copyleft, for the Linux operating system and for
62 * the djgpp ms-dos extender.
64 * W. Metzenthen June 1994.
73 #include <gnu/i386/fpemul/fpu_asm.h>
76 /* #define EXTRA_PRECISE*/
90 movl PARAM1,%esi /* accum */
91 movl PARAM2,%edi /* x */
92 movl PARAM3,%ebx /* terms */
93 movl PARAM4,%ecx /* n */
99 movl 4(%ebx,%ecx,1),%edx /* terms[n] */
101 movl (%ebx,%ecx,1),%edx /* terms[n] */
116 mull 4(%edi) /* x ms long */
121 mull (%edi) /* x ls long */
122 /* movl %eax,-16(%ebp) */ /* Not needed */
127 mull 4(%edi) /* x ms long */
143 /* Now add the next term */
144 movl (%ebx,%ecx,1),%eax
146 movl 4(%ebx,%ecx,1),%eax
149 /* And put into the second register */
172 /* And round the result */