forked from Lephenixnoir/fxos
25 lines
418 B
C++
25 lines
418 B
C++
|
#include <fxos/disassembly.h>
|
||
|
#include <optional>
|
||
|
#include <array>
|
||
|
|
||
|
namespace FxOS {
|
||
|
|
||
|
/* Instruction map */
|
||
|
static std::array<std::optional<Instruction>,65536> insmap;
|
||
|
|
||
|
/* Register an instruction at a given opcode. */
|
||
|
|
||
|
void register_instruction(Instruction ins)
|
||
|
{
|
||
|
uint16_t opcode = ins.opcode;
|
||
|
|
||
|
if(insmap[opcode])
|
||
|
{
|
||
|
throw std::logic_error("opcode collision");
|
||
|
}
|
||
|
|
||
|
insmap[opcode] = ins;
|
||
|
}
|
||
|
|
||
|
} /* namespace FxOS */
|