用Machin公式计算圆周率的源程序
/* Program to compute PI, by Jason Chen, May 1999
**
** Open VC++ IDE, new a win32 console application project,
** add this file to the project and build it.
**
** Homepage : http://www.jason314.com
** Email : jason@szonline.net
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <math.h>
#include <time.h>
#include <conio.h>
#include <io.h>
int *arctg5, *arctg239, *tmp;
int DecLen, BinLen;
int x, n, sign, NonZeroPtr;
int Step;
char fn_status[] = "~pi_sts.___";
char fn_arctg5[] = "~atg5.___";
char fn_arctg239[] = "~atg239.___";
char fn_tmp[] = "~tmp.___";
time_t TotalTime, time1, time2;
void __cdecl FirstDiv(int *arctg_array)
{
__asm {
mov esi, arctg_array
mov dword ptr [esi], 1
xor edx, edx
mov ebx, x
mov ecx, BinLen
fd1: mov eax, [esi]
div ebx
mov [esi], eax
add esi, 4
loop fd1
mov esi, arctg_array
mov edi, tmp
mov ecx, BinLen
pushf
cld
rep movsd
popf
}
}
void __cdecl arctgx(int *arctg_array)
{
int NonZeroBytePtr;
int key;
FILE *fp;
for (;NonZeroPtr<BinLen;) {
NonZeroBytePtr = NonZeroPtr * 4;
if (_kbhit()) {
key=_getch();
if (key==0 || key==0xe0) _getch();
if (key=='p') {
printf("Swap data to disk .../n");
if (x==25)
Step = 1;
else
Step = 2;
time(&time2);
TotalTime += time2 - time1;
if ((fp=fopen(fn_status,"wt"))==NULL) {
printf("Create file %s error!!/n", fn_status);
exit(0);
}
fprintf(fp, "%d %d %d %d %d %d %d