I want to load actual proccesor-specific machine code (as in
IBM-compatible, not as in 486 10 MHz only) and run it.
I plan to follow this order of actions:
1) malloc() memory and load the entire file into it,
2) set a pointer to a class to point to the first bit of file (may
change to header info @ begining of file)
3) do a pointer->function() type of operation to call code.
The file format currently stands at:
Code:
something function(int target, int *data){
switch (target){
case 1: called_function_1( data );
case 2: called_function_2( data );
...
}
return ( value );
};
void called_function_1( int *data ){
...
};
void called_function_2( int *data ){
...
};
This isn't really code, just something to carry the concept across,
all variables except for target and data in the first function would
be in memory the file code itself malloc()'ed. target and data
would be at locations at the end of the file in the file set aside
for that purpose.
This is intended to be used to incorporate plug-and-play type
functionality in a format that I understand, and in a format that I
choose (in case I need to change the format of the file later to
add a header or some-such thing). Unfortunatly, I don't know if
this will work, or even if I will need to have the program modify
the plug-in according to it's memory location.
May seem a bit of a doozy, but I really want to know the
answer (I figure it should be useful for a mechanism to port
programs from one OS to another on the same platform also).
Thanks.