however, this time I hope with a more interesting philosophical / design discussion - I think there is no straight-forward answer for this, unless I am just
What I want to tackle next is load code into memory (don't even know how to read a disk yet )and then execute it. However, I want to be able to call OS system methods from this code. This implies however that I know the entry addresses of the respective methods - as the OS is still subject to change and as I may potentially even load it to different locations, these addresses are not static though...
Implicitly I have to find a means of identifying the relevant addresses during load / execution. So far I can think of the following methods:
- Translate all jump / call addresses from a "unique" identifier into the current method addresses during load. This requires an identifier of some sort (a string?) as well as a means to identify the current addresses of the methods (how?). It furthermore requires that the whole code needs to be searched for the according ids.
- Use something like a translation table to which all method calls in the code jump and from where the actual procedure would be called (like a header). This makes it easier to "translate" the code, still requires IDs and identification of the method addresses though
- Export the OS functions into a library and link the library into the code during compilation. This is obviously least desirable, as it duplicates all functions and it is difficult to maintain updates.
- Execute the code in an interpreted fashion, i.e. load into memory but execute step by step and interpret the calls ("just in time compilation"). This is obviously the slowest version, but it would allow code management in the long run (see C#)
Cheers