home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 February / PCO_0298.ISO / filesbbs / os2 / pgp263.arj / PGP263I.SRC / PGP263II.ZIP / src / mpw32asm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-05  |  3.8 KB  |  171 lines

  1.  
  2.  
  3. #if !defined(USE_WIN32_ASSEMBLER)
  4.  
  5. #error "You shouldn't be including this file because you're not using assembler routines"
  6.  
  7. #endif
  8.  
  9.  
  10.  
  11. #define mp_addc    P_ADDC
  12.  
  13. #define mp_add    P_ADD
  14.  
  15. #define mp_rotate_left P_ROTATE_LEFT
  16.  
  17. #define mp_subb P_SUBB
  18.  
  19. #define mp_smula P_SMULA
  20.  
  21.  
  22.  
  23. #if !defined(_MSC_VER)
  24.  
  25. #error "This code needs a Microsoft compiler"
  26.  
  27. #endif
  28.  
  29.  
  30.  
  31. #if defined(_M_IX86)
  32.  
  33.  
  34.  
  35.  
  36.  
  37. #pragma warning(disable:4035)  // this stops the compiler complaining about no return values from the routines
  38.  
  39.  
  40.  
  41. extern unsigned int global_precision;
  42.  
  43.  
  44.  
  45.  
  46.  
  47. __inline boolean P_ROTATE_LEFT(unitptr r1, boolean carry)
  48.  
  49. {
  50.  
  51.     __asm{
  52.  
  53.         mov edi,DWORD PTR [global_precision]
  54.  
  55.         mov    ecx,DWORD PTR [r1]
  56.  
  57.         xor    esi,esi                                // clear esi, which is the offset into the digit arrays
  58.  
  59.         // cetup carry
  60.  
  61.         // note that the instruction above clears the carry
  62.  
  63.         mov    eax,DWORD PTR [carry]
  64.  
  65.         rcr    eax,1
  66.  
  67. loop_t3:
  68.  
  69.         mov    eax,DWORD PTR [ecx + esi * 4]
  70.  
  71.         rcl    eax,1
  72.  
  73.         mov DWORD PTR [ecx + esi * 4],eax
  74.  
  75.         inc    esi
  76.  
  77.         dec    edi
  78.  
  79.         jnz    loop_t3
  80.  
  81.         // compute carry
  82.  
  83.         rcl    eax,1
  84.  
  85.         and    eax,1
  86.  
  87.     }
  88.  
  89. }
  90.  
  91.  
  92.  
  93. __inline boolean P_SUBB(unitptr r1, unitptr r2, boolean borrow)
  94.  
  95. {
  96.  
  97.     __asm{
  98.  
  99.         mov edi,DWORD PTR [global_precision]
  100.  
  101.         mov    ecx,DWORD PTR [r1]
  102.  
  103.         mov edx,DWORD PTR [r2]
  104.  
  105.         xor    esi,esi                                // clear esi, which is the offset into the digit arrays
  106.  
  107.         // cetup carry
  108.  
  109.         // note that the instruction above clears the carry
  110.  
  111.         mov    eax,DWORD PTR [borrow]
  112.  
  113.         rcr    eax,1
  114.  
  115. loop_t3:
  116.  
  117.         mov    eax,DWORD PTR [ecx + esi * 4]
  118.  
  119.         mov    ebx,DWORD PTR [edx + esi * 4]
  120.  
  121.         sbb    eax,ebx
  122.  
  123.         mov DWORD PTR [ecx + esi * 4],eax
  124.  
  125.         inc    esi
  126.  
  127.         dec    edi
  128.  
  129.         jnz    loop_t3
  130.  
  131.         // compute carry
  132.  
  133.         rcl    eax,1
  134.  
  135.         and    eax,1
  136.  
  137.     }
  138.  
  139. }
  140.  
  141.  
  142.  
  143. __inline void P_SMULA(unitptr prod,unitptr multiplicand, unit multiplier)
  144.  
  145. {
  146.  
  147.     __asm{
  148.  
  149.         mov ecx,DWORD PTR [global_precision]
  150.  
  151.         mov    edi,DWORD PTR [prod]
  152.  
  153.         mov esi,DWORD PTR [multiplicand]
  154.  
  155.         push    ebp
  156.  
  157.         mov ebp,DWORD PTR [multiplier]
  158.  
  159.  
  160.  
  161.         xor ebx,ebx
  162.  
  163. loop_t3:
  164.  
  165.         mov    eax,DWORD PTR [esi]
  166.  
  167.         mul    ebp
  168.  
  169.         add eax,ebx
  170.  
  171.         adc    edx,0
  172.  
  173.         add eax,DWORD PTR [edi]
  174.  
  175.         adc    edx,0
  176.  
  177.         mov DWORD PTR [edi],eax
  178.  
  179.         mov    ebx,edx
  180.  
  181.         add    esi,4
  182.  
  183.         add    edi,4
  184.  
  185.         dec    ecx
  186.  
  187.         jnz    loop_t3
  188.  
  189.         add    DWORD PTR [edi],ebx
  190.  
  191.         pop    ebp
  192.  
  193.     }
  194.  
  195. }
  196.  
  197.  
  198.  
  199. __inline boolean P_ADDC(unitptr r1, unitptr r2, boolean carry)
  200.  
  201. {
  202.  
  203.     __asm{
  204.  
  205.         mov edi,DWORD PTR [global_precision]
  206.  
  207.         mov    ecx,DWORD PTR [r1]
  208.  
  209.         mov edx,DWORD PTR [r2]
  210.  
  211.         xor    esi,esi                                // clear esi, which is the offset into the digit arrays
  212.  
  213.         // cetup carry
  214.  
  215.         // note that the instruction above clears the carry
  216.  
  217.         mov    eax,DWORD PTR [carry]
  218.  
  219.         rcr    eax,1
  220.  
  221. loop_t3:
  222.  
  223.         mov    eax,DWORD PTR [ecx + esi * 4]
  224.  
  225.         mov    ebx,DWORD PTR [edx + esi * 4]
  226.  
  227.         adc    eax,ebx
  228.  
  229.         mov DWORD PTR [ecx + esi * 4],eax
  230.  
  231.         inc    esi
  232.  
  233.         dec    edi
  234.  
  235.         jnz    loop_t3
  236.  
  237.         // compute carry
  238.  
  239.         rcl    eax,1
  240.  
  241.         and    eax,1
  242.  
  243.     }
  244.  
  245. }
  246.  
  247.  
  248.  
  249.  
  250.  
  251. // special version which doesn't read or write a carry.
  252.  
  253. // we actually call this more often than the full version !
  254.  
  255. __inline P_ADD(unitptr r1, unitptr r2)
  256.  
  257. {
  258.  
  259.     __asm{
  260.  
  261.         mov edi,DWORD PTR [global_precision]
  262.  
  263.         mov    ecx,DWORD PTR [r1]
  264.  
  265.         mov edx,DWORD PTR [r2]
  266.  
  267.         xor    esi,esi                                // clear esi, which is the offset into the digit arrays
  268.  
  269. loop_t3:
  270.  
  271.         mov    eax,DWORD PTR [ecx + esi * 4]
  272.  
  273.         mov    ebx,DWORD PTR [edx + esi * 4]
  274.  
  275.         adc    eax,ebx
  276.  
  277.         mov DWORD PTR [ecx + esi * 4],eax
  278.  
  279.         inc    esi
  280.  
  281.         dec    edi
  282.  
  283.         jnz    loop_t3
  284.  
  285.     }
  286.  
  287. }
  288.  
  289.  
  290.  
  291. #if defined(SMITH)
  292.  
  293.  
  294.  
  295. #define  mp_quo_digit  P_QUO_DIGIT
  296.  
  297.  
  298.  
  299. extern unit reciph,recipl;
  300.  
  301. extern int  mshift;
  302.  
  303.  
  304.  
  305. #endif /*#defined(SMITH) */
  306.  
  307.  
  308.  
  309. #endif /* X86 */
  310.  
  311.  
  312.  
  313. #if defined(_M_PPC)
  314.  
  315. #error "We've not written the PowerPC Code Yet!"
  316.  
  317. #endif /* _M_PPC */
  318.  
  319.  
  320.  
  321. #if defined(_M_ALPHA)
  322.  
  323. #error "We've not written the Alpha Code Yet!"
  324.  
  325. #endif /* _M_ALPHA */
  326.  
  327.  
  328.  
  329. #if defined(_M_MRX000)
  330.  
  331. #error "We've not written the MIPS Code Yet!"
  332.  
  333. #endif /* _M_MRX000 */
  334.  
  335.  
  336.  
  337.  
  338.  
  339. #pragma warning(default:4035)
  340.  
  341.