From 06f0be9ecea4ff4335aa048dee04940b1b288dea Mon Sep 17 00:00:00 2001 From: Samy Solhi Date: Wed, 15 Feb 2023 14:33:40 +0100 Subject: [PATCH] Fixed R32F --- src/simulator/print.rs | 47 ++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/src/simulator/print.rs b/src/simulator/print.rs index 0567fef..4cf103b 100644 --- a/src/simulator/print.rs +++ b/src/simulator/print.rs @@ -142,79 +142,76 @@ pub fn print(ins: Instruction, pc: i32) -> String { //TODO pc should be u64 let name: &str; match ins.funct7 { RISCV_FP_ADD => { - name = "fadd"; + format!("{}\t{}{}{}", "fadd", REG_F[rd], REG_F[rs1], REG_F[rs2]) }, RISCV_FP_SUB => { - name = "fsub"; + format!("{}\t{}{}{}", "fsub.s", REG_F[rd], REG_F[rs1], REG_F[rs2]) }, RISCV_FP_MUL => { - name = "fmul"; + format!("{}\t{}{}{}", "fmul.s", REG_F[rd], REG_F[rs1], REG_F[rs2]) }, RISCV_FP_DIV => { - name = "fdiv"; + format!("{}\t{}{}{}", "fdiv.s", REG_F[rd], REG_F[rs1], REG_F[rs2]) }, RISCV_FP_SQRT => { - name = "fsqrt"; + format!("{}\t{}{}", "fsqrt.s", REG_F[rd], REG_F[rs1]) }, RISCV_FP_FSGN => { - match ins.funct3 { RISCV_FP_FSGN_J => { - name = "fsgnj"; + format!("{}\t{}{}{}", "fsgnj.s", REG_F[rd], REG_F[rs1], REG_F[rs2]) }, RISCV_FP_FSGN_JN => { - name = "fsgnn"; + format!("{}\t{}{}{}", "fsgnn.s", REG_F[rd], REG_F[rs1], REG_F[rs2]) }, RISCV_FP_FSGN_JX => { - name = "fsgnx"; + format!("{}\t{}{}{}", "fsgnx.s", REG_F[rd], REG_F[rs1], REG_F[rs2]) }, - _ => name = "fsgn" + _ => todo!("Unknown code") } }, RISCV_FP_MINMAX => { if ins.funct3 == 0 { - name = "fmin"; + format!("{}\t{}{}{}", "fmin.s", REG_F[rd], REG_F[rs1], REG_F[rs2]) } else { - name = "fmax"; + format!("{}\t{}{}{}", "fmax.s", REG_F[rd], REG_F[rs1], REG_F[rs2]) } }, RISCV_FP_FCVTW => { if rs2 == 0 { - name = "fcvt.w.s"; + format!("{}\t{}{}", "fcvt.w.s", REG_F[rd], REG_F[rs1]) } else { - name = "fcvt.wu.s"; + format!("{}\t{}{}", "fcvt.wu.s", REG_F[rd], REG_F[rs1]) } - }, RISCV_FP_FMVXFCLASS => { if ins.funct3 == 0 { - name = "fmv.x.w"; + format!("{}\t{}{}", "fmv.x.w", REG_F[rd], REG_F[rs1]) } else { - name = "fclass.s"; + format!("{}\t{}{}", "fclass.s", REG_F[rd], REG_F[rs1]) } }, RISCV_FP_FCMP => { if ins.funct3 == 0 { - name = "fle.s"; + format!("{}\t{}{}{}", "fle.s", REG_F[rd], REG_F[rs1], REG_F[rs2]) } else if ins.funct3 == 1 { - name = "flt.s"; + format!("{}\t{}{}{}", "flt.s", REG_F[rd], REG_F[rs1], REG_F[rs2]) } else { - name = "feq.s"; + format!("{}\t{}{}{}", "feq.s", REG_F[rd], REG_F[rs1], REG_F[rs2]) } }, RISCV_FP_FCVTS => { if rs2 == 0 { - name = "fcvt.s.w" + format!("{}\t{}{}", "fcvt.s.w", REG_F[rd], REG_F[rs1]) } else { - name = "fcvt.s.wu" + format!("{}\t{}{}", "fcvt.s.wu", REG_F[rd], REG_F[rs1]) } }, RISCV_FP_FMVW => { - name = "fmv.w.x"; + format!("{}\t{}{}", "fmv.w.x", REG_F[rd], REG_F[rs1]) }, - _ => name = "todo" + _ => todo!("Unknown code") } - format!("{}\t{}{}{}", name, REG_F[rd], REG_F[rs1], REG_F[rs2]) }, RISCV_SYSTEM => {