Having a little trouble here with a call instruction.
basically it goes somethin' like this:
__asm
{
xor eax,eax // Intialize
xor ebx,ebx // ^
xor ecx,ecx // ^
xor edx,edx // ^
rdtsc // Get Time Stamp Counter
xchg eax,ebx // EAX -> EBX , EDX -> ECX
xchg edx,ecx // TSC EBX:ECX
push ebx // Push start TSC
push ecx // ^
//xor ebx,ebx // Clear for use - replaced xor w/ a mozx ebx,[var] so no xor is needed
xor eax,eax
xor ecx,ecx // ^
movzx ebx,[duration] // EBX[15-0] = sample length in ms
//call GetTickCount // get time in ms
xchg ecx,eax // move time into ecx from eax
$LoopUntilDuration:
//call GetTickCount
sub eax,ebx // current time - duration
cmp ecx,eax // compare to start time
jl short $LoopUntilDuration // jump if less than start time
sub eax,ecx
add [duration],eax // return actual duration
rdtsc // get current time stamp
pop ecx // get start time stamp
pop edx // ^
sub eax,ebx // get no of clocks passed
sub edx,ecx // ^
mov dword ptr [clockspassed+0],eax // return clocks passed
mov dword ptr [clockspassed+4],edx // ^
}
clockspassed = (clockspassed - GetRDTSCLatency());
// where clockspassed is __int64
// and GetRDTSCLatency() returns the latency of the RDTSC
//and subsequnct stores
The return from the first call causes it to jump into privileged memory, as though the return address is invalid.
Maybe I'm just not seeing a mistake, or I've missunderstood something.
This has been bugging me for a while, so any help would be very much appreciated.
Thank you...
basically it goes somethin' like this:
__asm
{
xor eax,eax // Intialize
xor ebx,ebx // ^
xor ecx,ecx // ^
xor edx,edx // ^
rdtsc // Get Time Stamp Counter
xchg eax,ebx // EAX -> EBX , EDX -> ECX
xchg edx,ecx // TSC EBX:ECX
push ebx // Push start TSC
push ecx // ^
//xor ebx,ebx // Clear for use - replaced xor w/ a mozx ebx,[var] so no xor is needed
xor eax,eax
xor ecx,ecx // ^
movzx ebx,[duration] // EBX[15-0] = sample length in ms
//call GetTickCount // get time in ms
xchg ecx,eax // move time into ecx from eax
$LoopUntilDuration:
//call GetTickCount
sub eax,ebx // current time - duration
cmp ecx,eax // compare to start time
jl short $LoopUntilDuration // jump if less than start time
sub eax,ecx
add [duration],eax // return actual duration
rdtsc // get current time stamp
pop ecx // get start time stamp
pop edx // ^
sub eax,ebx // get no of clocks passed
sub edx,ecx // ^
mov dword ptr [clockspassed+0],eax // return clocks passed
mov dword ptr [clockspassed+4],edx // ^
}
clockspassed = (clockspassed - GetRDTSCLatency());
// where clockspassed is __int64
// and GetRDTSCLatency() returns the latency of the RDTSC
//and subsequnct stores
The return from the first call causes it to jump into privileged memory, as though the return address is invalid.
Maybe I'm just not seeing a mistake, or I've missunderstood something.
This has been bugging me for a while, so any help would be very much appreciated.
Thank you...