Stub di tutte le istruzioni

This commit is contained in:
Giulio De Pasquale 2017-05-17 19:31:27 +02:00
parent ffb11f9a2e
commit d8bd273df9
4 changed files with 57 additions and 11 deletions

View File

@ -12,7 +12,6 @@ enum OPS_STARTING_VALUES {
SUBR,
XORI,
XORR,
NOTI,
NOTR,
MULI,
MULR,
@ -20,7 +19,11 @@ enum OPS_STARTING_VALUES {
DIVR,
PUSH,
POOP,
COMP,
JUMP,
JMPA,
JMPB,
JMPE,
SHIT,
NOPE,
GERM,
@ -29,8 +32,14 @@ enum OPS_STARTING_VALUES {
uint8_t OPS[NUM_OPS];
#define MOVI_SIZE 4
#define MOVR_SIZE 2
#define LOAD_SIZE 4
#define STOR_SIZE 4
#define ADDI_SIZE 4
#define REG2REG 2
#define IMM2REG 4
#define REG2IMM 4
#define UNARY 1
#define MOVI_SIZE IMM2REG
#define MOVR_SIZE REG2REG
#define LOAD_SIZE IMM2REG
#define STOR_SIZE REG2IMM
#define ADDI_SIZE IMM2REG
#define ADDR_SIZE REG2REG

View File

@ -241,7 +241,7 @@ bool VM::execADDI(void) {
return true;
}
void VM::execADDR(void) {
bool VM::execADDR(void) {
uint8_t dst;
uint8_t src;
@ -249,9 +249,26 @@ void VM::execADDR(void) {
src = as.code[regs[IP] + 1] & 0b00001111;
DBG_INFO(("ADDR %s, 0x%x\n", getRegName(dst), src));
regs[dst] += regs[src];
return;
return true;
}
bool VM::execSUBI(void) { return true; }
bool VM::execSUBR(void) { return true; }
bool VM::execXORI(void) { return true; }
bool VM::execXORR(void) { return true; }
bool VM::execNOTR(void) { return true; }
bool VM::execMULI(void) { return true; }
bool VM::execMULR(void) { return true; }
bool VM::execDIVI(void) { return true; }
bool VM::execDIVR(void) { return true; }
bool VM::execPUSH(void) { return true; }
bool VM::execPOOP(void) { return true; }
bool VM::execCOMP(void) { return true; }
bool VM::execJUMP(void) { return true; }
bool VM::execJMPA(void) { return true; }
bool VM::execJMPB(void) { return true; }
bool VM::execJMPE(void) { return true; }
bool VM::execGERM(void) { return true; }
void VM::run(void) {
uint8_t opcode;
bool finished = false;

View File

@ -36,7 +36,24 @@ private:
bool execLOAD(void);
bool execSTOR(void);
bool execADDI(void);
void execADDR(void);
bool execADDR(void);
bool execSUBI(void);
bool execSUBR(void);
bool execXORI(void);
bool execXORR(void);
bool execNOTR(void);
bool execMULI(void);
bool execMULR(void);
bool execDIVI(void);
bool execDIVR(void);
bool execPUSH(void);
bool execPOOP(void);
bool execCOMP(void);
bool execJUMP(void);
bool execJMPA(void);
bool execJMPB(void);
bool execJMPE(void);
bool execGERM(void);
public:
VM(uint8_t *key);

View File

@ -252,7 +252,6 @@ op_names = ["MOVI",
"SUBR",
"XORI",
"XORR",
"NOTI",
"NOTR",
"MULI",
"MULR",
@ -260,7 +259,11 @@ op_names = ["MOVI",
"DIVR",
"PUSH",
"POOP",
"CALL",
"COMP",
"JUMP",
"JMPA",
"JMPB",
"JMPE",
"SHIT",
"NOPE",
"GERM"]