From d8bd273df99975e2768e3c364fadef1d3ef7e217 Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Wed, 17 May 2017 19:31:27 +0200 Subject: [PATCH] Stub di tutte le istruzioni --- cpp/opcodes.h | 21 +++++++++++++++------ cpp/vm.cpp | 21 +++++++++++++++++++-- cpp/vm.h | 19 ++++++++++++++++++- python/assembler.py | 7 +++++-- 4 files changed, 57 insertions(+), 11 deletions(-) diff --git a/cpp/opcodes.h b/cpp/opcodes.h index 76cc530..a4fac7b 100644 --- a/cpp/opcodes.h +++ b/cpp/opcodes.h @@ -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 \ No newline at end of file +#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 \ No newline at end of file diff --git a/cpp/vm.cpp b/cpp/vm.cpp index f5193bc..fec1f7e 100644 --- a/cpp/vm.cpp +++ b/cpp/vm.cpp @@ -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; diff --git a/cpp/vm.h b/cpp/vm.h index 21a0195..05cfd93 100644 --- a/cpp/vm.h +++ b/cpp/vm.h @@ -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); diff --git a/python/assembler.py b/python/assembler.py index 95825ab..668607b 100644 --- a/python/assembler.py +++ b/python/assembler.py @@ -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"]