Original Post
Hi,
I'm currently designing a gaming engine and had that bad feeling about performance when my design required a quite large switch statement, so I decided to replace the switch statement with the following code:
__asm {
call dummy
dummy: pop eax
add eax, switchVar
jmp eax
// case1
...
// case2
...
// ...
...
// lastCase
...
}
As you may see, I defined my state-constants so that they have the offset from dummy to the code to be executed. I think that should be a lot faster than a switch cause I have just a simple add and jmp instead of a multitude of sub's an je's. Please correct me if I'm wrong.
My actual question is how I call member functions of a class in asm, cause I don't know in which order I have to put the parameters and this pointer on the stack and if I have to clean up the stack and so on.
Thanks in advance and tell me what you think about my optimization attempt
Edited by - Doener on January 2, 2002 9:11:23 PM