This commit is contained in:
2024-05-12 17:02:54 +02:00
parent 8ebaea4583
commit f9541157b6
2 changed files with 93 additions and 2 deletions

View File

@ -263,6 +263,36 @@ static void test_m()
execute(&hart, 0x022091b3); // mulh x3, x1, x2
assert(hart.regs[3] == 0x00000000);
hart.regs[1] = (uint32_t)-63;
hart.regs[2] = 4;
execute(&hart, 0x0220c1b3); // div x3, x1, x2
assert(hart.regs[3] == (uint32_t)-15);
execute(&hart, 0x0220d1b3); // divu x3, x1, x2
assert(hart.regs[3] == 0x3FFFFFF0);
execute(&hart, 0x0220e1b3); // rem x3, x1, x2
assert(hart.regs[3] == (uint32_t)-3);
execute(&hart, 0x0220f1b3); // remu x3, x1, x2
assert(hart.regs[3] == 1);
hart.regs[1] = 30;
hart.regs[2] = 0;
execute(&hart, 0x0220c1b3); // div x3, x1, x2
assert(hart.regs[3] == 0xFFFFFFFF);
execute(&hart, 0x0220d1b3); // divu x3, x1, x2
assert(hart.regs[3] == 0xFFFFFFFF);
execute(&hart, 0x0220e1b3); // rem x3, x1, x2
assert(hart.regs[3] == 30);
execute(&hart, 0x0220f1b3); // remu x3, x1, x2
assert(hart.regs[3] == 30);
}
int main(int argc, char* argv[])