From 1961b4b237083f4cfac9ca6b249c1d6cb665d149 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Tue, 14 Jul 2026 17:29:02 +0200 Subject: Initial (refactor) --- test/ui/v1/3rops/links.json | 1 + test/ui/v1/3rops/ui.c | 65 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 test/ui/v1/3rops/links.json create mode 100644 test/ui/v1/3rops/ui.c (limited to 'test/ui/v1/3rops') diff --git a/test/ui/v1/3rops/links.json b/test/ui/v1/3rops/links.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/test/ui/v1/3rops/links.json @@ -0,0 +1 @@ +[] diff --git a/test/ui/v1/3rops/ui.c b/test/ui/v1/3rops/ui.c new file mode 100644 index 0000000..2a53197 --- /dev/null +++ b/test/ui/v1/3rops/ui.c @@ -0,0 +1,65 @@ +// file : test/ui/v1/3rops/ui.c +// project : Salis-VM +// author : Paul Oliver + +#include +#include +#include +#include + +#include "arch_spec.h" +#include "arch_inst.h" +#include "compress.h" +#include "salis.h" + +int main(void) { + salis_init(); + + while (mvec_is_proc_owner(g_cores, g_cores->pvec->ip, g_cores->pcur)) { + uint8_t inst = mvec_get_inst(g_cores, g_cores->pvec->ip); + + if (inst != addn && inst != subn && inst != muln && inst != divn) { + salis_step(1); + continue; + } + + uint64_t *regs[3] = { + &g_cores->pvec->r0x, + &g_cores->pvec->r0x, + &g_cores->pvec->r0x, + }; + + for (uint64_t i = 0; i < 3; i++) { + uint8_t rmod = mvec_get_inst(g_cores, g_cores->pvec->ip + 1 + i); + + if (rmod == nop0) regs[i] = &g_cores->pvec->r0x; + else if (rmod == nop1) regs[i] = &g_cores->pvec->r1x; + else if (rmod == nop2) regs[i] = &g_cores->pvec->r2x; + else if (rmod == nop3) regs[i] = &g_cores->pvec->r3x; + else break; + } + + uint64_t reg_vals[3] = {*regs[0], *regs[1], *regs[2]}; + salis_step(1); + uint64_t result = *regs[0]; + + switch (inst) { + case addn: + assert(result == reg_vals[1] + reg_vals[2]); + break; + case subn: + assert(result == reg_vals[1] - reg_vals[2]); + break; + case muln: + assert(result == reg_vals[1] * reg_vals[2]); + break; + case divn: + assert(reg_vals[2] != 0); + assert(result == reg_vals[1] / reg_vals[2]); + break; + } + } + + salis_save_and_free(); + return 0; +} -- cgit v1.2.1