/*******************************************************************1** m a t h 6 4 . h2** Forth Inspired Command Language - 64 bit math support routines3** Author: John Sadler ([email protected])4** Created: 25 January 19985** $Id: math64.h,v 1.9 2001/12/05 07:21:34 jsadler Exp $6*******************************************************************/7/*8** Copyright (c) 1997-2001 John Sadler ([email protected])9** All rights reserved.10**11** I am interested in hearing from anyone who uses ficl. If you have12** a problem, a success story, a defect, an enhancement request, or13** if you would like to contribute to the ficl release, please14** contact me by email at the address above.15**16** Get the latest Ficl release at http://ficl.sourceforge.net17**18** L I C E N S E and D I S C L A I M E R19**20** Redistribution and use in source and binary forms, with or without21** modification, are permitted provided that the following conditions22** are met:23** 1. Redistributions of source code must retain the above copyright24** notice, this list of conditions and the following disclaimer.25** 2. Redistributions in binary form must reproduce the above copyright26** notice, this list of conditions and the following disclaimer in the27** documentation and/or other materials provided with the distribution.28**29** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND30** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE31** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE32** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE33** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL34** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS35** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)36** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT37** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY38** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF39** SUCH DAMAGE.40*/414243#if !defined (__MATH64_H__)44#define __MATH64_H__4546#ifdef __cplusplus47extern "C" {48#endif4950DPINT m64Abs(DPINT x);51int m64IsNegative(DPINT x);52DPUNS m64Mac(DPUNS u, FICL_UNS mul, FICL_UNS add);53DPINT m64MulI(FICL_INT x, FICL_INT y);54DPINT m64Negate(DPINT x);55INTQR m64FlooredDivI(DPINT num, FICL_INT den);56void i64Push(FICL_STACK *pStack, DPINT i64);57DPINT i64Pop(FICL_STACK *pStack);58void u64Push(FICL_STACK *pStack, DPUNS u64);59DPUNS u64Pop(FICL_STACK *pStack);60INTQR m64SymmetricDivI(DPINT num, FICL_INT den);61UNS16 m64UMod(DPUNS *pUD, UNS16 base);626364#if PORTABLE_LONGMULDIV != 0 /* see sysdep.h */65DPUNS m64Add(DPUNS x, DPUNS y);66DPUNS m64ASL( DPUNS x );67DPUNS m64ASR( DPUNS x );68int m64Compare(DPUNS x, DPUNS y);69DPUNS m64Or( DPUNS x, DPUNS y );70DPUNS m64Sub(DPUNS x, DPUNS y);71#endif7273#define i64Extend(i64) (i64).hi = ((i64).lo < 0) ? -1L : 074#define m64CastIU(i64) (*(DPUNS *)(&(i64)))75#define m64CastUI(u64) (*(DPINT *)(&(u64)))76#define m64CastQRIU(iqr) (*(UNSQR *)(&(iqr)))77#define m64CastQRUI(uqr) (*(INTQR *)(&(uqr)))7879#define CELL_HI_BIT (1L << (BITS_PER_CELL-1))8081#ifdef __cplusplus82}83#endif8485#endif86878889