summaryrefslogtreecommitdiff
path: root/arch/v1/arch_inst.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/v1/arch_inst.c')
-rw-r--r--arch/v1/arch_inst.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/arch/v1/arch_inst.c b/arch/v1/arch_inst.c
new file mode 100644
index 0000000..4d75ede
--- /dev/null
+++ b/arch/v1/arch_inst.c
@@ -0,0 +1,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;
+}