created basic simulator
This commit is contained in:
parent
8c02a9e950
commit
5a06b2bc0b
12 changed files with 541 additions and 0 deletions
73
ass2/Machine.h
Normal file
73
ass2/Machine.h
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
#ifndef MACHINE_H
|
||||
#define MACHINE_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "Device.h"
|
||||
|
||||
const int MAX_ADDRESS = 0xFFFFF;
|
||||
const int MAX_DEVICES = 256;
|
||||
|
||||
class Machine {
|
||||
private:
|
||||
uint8_t memory[MAX_ADDRESS + 1];
|
||||
Device* devices[MAX_DEVICES];
|
||||
|
||||
// registers
|
||||
int A; // Accumulator (24-bit)
|
||||
int X; // Index (24-bit)
|
||||
int L; // Linkage (24-bit)
|
||||
int B; // Base (24-bit)
|
||||
int S; // General purpose (24-bit)
|
||||
int T; // General purpose (24-bit)
|
||||
double F; // Floating point accumulator (48-bit)
|
||||
int PC; // Program Counter (24-bit)
|
||||
int SW; // Status Word (24-bit)
|
||||
|
||||
public:
|
||||
Machine();
|
||||
~Machine();
|
||||
|
||||
// getters
|
||||
int getA() const;
|
||||
int getX() const;
|
||||
int getL() const;
|
||||
int getB() const;
|
||||
int getS() const;
|
||||
int getT() const;
|
||||
double getF() const;
|
||||
int getPC() const;
|
||||
int getSW() const;
|
||||
|
||||
// setters
|
||||
void setA(int val);
|
||||
void setX(int val);
|
||||
void setL(int val);
|
||||
void setB(int val);
|
||||
void setS(int val);
|
||||
void setT(int val);
|
||||
void setF(double val);
|
||||
void setPC(int val);
|
||||
void setSW(int val);
|
||||
|
||||
// condition codes for SW
|
||||
void setCC_less();
|
||||
void setCC_equal();
|
||||
void setCC_greater();
|
||||
int getCC() const;
|
||||
|
||||
// 0=A, 1=X, 2=L, 3=B, 4=S, 5=T, 6=F, 8=PC, 9=SW
|
||||
int getReg(int reg) const;
|
||||
void setReg(int reg, int val);
|
||||
|
||||
int getByte(int addr) const;
|
||||
void setByte(int addr, int val);
|
||||
|
||||
int getWord(int addr) const;
|
||||
void setWord(int addr, int val);
|
||||
|
||||
Device* getDevice(int num) const;
|
||||
void setDevice(int num, Device* device);
|
||||
};
|
||||
|
||||
#endif // MACHINE_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue