added instruction functionality
This commit is contained in:
parent
483a16c194
commit
d4754a048d
9 changed files with 754 additions and 170 deletions
|
|
@ -4,18 +4,15 @@
|
|||
#include <string>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include "constants.h"
|
||||
#include "device.h"
|
||||
#include "input_device.h"
|
||||
#include "output_device.h"
|
||||
#include "file_device.h"
|
||||
#include "opcode.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#define MEMORY_SIZE 65536
|
||||
#define NUM_DEVICES 256
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
using std::string;
|
||||
using std::cerr;
|
||||
|
|
@ -28,28 +25,29 @@ public:
|
|||
Machine();
|
||||
~Machine();
|
||||
|
||||
// Accessor methods for registers
|
||||
int getA() const { return A; }
|
||||
void setA(int value) { A = value; }
|
||||
void setA(int value) { A = toSIC24(value); }
|
||||
|
||||
int getB() const { return B; }
|
||||
void setB(int value) { B = value; }
|
||||
void setB(int value) { B = toSIC24(value); }
|
||||
|
||||
int getX() const { return X; }
|
||||
void setX(int value) { X = value; }
|
||||
void setX(int value) { X = toSIC24(value); }
|
||||
|
||||
int getL() const { return L; }
|
||||
void setL(int value) { L = value; }
|
||||
void setL(int value) { L = toSIC24(value); }
|
||||
|
||||
int getS() const { return S; }
|
||||
void setS(int value) { S = value; }
|
||||
void setS(int value) { S = toSIC24(value); }
|
||||
|
||||
int getT() const { return T; }
|
||||
void setT(int value) { T = value; }
|
||||
void setT(int value) { T = toSIC24(value); }
|
||||
|
||||
// PC is an address → don't mask to 24 unless you want 24-bit addressing
|
||||
int getPC() const { return PC; }
|
||||
void setPC(int value) { PC = value; }
|
||||
|
||||
// status word: keep as-is
|
||||
int getSW() const { return SW; }
|
||||
void setSW(int value) { SW = value; }
|
||||
|
||||
|
|
@ -83,7 +81,7 @@ public:
|
|||
|
||||
bool execF1(int opcode);
|
||||
bool execF2(int opcode, int operand);
|
||||
bool execSICF3F4(int opcode, int ni, int operand);
|
||||
bool execSICF3F4(int opcode, int ni, int x, int b, int p, int e, int operand);
|
||||
|
||||
// error handling methods
|
||||
void notImplemented(string mnemonic);
|
||||
|
|
@ -106,40 +104,6 @@ private:
|
|||
Device fallbackDevice;
|
||||
};
|
||||
|
||||
// Convert integer to 24-bit signed SIC representation
|
||||
inline int toSIC24(int value) {
|
||||
value &= 0xFFFFFF;
|
||||
if (value & 0x800000) {
|
||||
value -= 0x1000000;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
inline int setCC(int sw, int cc) {
|
||||
sw &= ~CC_MASK;
|
||||
sw |= (cc & CC_MASK);
|
||||
return sw;
|
||||
}
|
||||
|
||||
inline int sic_comp(int a, int b, int sw) {
|
||||
int sa = toSIC24(a);
|
||||
int sb = toSIC24(b);
|
||||
|
||||
int cc;
|
||||
if (sa < sb) {
|
||||
cc = CC_LT;
|
||||
} else if (sa == sb) {
|
||||
cc = CC_EQ;
|
||||
} else {
|
||||
cc = CC_GT;
|
||||
}
|
||||
|
||||
return setCC(sw, cc);
|
||||
}
|
||||
|
||||
inline int getCC(int sw) {
|
||||
return sw & CC_MASK;
|
||||
}
|
||||
|
||||
|
||||
#endif // MACHINE_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue