diff options
Diffstat (limited to 'test/ui/v1')
| -rw-r--r-- | test/ui/v1/1rops/links.json | 1 | ||||
| -rw-r--r-- | test/ui/v1/1rops/ui.c | 74 | ||||
| -rw-r--r-- | test/ui/v1/2rops/links.json | 1 | ||||
| -rw-r--r-- | test/ui/v1/2rops/ui.c | 56 | ||||
| -rw-r--r-- | test/ui/v1/3rops/links.json | 1 | ||||
| -rw-r--r-- | test/ui/v1/3rops/ui.c | 65 | ||||
| -rw-r--r-- | test/ui/v1/addrs/links.json | 1 | ||||
| -rw-r--r-- | test/ui/v1/addrs/ui.c | 58 | ||||
| -rw-r--r-- | test/ui/v1/allos/links.json | 1 | ||||
| -rw-r--r-- | test/ui/v1/allos/ui.c | 80 | ||||
| -rw-r--r-- | test/ui/v1/ifnzs/links.json | 1 | ||||
| -rw-r--r-- | test/ui/v1/ifnzs/ui.c | 56 | ||||
| -rw-r--r-- | test/ui/v1/ioops/links.json | 1 | ||||
| -rw-r--r-- | test/ui/v1/ioops/ui.c | 66 | ||||
| -rw-r--r-- | test/ui/v1/jumps/links.json | 1 | ||||
| -rw-r--r-- | test/ui/v1/jumps/ui.c | 31 | ||||
| -rw-r--r-- | test/ui/v1/mbops/links.json | 1 | ||||
| -rw-r--r-- | test/ui/v1/mbops/ui.c | 46 | ||||
| -rw-r--r-- | test/ui/v1/noops/links.json | 1 | ||||
| -rw-r--r-- | test/ui/v1/noops/ui.c | 136 | ||||
| -rw-r--r-- | test/ui/v1/stack/links.json | 1 | ||||
| -rw-r--r-- | test/ui/v1/stack/ui.c | 85 |
22 files changed, 764 insertions, 0 deletions
diff --git a/test/ui/v1/1rops/links.json b/test/ui/v1/1rops/links.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/test/ui/v1/1rops/links.json @@ -0,0 +1 @@ +[] diff --git a/test/ui/v1/1rops/ui.c b/test/ui/v1/1rops/ui.c new file mode 100644 index 0000000..637e3f5 --- /dev/null +++ b/test/ui/v1/1rops/ui.c @@ -0,0 +1,74 @@ +// file : test/ui/v1/1rops/ui.c +// project : Salis-VM +// author : Paul Oliver <contact@pauloliver.dev> + +#include <assert.h> +#include <stdint.h> +#include <threads.h> +#include <zlib.h> + +#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 != incn && inst != decn && inst != notn && inst != shfl && inst != shfr && inst != zero && inst != unit) { + salis_step(1); + continue; + } + + uint64_t *reg = &g_cores->pvec->r0x; + + switch (mvec_get_inst(g_cores, g_cores->pvec->ip + 1)) { + case nop0: + reg = &g_cores->pvec->r0x; + break; + case nop1: + reg = &g_cores->pvec->r1x; + break; + case nop2: + reg = &g_cores->pvec->r2x; + break; + case nop3: + reg = &g_cores->pvec->r3x; + break; + } + + uint64_t reg_val = *reg; + + salis_step(1); + + switch (inst) { + case incn: + assert(*reg == reg_val + 1); + break; + case decn: + assert(*reg == reg_val - 1); + break; + case notn: + assert(*reg == !reg_val); + break; + case shfl: + assert(*reg == reg_val << 1); + break; + case shfr: + assert(*reg == reg_val >> 1); + break; + case zero: + assert(*reg == 0); + break; + case unit: + assert(*reg == 1); + break; + } + } + + salis_save_and_free(); + return 0; +} diff --git a/test/ui/v1/2rops/links.json b/test/ui/v1/2rops/links.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/test/ui/v1/2rops/links.json @@ -0,0 +1 @@ +[] diff --git a/test/ui/v1/2rops/ui.c b/test/ui/v1/2rops/ui.c new file mode 100644 index 0000000..e74172b --- /dev/null +++ b/test/ui/v1/2rops/ui.c @@ -0,0 +1,56 @@ +// file : test/ui/v1/2rops/ui.c +// project : Salis-VM +// author : Paul Oliver <contact@pauloliver.dev> + +#include <assert.h> +#include <stdint.h> +#include <threads.h> +#include <zlib.h> + +#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 != rdup && inst != rswp) { + salis_step(1); + continue; + } + + uint64_t *regs[2] = { + &g_cores->pvec->r0x, + &g_cores->pvec->r0x, + }; + + for (uint64_t i = 0; i < 2; 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[2] = {*regs[0], *regs[1]}; + salis_step(1); + + switch (inst) { + case rdup: + assert(*regs[1] == reg_vals[0]); + break; + case rswp: + assert(*regs[0] == reg_vals[1]); + assert(*regs[1] == reg_vals[0]); + break; + } + } + + salis_save_and_free(); + return 0; +} 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 <contact@pauloliver.dev> + +#include <assert.h> +#include <stdint.h> +#include <threads.h> +#include <zlib.h> + +#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; +} diff --git a/test/ui/v1/addrs/links.json b/test/ui/v1/addrs/links.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/test/ui/v1/addrs/links.json @@ -0,0 +1 @@ +[] diff --git a/test/ui/v1/addrs/ui.c b/test/ui/v1/addrs/ui.c new file mode 100644 index 0000000..eb4361c --- /dev/null +++ b/test/ui/v1/addrs/ui.c @@ -0,0 +1,58 @@ +// file : test/ui/v1/addrs/ui.c +// project : Salis-VM +// author : Paul Oliver <contact@pauloliver.dev> + +#include <assert.h> +#include <stdint.h> +#include <threads.h> +#include <zlib.h> + +#include "arch_spec.h" +#include "arch_inst.h" +#include "compress.h" +#include "salis.h" + +static void check_found(uint64_t addr, uint64_t lok, uint64_t regi) { + assert(mvec_get_inst(g_cores, addr - 1) == (regi % 2 == 0 ? adrf : adrb)); + assert(mvec_get_inst(g_cores, (&g_cores->pvec->r0x)[regi]) == lok); +} + +int main(void) { + uint64_t regi = 0; + + 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); + + switch (inst) { +#define CASE(id) \ + case key##id: \ + check_found(g_cores->pvec->ip, lok##id, regi); \ + regi = (regi + 1) % 4; \ + break; + CASE(a) + CASE(b) + CASE(c) + CASE(d) + CASE(e) + CASE(f) + CASE(g) + CASE(h) + CASE(i) + CASE(j) + CASE(k) + CASE(l) + CASE(m) + CASE(n) + CASE(o) + CASE(p) +#undef CASE + } + + salis_step(1); + } + + salis_save_and_free(); + return 0; +} diff --git a/test/ui/v1/allos/links.json b/test/ui/v1/allos/links.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/test/ui/v1/allos/links.json @@ -0,0 +1 @@ +[] diff --git a/test/ui/v1/allos/ui.c b/test/ui/v1/allos/ui.c new file mode 100644 index 0000000..5b0da79 --- /dev/null +++ b/test/ui/v1/allos/ui.c @@ -0,0 +1,80 @@ +// file : test/ui/v1/allos/ui.c +// project : Salis-VM +// author : Paul Oliver <contact@pauloliver.dev> + +#include <assert.h> +#include <stdint.h> +#include <threads.h> +#include <zlib.h> + +#include "arch_spec.h" +#include "arch_inst.h" +#include "compress.h" +#include "salis.h" + +#define CHILD_SIZE 4 + +static const struct Proc *first_proc(void) { + return proc_fetch(g_cores, g_cores->pfst); +} + +static void check_new_proc(void) { + const struct Proc *proc = proc_get(g_cores, g_cores->plst); + + assert(proc->mb0s == CHILD_SIZE); + assert(proc->mb1a == 0); + assert(proc->mb1s == 0); + assert(proc->r0x == 0); + assert(proc->r1x == 0); + assert(proc->r2x == 0); + assert(proc->r3x == 0); + assert(proc->s0 == 0); + assert(proc->s1 == 0); + assert(proc->s2 == 0); + assert(proc->s3 == 0); + assert(proc->s4 == 0); + assert(proc->s5 == 0); + assert(proc->s6 == 0); + assert(proc->s7 == 0); + + uint64_t birth_addr = (uint64_t)-1; + + switch (g_cores->plst) { + case 1: + birth_addr = ANC_SIZE; + break; + case 2: + birth_addr = ANC_SIZE - 7; + break; + default: + assert(false); + } + + assert(proc->ip == birth_addr); + assert(proc->sp == birth_addr); + assert(proc->mb0a == birth_addr); +} + +int main(void) { + salis_init(); + + while (first_proc()->ip < (ANC_SIZE + (CHILD_SIZE * 2))) { + bool will_split = g_cores->pcur == g_cores->pfst && mvec_get_inst(g_cores, first_proc()->ip) == bspl && first_proc()->mb1s; + uint64_t pnum = g_cores->pnum; + + salis_step(1); + + if (will_split) { + assert(g_cores->pnum == pnum + 1); + assert(g_cores->plst == pnum); + check_new_proc(); + } else { + assert(g_cores->pnum == pnum); + } + } + + assert(g_cores->pnum == 3); + + salis_save_and_free(); + return 0; +} diff --git a/test/ui/v1/ifnzs/links.json b/test/ui/v1/ifnzs/links.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/test/ui/v1/ifnzs/links.json @@ -0,0 +1 @@ +[] diff --git a/test/ui/v1/ifnzs/ui.c b/test/ui/v1/ifnzs/ui.c new file mode 100644 index 0000000..0c3921e --- /dev/null +++ b/test/ui/v1/ifnzs/ui.c @@ -0,0 +1,56 @@ +// file : test/ui/v1/ifnzs/ui.c +// project : Salis-VM +// author : Paul Oliver <contact@pauloliver.dev> + +#include <assert.h> +#include <stdint.h> +#include <threads.h> +#include <zlib.h> + +#include "arch_spec.h" +#include "arch_inst.h" +#include "compress.h" +#include "salis.h" + +int main(void) { + uint64_t next_addr = 0; + + salis_init(); + + while (mvec_is_proc_owner(g_cores, g_cores->pvec->ip, g_cores->pcur)) { + assert(g_cores->pvec->ip == next_addr); + + if (mvec_get_inst(g_cores, g_cores->pvec->ip) == ifnz) { + switch (mvec_get_inst(g_cores, g_cores->pvec->ip + 1)) { + case nop0: + next_addr += g_cores->pvec->r0x ? 1 : 2; + break; + case nop1: + next_addr += g_cores->pvec->r1x ? 1 : 2; + break; + case nop2: + next_addr += g_cores->pvec->r2x ? 1 : 2; + break; + case nop3: + next_addr += g_cores->pvec->r3x ? 1 : 2; + break; + default: + next_addr += g_cores->pvec->r0x ? 0 : 1; + } + } + + salis_step(1); + next_addr++; + + assert(g_cores->pvec->ip == next_addr); + } + + assert(g_cores->pvec->ip == ANC_SIZE); + assert(g_cores->pvec->r0x == 2); + assert(g_cores->pvec->r1x == 2); + assert(g_cores->pvec->r2x == 2); + assert(g_cores->pvec->r3x == 2); + + salis_save_and_free(); + return 0; +} diff --git a/test/ui/v1/ioops/links.json b/test/ui/v1/ioops/links.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/test/ui/v1/ioops/links.json @@ -0,0 +1 @@ +[] diff --git a/test/ui/v1/ioops/ui.c b/test/ui/v1/ioops/ui.c new file mode 100644 index 0000000..8ec21b2 --- /dev/null +++ b/test/ui/v1/ioops/ui.c @@ -0,0 +1,66 @@ +// file : test/ui/v1/ioops/ui.c +// project : Salis-VM +// author : Paul Oliver <contact@pauloliver.dev> + +#include <assert.h> +#include <stdint.h> +#include <threads.h> +#include <zlib.h> + +#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 != rloa && inst != rwrt) { + salis_step(1); + continue; + } + + uint64_t *regs[2] = { + &g_cores->pvec->r0x, + &g_cores->pvec->r0x, + }; + + for (uint64_t i = 0; i < 2; 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; + } + + if (g_cores->pvec->sp != *regs[0]) { + salis_step(1); + continue; + } + + uint64_t reg_vals[2] = {*regs[0], *regs[1]}; + + assert(g_cores->pvec->sp == *regs[0]); + salis_step(1); + assert(g_cores->pvec->sp == g_cores->pvec->ip); + + switch (inst) { + case rloa: + assert(*regs[1] == (uint64_t)mvec_get_inst(g_cores, reg_vals[0])); + break; + case rwrt: + assert(*regs[0] == reg_vals[0]); + assert(*regs[1] == reg_vals[1]); + assert(mvec_get_inst(g_cores, *regs[0]) == (*regs[1] & ARCH_INST_MASK)); + break; + } + } + + salis_save_and_free(); + return 0; +} diff --git a/test/ui/v1/jumps/links.json b/test/ui/v1/jumps/links.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/test/ui/v1/jumps/links.json @@ -0,0 +1 @@ +[] diff --git a/test/ui/v1/jumps/ui.c b/test/ui/v1/jumps/ui.c new file mode 100644 index 0000000..2ef5caa --- /dev/null +++ b/test/ui/v1/jumps/ui.c @@ -0,0 +1,31 @@ +// file : test/ui/v1/jumps/ui.c +// project : Salis-VM +// author : Paul Oliver <contact@pauloliver.dev> + +#include <assert.h> +#include <stdint.h> +#include <threads.h> +#include <zlib.h> + +#include "arch_spec.h" +#include "arch_inst.h" +#include "compress.h" +#include "salis.h" + +int main(void) { + uint8_t lok = loka; + + salis_init(); + + while (lok != lokp) { + if (mvec_get_inst(g_cores, g_cores->pvec->ip) == lok) { + lok = lok + 1; + } + + salis_step(1); + assert(g_cores->pvec->ip < ANC_SIZE); + } + + salis_save_and_free(); + return 0; +} diff --git a/test/ui/v1/mbops/links.json b/test/ui/v1/mbops/links.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/test/ui/v1/mbops/links.json @@ -0,0 +1 @@ +[] diff --git a/test/ui/v1/mbops/ui.c b/test/ui/v1/mbops/ui.c new file mode 100644 index 0000000..ea417d6 --- /dev/null +++ b/test/ui/v1/mbops/ui.c @@ -0,0 +1,46 @@ +// file : test/ui/v1/mbops/ui.c +// project : Salis-VM +// author : Paul Oliver <contact@pauloliver.dev> + +#include <assert.h> +#include <stdint.h> +#include <threads.h> +#include <zlib.h> + +#include "arch_spec.h" +#include "arch_inst.h" +#include "compress.h" +#include "salis.h" + +int main(void) { + salis_init(); + + while (g_cores->pvec->ip < ANC_SIZE) { + bool on_swap = mvec_get_inst(g_cores, g_cores->pvec->ip) == bswp; + bool on_clear = mvec_get_inst(g_cores, g_cores->pvec->ip) == bclr; + + uint64_t mb0a = g_cores->pvec->mb0a; + uint64_t mb0s = g_cores->pvec->mb0s; + uint64_t mb1a = g_cores->pvec->mb1a; + uint64_t mb1s = g_cores->pvec->mb1s; + + salis_step(1); + + if (on_swap) { + if (mb1s) { + assert(g_cores->pvec->mb0a == mb1a); + assert(g_cores->pvec->mb0s == mb1s); + assert(g_cores->pvec->mb1a == mb0a); + assert(g_cores->pvec->mb1s == mb0s); + } + } + + if (on_clear) { + assert(g_cores->pvec->mb1a == 0); + assert(g_cores->pvec->mb1s == 0); + } + } + + salis_save_and_free(); + return 0; +} diff --git a/test/ui/v1/noops/links.json b/test/ui/v1/noops/links.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/test/ui/v1/noops/links.json @@ -0,0 +1 @@ +[] diff --git a/test/ui/v1/noops/ui.c b/test/ui/v1/noops/ui.c new file mode 100644 index 0000000..b0ad004 --- /dev/null +++ b/test/ui/v1/noops/ui.c @@ -0,0 +1,136 @@ +// file : test/ui/v1/noops/ui.c +// project : Salis-VM +// author : Paul Oliver <contact@pauloliver.dev> + +#include <assert.h> +#include <stdint.h> +#include <threads.h> +#include <zlib.h> + +#include "arch_spec.h" +#include "arch_inst.h" +#include "compress.h" +#include "salis.h" + +static uint8_t g_anc_bytes[] = ANC_BYTES; + +static void check_invariants(void) { + assert(g_cores->mall == ANC_SIZE); + assert(g_cores->muta[0] == 0); + assert(g_cores->muta[1] == 0); + assert(g_cores->muta[2] == 0); + assert(g_cores->muta[3] == 0); + assert(g_cores->pnum == 1); + assert(g_cores->pcap == 1); + assert(g_cores->pfst == 0); + assert(g_cores->plst == 0); + assert(g_cores->pcur == 0); + assert(g_cores->psli == 1); + + for (uint64_t i = 0; i < SYNC_INTERVAL; i++) { + assert(g_cores->ivav[i] == 0); + assert(g_cores->iviv[i] == 0); + } + + for (uint64_t i = 0; i < MVEC_SIZE; i++) { + if (i < ANC_SIZE) { + assert(mvec_get_inst(g_cores, i) == g_anc_bytes[i]); + } else { + assert(mvec_get_inst(g_cores, i) == 0); + } + } + + assert(g_cores->pvec->mb0a == 0); + assert(g_cores->pvec->mb0s == ANC_SIZE); + assert(g_cores->pvec->mb1a == 0); + assert(g_cores->pvec->mb1s == 0); + assert(g_cores->pvec->r0x == 0); + assert(g_cores->pvec->r1x == 0); + assert(g_cores->pvec->r2x == 0); + assert(g_cores->pvec->r3x == 0); + assert(g_cores->pvec->s0 == 0); + assert(g_cores->pvec->s1 == 0); + assert(g_cores->pvec->s2 == 0); + assert(g_cores->pvec->s3 == 0); + assert(g_cores->pvec->s4 == 0); + assert(g_cores->pvec->s5 == 0); + assert(g_cores->pvec->s6 == 0); + assert(g_cores->pvec->s7 == 0); + + assert(g_cores->amb0 == 0.); + assert(g_cores->amb1 == 0.); + + assert(g_cores->emb1 == 0); + assert(g_cores->eliv == 0); + assert(g_cores->edea == 0); + + for (uint64_t i = 0; i < MVEC_SIZE; i++) { + assert(g_cores->aeva.data[i] == 0); + assert(g_cores->beva.data[i] == 0); + } + + // V1 arch specific + for (uint64_t i = 0; i < ARCH_INST_COUNT; i++) { + assert(g_cores->ipop[i] == 0); + assert(g_cores->iwrt[i] == 0); + } + + assert(g_cores->wmb0 == 0); + assert(g_cores->wmb1 == 0); + assert(g_cores->wdea == 0); + assert(g_cores->hlts == 0); + + for (uint64_t i = 0; i < MVEC_SIZE; i++) { + assert(g_cores->weva.data[i] == 0); + assert(g_cores->xeva.data[i] == 0); + } +} + +static void check_variants(void) { + assert(g_cores->step == g_step); + assert(g_cores->cycl == g_step); + assert(g_cores->ivpt == g_step); + + assert(g_cores->pvec->ip == g_step); + assert(g_cores->pvec->sp == g_step); + + assert(g_cores->emb0 == g_step); + + for (uint64_t i = 0; i < MVEC_SIZE; i++) { + assert(g_cores->eeva.data[i] == (i < g_step ? 1 : 0)); + } + + // V1 arch specific + for (uint64_t i = 0; i < ARCH_INST_COUNT; i++) { + uint64_t exed = 0; + + for (uint64_t j = 0; j < g_step; j++) { + if (mvec_get_inst(g_cores, j) == i) { + exed++; + } + } + + assert(g_cores->iexe[i] == exed); + } +} + +static void check_final(void) { + assert(g_cores->pvec->ip == ANC_SIZE); + assert(g_cores->pvec->sp == ANC_SIZE); +} + +int main(void) { + salis_init(); + check_invariants(); + check_variants(); + + while (mvec_is_proc_owner(g_cores, g_cores->pvec->ip, g_cores->pcur)) { + salis_step(1); + check_invariants(); + check_variants(); + } + + check_final(); + salis_save_and_free(); + return 0; +} diff --git a/test/ui/v1/stack/links.json b/test/ui/v1/stack/links.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/test/ui/v1/stack/links.json @@ -0,0 +1 @@ +[] diff --git a/test/ui/v1/stack/ui.c b/test/ui/v1/stack/ui.c new file mode 100644 index 0000000..f74b629 --- /dev/null +++ b/test/ui/v1/stack/ui.c @@ -0,0 +1,85 @@ +// file : test/ui/v1/stack/ui.c +// project : Salis-VM +// author : Paul Oliver <contact@pauloliver.dev> + +#include <assert.h> +#include <stdint.h> +#include <threads.h> +#include <zlib.h> + +#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 != rpsh && inst != rpop) { + salis_step(1); + continue; + } + + uint64_t *reg = &g_cores->pvec->r0x; + + switch (mvec_get_inst(g_cores, g_cores->pvec->ip + 1)) { + case nop0: + reg = &g_cores->pvec->r0x; + break; + case nop1: + reg = &g_cores->pvec->r1x; + break; + case nop2: + reg = &g_cores->pvec->r2x; + break; + case nop3: + reg = &g_cores->pvec->r3x; + break; + } + + uint64_t reg_val = *reg; + uint64_t stack_val[8] = { + g_cores->pvec->s0, + g_cores->pvec->s1, + g_cores->pvec->s2, + g_cores->pvec->s3, + g_cores->pvec->s4, + g_cores->pvec->s5, + g_cores->pvec->s6, + g_cores->pvec->s7, + }; + + salis_step(1); + + switch (inst) { + case rpsh: + assert(*reg == reg_val); + assert(g_cores->pvec->s0 == *reg); + assert(g_cores->pvec->s1 == stack_val[0]); + assert(g_cores->pvec->s2 == stack_val[1]); + assert(g_cores->pvec->s3 == stack_val[2]); + assert(g_cores->pvec->s4 == stack_val[3]); + assert(g_cores->pvec->s5 == stack_val[4]); + assert(g_cores->pvec->s6 == stack_val[5]); + assert(g_cores->pvec->s7 == stack_val[6]); + break; + case rpop: + assert(*reg == stack_val[0]); + assert(g_cores->pvec->s0 == stack_val[1]); + assert(g_cores->pvec->s1 == stack_val[2]); + assert(g_cores->pvec->s2 == stack_val[3]); + assert(g_cores->pvec->s3 == stack_val[4]); + assert(g_cores->pvec->s4 == stack_val[5]); + assert(g_cores->pvec->s5 == stack_val[6]); + assert(g_cores->pvec->s6 == stack_val[7]); + assert(g_cores->pvec->s7 == 0); + break; + } + } + + salis_save_and_free(); + return 0; +} |
