blob: 4d75edea8eef17687dac5109c794d557c3e621f3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// file : arch/v1/arch_inst.c
// project : Salis-VM
// author : Paul Oliver <contact@pauloliver.dev>
#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#define ARCH_EXPORT_INST_COUNT
#include "arch_spec.h"
#include "arch_inst.h"
wchar_t arch_inst_symbol(uint8_t inst) {
assert(inst < ARCH_INST_COUNT);
assert(inst_enum_count == ARCH_INST_COUNT);
switch (inst) {
#define ARCH_SPEC_INST(label, symbol, core) case label: return symbol;
ARCH_SPEC_INST_SET(core)
#undef ARCH_SPEC_INST
}
assert(false);
return L'\0';
}
const char *arch_inst_mnemonic(uint8_t inst) {
assert(inst < ARCH_INST_COUNT);
assert(inst_enum_count == ARCH_INST_COUNT);
switch (inst) {
#define ARCH_SPEC_INST(label, symbol, core) case label: return #label;
ARCH_SPEC_INST_SET(core)
#undef ARCH_SPEC_INST
}
assert(false);
return NULL;
}
|