spo/simulator_SIC_XE/include/mnemonic.h
2025-12-10 18:02:06 +01:00

45 lines
1.1 KiB
C++

// mnemonic.h
#ifndef MNEMONIC_H
#define MNEMONIC_H
#include <cstdint>
#include <string>
#include <vector>
#include <variant>
#include "opcode.h"
struct Empty {};
struct Register { int num; };
struct Immediate { int value; };
struct SymbolRef {
std::string name;
bool indexed = false;
bool immediate = false;
bool indirect = false;
};
using Operand = std::variant<Empty, Register, Immediate, SymbolRef>;
class Mnemonic {
public:
Mnemonic(std::uint8_t opcode, InstructionType type, bool extended)
: _opcode(opcode), _extended(extended), _type(type) {}
std::uint8_t opcode() const { return _opcode; }
bool extended() const { return _extended; }
InstructionType type() const { return _type; }
std::vector<Operand>& operands() { return _operands; }
const std::vector<Operand>& operands() const { return _operands; }
std::string toString() const;
private:
std::uint8_t _opcode;
bool _extended;
InstructionType _type;
std::vector<Operand> _operands;
};
#endif // MNEMONIC_H