Script formals to function formals
Posted 10 January 2005 - 01:21 PM
One of the things I have been pondering about lately is the ability to call native engine functions from the script, functions that would be too slow for script execution. One of my current ideas is to map native functions in the engine to literal symbols, which would be easy to recognize and transform from the script manager/handler/whatever. On loading scripts, these symbols would then be substituted with function pointers, so that a lookup is not required on every native call.
My concern then comes to calling the native functions. They are not restricted to any number of specific parameters, so typedef’ing a common function type would not be practical. My idea was to write some assembly code to handle the loading of the different types of parameters, and then push those variables on to the stack. What I do not know, is how to do this efficiently. I am not that confident in the realm of assembly, but it would make it easier than doing it in C/C++ (if that is even possible). I have not decided on any final type of script stack, so anything is still possible. My first idea is to have two separate stacks: one for the script variables, and one for the values of the variable. The first stack of a common variable class, will hold different kinds of information on the values it points to in the second stack, which will just be an array of bytes, like offset, count and size. All the values of the script stack lay in a linear array, and I was wondering how different this is from the registers EBP/ESP. Would it be possible to just push the position of the first value on the value stack? This would remove any kind of formal-type recognition, and the need to write special code for different variable types.
Everyone is encouraged to toss any idea or suggestions you might have into the pool, everything will be appreciated. I have never done anything like this before, so all kinds of feedback is will surely help.
Posted 10 January 2005 - 02:33 PM
now my script lang is also only 10 instructions :cool:
Posted 10 January 2005 - 05:13 PM
Posted 10 January 2005 - 05:20 PM
I have already read that document, and I am not comfortable with scripts being able to call all my exported function (my engine.dll has ~1400, core.dll ~900), especially not functions like 'appCoreExit()', 'appFatalExit()', 'GiveMyCharacterInfinteLifeAndAllWeapons()' and so on, you get my point.
But thanks for the reply, keep 'em coming!
Posted 10 January 2005 - 05:36 PM
10 instructions!?! My last VM had 140 instructions, and that was not even enough :blink:
Must be low in functionality...
Posted 11 January 2005 - 04:50 AM
it's a stew of pic assembly and int 16.. with just the basic ops
but it works and it's fast as hell
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users