Set istruzioni completato, si spera + tutti gli stub
This commit is contained in:
parent
d8bd273df9
commit
702bb1ad9b
@ -10,7 +10,8 @@ enum OPS_STARTING_VALUES {
|
|||||||
ADDR,
|
ADDR,
|
||||||
SUBI,
|
SUBI,
|
||||||
SUBR,
|
SUBR,
|
||||||
XORI,
|
XORB,
|
||||||
|
XORW,
|
||||||
XORR,
|
XORR,
|
||||||
NOTR,
|
NOTR,
|
||||||
MULI,
|
MULI,
|
||||||
@ -19,27 +20,57 @@ enum OPS_STARTING_VALUES {
|
|||||||
DIVR,
|
DIVR,
|
||||||
PUSH,
|
PUSH,
|
||||||
POOP,
|
POOP,
|
||||||
COMP,
|
CMPI,
|
||||||
|
CMPR,
|
||||||
JUMP,
|
JUMP,
|
||||||
JMPA,
|
JMPA,
|
||||||
JMPB,
|
JMPB,
|
||||||
JMPE,
|
JMPE,
|
||||||
SHIT,
|
SHIT,
|
||||||
NOPE,
|
NOPE,
|
||||||
GERM,
|
GRMN,
|
||||||
NUM_OPS
|
NUM_OPS
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t OPS[NUM_OPS];
|
uint8_t OPS[NUM_OPS];
|
||||||
|
|
||||||
|
/*
|
||||||
|
INSTRUCTION SIZE TYPES
|
||||||
|
*/
|
||||||
#define REG2REG 2
|
#define REG2REG 2
|
||||||
#define IMM2REG 4
|
#define IMM2REG 4
|
||||||
#define REG2IMM 4
|
#define REG2IMM 4
|
||||||
#define UNARY 1
|
#define BYT2REG 3
|
||||||
|
#define UNARY 2
|
||||||
|
#define SINGLE 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
INSTRUCTION SIZES
|
||||||
|
*/
|
||||||
#define MOVI_SIZE IMM2REG
|
#define MOVI_SIZE IMM2REG
|
||||||
#define MOVR_SIZE REG2REG
|
#define MOVR_SIZE REG2REG
|
||||||
#define LOAD_SIZE IMM2REG
|
#define LOAD_SIZE IMM2REG
|
||||||
#define STOR_SIZE REG2IMM
|
#define STOR_SIZE REG2IMM
|
||||||
#define ADDI_SIZE IMM2REG
|
#define ADDI_SIZE IMM2REG
|
||||||
#define ADDR_SIZE REG2REG
|
#define ADDR_SIZE REG2REG
|
||||||
|
#define SUBI_SIZE IMM2REG
|
||||||
|
#define SUBR_SIZE REG2REG
|
||||||
|
#define XORB_SIZE BYT2REG
|
||||||
|
#define XORW_SIZE IMM2REG
|
||||||
|
#define XORR_SIZE REG2REG
|
||||||
|
#define NOTR_SIZE UNARY
|
||||||
|
#define MULI_SIZE IMM2REG
|
||||||
|
#define MULR_SIZE REG2REG
|
||||||
|
#define DIVI_SIZE IMM2REG
|
||||||
|
#define DIVR_SIZE REG2REG
|
||||||
|
#define PUSH_SIZE UNARY
|
||||||
|
#define POOP_SIZE UNARY
|
||||||
|
#define CMPI_SIZE IMM2REG
|
||||||
|
#define CMPR_SIZE REG2REG
|
||||||
|
#define JUMP_SIZE UNARY
|
||||||
|
#define JMPA_SIZE UNARY
|
||||||
|
#define JMPB_SIZE UNARY
|
||||||
|
#define JMPE_SIZE UNARY
|
||||||
|
#define SHIT_SIZE SINGLE
|
||||||
|
#define NOPE_SIZE SINGLE
|
||||||
|
#define GRMN_SIZE SINGLE
|
67
cpp/vm.cpp
67
cpp/vm.cpp
@ -254,7 +254,8 @@ bool VM::execADDR(void) {
|
|||||||
|
|
||||||
bool VM::execSUBI(void) { return true; }
|
bool VM::execSUBI(void) { return true; }
|
||||||
bool VM::execSUBR(void) { return true; }
|
bool VM::execSUBR(void) { return true; }
|
||||||
bool VM::execXORI(void) { return true; }
|
bool VM::execXORB(void) { return true; }
|
||||||
|
bool VM::execXORW(void) { return true; }
|
||||||
bool VM::execXORR(void) { return true; }
|
bool VM::execXORR(void) { return true; }
|
||||||
bool VM::execNOTR(void) { return true; }
|
bool VM::execNOTR(void) { return true; }
|
||||||
bool VM::execMULI(void) { return true; }
|
bool VM::execMULI(void) { return true; }
|
||||||
@ -263,12 +264,13 @@ bool VM::execDIVI(void) { return true; }
|
|||||||
bool VM::execDIVR(void) { return true; }
|
bool VM::execDIVR(void) { return true; }
|
||||||
bool VM::execPUSH(void) { return true; }
|
bool VM::execPUSH(void) { return true; }
|
||||||
bool VM::execPOOP(void) { return true; }
|
bool VM::execPOOP(void) { return true; }
|
||||||
bool VM::execCOMP(void) { return true; }
|
bool VM::execCMPI(void) { return true; }
|
||||||
|
bool VM::execCMPR(void) { return true; }
|
||||||
bool VM::execJUMP(void) { return true; }
|
bool VM::execJUMP(void) { return true; }
|
||||||
bool VM::execJMPA(void) { return true; }
|
bool VM::execJMPA(void) { return true; }
|
||||||
bool VM::execJMPB(void) { return true; }
|
bool VM::execJMPB(void) { return true; }
|
||||||
bool VM::execJMPE(void) { return true; }
|
bool VM::execJMPE(void) { return true; }
|
||||||
bool VM::execGERM(void) { return true; }
|
bool VM::execGRMN(void) { return true; }
|
||||||
void VM::run(void) {
|
void VM::run(void) {
|
||||||
uint8_t opcode;
|
uint8_t opcode;
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
@ -289,8 +291,67 @@ void VM::run(void) {
|
|||||||
} else if (opcode == OPS[ADDI]) {
|
} else if (opcode == OPS[ADDI]) {
|
||||||
execADDI();
|
execADDI();
|
||||||
regs[IP] += ADDI_SIZE;
|
regs[IP] += ADDI_SIZE;
|
||||||
|
} else if (opcode == OPS[ADDR]) {
|
||||||
|
execADDR();
|
||||||
|
regs[IP] += ADDR_SIZE;
|
||||||
|
} else if (opcode == OPS[SUBI]) {
|
||||||
|
execSUBI();
|
||||||
|
regs[IP] += SUBI_SIZE;
|
||||||
|
} else if (opcode == OPS[SUBR]) {
|
||||||
|
execSUBR();
|
||||||
|
regs[IP] += SUBR_SIZE;
|
||||||
|
} else if (opcode == OPS[XORB]) {
|
||||||
|
execXORB();
|
||||||
|
regs[IP] += XORB_SIZE;
|
||||||
|
} else if (opcode == OPS[XORW]) {
|
||||||
|
execXORW();
|
||||||
|
regs[IP] += XORW_SIZE;
|
||||||
|
} else if (opcode == OPS[XORR]) {
|
||||||
|
execXORR();
|
||||||
|
regs[IP] += XORR_SIZE;
|
||||||
|
} else if (opcode == OPS[NOTR]) {
|
||||||
|
execNOTR();
|
||||||
|
regs[IP] += NOTR_SIZE;
|
||||||
|
} else if (opcode == OPS[MULI]) {
|
||||||
|
execMULI();
|
||||||
|
regs[IP] += MULI_SIZE;
|
||||||
|
} else if (opcode == OPS[MULR]) {
|
||||||
|
execMULR();
|
||||||
|
regs[IP] += MULR_SIZE;
|
||||||
|
} else if (opcode == OPS[DIVI]) {
|
||||||
|
execDIVI();
|
||||||
|
regs[IP] += DIVI_SIZE;
|
||||||
|
} else if (opcode == OPS[PUSH]) {
|
||||||
|
execPUSH();
|
||||||
|
regs[IP] += PUSH_SIZE;
|
||||||
|
} else if (opcode == OPS[POOP]) {
|
||||||
|
execPOOP();
|
||||||
|
regs[IP] += POOP_SIZE;
|
||||||
|
} else if (opcode == OPS[CMPI]) {
|
||||||
|
execCMPI();
|
||||||
|
regs[IP] += CMPI_SIZE;
|
||||||
|
} else if (opcode == OPS[CMPR]) {
|
||||||
|
execCMPR();
|
||||||
|
regs[IP] += CMPR_SIZE;
|
||||||
|
} else if (opcode == OPS[JUMP]) {
|
||||||
|
execJUMP();
|
||||||
|
regs[IP] += JUMP_SIZE;
|
||||||
|
} else if (opcode == OPS[JMPA]) {
|
||||||
|
execJMPA();
|
||||||
|
regs[IP] += JMPA_SIZE;
|
||||||
|
} else if (opcode == OPS[JMPB]) {
|
||||||
|
execJMPB();
|
||||||
|
regs[IP] += JMPB_SIZE;
|
||||||
|
} else if (opcode == OPS[JMPE]) {
|
||||||
|
execJMPE();
|
||||||
|
regs[IP] += JMPE_SIZE;
|
||||||
|
} else if (opcode == OPS[GRMN]) {
|
||||||
|
execGRMN();
|
||||||
|
regs[IP] += GRMN_SIZE;
|
||||||
} else if (opcode == OPS[SHIT]) {
|
} else if (opcode == OPS[SHIT]) {
|
||||||
finished = true;
|
finished = true;
|
||||||
|
} else if (opcode == OPS[NOPE]) {
|
||||||
|
regs[IP] += NOPE_SIZE;
|
||||||
} else {
|
} else {
|
||||||
DBG_ERROR(("WAT\n"));
|
DBG_ERROR(("WAT\n"));
|
||||||
finished = true;
|
finished = true;
|
||||||
|
8
cpp/vm.h
8
cpp/vm.h
@ -39,7 +39,8 @@ private:
|
|||||||
bool execADDR(void);
|
bool execADDR(void);
|
||||||
bool execSUBI(void);
|
bool execSUBI(void);
|
||||||
bool execSUBR(void);
|
bool execSUBR(void);
|
||||||
bool execXORI(void);
|
bool execXORB(void);
|
||||||
|
bool execXORW(void);
|
||||||
bool execXORR(void);
|
bool execXORR(void);
|
||||||
bool execNOTR(void);
|
bool execNOTR(void);
|
||||||
bool execMULI(void);
|
bool execMULI(void);
|
||||||
@ -48,12 +49,13 @@ private:
|
|||||||
bool execDIVR(void);
|
bool execDIVR(void);
|
||||||
bool execPUSH(void);
|
bool execPUSH(void);
|
||||||
bool execPOOP(void);
|
bool execPOOP(void);
|
||||||
bool execCOMP(void);
|
bool execCMPI(void);
|
||||||
|
bool execCMPR(void);
|
||||||
bool execJUMP(void);
|
bool execJUMP(void);
|
||||||
bool execJMPA(void);
|
bool execJMPA(void);
|
||||||
bool execJMPB(void);
|
bool execJMPB(void);
|
||||||
bool execJMPE(void);
|
bool execJMPE(void);
|
||||||
bool execGERM(void);
|
bool execGRMN(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VM(uint8_t *key);
|
VM(uint8_t *key);
|
||||||
|
@ -259,14 +259,15 @@ op_names = ["MOVI",
|
|||||||
"DIVR",
|
"DIVR",
|
||||||
"PUSH",
|
"PUSH",
|
||||||
"POOP",
|
"POOP",
|
||||||
"COMP",
|
"CMPI",
|
||||||
|
"CMPR",
|
||||||
"JUMP",
|
"JUMP",
|
||||||
"JMPA",
|
"JMPA",
|
||||||
"JMPB",
|
"JMPB",
|
||||||
"JMPE",
|
"JMPE",
|
||||||
"SHIT",
|
"SHIT",
|
||||||
"NOPE",
|
"NOPE",
|
||||||
"GERM"]
|
"GRMN"]
|
||||||
|
|
||||||
reg_names = ["R0", "R1", "R2", "R3", "S0", "S1", "S2", "S3", "IP", "BP", "SP"]
|
reg_names = ["R0", "R1", "R2", "R3", "S0", "S1", "S2", "S3", "IP", "BP", "SP"]
|
||||||
section_names = ["DATA:", "CODE:", "STACK:"]
|
section_names = ["DATA:", "CODE:", "STACK:"]
|
||||||
|
Loading…
Reference in New Issue
Block a user