-
-
[求助]汇编中利用指针传回数据的问题
-
发表于:
2013-10-17 10:31
5634
-
初学汇编,看罗云彬的书,将书中的例子封装成函数出现错误
.386
.model flat, stdcall
option casemap:none
include windows.inc
include kernel32.inc
includelib kernel32.lib
include msvcrt.inc
includelib msvcrt.lib
.data
dqTickCounterStart qword ?
dqTickCounterEnd qword ?
dqTime qword ?
.const
szFormat db "%I64u",0Dh, 0Ah, 0
.code
HighResolutionTimer proc uses ebx edi esi, _dqTickCounterStart : qword, _dqTickCounterEnd : qword, _lpdqTime : dword
local @dqFreq : qword ;计数精度
local @dw1m : dword ;常数
mov @dw1m, 1000000
invoke QueryPerformanceFrequency, addr @dqFreq
mov eax, dword ptr _dqTickCounterStart
mov edx, dword ptr _dqTickCounterStart + sizeof dword
sub dword ptr _dqTickCounterEnd, eax
sbb dword ptr _dqTickCounterEnd + sizeof dword, edx
finit
fild @dqFreq
fild _dqTickCounterEnd
fimul @dw1m
fdivr
fistp qword ptr [_lpdqTime]
;invoke crt_printf, addr szFormat, qword ptr [_lpdqTime] ;这里显示的是对的
ret
HighResolutionTimer endp
start:
invoke QueryPerformanceCounter, addr dqTickCounterStart
;;其他计算
invoke Sleep, 2000
invoke QueryPerformanceCounter, addr dqTickCounterEnd
invoke HighResolutionTimer, dqTickCounterStart, dqTickCounterEnd, addr dqTime
invoke crt_printf, addr szFormat, dqTime ;显示0,不知道为什么结果没写入到dqTime中
invoke ExitProcess, 0
end start
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课