在windows中测试机器语言中关于加快还是乘快的问题,这里只是用到了低精度的计时器GetTickCount,测试机器为:
内存:512MB
cpu: AMD Sempron 2400+ 单核2GHz
测试代码如下:
buf dword 256 dup(?)
AddWay proc
TIMES = 10000000h
AddWay proc
mov ecx,TIMES
xor eax,eax
.while ecx
.if eax == 256
xor eax,eax
.endif
mov buf[eax],0aabbccddh
add eax,4
dec ecx
.endw
ret
AddWay endp
MulWay proc
mov ecx,TIMES
xor eax,eax
.while ecx
.if eax == 256
xor eax,eax
.endif
mov buf[eax * 4],0aabbccddh
dec ecx
.endw
ret
MulWay endp
测试结果为(平均):
AddWay 720
MulWay 810