koncal stari sic format
This commit is contained in:
parent
12472d2590
commit
b105f4cc6a
2 changed files with 133 additions and 3 deletions
|
|
@ -172,6 +172,8 @@ bool Machine::execSICF3F4(int opcode, int ni, int operand) {
|
||||||
int operand2 = fetch();
|
int operand2 = fetch();
|
||||||
int UA;
|
int UA;
|
||||||
int UV;
|
int UV;
|
||||||
|
int temp;
|
||||||
|
bool ready = false;
|
||||||
if (ni == 0) { // stari SIC (neposredno in enostavno naslavljanje)
|
if (ni == 0) { // stari SIC (neposredno in enostavno naslavljanje)
|
||||||
if (((operand >> 7) & 0x1) == 1) { //preverimo ali je indeksno naslavljanje
|
if (((operand >> 7) & 0x1) == 1) { //preverimo ali je indeksno naslavljanje
|
||||||
x_val = getX();
|
x_val = getX();
|
||||||
|
|
@ -185,7 +187,6 @@ bool Machine::execSICF3F4(int opcode, int ni, int operand) {
|
||||||
}
|
}
|
||||||
|
|
||||||
UV = (memory[UA] << 16) | (memory[UA + 1] << 8) | memory[UA + 2]; //izracunamo operand oz. uporabno vrednost
|
UV = (memory[UA] << 16) | (memory[UA + 1] << 8) | memory[UA + 2]; //izracunamo operand oz. uporabno vrednost
|
||||||
|
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case Opcode::ADD:
|
case Opcode::ADD:
|
||||||
setA(getA() + UV);
|
setA(getA() + UV);
|
||||||
|
|
@ -194,10 +195,137 @@ bool Machine::execSICF3F4(int opcode, int ni, int operand) {
|
||||||
setA(getA() & UV);
|
setA(getA() & UV);
|
||||||
return true;
|
return true;
|
||||||
case Opcode::COMP:
|
case Opcode::COMP:
|
||||||
if (getA() < UV) {
|
temp = getA();
|
||||||
|
if (temp < UV) {
|
||||||
|
setSW(0x40);
|
||||||
|
} else if (temp == UV) {
|
||||||
|
setSW(0x0);
|
||||||
} else {
|
} else {
|
||||||
|
setSW(0x80);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
break;
|
||||||
|
case Opcode::DIV:
|
||||||
|
if (UV == 0) {
|
||||||
|
cerr << "Error: Divison by zero." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
setA(getA() / UV);
|
||||||
|
return true;
|
||||||
|
case Opcode::J:
|
||||||
|
setPC(UV);
|
||||||
|
return true;
|
||||||
|
case Opcode::JEQ:
|
||||||
|
if (getSW() == 0x00) {
|
||||||
|
setPC(UV);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case Opcode::JGT:
|
||||||
|
if (getSW() == 0x80) {
|
||||||
|
setPC(UV);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case Opcode::JLT:
|
||||||
|
if (getSW() == 0x40) {
|
||||||
|
setPC(UV);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case Opcode::JSUB:
|
||||||
|
setL(getPC());
|
||||||
|
setPC(UV);
|
||||||
|
return true;
|
||||||
|
case Opcode::LDA:
|
||||||
|
setA(UV);
|
||||||
|
return true;
|
||||||
|
case Opcode::LDB:
|
||||||
|
setB(UV);
|
||||||
|
return true;
|
||||||
|
case Opcode::LDCH:
|
||||||
|
setA((getA() & 0xFFFF00) | (UV & 0xFF));
|
||||||
|
return true;
|
||||||
|
case Opcode::LDL:
|
||||||
|
setL(UV);
|
||||||
|
return true;
|
||||||
|
case Opcode::LDS:
|
||||||
|
setS(UV);
|
||||||
|
return true;
|
||||||
|
case Opcode::LDT:
|
||||||
|
setT(UV);
|
||||||
|
return true;
|
||||||
|
case Opcode::LDX:
|
||||||
|
setX(UV);
|
||||||
|
return true;
|
||||||
|
case Opcode::MUL:
|
||||||
|
setA(getA() * UV);
|
||||||
|
return true;
|
||||||
|
case Opcode::OR:
|
||||||
|
setA(getA() | UV);
|
||||||
|
return true;
|
||||||
|
case Opcode::RD:
|
||||||
|
temp = UV & 0xFF;
|
||||||
|
if (devices[temp] != nullptr) {
|
||||||
|
setA(devices[temp]->read());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case Opcode::RSUB:
|
||||||
|
setPC(getL());
|
||||||
|
return true;
|
||||||
|
case Opcode::STA:
|
||||||
|
temp = getA();
|
||||||
|
memory[UV] = (temp >> 16) & 0xFF;
|
||||||
|
memory[UV + 1] = (temp >> 8) & 0xFF;
|
||||||
|
memory[UV + 2] = temp & 0xFF;
|
||||||
|
return true;
|
||||||
|
case Opcode::STCH:
|
||||||
|
temp = getA();
|
||||||
|
memory[UV] = temp & 0xFF;
|
||||||
|
return true;
|
||||||
|
case Opcode::STL:
|
||||||
|
temp = getL();
|
||||||
|
memory[UV] = (temp >> 16) & 0xFF;
|
||||||
|
memory[UV + 1] = (temp >> 8) & 0xFF;
|
||||||
|
memory[UV + 2] = temp & 0xFF;
|
||||||
|
return true;
|
||||||
|
case Opcode::STSW:
|
||||||
|
temp = getSW();
|
||||||
|
memory[UV] = (temp >> 16) & 0xFF;
|
||||||
|
memory[UV + 1] = (temp >> 8) & 0xFF;
|
||||||
|
memory[UV + 2] = temp & 0xFF;
|
||||||
|
return true;
|
||||||
|
case Opcode::STX:
|
||||||
|
temp = getX();
|
||||||
|
memory[UV] = (temp >> 16) & 0xFF;
|
||||||
|
memory[UV + 1] = (temp >> 8) & 0xFF;
|
||||||
|
memory[UV + 2] = temp & 0xFF;
|
||||||
|
return true;
|
||||||
|
case Opcode::SUB:
|
||||||
|
setA(getA() - UV);
|
||||||
|
return true;
|
||||||
|
case Opcode::TD:
|
||||||
|
temp = UV & 0xFF;
|
||||||
|
|
||||||
|
ready = false;
|
||||||
|
if (devices[temp] != nullptr) {
|
||||||
|
ready = devices[temp]->test();
|
||||||
|
}
|
||||||
|
if (ready) {
|
||||||
|
setSW(0X40);
|
||||||
|
} else {
|
||||||
|
setSW(0x00);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
case Opcode::TIX:
|
||||||
|
temp = getX();
|
||||||
|
setX(temp + 1);
|
||||||
|
if (temp < UV) setSW(0x40);
|
||||||
|
else if (temp == UV) setSW(0x00);
|
||||||
|
else setSW(0x80);
|
||||||
|
return true;
|
||||||
|
case Opcode::WD:
|
||||||
|
temp = UV & 0xFF;
|
||||||
|
if (devices[temp] != nullptr) {
|
||||||
|
devices[temp]->write(getA() & 0xFF);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ public:
|
||||||
int getS() { return S; }
|
int getS() { return S; }
|
||||||
int getX() { return X; }
|
int getX() { return X; }
|
||||||
int getPC() { return PC; }
|
int getPC() { return PC; }
|
||||||
|
int getSW() { return SW; }
|
||||||
double getF() { return F; }
|
double getF() { return F; }
|
||||||
|
|
||||||
void setA(int val) { A = val; }
|
void setA(int val) { A = val; }
|
||||||
|
|
@ -37,6 +38,7 @@ public:
|
||||||
void setS(int val) { S = val; }
|
void setS(int val) { S = val; }
|
||||||
void setX(int val) { X = val; }
|
void setX(int val) { X = val; }
|
||||||
void setPC(int val) { PC = val; }
|
void setPC(int val) { PC = val; }
|
||||||
|
void setSW(int val) { SW = val; }
|
||||||
void setF(double val) { F = val; }
|
void setF(double val) { F = val; }
|
||||||
|
|
||||||
int getReg(int reg);
|
int getReg(int reg);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue