//finally 4560 ticks extern int zlongdiv(); unsigned int zugh1lb,zugh1rb,zugh1rbrb,zugh1rblb,zugh1lbrb; unsigned zproduct,zeax,zebx,zedx,zedxeax; unsigned int y2lb,y2rb,zcarrylb,zcarryrb,rightright,rightleft,leftright; unsigned int leftleft,lbofrightleft; unsigned int rbofrightleft,lbofleftright,rbofleftright; unsigned int slot1,slot3; unsigned int center,lbofcenter,rbofcenter; unsigned int zdivisorlb,zdivisorrb; unsigned int zlint2lb,zlint2rb; unsigned int znumerator1,znumerator2; unsigned int znumerator1lb,znumerator1rb; unsigned int znumerator2lb,znumerator2rb; //numerator=znumerator1,znumerator2 unsigned int zdenominator=0xffffffff; //denominator zdenominator unsigned int zdenominatorlb,zdenominatorrb; unsigned int zborrowfromleft; unsigned int crossl,crossr,rbofcrossr,lbofcrossr; unsigned int reml,remr,lbofremr; unsigned int remainderl,remainderr,lbofremainderr; unsigned int zquotient1,zquotient2; unsigned int zquotient,zremainder; unsigned int zdlb,zdrb; void modex() {int zecx; for (zecx=1;zecx>16; //left bits of zugh1=leftpart zugh1rb=zugh1<<16; zugh1rb=zugh1rb>>16; //right bits of zugh1=rightpart zugh1rb=10*zugh1rb+zcarryprnt; //10*rightpart+zcarryprnt; zugh1rbrb=zugh1rb<<16; zugh1rbrb=zugh1rbrb>>16; //right bits of that=rightbits zugh1rblb=zugh1rb-zugh1rbrb; zugh1rblb=zugh1rblb>>16; //left bits of that=leftbits zugh1lb=10*zugh1lb+zugh1rblb; //10*leftpart+leftbits=left zcarryprnt=zugh1lb>>16; //pick off the carry zugh1=zugh1lb<<16; //should have been ffff<<16 zugh1=zugh1+zugh1rbrb; } void mode4() {int zecx,zedx; z[1]=x[1]+y[1]; if (z[1]> outside of loops they were unnecessarily in. //But this is what I expected. void mode6() //zlint28 set in genprecd.h2 {int zebx,zecx; zlint2lb=zlint2>>16; zlint2rb=zlint2<<16; zlint2rb=zlint2rb>>16; zugh1=zlint28; zugh1lb=zugh1>>16; zugh1rb=zugh1<<16; zugh1rb=zugh1rb>>16; leftleft=zugh1lb*zlint2lb; leftright=zugh1lb*zlint2rb; rightleft=zugh1rb*zlint2lb; rightright=zugh1rb*zlint2rb; slot1=rightright+zcarry; if (slot1>16; //break them into 16 bit lb and rb slot3=slot3+lbofcenter+leftleft; rbofcenter=center<<16; slot1=slot1+rbofcenter; if (slot1>16; zugh1rb=zugh1<<16; zugh1rb=zugh1rb>>16; leftleft=zugh1lb*zlint2lb; leftright=zugh1lb*zlint2rb; rightleft=zugh1rb*zlint2lb; rightright=zugh1rb*zlint2rb; slot1=rightright+zcarry; if (slot1>16; //break them into 16 bit lb and rb slot3=slot3+lbofcenter+leftleft; rbofcenter=center<<16; slot1=slot1+rbofcenter; if (slot1>16; //zlint2 has been set zlint2rb=zlint2<<16; zlint2rb=zlint2rb>>16; zebx=0; //zcarry has been set for (zecx=precp1mzkisky+1;zecx>16; zugh1rb=zugh1<<16; zugh1rb=zugh1rb>>16; leftleft=zugh1lb*zlint2lb; leftright=zugh1lb*zlint2rb; rightleft=zugh1rb*zlint2lb; rightright=zugh1rb*zlint2rb; slot1=rightright+zcarry; if (slot1>16; //break them into 16 bit lb and rb slot3=slot3+lbofcenter+leftleft; rbofcenter=center<<16; slot1=slot1+rbofcenter; if (slot10;zecx--) // =znumerator1,znumerator2 {znumerator2=z11[zecx]; //next look will be zdenominator=zkk2; zlongdiv(); z[zecx]=zquotient; //quotient into z znumerator1=zremainder; //remainder is carried } return 0; } //mode1(*(zden+precmzknpr)); //cross multiplies zd*zden to get zL //moved to genprecd.h2 //4135 ticks after mode1 (main divider routine) redone //up to 3065 ticks after mode2 replaced int mode22() {znumerator1=zftemp1; znumerator2=0; zdenominator=za; zlongdiv(); zugh1=zremainder; return 0; } int mode3() {int zecx,zedx,zebx; zedx=0; for (zecx=0;zecx>16; znumerator1rb=znumerator1<<16; znumerator1rb=znumerator1rb>>16; znumerator2lb=znumerator2>>16; znumerator2rb=znumerator2<<16; znumerator2rb=znumerator2rb>>16; zdenominatorlb=zdenominator>>16; //when zdenominator=6 this is? zdenominatorrb=zdenominator<<16; zdenominatorrb=zdenominatorrb>>16; if (zdenominatorlb==0) //shift whole thing over {zdenominator=zdenominatorrb<<16; //no more reference to zdenominator znumerator1=znumerator1rb<<16; znumerator1=znumerator1+znumerator2lb; znumerator2=znumerator2<<16; zshiftmarker=1; //remember to shift remainder goto zverytop; } zquotient1=znumerator1/zdenominatorlb; //first divide::should be 16 bits if (zquotient1>0xffff) zquotient1=0xffff; tryanotherzquotient1: crossr=zquotient1*zdenominatorrb; //first part of cross will be 32 bits lbofcrossr=crossr>>16; rbofcrossr=crossr<<16; crossr=rbofcrossr>>16; //crossr willnow be 16 bits crossl=zquotient1*zdenominatorlb+lbofcrossr; crossr=crossr<<16; //adds a 0 to crossr if (crossr>znumerator2) //borrow 1 0000 0000 { remr=crossr-znumerator2-1; //this will be + remr=0xffffffff-remr; //this will be + zborrowfromleft=1; } else {remr=znumerator2-crossr; zborrowfromleft=0; } if (crossl+zborrowfromleft>znumerator1) {zquotient1=zquotient1-1; goto tryanotherzquotient1;} reml=znumerator1-zborrowfromleft-crossl; if (reml>zdenominatorlb) {zquotient1=zquotient1+1; goto tryanotherzquotient1; } lbofremr=remr>>16; //shift rem left reml=reml<<16; reml=reml+lbofremr; remr=remr<<16; zquotient2=reml/zdenominatorlb; tryanotherzquotient2: if (zquotient2>0xffff) zquotient2=0xffff; crossr=zquotient2*zdenominatorrb; //first part of cross will be 32 bits lbofcrossr=crossr>>16; rbofcrossr=crossr<<16; crossr=rbofcrossr>>16; //crossr willnow be 16 bits crossl=zquotient2*zdenominatorlb+lbofcrossr; crossr=crossr<<16; //adds a 0 to crossr if (crossr>remr) //borrow 1 0000 0000 //ok { remainderr=crossr-remr-1; //this will be + remainderr=0xffffffff-remainderr; //this will be + zborrowfromleft=1; } else {remainderr=remr-crossr; zborrowfromleft=0; } if (crossl+zborrowfromleft>reml) {zquotient2=zquotient2-1; goto tryanotherzquotient2; } remainderl=reml-zborrowfromleft-crossl; if (remainderl>zdenominatorlb) {zquotient2=zquotient2+1; goto tryanotherzquotient2; } lbofremainderr=remainderr>>16; //shift rem left remainderl=remainderl<<16; zremainder=remainderl+lbofremainderr; //remainderl=remainderl+lbofremainderr; //remainderr=remainderr<<16; //does nothing, should be removed zquotient1=zquotient1<<16; zquotient=zquotient1+zquotient2; //output is zquotient,zremainder if (zshiftmarker==1) zremainder=zremainder>>16; return 0; }