Dodal ukaze za format 3 in 4
This commit is contained in:
parent
cf3dd766d0
commit
8222f8dd0a
4 changed files with 117 additions and 8 deletions
15
.vscode/c_cpp_properties.json
vendored
Normal file
15
.vscode/c_cpp_properties.json
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Linux",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/**"
|
||||||
|
],
|
||||||
|
"defines": [],
|
||||||
|
"cStandard": "c23",
|
||||||
|
"cppStandard": "c++23",
|
||||||
|
"intelliSenseMode": "linux-gcc-x64"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
55
.vscode/settings.json
vendored
Normal file
55
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"array": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"bit": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"chrono": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"compare": "cpp",
|
||||||
|
"concepts": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"ratio": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"fstream": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"numbers": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"semaphore": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"stop_token": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"thread": "cpp",
|
||||||
|
"typeinfo": "cpp",
|
||||||
|
"sstream": "cpp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -45,6 +45,50 @@ machine::machine() {
|
||||||
else setSW(CC_GT);
|
else setSW(CC_GT);
|
||||||
return true;}},
|
return true;}},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ukaziSICF3F4 = {
|
||||||
|
{"ADD", [&](int m){setA(getA()+getWord(m)); return true;}},
|
||||||
|
{"SUB", [&](int m){setA(getA()-getWord(m)); return true;}},
|
||||||
|
{"MUL", [&](int m){setA(getA()*getWord(m)); return true;}},
|
||||||
|
{"DIV", [&](int m){if(getWord(m) == 0) divisionByZero();setA(getA()/getWord(m)); return true;}},
|
||||||
|
{"AND", [&](int m){setA(getA()&getWord(m)); return true;}},
|
||||||
|
{"OR", [&](int m){setA(getA()|getWord(m)); return true;}},
|
||||||
|
{"COMP", [&](int m){int a = getA(); int b = getWord(m);
|
||||||
|
if (a < b) setSW(CC_LT);
|
||||||
|
else if (a == b) setSW(CC_EQ);
|
||||||
|
else setSW(CC_GT);
|
||||||
|
return true;}},
|
||||||
|
{"J", [&](int m){setPC(m); return true;}},
|
||||||
|
{"JEQ", [&](int m){if (getSW() == CC_EQ){setPC(m);}
|
||||||
|
else {setPC(getPC()+1);} return true;}},
|
||||||
|
{"JGT", [&](int m){if (getSW() == CC_GT) {setPC(m);}
|
||||||
|
else {setPC(getPC()+1);} return true;}},
|
||||||
|
{"JLT", [&](int m){if (getSW() == CC_LT){setPC(m);}
|
||||||
|
else{setPC(getPC()+1);} return true;}},
|
||||||
|
{"JSUB", [&](int m){setL(getPC()); setPC(m); return true;}},
|
||||||
|
{"RSUB", [&](int m){setPC(getL()); return true;}},
|
||||||
|
{"LDA", [&](int m){setA(getWord(m)); return true;}},
|
||||||
|
{"LDB", [&](int m){setB(getWord(m)); return true;}},
|
||||||
|
{"LDT", [&](int m){setT(getWord(m)); return true;}},
|
||||||
|
{"LDX", [&](int m){setX(getWord(m)); return true;}},
|
||||||
|
{"LDS", [&](int m){setS(getWord(m)); return true;}},
|
||||||
|
{"LDL", [&](int m){setL(getWord(m)); return true;}},
|
||||||
|
{"LDCH", [&](int m){setA(getByte(m)); return true;}}, //POPRAVIT
|
||||||
|
{"STA", [&](int m){setWord(m, getA()); return true;}},
|
||||||
|
{"STB", [&](int m){setWord(m, getB()); return true;}},
|
||||||
|
{"STT", [&](int m){setWord(m, getT()); return true;}},
|
||||||
|
{"STX", [&](int m){setWord(m, getX()); return true;}},
|
||||||
|
{"STL", [&](int m){setWord(m, getL()); return true;}},
|
||||||
|
{"STS", [&](int m){setWord(m, getS()); return true;}},
|
||||||
|
{"STCH", [&](int m){setByte(m, getA()); return true;}}, //POPRAVIT
|
||||||
|
{"TIX", [&](int m){setX(getX()+1);
|
||||||
|
if (getX() < getWord(m)) setSW(CC_LT);
|
||||||
|
else if (getX() == getWord(m)) setSW(CC_EQ);
|
||||||
|
else setSW(CC_GT);
|
||||||
|
return true;}},
|
||||||
|
{"WD", [&](int m){return true;}},//POPRAVIT
|
||||||
|
{"RD", [&](int m){return true;}},//POPRAVIT
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//machine::getterji, setterji
|
//machine::getterji, setterji
|
||||||
|
|
@ -145,13 +189,6 @@ machine::machine() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*void incompatibleArgument(const type_info& t1, const type_info& t2) {
|
|
||||||
stringstream ss;
|
|
||||||
ss << "Tipa vrednosti se razlikujeta: " << t1.name() << " vs " << t2.name();
|
|
||||||
throw invalid_argument(ss.str());
|
|
||||||
}*/
|
|
||||||
|
|
||||||
void machine::outOfMemoryRange(int memory) {
|
void machine::outOfMemoryRange(int memory) {
|
||||||
throw out_of_range("Naslov je izven pomnilniškega obmocja: " + to_string(memory));
|
throw out_of_range("Naslov je izven pomnilniškega obmocja: " + to_string(memory));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ private:
|
||||||
std::array<uint8_t, MAX_ADRESS> pomnilnik{};
|
std::array<uint8_t, MAX_ADRESS> pomnilnik{};
|
||||||
std::array<std::unique_ptr<Device>, 256> naprave{};
|
std::array<std::unique_ptr<Device>, 256> naprave{};
|
||||||
std::unordered_map<std::string, std::function<bool(int,int)>> ukaziF2;
|
std::unordered_map<std::string, std::function<bool(int,int)>> ukaziF2;
|
||||||
|
std::unordered_map<std::string, std::function<bool(int)>> ukaziSICF3F4;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
machine();
|
machine();
|
||||||
|
|
@ -61,7 +62,7 @@ public:
|
||||||
void setByte(int adr, int val);
|
void setByte(int adr, int val);
|
||||||
int getWord(int adr);
|
int getWord(int adr);
|
||||||
void setWord(int adr, int val);
|
void setWord(int adr, int val);
|
||||||
|
int getUN(int n, int x, int b, int p, int e, int operand);
|
||||||
// devices
|
// devices
|
||||||
Device& getDevice(uint8_t dev);
|
Device& getDevice(uint8_t dev);
|
||||||
void setDevice(uint8_t num, std::unique_ptr<Device> dev);
|
void setDevice(uint8_t num, std::unique_ptr<Device> dev);
|
||||||
|
|
@ -73,6 +74,7 @@ public:
|
||||||
void invalidAdressing();
|
void invalidAdressing();
|
||||||
void invalidRegister(const std::string& mnemonic, int r1, int r2);
|
void invalidRegister(const std::string& mnemonic, int r1, int r2);
|
||||||
void outOfMemoryRange(int mem);
|
void outOfMemoryRange(int mem);
|
||||||
|
void divisionByZero();
|
||||||
|
|
||||||
// execution
|
// execution
|
||||||
uint8_t fetch();
|
uint8_t fetch();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue