/*************************************************
* MPI Algorithms Implementation Header File      *
* (C) 1999-2003 The Botan Project                *
*************************************************/

#ifndef BOTAN_MP_IMPL_H__
#define BOTAN_MP_IMPL_H__

#include <botan/mp_core.h>

extern "C" {

#if (MP_WORD_BITS == 8)
  typedef Botan::u16bit dword;
#elif (MP_WORD_BITS == 16)
  typedef Botan::u32bit dword;
#elif (MP_WORD_BITS == 32)
  typedef Botan::u64bit dword;
#elif (MP_WORD_BITS == 64)
  #error MP_WORD_BITS can only be 64 with an assembler backend
#else
  #error MP_WORD_BITS must be 8, 16, 32, or 64
#endif

/*************************************************
* Do a Multiply-Add Operation                    *
*************************************************/
inline void bigint_madd(word a, word b, word c, word d,
                        word* out_low, word* out_high)
   {
   dword z = (dword)a * b + c + d;
   *out_low =  (word)((z                ) & MP_WORD_MAX);
   *out_high = (word)((z >> MP_WORD_BITS) & MP_WORD_MAX);
   }

}

#endif
