--- pgp/src/r3000.c 2018/04/24 16:38:42 1.1.1.1 +++ pgp/src/r3000.c 2018/04/24 16:42:23 1.1.1.4 @@ -13,11 +13,23 @@ Boulder, CO 80304 (303) 541-0140 - (c) Copyright 1986-92 by Philip Zimmermann. All rights reserved. + (c) Copyright 1990-1994 by Philip Zimmermann. All rights reserved. The author assumes no liability for damages resulting from the use of this software, even if the damage results from defects in this software. No warranty is expressed or implied. + Note that while most PGP source modules bear Philip Zimmermann's + copyright notice, many of them have been revised or entirely written + by contributors who frequently failed to put their names in their + code. Code that has been incorporated into PGP from other authors + was either originally published in the public domain or is used with + permission from the various authors. + + PGP is available for free to the public under certain restrictions. + See the PGP User's Guide (included in the release package) for + important information about licensing, patent restrictions on + certain algorithms, trademarks, copyrights, and export controls. + -- Adapt so that the unit size can be a full int size. This was inspired by the lack of a carry bit on MIPSco processors. On such machines, the advantage of assembly language coding @@ -55,7 +67,8 @@ boolean mp_addc (register unitptr r1,register unitptr r2,register boolean carry) /* multiprecision add with carry r2 to r1, result in r1 */ /* carry is incoming carry flag-- value should be 0 or 1 */ -{ register unit x,x1; +{ + register unit x,x1; int i; short precision; /* number of units to add */ unsigned int mcarry = carry; @@ -64,8 +77,7 @@ boolean mp_addc make_lsbptr(r2,precision); i = precision&3; - while (i--) - { + while (i--) { if (mcarry) { x = *r1 + *r2 + 1; x1 = ~ *r1; @@ -79,8 +91,7 @@ boolean mp_addc } i = precision>>2; - while (i--) - { + while (i--) { #define ADDC(n) \ if (mcarry) { \ x = word_v(r1,n) + word_v(r2,n) + 1; \ @@ -109,7 +120,8 @@ boolean mp_subb (register unitptr r1,register unitptr r2,register boolean borrow) /* multiprecision subtract with borrow, r2 from r1, result in r1 */ /* borrow is incoming borrow flag-- value should be 0 or 1 */ -{ register unit x; +{ + register unit x; unsigned int mborrow = borrow; int i; short precision; /* number of units to subtract */ @@ -118,8 +130,8 @@ boolean mp_subb make_lsbptr(r2,precision); i = precision&3; - while (i--) - { if (mborrow) { + while (i--) { + if (mborrow) { x = *r1 - *r2 - mborrow; mborrow = 1 ^ (*r2 < *r1); } else { @@ -131,8 +143,7 @@ boolean mp_subb } i = precision>>2; - while (i--) - { + while (i--) { #define SUBB(n) \ if (mborrow) { \ @@ -167,7 +178,8 @@ boolean mp_subb boolean mp_rotate_left(register unitptr r1,register boolean carry) /* multiprecision rotate left 1 bit with carry, result in r1. */ /* carry is incoming carry flag-- value should be 0 or 1 */ -{ register int precision; /* number of units to rotate */ +{ + register int precision; /* number of units to rotate */ unsigned int mcarry = carry, carry2,carry3,carry4, nextcarry; int i; @@ -181,8 +193,7 @@ boolean mp_rotate_left(register unitptr pre_higherunit(r1); } i = precision>>2; - while (i--) - { + while (i--) { carry2 = (((signedunit) *r1) < 0); *r1 = (*r1 << 1) | mcarry; @@ -200,7 +211,7 @@ boolean mp_rotate_left(register unitptr return(mcarry); /* return the final carry flag bit */ } /* mp_rotate_left */ -void p_setp(short nbits){} ; +void p_setp(short nbits){} /************** end of primitives that should be in assembly *************/ @@ -217,7 +228,7 @@ typedef unsigned int MULTUNIT; #define MULTUNIT_hmask ((1UL << (MULTUNITSIZE/2))-1) #define MULTUNIT_mask ((MULTUNIT_hmask<<(MULTUNITSIZE/2)) | MULTUNIT_hmask) -p_smula ( +void p_smula ( MULTUNIT *prod, MULTUNIT *multiplicand, MULTUNIT multiplier) @@ -238,22 +249,22 @@ MULTUNIT multiplier) ah = 0; ch = 0; while(--i) { - lmul(multiplier, *multiplicand, npl, nph); - post_higherunit(multiplicand); - al += *prod; - cl = (al < *prod); - al += pl; - cl += (al < pl); - ah += ph; - ch = (ah < ph); - ah += cl; - ch += (ah < cl); - *prod = al; - post_higherunit(prod); - al = ah; - ah = ch; - pl = npl; - ph = nph; + lmul(multiplier, *multiplicand, npl, nph); + post_higherunit(multiplicand); + al += *prod; + cl = (al < *prod); + al += pl; + cl += (al < pl); + ah += ph; + ch = (ah < ph); + ah += cl; + ch += (ah < cl); + *prod = al; + post_higherunit(prod); + al = ah; + ah = ch; + pl = npl; + ph = nph; } al += *prod; cl = (al < *prod);