Add test for opi, fix func3 sltiu
This commit is contained in:
parent
42221a26c3
commit
4e44c5a9ec
13
src/print.rs
13
src/print.rs
@ -131,7 +131,7 @@ const RISCV_FP_FMVW: u8 = 0x78;
|
|||||||
|
|
||||||
|
|
||||||
const names_op: [&str; 8] = ["add", "sll", "slt", "sltu", "xor", "sr", "or", "and"];
|
const names_op: [&str; 8] = ["add", "sll", "slt", "sltu", "xor", "sr", "or", "and"];
|
||||||
const names_opi: [&str; 8] = ["addi", "slli", "slti", "cmpltuii", "xori", "slri", "ori", "andi"];
|
const names_opi: [&str; 8] = ["addi", "slli", "slti", "sltiu", "xori", "slri", "ori", "andi"];
|
||||||
const names_mul: [&str; 8] = ["mpylo", "mpyhi", "mpyhi", "mpyhi", "divhi", "divhi", "divlo", "divlo"];
|
const names_mul: [&str; 8] = ["mpylo", "mpyhi", "mpyhi", "mpyhi", "divhi", "divhi", "divlo", "divlo"];
|
||||||
const names_br: [&str; 8] = ["beq", "bne", "", "", "blt", "bge", "bltu", "bgeu"];
|
const names_br: [&str; 8] = ["beq", "bne", "", "", "blt", "bge", "bltu", "bgeu"];
|
||||||
const names_st: [&str; 4] = ["sb", "sh", "sw", "sd"];
|
const names_st: [&str; 4] = ["sb", "sh", "sw", "sd"];
|
||||||
@ -261,6 +261,7 @@ pub fn print(ins: Instruction, pc: i32) -> String { //TODO pc should be u64
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
||||||
use crate::{print, decode};
|
use crate::{print, decode};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -282,7 +283,17 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_opi() {
|
fn test_opi() {
|
||||||
let addi = decode::decode(0b0000000000_10001_000_11100_0010011);
|
let addi = decode::decode(0b0000000000_10001_000_11100_0010011);
|
||||||
|
let slli = decode::decode(0b0000000000_10001_001_11100_0010011);
|
||||||
|
let slti = decode::decode(0b0000000000_10001_010_11100_0010011);
|
||||||
|
let sltiu = decode::decode(0b0000000000_10001_011_11100_0010011);
|
||||||
|
let xori = decode::decode(0b_0000000000010001_100_11100_0010011);
|
||||||
|
let ori = decode::decode(0b00000000000_10001_110_11100_0010011);
|
||||||
assert_eq!("addi x28, x17, 0", print::print(addi, 0));
|
assert_eq!("addi x28, x17, 0", print::print(addi, 0));
|
||||||
|
assert_eq!("slli x28, x17, 0", print::print(slli, 0));
|
||||||
|
assert_eq!("slti x28, x17, 0", print::print(slti, 0));
|
||||||
|
assert_eq!("sltiu x28, x17, 0", print::print(sltiu, 0));
|
||||||
|
assert_eq!("xori x28, x17, 0", print::print(xori, 0));
|
||||||
|
assert_eq!("ori x28, x17, 0", print::print(ori, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user