1 /*******************************************************************
3 ** Forth Inspired Command Language - 64 bit math support routines
4 ** Author: John Sadler (john_sadler@alum.mit.edu)
5 ** Created: 25 January 1998
7 *******************************************************************/
9 ** N O T I C E -- DISCLAIMER OF WARRANTY
11 ** Ficl is freeware. Use it in any way that you like, with
12 ** the understanding that the code is not supported.
14 ** Any third party may reproduce, distribute, or modify the ficl
15 ** software code or any derivative works thereof without any
16 ** compensation or license, provided that the author information
17 ** and this disclaimer text are retained in the source code files.
18 ** The ficl software code is provided on an "as is" basis without
19 ** warranty of any kind, including, without limitation, the implied
20 ** warranties of merchantability and fitness for a particular purpose
21 ** and their equivalents under the laws of any jurisdiction.
23 ** I am interested in hearing from anyone who uses ficl. If you have
24 ** a problem, a success story, a defect, an enhancement request, or
25 ** if you would like to contribute to the ficl release (yay!), please
26 ** send me email at the address above.
28 ** NOTE: this file depends on sysdep.h for the definition
29 ** of PORTABLE_LONGMULDIV and several abstract types.
33 /* $FreeBSD: src/sys/boot/ficl/math64.h,v 1.2 1999/09/29 04:43:06 dcs Exp $ */
35 #if !defined (__MATH64_H__)
42 DPINT m64Abs(DPINT x);
43 int m64IsNegative(DPINT x);
44 DPUNS m64Mac(DPUNS u, FICL_UNS mul, FICL_UNS add);
45 DPINT m64MulI(FICL_INT x, FICL_INT y);
46 DPINT m64Negate(DPINT x);
47 INTQR m64FlooredDivI(DPINT num, FICL_INT den);
48 void i64Push(FICL_STACK *pStack, DPINT i64);
49 DPINT i64Pop(FICL_STACK *pStack);
50 void u64Push(FICL_STACK *pStack, DPUNS u64);
51 DPUNS u64Pop(FICL_STACK *pStack);
52 INTQR m64SymmetricDivI(DPINT num, FICL_INT den);
53 UNS16 m64UMod(DPUNS *pUD, UNS16 base);
56 #if PORTABLE_LONGMULDIV != 0 /* see sysdep.h */
57 DPUNS m64Add(DPUNS x, DPUNS y);
58 DPUNS m64ASL( DPUNS x );
59 DPUNS m64ASR( DPUNS x );
60 int m64Compare(DPUNS x, DPUNS y);
61 DPUNS m64Or( DPUNS x, DPUNS y );
62 DPUNS m64Sub(DPUNS x, DPUNS y);
65 #define i64Extend(i64) (i64).hi = ((i64).lo < 0) ? -1L : 0
66 #define m64CastIU(i64) (*(DPUNS *)(&(i64)))
67 #define m64CastUI(u64) (*(DPINT *)(&(u64)))
68 #define m64CastQRIU(iqr) (*(UNSQR *)(&(iqr)))
69 #define m64CastQRUI(uqr) (*(INTQR *)(&(uqr)))
71 #define CELL_HI_BIT (1L << (BITS_PER_CELL-1))