Register | Login
Forum Index > Requests and Feedback > calling functions by register token
Author Message
Pages: 1
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[85] calling functions by register token - posted: 2011-10-23 18:52:05
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
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[90] - posted: 2011-10-23 23:04:54
This could be interesting, the current method is to create a pointer function

Code:
function* Name(params); DWord; stdcall;


and then assign the register to the function pointer.

Code:
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...

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[95] - posted: 2011-10-23 23:44:09

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
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[96] - posted: 2011-10-23 23:58:20
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.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[97] - posted: 2011-10-24 00:10:11

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 = Ebx[1](par1,par2,par3); // call first function in array pointer.
var4 = Ebx[4](par1); // call 4 th function in array pointer.

and so on

what do you think ?

Emil.

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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[99] - posted: 2011-10-24 00:43:34
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.

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


default is stdcall.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[102] - posted: 2011-10-24 08:00:57

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

implementing it with next release is very nice , smile

i will continue feeding another ideas.

thank you for your Ziron cake.

Emil.

http://www.freewebs.com/ogremagic/index.htm
Pages: 1
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 1 user(s) online. 0 member(s) and 1 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd