I\'d like to write a very small proof-of-concept JIT compiler for a toy language processor I\'ve written (purely academic), but I\'m having some trouble in the middle-altitu
In addition to the techniques suggested so far, it might be worthwhile to look into the thread creation functions. If you create a new thread, with the starting address set to your generated code, you know for sure that there are no old registers that need saving or restoring, and the OS handles the setup of the relevant registers for you. I.e you eliminate steps 3, 4 and 6 of your list.