怎么提高这个程序的执行速度
发布时间:2010-06-14 15:17:14 文章来源:www.iduyao.cn 采编人员:星星草
如何提高这个程序的执行速度?
程序的功能是读取硬盘上的3个文件,在申请的内存中让这3个文件异或,最后把目标文件写入磁盘。文件基本都是上百G的所以循环执行上面的操作。现在的问题是速度太慢,请帮忙看看怎么提高速度。部分源代码如下:
先申请内存
;**********************************************************************
;读指定文件到申请的虚拟内存
;**********************************************************************
push ecx ;压入的是要循环的次数,每次循环执行8M(1024*1024*8这个值是可以变化的)的异或操作,
invoke ReadFile,@hHD1,Buffer_Point1,BUFFER_SIZE,addr dwCount,NULL
.if eax == 0
invoke MessageBox,0,$CTA0("读1.img文件错误"),NULL,MB_ICONEXCLAMATION
.endif
invoke ReadFile,@hHD2,Buffer_Point2,BUFFER_SIZE,addr dwCount,NULL
.if eax == 0
invoke MessageBox,0,$CTA0("读4.img文件错误"),NULL,MB_ICONEXCLAMATION
.endif
invoke ReadFile,@hHD3,Buffer_Point3,BUFFER_SIZE,addr dwCount,NULL
.if eax == 0
invoke MessageBox,0,$CTA0("读5.img文件错误"),NULL,MB_ICONEXCLAMATION
jmp _exit
.endif
jmp _PerXor
@@:
push ecx
invoke ReadFile,@hHD1,Buffer_Point1,BUFFER_SIZE,addr dwCount,NULL
invoke ReadFile,@hHD2,Buffer_Point2,BUFFER_SIZE,addr dwCount,NULL
invoke ReadFile,@hHD3,Buffer_Point3,BUFFER_SIZE,addr dwCount,NULL
;***************************************************************************
;执行异或操作
;***************************************************************************
_PerXor:
mov ecx,1024*1024*8/4 ;对应下面的loop指令中的ecx
mov edi,Buffer_Point1 ;Buffer_Point1为指针变量,值为申请内存的地址,其他类似
mov esi,Buffer_Point2
mov ebx,Buffer_Point3
@:
mov eax,[edi]
xor eax,[esi]
xor eax,[ebx]
mov [edi],eax
add edi,4
add esi,4
add ebx,4
loop @
;写入目标文件
invoke WriteFile,@hHD4,Buffer_Point1,BUFFER_SIZE,addr dwCount,NULL
.if eax == 0
invoke MessageBox,0,$CTA0("写失败"),NULL,MB_OK
jmp _exit
.endif
pop ecx
dec ecx
cmp ecx,0
jg @B
以下是我改写成读异步的源代码,在XP上执行正确但速度没什么提高,在windows2003的操作系统上面总是写失败,不知道什么原因。读异步一直没成功。请高手指教!invoke ReadFile,@hHD1,Buffer_Point1,BUFFER_SIZE,addr dwCount,NULL
.if eax == 0
invoke MessageBox,0,$CTA0("读1.img文件错误"),NULL,MB_ICONEXCLAMATION
.endif
invoke ReadFile,@hHD2,Buffer_Point2,BUFFER_SIZE,addr dwCount,NULL
.if eax == 0
invoke MessageBox,0,$CTA0("读4.img文件错误"),NULL,MB_ICONEXCLAMATION
.endif
invoke ReadFile,@hHD3,Buffer_Point3,BUFFER_SIZE,addr dwCount,NULL
.if eax == 0
invoke MessageBox,0,$CTA0("读5.img文件错误"),NULL,MB_ICONEXCLAMATION
jmp _exit
.endif
mov @overlapped.loffset,0
mov @overlapped.OffsetHigh,0
cld
jmp _PerXor
@@:
push ecx
add @overlapped.loffset,BUFFER_SIZE
mov @overlapped.OffsetHigh,0
invoke ReadFile,@hHD1,Buffer_Point1,BUFFER_SIZE,addr dwCount,NULL
invoke ReadFile,@hHD2,Buffer_Point2,BUFFER_SIZE,addr dwCount,NULL
invoke ReadFile,@hHD3,Buffer_Point3,BUFFER_SIZE,addr dwCount,NULL
;***************************************************************************
;执行异或操作
;***************************************************************************
_PerXor:
mov ecx,1024*1024*64/4 ;对应下面的loop指令中的ecx
mov edi,Buffer_Point1
mov esi,Buffer_Point2
mov ebx,Buffer_Point3
@:
mov eax,[edi]
xor eax,[esi]
xor eax,[ebx]
mov [edi],eax
add edi,4
add esi,4
add ebx,4
loop @
;写入目标文件
invoke WriteFile,@hHD4,Buffer_Point1,BUFFER_SIZE,addr dwCount,addr @overlapped
.if eax == 0
invoke MessageBox,0,$CTA0("写失败"),NULL,MB_OK
jmp _exit
.endif
pop ecx
dec ecx
cmp ecx,0
jg @B
------解决方案--------------------
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。
其他相似内容:
-
MSN通讯协议逆向
MSN 进行数据通讯中,据说用了TWN认证,通过SSL/TLS连接到login.passport.com和 loginnet.passportr.com 等服务器。
...
-
win7+64位cpu的exe反汇编问题,多次问人,无果
vs20008写的一个很简单的c++控制台程序
平台是:win7 64位操作系统
用od进行反汇编,...
-
可能很白痴的问题:想给ax赋一个负数怎么做?
比如想要赋一个-5给ax,是不是只有求出这个-5的补码,然后mov进这个补码这一种方法?
------...
-
居然显示不出负数来,悲剧
Assembly code
.386
.model flat,stdcall
include kernel32.inc
includelib kernel32.lib
include ms...
-
call far ptr '标号'的问题[在线等答案]
为什么ax会是1010?不是1006??求详细解答
难道call far ptr不是执行了push cs,push ip,jm...
-
CPU的程序计数器PC和指令指针寄存器IP是一个东西吗?
看上去好像功能完全一样,又觉得不应该是一回事,求教
------解决方案----------...
-
菜鸟问题,高人来帮忙
编程,统计data段中数值为8的字节的个数,用ax保存结果
我的代码
Assembly code
assume cs:code,ds:data
data se...
-
一个死循环问题
什么原因造成内循环才刚循环一次还没完,到了loop s1的时候cx突然变成F?
Assembly code
assume cs:codesg,ds:datas...
-
初学MUL乘法指令,写法求解释下
MUL r8/m8 ;无符号字节乘:AX←AL×r8/m8
MUL r16/m16 ;无符号字乘:DX.AX←AX×r16/...
-
汇编如何 取到8051的P0口的内容呢?
Assembly code
ORG 0000H
AJMP START
ORG 0030H
START: MOV P0,#00H
LOOP: ...