From 49a94ca17421c66f96a7c660cbba618498081ea0 Mon Sep 17 00:00:00 2001 From: Toby Jaffey Date: Sun, 14 Dec 2025 21:53:54 +0000 Subject: [PATCH] Add BLT test --- test/opcodes/rom/rom.c | 8 ++++++++ test/opcodes/shared.h | 1 + test/opcodes/test/tests.c | 16 ++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/test/opcodes/rom/rom.c b/test/opcodes/rom/rom.c index 064affa..799a0ad 100644 --- a/test/opcodes/rom/rom.c +++ b/test/opcodes/rom/rom.c @@ -7,6 +7,14 @@ void main(void) { asm("auipc t0, 0"); // copy pc into t0 asm("auipc t1, 0"); // copy pc into t1 break; + case TEST2: + asm("li t0, 2"); + asm("li t1, 1"); + label2: + println("loop"); + asm goto("blt t0, t1, %l0" : : : : label2); + break; + } } diff --git a/test/opcodes/shared.h b/test/opcodes/shared.h index c9db0c3..00905de 100644 --- a/test/opcodes/shared.h +++ b/test/opcodes/shared.h @@ -3,4 +3,5 @@ enum { TEST1, + TEST2, }; diff --git a/test/opcodes/test/tests.c b/test/opcodes/test/tests.c index 6736cd5..3b1fcdc 100644 --- a/test/opcodes/test/tests.c +++ b/test/opcodes/test/tests.c @@ -59,4 +59,20 @@ void test_auipc(void) { TEST_ASSERT_EQUAL(vmst._core.regs[6], vmst._core.regs[5] + 4); } +void test_blt(void) { + uvm32_run(&vmst, &evt, 100); + // check for picktest syscall + TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL); + TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST); + uvm32_arg_setval(&vmst, &evt, RET, TEST2); + + uvm32_run(&vmst, &evt, 100); + TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL); + TEST_ASSERT_EQUAL(evt.data.syscall.code, UVM32_SYSCALL_PRINTLN); + + // run vm to completion + uvm32_run(&vmst, &evt, 100); + TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_END); +} +