Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Requests and Feedback

calling functions by register token

A community discussion post from the original code:zIRON forum.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

calling functions by register token

hi OverHertz.

suppose you have a pointer to a function or a procedure which has it's parameters , stored in

a register. so can call that function by it's name as usual or by register token. .eg

function blabla(param1,param2,param3)

{

..............

}

we can call it as usual

myvar = blabla(p1,p2,p3);

so we can get it's address stored in ebx register

ebx = @blabla;

then we can call it by ebx register

myvar = Ebx(p1,p2,p3);

Emil.

http://www.freewebs.com/ogremagic/index.htm

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

This could be interesting, the current method is to create a pointer function

function* Name(params); DWord; stdcall;

and then assign the register to the function pointer.

Name = ebx;

if we come up with a way to allow the compiler to know which function method is inside ebx, then this will be possible...

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

I think compiler did not need to know which function method is inside ebx, so

you can push all the parameters then emit call [ebx] instruction.

may be the point here is the calling type which mean ,cdecl , stdcall ,...etc

and the solution can be as the following.

Ebx(p1,p2,p3); // default to stdcall

Ebx(p1,p2,p3) as cdecl; // self explnaition

Emil.

http://www.freewebs.com/ogremagic/index.htm

Colin admin
Posts
928
Threads
49
Location
Bulgaria

This is a fine solution, however it will not be able to type-check or check the amount of parameters; but i guess for such a thing it does not really matter. I will see about adding this for next release.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

very nice , thank you.

BTW , this feature will easily calling a function which stored in array , if we have

an array which hold a pointers to some functions , so we also do the following.

var1 = Ebx1; // call first function in array pointer.

var4 = Ebx4; // call 4 th function in array pointer.

and so on

what do you think ?

Emil.

http://www.freewebs.com/ogremagic/index.htm

Colin admin
Posts
928
Threads
49
Location
Bulgaria

I am not too sure about that, since ebx[4] will be fourth byte of ebx... [ebx+3] .. i will look into that further.

meanwhile i have added register calling for next release, however it will be experimental, it will probably need alot of testing for the next few releases.

eax(1,2,3,4) as cdecl;

default is stdcall.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

yes , i was wrong , Ebx[3] is the fourth function in array.

implementing it with next release is very nice , :yess:

i will continue feeding another ideas.

thank you for your Ziron cake.

Emil.

http://www.freewebs.com/ogremagic/index.htm