KSP Task 1Construct the Ninja VM version 1 that can execute the instructions listed here. Each instruction of a program is stored in an "unsigned int", where the opcode (the number behind each...

KSP Task 1Construct the Ninja VM version 1 that can execute the instructions listed here. Each instruction of a program is stored in an "unsigned int", where the opcode (the number behind each instruction in the table) is stored in the top 8 bits of the "unsigned int". The remaining 24 bits are used to store an immediate value. At the moment, this is only needed for the instruction "pushc", where it represents the value to be placed on the stack.
This table lists the effect of each instruction on the stack. Three dots "..." in the table stand for the stack content not changed by the instruction; the "Top-of-Stack" is on the right. The operands for arithmetic operations are always integers, just like the values read in at "rdint" and "rdchr" or output at "wrint" and "wrchr".
The three programs listed here are to be permanently programmed into the VM. By entering a command line argument when calling the VM, the user can select one of the programs, which is then copied into the program memory of the VM. After the VM has started, the program is only listed in a readable form; you can find a possible representation in the reference implementation. It is then executed. Please note that "List" and "Execute" are two separate actions on the program that should happen strictly one after the other.
Here is the reference implementation again:njvm (I will attach the file)
Apr 23, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here