diff options
| author | Nathan Lee <me@nwlee.tech> | 2026-08-24 20:23:16 -0500 |
|---|---|---|
| committer | Nathan Lee <me@nwlee.tech> | 2026-08-24 20:23:16 -0500 |
| commit | bfd7592c10befe0ba086f15bf169ab85a311a75e (patch) | |
| tree | 9d2c6a3cf11905947fad58cc65b7b40464c4f6d6 /src/core.rs | |
| parent | ec38c56677fae2bf46fc50e04e404a8bdb336d44 (diff) | |
Diffstat (limited to 'src/core.rs')
| -rw-r--r-- | src/core.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/core.rs b/src/core.rs index 2746d1b..24c6a8f 100644 --- a/src/core.rs +++ b/src/core.rs @@ -388,8 +388,12 @@ pub fn fdiv_s(state: &mut CpuState, rd: usize, rs1: usize, rs2: usize) { let b = state.f_registers[rs2]; state.f_registers[rd] = if b == 0.0 { - f32::NAN - // todo: raise division by zero in csr + state.csr[0x001 /*fflags*/] |= 0b100; + if a.is_sign_positive() { + f32::INFINITY + } else { + f32::NEG_INFINITY + } } else { a / b } |
