» UVSim «

by Void (Vadim Pidoshva; Katia Anatska; Martin Robinette; Devyn Clayson; Christopher Pryor)"

Our implementation:

The team project which demonstrates how machine language operates with memory.

  • Used a set of operations that were split into the op-code and operand. The op-code determined the operation that needed to be performed at the memory location specified by the operand.
  • Implemented a Virtual Machine (VM) that redirected the operation to the instruction function for execution.
  • Introduced the memory array where all of the operations were stored as they would do in the computer and perfectly visualized it.

Breakdown:

memory.cpp We used a fixed array of 1000 “memory slots” and used indexing to access the required memory location.

int memoryArray[1000];

main.cpp We implemented a loop to collect all the instructions from the user.
Example:
00? 1000
vm.cpp Instructions are then passed to the Virtual Machine (VM) and split into opCode and operand (example: 1000; 10 is opCode/instruction, 00 is memory location). Each opCode is then passed to the function that assigns the actual instruction. Example:

bool call_Operation(int opCode, int operand, Memory& m){
    instructions instructions;
    bool continueRunning = true;
    switch(opCode) {
      case 10://READ
        instructions.read(operand, m);
        break;

instructions.cpp Is where the instructions are stored. Example:

void instructions::read(int operand, Memory& m){
    int input_value;
    cout<<"\nEnter an integer: ";
    if (!(cin >> inputValue)) // check if input_value is a valid integer, throw error: not and integer
        throw runtime_error("Error: Invalid input, must be an integer.");
    m.setValue(operand,inputValue);
}

*This instruction stores an input value at the location specified (example: 1000. 10=reads the value to the location=00)


Alt text