![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Game engine designer
Join Date: May 2005
Location: Sweden
Posts: 296
Rep Power: 4
![]() |
[x86 inline]Register needs to be prepared?
I want to do a call to the win32 api function GetTickCount(). Sadly it crashes. So I got two questions to ask you:
1. Why does it crashes? 2. In which register do the function put its return value? eax? #include <iostream>
#include <windows.h>
int main()
{
_asm
{
call GetTickCount
}
system("pause");
return 0;
} |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
1. Sorry, I don't know.
2. It stores its return value in eax. |
|
|
|
|
|
#3 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Can I ask why you don't just call this in the C++ code?
int current_time = GetTickCount(); ![]() |
|
|
|
|
|
#4 | |
|
Game engine designer
Join Date: May 2005
Location: Sweden
Posts: 296
Rep Power: 4
![]() |
Quote:
I shall ask your questions. If you have read in the assembly forum the last week you might have seen that I have been doing a lot of posts. This because I am working on an OpenGL application totally written in assembly code (to minimize file size, and for learning/fun). I do have bad debugging opportunities in my GL app, so I have been testing all my code in inline first. The next step in my project is to make a timer that calculates the delta time between each frame, and therefor I need a call to the GetTickCount function. This is not an assignment. And I have been testing to solve the problem for a while now. But a strange thing is (that probably are not strange) that it worked great to call the function from my assembly app! To bad I can't see if it works...yet. ![]() And oh! Thank you guys for taking time answearing my questions! ![]() /Klarre |
|
|
|
|
|
|
#5 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 824
Rep Power: 4
![]() |
I had a look at the code generated by the C compiler when calling
GetTickCount(); and it seems you need to use _asm
{
call dword ptr GetTickCount
}and yes, the result is in EAX |
|
|
|
|
|
#6 | |
|
Game engine designer
Join Date: May 2005
Location: Sweden
Posts: 296
Rep Power: 4
![]() |
Quote:
Thank you The Dark! It works great now! |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|