Naredil opcode seznam in mapper, fetch in execute v machine ter exceptione
This commit is contained in:
parent
513cb421ec
commit
5dae60dcec
3 changed files with 140 additions and 0 deletions
|
|
@ -139,6 +139,72 @@ public:
|
|||
naprave[num] = make_unique<fileDevice>(filename);
|
||||
}
|
||||
|
||||
void notImplemented(string mnemonic) {
|
||||
throw runtime_error("Mnemonic ni implementiran: " + mnemonic);
|
||||
}
|
||||
|
||||
void invalidOpcode (int opcode) {
|
||||
throw invalid_argument("Opcode ne obstaja: " + to_string(opcode) + ".");
|
||||
}
|
||||
|
||||
void invalidAdressing() {
|
||||
throw invalid_argument("Ta način naslavljanja ni podprt.");
|
||||
}
|
||||
|
||||
uint8_t fetch() {
|
||||
return getByte(registri[PC]++);
|
||||
}
|
||||
|
||||
void execute() {
|
||||
uint8_t opcode8 = fetch();
|
||||
uint8_t opcode6 = opcode8 & 0xFC;
|
||||
|
||||
auto it = Opcode::OPCODES.find(opcode6);
|
||||
if (it == Opcode::OPCODES.end()) {
|
||||
invalidOpcode(opcode6);
|
||||
return;
|
||||
}
|
||||
|
||||
InstructionInfo ii = it->second;
|
||||
|
||||
switch (ii.format) {
|
||||
case 1:
|
||||
execF1(opcode8, ii.mnemonic);
|
||||
break;
|
||||
|
||||
case 2: {
|
||||
uint8_t operand = fetch();
|
||||
execF2(opcode8, operand, ii.mnemonic);
|
||||
break;
|
||||
}
|
||||
|
||||
case 3: {
|
||||
uint8_t b2 = fetch();
|
||||
uint8_t b3 = fetch();
|
||||
execSIC_F3_F4(opcode8, b2, b3, ii.mnemonic);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool execF1(uint8_t opcode, string mnemonic){
|
||||
|
||||
}
|
||||
|
||||
bool execF2(uint8_t opcode, uint8_t operand, string mnemonic){
|
||||
uint8_t r1 = (operand & 0xF0) >> 4;
|
||||
uint8_t r2 = (operand & 0x0F);
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool execSIC_F3_F4(uint8_t opcdode, uint8_t b1, uint8_t b2, string mnemonic) {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue