home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / crypl200.zip / BNLIB / LBNPPC.H < prev    next >
C/C++ Source or Header  |  1996-05-17  |  2KB  |  60 lines

  1. #ifndef LBNPPC_H
  2. #define LBNPPC_H
  3.  
  4. /*
  5.  * Assembly-language routines for the Power PC processor.
  6.  * Annoyingly, the Power PC does not have 64/32->32 bit divide,
  7.  * so the C code should be reasonably fast.  But it does have
  8.  * 32x32->64-bit multiplies, and these routines provide access
  9.  * to that.
  10.  *
  11.  * In versions of CodeWarrior before 8.0, there was no PPC assembler,
  12.  * so a kludged-up one in CPP is used.  This requires casting an
  13.  * array of unsigneds to function pointer type, and a function pointer
  14.  * is not a pointer to the code, but rather a pointer to a (code,TOC)
  15.  * pointer pair which we fake up.
  16.  *
  17.  * CodeWarrior 8.0 supports PCC assembly, which is used directly.
  18.  *
  19.  */
  20.  
  21. /*
  22.  * Bignums are stored in arrays of 32-bit words, and the least
  23.  * significant 32-bit word has the lowest address, thus "little-endian".
  24.  * The C code is slightly more efficient this way, so unless the
  25.  * processor cares (the PowerPC, like most RISCs, doesn't), it is
  26.  * best to use BN_LITTLE_ENDIAN.
  27.  * Note that this has NOTHING to do with the order of bytes within a 32-bit
  28.  * word; the math library is insensitive to that.
  29.  */
  30. #define BN_LITTLE_ENDIAN 1
  31.  
  32. typedef unsigned bnword32;
  33. #define BNWORD32 bnword32
  34.  
  35. #if __MWERKS__ < 0x800
  36.  
  37. /* Shared transition vector array */
  38. extern unsigned const * const lbnPPC_tv[];
  39.  
  40. /* A function pointer on the PowerPC is a pointer to a transition vector */
  41. #define lbnMulN1_32 \
  42. ((void (*)(unsigned *, unsigned const *, unsigned, unsigned))(lbnPPC_tv+0))
  43. #define lbnMulAdd1_32 \
  44. ((unsigned (*)(unsigned *, unsigned const *, unsigned, unsigned))(lbnPPC_tv+1))
  45. #define lbnMulSub1_32 \
  46. ((unsigned (*)(unsigned *, unsigned const *, unsigned, unsigned))(lbnPPC_tv+2))
  47.  
  48. #else /* __MWERKS__ >= 0x800 */
  49.  
  50. void lbnMulN1_32(unsigned *, unsigned const *, unsigned, unsigned);
  51. #define lbnMulN1_32 lbnMulN1_32
  52. unsigned lbnMulAdd1_32(unsigned *, unsigned const *, unsigned, unsigned);
  53. #define lbnMulAdd1_32 lbnMulAdd1_32
  54. unsigned lbnMulSub1_32(unsigned *, unsigned const *, unsigned, unsigned);
  55. #define lbnMulSub1_32 lbnMulSub1_32
  56.  
  57. #endif /* __MWERKS__ >= 0x800 */
  58.  
  59. #endif /* LBNPPC_H */
  60.