Merge branch 'decode_print' of gitlab.istic.univ-rennes1.fr:simpleos/burritos into decode_print

This commit is contained in:
Baptiste 2022-11-09 15:10:39 +01:00
commit 3cbe1c0601

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
#![allow(unused_variables)]
use crate::decode::Instruction;
const RISCV_LUI: u8 = 0x37;
@ -254,4 +256,26 @@ pub fn print(ins: Instruction, pc: i32) -> String { //TODO pc should be u64
_ => "Unknown".to_string() // Error
}
}
#[cfg(test)]
mod Test {
use crate::{print, decode};
#[test]
fn test1() {
let sub = decode::decode(0b01000001000010001000111000110011);
let add = decode::decode(0b00000001000010001000111000110011);
let xor = decode::decode(0b00000001000010001100111000110011);
let slr = decode::decode(0b00000001000010001101111000110011);
let sra = decode::decode(0b01000001000010001101111000110011);
assert_eq!("sub r28, r17, r16", print::print(sub, 0));
assert_eq!("xor r28, r17, r16", print::print(xor, 0));
assert_eq!("srl r28, r17, r16", print::print(slr, 0));
assert_eq!("sra r28, r17, r16", print::print(sra, 0));
assert_eq!("add r28, r17, r16", print::print(add, 0));
}
}