From c7bf66f210ea2ce6112b813dea037662c7237e90 Mon Sep 17 00:00:00 2001 From: AmauryBrodu <60550980+AmauryBrodu@users.noreply.github.com> Date: Thu, 10 Nov 2022 00:47:32 +0100 Subject: [PATCH] add of the test function for br instructions --- src/print.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/print.rs b/src/print.rs index e51f0d2..da9f92f 100644 --- a/src/print.rs +++ b/src/print.rs @@ -350,4 +350,20 @@ mod test { } + #[test] + fn test_br() { + let beq: decode::Instruction = decode::decode(0b0000000_10000_10001_000_00000_1100011); + let bne: decode::Instruction = decode::decode(0b0000000_10000_10001_001_00000_1100011); + let blt: decode::Instruction = decode::decode(0b0000000_10000_10001_100_00000_1100011); + let bge: decode::Instruction = decode::decode(0b0000000_10000_10001_101_00000_1100011); + let bltu: decode::Instruction = decode::decode(0b0000000_10000_10001_110_00000_1100011); + let bgeu: decode::Instruction = decode::decode(0b0000000_10000_10001_111_00000_1100011); + assert_eq!("blt r17 x16 0", print::print(blt, 0)); + assert_eq!("bge r17 x16 0", print::print(bge, 0)); + assert_eq!("bltu r17 x16 0", print::print(bltu, 0)); + assert_eq!("bgeu r17 x16 0", print::print(bgeu, 0)); + assert_eq!("bne r17 x16 0", print::print(bne, 0)); + assert_eq!("beq r17 x16 0", print::print(beq, 0)); + } + } \ No newline at end of file