Question: Java Lab Please help CS 13 Virtual Machine Proiect Implement the a virtual machine for the instructions listed in the chart on page two Your
Java Lab
Please help




CS 13 Virtual Machine Proiect Implement the a virtual machine for the instructions listed in the chart on page two Your VM class should have the following fields: Field Description Function Program Counter; type int Array of type int Operand and CPU stack Contains the address of the next instruction to fetch memory Contains instructions (a program) and stack Used for processing arithmetic instructions and storing return address The pc should be initialized to 0 so the first instruction is fetched from memory location zero. The memory should contain a sample machine language program. This program could be loaded from a text file, or you can directly initialize the memory array when it is created. The stack is the integer stack discussed in part 1 of this assignment. The stack should be properly initialized by its constructor. To execute the program in memory you will need a method that: 1. Fetches the instruction at the address contained in the pc 2. Increments the pc 3. Decodes the instruction. This is done with a switch statement. 4. Executes the instruction 5. Repeats this process until a HALT is executed. CS 13 Virtual Machine Proiect Implement the a virtual machine for the instructions listed in the chart on page two Your VM class should have the following fields: Field Description Function Program Counter; type int Array of type int Operand and CPU stack Contains the address of the next instruction to fetch memory Contains instructions (a program) and stack Used for processing arithmetic instructions and storing return address The pc should be initialized to 0 so the first instruction is fetched from memory location zero. The memory should contain a sample machine language program. This program could be loaded from a text file, or you can directly initialize the memory array when it is created. The stack is the integer stack discussed in part 1 of this assignment. The stack should be properly initialized by its constructor. To execute the program in memory you will need a method that: 1. Fetches the instruction at the address contained in the pc 2. Increments the pc 3. Decodes the instruction. This is done with a switch statement. 4. Executes the instruction 5. Repeats this process until a HALT is executed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
