From bce7047c5c703ddbf56cdf2f9af729e0eb68e651 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Wed, 1 Feb 2023 17:32:17 +0100 Subject: [PATCH] Convert some fp reg from array to struct call --- src/simulator/machine.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/simulator/machine.rs b/src/simulator/machine.rs index 4d4ee63..1981c8e 100644 --- a/src/simulator/machine.rs +++ b/src/simulator/machine.rs @@ -470,20 +470,20 @@ impl Machine { machine.fp_reg.set_reg(inst.rd as usize, machine.fp_reg.get_reg(inst.rs1 as usize).sqrt()); }, RISCV_FP_FSGN => { - let local_float = machine.fp_reg[inst.rs1 as usize]; + let local_float = machine.fp_reg.get_reg(inst.rs1 as usize); match inst.funct3 { RISCV_FP_FSGN_J => { - if machine.fp_reg[inst.rs2 as usize] < 0 { - machine.fp_reg[inst.rd as usize] = -local_float; + if machine.fp_reg.get_reg(inst.rs2 as usize) < 0f32 { + machine.fp_reg.set_reg(inst.rd as usize, -local_float); } else { - machine.fp_reg[inst.rd as usize] = local_float; + machine.fp_reg.set_reg(inst.rd as usize, local_float); } } RISCV_FP_FSGN_JN => { - if machine.fp_reg[inst.rs2 as usize] < 0 { - machine.fp_reg[inst.rd as usize] = local_float; + if machine.fp_reg.get_reg(inst.rs2 as usize) < 0f32 { + machine.fp_reg.set_reg(inst.rd as usize, local_float); } else { - machine.fp_reg[inst.rd as usize] = -local_float; + machine.fp_reg.set_reg(inst.rd as usize, -local_float); } } RISCV_FP_FSGN_JX => {