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.
67 * $FreeBSD: src/sys/gnu/i386/fpemul/polynomial.s,v 1.8 1999/08/28 00:42:55 peter Exp $
68 * $DragonFly: src/sys/i386/gnu/fpemul/Attic/polynomial.s,v 1.3 2003/08/07 21:17:20 dillon Exp $
77 /* #define EXTRA_PRECISE*/
91 movl PARAM1,%esi /* accum */
92 movl PARAM2,%edi /* x */
93 movl PARAM3,%ebx /* terms */
94 movl PARAM4,%ecx /* n */
100 movl 4(%ebx,%ecx,1),%edx /* terms[n] */
102 movl (%ebx,%ecx,1),%edx /* terms[n] */
117 mull 4(%edi) /* x ms long */
122 mull (%edi) /* x ls long */
123 /* movl %eax,-16(%ebp) */ /* Not needed */
128 mull 4(%edi) /* x ms long */
144 /* Now add the next term */
145 movl (%ebx,%ecx,1),%eax
147 movl 4(%ebx,%ecx,1),%eax
150 /* And put into the second register */
173 /* And round the result */