Administrator
|
When you write a VM program, it is not that far removed from writing an ASM program. It is the responsibility of the person writing the program to push the arguments onto the stack BEFORE they call the function. The 'call' command has to include the number of arguments because the VM has to know how many arguments were pushed onto the stack so that it can take that into account when determining where the beginning of the ARG segment is.
Similarly, the 'function' command has to include the number of local variables so that the VM can allocated memory for them on the stack and initialize them to zero.
Yes, your VM translator will need to add a unique label to the generated ASM code and push this label onto the stack.
The booting process is fairly simple. When the computer is reset is starts execution at ROM[0] and with nothing but unknown junk in RAM. Before your program can run successfully, a few RAM locations need to be set up properly. For instance, the Stack Pointer needs to be set so that the it points to the first memory location on the stack. Once the initialization of RAM is done, it then needs to call a specific function to get the VM program running.
|