From e241d5ff197d89c0b8b44fa4429e3d1ca770ddaf Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Tue, 5 Feb 2019 12:47:26 +0100 Subject: Include test for BGEZ, BGTZ, BLEZ, BLTZ, BEQ and BNE. This complex test check for correct behavior for -1, 0 and 1 values. Signed-off-by: Pavel Pisa --- qtmips_machine/tests/testcore.cpp | 64 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'qtmips_machine/tests/testcore.cpp') diff --git a/qtmips_machine/tests/testcore.cpp b/qtmips_machine/tests/testcore.cpp index 29b647a..65b529a 100644 --- a/qtmips_machine/tests/testcore.cpp +++ b/qtmips_machine/tests/testcore.cpp @@ -609,6 +609,70 @@ static void core_alu_forward_data() { regs_res.pc_abs_jmp(regs_init.read_pc() + 4 * code.length() - 4); QTest::newRow("mul-div") << code << regs_init << regs_res; } + + // branches + { + QVector code{ + // start: + 0x2001ffff, // addi at,zero,-1 + 0x20020001, // addi v0,zero,1 + 0x20030000, // addi v1,zero,0 + 0x20040002, // addi a0,zero,2 + // test_branch: + 0x20050001, // addi a1,zero,1 + 0x04200004, // bltz at,80020028 + 0x00000000, // nop + 0x20050000, // addi a1,zero,0 + 0x20631000, // addi v1,v1,4096 + 0x00611820, // add v1,v1,at + 0x20050001, // addi a1,zero,1 + 0x18200004, // blez at,80020040 + 0x00000000, // nop + 0x20050000, // addi a1,zero,0 + 0x20630100, // addi v1,v1,256 + 0x00611820, // add v1,v1,at + 0x20050001, // addi a1,zero,1 + 0x04210004, // bgez at,80020058 + 0x00000000, // nop + 0x20050000, // addi a1,zero,0 + 0x20632000, // addi v1,v1,8192 + 0x00611820, // add v1,v1,at + 0x20050001, // addi a1,zero,1 + 0x1c200004, // bgtz at,80020070 + 0x00000000, // nop + 0x20050000, // addi a1,zero,0 + 0x20630200, // addi v1,v1,512 + 0x00611820, // add v1,v1,at + 0x20050001, // addi a1,zero,1 + 0x14220004, // bne at,v0,80020088 + 0x00000000, // nop + 0x20050000, // addi a1,zero,0 + 0x20634000, // addi v1,v1,16384 + 0x00611820, // add v1,v1,at + 0x20050001, // addi a1,zero,1 + 0x10220004, // beq at,v0,800200a0 + 0x00000000, // nop + 0x20050000, // addi a1,zero,0 + 0x20630400, // addi v1,v1,1024 + 0x00611820, // add v1,v1,at + 0x20210001, // addi at,at,1 + 0x1424ffda, // bne at,a0,80020010 + 0x00000000, // nop + // loop: + 0x1000ffff, // b 800200ac + 0x00000000, // nop + }; + Registers regs_init; + regs_init.pc_abs_jmp(0x80020000); + Registers regs_res(regs_init); + regs_res.write_gp(1, 2); + regs_res.write_gp(2, 1); + regs_res.write_gp(3, 0x8d00); + regs_res.write_gp(4, 2); + regs_res.write_gp(5, 1); + regs_res.pc_abs_jmp(regs_init.read_pc() + 4 * code.length()); + QTest::newRow("branch_conditions_test") << code << regs_init << regs_res; + } } void MachineTests::singlecore_alu_forward_data() { -- cgit v1.2.3