From ab276c733ce9dc80983e5c8ae5c530e1477cf990 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 31 Mar 2024 23:10:44 +0300 Subject: implement more meta instructions + Also have a working draft of ABI names for registers, matches qbt currently but should probably codify somewhere --- triscv/src/mem.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'triscv/src/mem.c') diff --git a/triscv/src/mem.c b/triscv/src/mem.c index 84bd71f..1bcecfc 100644 --- a/triscv/src/mem.c +++ b/triscv/src/mem.c @@ -26,17 +26,18 @@ void mem_init(struct mem *mem, const void *buf, size_t len) static void mem_write1(struct cpu *cpu, struct mem *mem, pm_t addr, tri_t t) { (void)cpu; - (void)mem; - (void)addr; - (void)t; + mem->buf[addr] = tri_mask(t, 9); } static void mem_write3(struct cpu *cpu, struct mem *mem, pm_t addr, tri_t t) { (void)cpu; - (void)mem; - (void)addr; - (void)t; + tri_t t0 = tri_mask(t, 9); + tri_t t1 = tri_mask(tri_sr(t, 9), 9); + tri_t t2 = tri_mask(tri_sr(t, 18), 9); + mem_write1(cpu, mem, addr + 0, t0); + mem_write1(cpu, mem, addr + 1, t1); + mem_write1(cpu, mem, addr + 2, t2); } static tri_t mem_read1(struct cpu *cpu, struct mem *mem, pm_t addr) -- cgit v1.3