From 9cf92379d5fcf0076c25dae0935daab446c992cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 30 Aug 2017 21:37:53 +0200 Subject: Initial commit Adding work done so far. --- qtmips_machine/instruction.h | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 qtmips_machine/instruction.h (limited to 'qtmips_machine/instruction.h') diff --git a/qtmips_machine/instruction.h b/qtmips_machine/instruction.h new file mode 100644 index 0000000..6ab7015 --- /dev/null +++ b/qtmips_machine/instruction.h @@ -0,0 +1,48 @@ +#ifndef INSTRUCTION_H +#define INSTRUCTION_H + +#include +#include +#include "registers.h" +#include "memory.h" + +class Instruction { +public: + // TODO return types should be according to what instruction can pass from this stage + //virtual void decode(Registers *regs) = 0; // Read and prepare instructions + //virtual void execute() = 0; // ALU operations + //virtual void memory(Memory *mem) = 0; // Read or write to memory + //virtual void write_back(Registers *regs) = 0; // Write results to registers + + virtual std::vector to_strs() = 0; // Returns all fields of instructions in string +}; + +class InstructionR : public Instruction { +public: + InstructionR(std::uint8_t rs, std::uint8_t rd, std::uint8_t rt, std::uint8_t sa); + + std::vector to_strs(); +protected: + std::uint8_t rs, rd, rt, sa; +}; + +class InstructionI : public Instruction { +public: + InstructionI(std::uint8_t rs, std::uint8_t rt, std::uint16_t immediate); + + std::vector to_strs(); +protected: + std::uint8_t rs, rt; + std::uint16_t immediage; +}; + +class InstructionJ : public Instruction { +public: + InstructionJ(std::uint32_t address); + + std::vector to_strs(); +protected: + std::uint32_t address; +}; + +#endif // INSTRUCTION_H -- cgit v1.2.3