Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Filename: VirtualMachine.h
- By: Matthew DeBord and Ronald Radut
- Created: 04/11/2011
- Last Modified: 04/20/2011
- Description: This header contains class declarations for the Virtual Machine
- ******************************************************************************/
- #include <cstdlib>
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- #include <sstream>
- using namespace std;
- // following format classes property of K Zemoudeh
- class format1 {
- public:
- unsigned UNUSED:6;
- unsigned RS:2;
- unsigned I:1;
- unsigned RD:2;
- unsigned OP:5;
- };
- class format2 {
- public:
- unsigned ADDR:8;
- unsigned I:1;
- unsigned RD:2;
- unsigned OP:5;
- };
- class format3 {
- public:
- int CONST:8;
- unsigned I:1;
- unsigned RD:2;
- unsigned OP:5;
- };
- union instruction {
- int i;
- format1 f1;
- format2 f2;
- format3 f3;
- };
- // Begin Virtual Machine Class
- class VirtualMachine
- {
- private:
- static const int REG_FILE_SIZE = 4;
- static const int MEM_SIZE = 256;
- vector<int> r;
- vector<int> mem;
- string line;
- unsigned int ir, pc, sr, sp, clock, base, limit;
- //sign extender
- int signExtend(int i);
- // following functions set the corresponding bit for the sr
- void setV(int i);
- void setL(int i);
- void setE(int i);
- void setG(int i);
- void setC(int i);
- //following functions GET the corresponding bit from sr
- int getV();
- int getL();
- int getE();
- int getG();
- int getC();
- bool checkOverflow(int a, int b);
- bool checkOverflow3(int a, int b, int c);
- bool checkOverflow1(int a);
- // need base/limit registers?? <--- ATTN <----
- public:
- VirtualMachine();
- void Execute();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement