- 注册时间
- 2008-2-6
- 最后登录
- 1970-1-1
- 威望
- 星
- 金币
- 枚
- 贡献
- 分
- 经验
- 点
- 鲜花
- 朵
- 魅力
- 点
- 上传
- 次
- 下载
- 次
- 积分
- 51573
- 在线时间
- 小时
|
发表于 2008-7-31 08:43:04
|
显示全部楼层
我把我新写的尽量少分支的Pasal贴上来GxQ看看吧
还有两个跳转无法消除,哎
另外程序得到和GxQ相同的结果后已运行了14小时了
还没出新结果,效率大约相当于GxQ程序的1/2
所以过4个小时将超越38小时的运行结果哦- program square;
-
-
-
- uses SysUtils;
-
-
-
- const
-
- TenPower = 10000;
-
- StatusFileName = 'Square.Status';
-
- LogFileName = 'Square.Log';
-
- BlockSize = 8;
-
- BoolSize = 320;
-
-
-
- type
-
- TStatus = record
-
- S:array[0..BoolSize - 1] of integer;
-
- SquareValue:array[0..BlockSize - 1] of integer;
-
- Delta:array[0..BlockSize - 1] of integer;
-
- end;
-
-
-
- var
-
- Status:TStatus;
-
- StatusFile: File of TStatus;
-
- LogFile:TextFile;
-
- SumOfDigit4: array[0..TenPower - 1] of integer;
-
- ExeFilePath: string;
-
- Counter:Integer;
-
- s: integer;
-
-
-
- procedure WriteLog (s:string);
-
- begin
-
- Assign (LogFile, ExeFilePath + LogFileName);
-
- if FileExists(ExeFilePath + LogFileName) then
-
- Append (LogFile)
-
- else
-
- Rewrite (LogFile);
-
- writeln (LogFile, s);
-
- Close (LogFile);
-
- end;
-
-
-
- procedure InitStatus;
-
- var
-
- i:integer;
-
- begin
-
- for I := 0 to BoolSize - 1 do
-
- Status.s[i]:= 0;
-
- for i := 0 to BlockSize - 1 do
-
- begin
-
- status.SquareValue[i]:= 0;
-
- status.delta[i]:= 0;
-
- end;
-
- Status.Delta[0]:= 1;
-
- end;
-
-
-
- procedure ReadStatus;
-
- begin
-
- Assign (StatusFile, ExeFilePath + StatusFileName);
-
- if FileExists(ExeFilePath + StatusFileName) then
-
- begin
-
- Reset (StatusFile);
-
- Read (StatusFile, Status);
-
- Close (StatusFile);
-
- end
-
- else
-
- InitStatus;
-
- end;
-
-
-
- procedure WriteStatus;
-
- begin
-
- Assign (StatusFile, ExeFilePath + StatusFileName);
-
- Rewrite (StatusFile);
-
- Write (StatusFile, Status);
-
- Close (StatusFile);
-
- end;
-
-
-
- procedure InitSumOfDigit4;
-
- var
-
- i3, i2, i1, i0, k:integer;
-
- begin
-
- k:= 0;
-
- for I3 := 0 to 9 do
-
- for I2 := 0 to 9 do
-
- for I1 := 0 to 9 do
-
- for I0 := 0 to 9 do
-
- begin
-
- SumOfDigit4[k]:= i3 + i2 + i1 + i0;
-
- INC (k);
-
- end;
-
- end;
-
-
-
- procedure WriteResult;
-
- var
-
- Str:String[128];
-
- i:integer;
-
- begin
-
- Str:= '';
-
- for i := BlockSize-1 downto 0 do
-
- if Status.SquareValue[i] > 0 then
-
- Str:= str + Format ('%4d', [Status.SquareValue[i]]);
-
- writeln (DateTimeToStr (now) + ': ' + IntToStr (s) + ' ' + str);
-
- writelog (DateTimeToStr (now) + ': ' + IntToStr (s) + ' ' + str);
-
- end;
-
-
-
- label label0, label1;
-
-
-
- begin
-
- WriteLog ('程序启动: ' + DateTimeToStr (now));
-
- WriteLn ('程序启动: ' + DateTimeToStr (now));
-
- ExeFilePath:= ExtractFilePath (ParamStr(0));
-
- Counter:= 0;
-
- InitSumOfDigit4;
-
- ReadStatus;
-
- WriteLog ('初始化完成: ' + DateTimeToStr (now));
-
- WriteLn ('初始化完成: ' + DateTimeToStr (now));
-
-
-
- //ADDDelta
-
- asm
-
- label0:
-
- mov eax, dword ptr [Status.SquareValue]
-
- add eax,dword ptr [Status.Delta]
-
- mov ebx,dword ptr [Status.SquareValue + 4]
-
- add ebx,dword ptr [Status.Delta + 4]
-
- mov esi, eax
-
- sub esi, TenPower
-
- cmovnc eax, esi
-
- cmc
-
- adc ebx, 0
-
- mov edx,dword ptr [SumOfDigit4 + 4 * eax]
-
- mov dword ptr [Status.SquareValue], eax
-
- mov eax,dword ptr [Status.SquareValue + 8]
-
- add eax,dword ptr [Status.Delta + 8]
-
- mov edi, ebx
-
- sub edi, TenPower
-
- cmovnc ebx, edi
-
- cmc
-
- adc eax, 0
-
- mov dword ptr [Status.SquareValue + 4], ebx
-
- add edx,dword ptr [SumOfDigit4 + 4 * ebx]
-
- mov ebx,dword ptr [Status.SquareValue + 12]
-
- add ebx,dword ptr [Status.Delta + 12]
-
- mov esi, eax
-
- sub esi, TenPower
-
- cmovnc eax, esi
-
- cmc
-
- adc ebx, 0
-
- mov dword ptr [Status.SquareValue + 8], eax
-
- add edx,dword ptr [SumOfDigit4 + 4 * eax]
-
- mov eax,dword ptr [Status.SquareValue + 16]
-
- mov edi, ebx
-
- sub edi, TenPower
-
- cmovnc ebx, edi
-
- cmc
-
- adc eax, 0
-
- mov dword ptr [Status.SquareValue + 12], ebx
-
- add edx,dword ptr [SumOfDigit4 + 4 * ebx]
-
- mov ebx,dword ptr [Status.SquareValue + 20]
-
- mov esi, eax
-
- sub esi, TenPower
-
- cmovnc eax, esi
-
- cmc
-
- adc ebx, 0
-
- mov dword ptr [Status.SquareValue + 16], eax
-
- add edx,dword ptr [SumOfDigit4 + 4 * eax]
-
- mov eax,dword ptr [Status.SquareValue + 24]
-
- mov edi, ebx
-
- sub edi, TenPower
-
- cmovnc ebx, edi
-
- cmc
-
- adc eax, 0
-
- mov dword ptr [Status.SquareValue + 20], ebx
-
- add edx,dword ptr [SumOfDigit4 + 4 * ebx]
-
- mov ebx,dword ptr [Status.SquareValue + 28]
-
- mov esi, eax
-
- sub esi, TenPower
-
- cmovnc eax, esi
-
- cmc
-
- adc ebx, 0
-
- mov dword ptr [Status.SquareValue + 24], eax
-
- mov dword ptr [Status.SquareValue + 28], ebx
-
- add edx,dword ptr [SumOfDigit4 + 4 * eax]
-
- add edx,dword ptr [SumOfDigit4 + 4 * ebx]
-
- mov dword ptr [s], edx
-
- mov eax, 1
-
- xchg eax,dword ptr [Status.S + 4 * edx]
-
- cmp eax, 1
-
- je label1
-
- call WriteResult;
-
- label1:
-
- mov eax,dword ptr [Status.Delta]
-
- mov ebx,dword ptr [Status.Delta + 4]
-
- mov ecx,dword ptr [Status.Delta + 8]
-
- mov edx,dword ptr [Status.Delta + 12]
-
- add eax, 2
-
- mov esi, eax
-
- sub esi, TenPower
-
- cmovnc eax, esi
-
- cmc
-
- adc ebx, 0
-
- mov edi, ebx
-
- sub edi, TenPower
-
- cmovnc ebx, edi
-
- cmc
-
- adc ecx, 0
-
- mov esi, ecx
-
- sub esi, TenPower
-
- cmovnc ecx, esi
-
- cmc
-
- adc edx, 0
-
- mov dword ptr [Status.Delta], eax
-
- mov dword ptr [Status.Delta + 4], ebx
-
- mov dword ptr [Status.Delta + 8], ecx
-
- mov dword ptr [Status.Delta + 12], edx
-
- inc dword ptr [Counter]
-
- jne Label0
-
- call WriteStatus
-
- jmp label0
-
- end;
-
- end.
复制代码 下面是三个我编译的程序
GxQ运行下,因为有中断运行后自动恢复机制,要在不同目录运行,运行到产生157的地方停止
帮我看下在你机器上的时间信息
1.tar.bz2
(47.79 KB, 下载次数: 3)
|
|