#pragma once #include #include #include enum class InstType : uint8_t { MOV, MVI, ADD, SUB, LOAD, STORE, AND, OR, XOR, SHF, JMP, JIZ, CALL, RET, SYS, HLT }; enum class OperandType { ImmNone, Imm4, Imm8 }; using BytecodeInstruction = uint16_t; static std::unordered_map> instructionOperandTypes = { {InstType::MOV, {OperandType::Imm4, OperandType::Imm4, OperandType::Imm4}} }; struct Instruction { InstType opcode = InstType::MOV; uint16_t arg1 = 0; uint16_t arg2 = 0; uint16_t arg3 = 0; BytecodeInstruction asBytecodeInstruction() const; Instruction() = default; Instruction(InstType opcode, uint16_t arg1, uint16_t arg2, uint16_t arg3) : opcode(opcode), arg1(arg1), arg2(arg2), arg3(arg3) {} Instruction(BytecodeInstruction bytecodeInst); };