Skip to content

Commit

Permalink
Fix fist (store float as 32-bit integer)
Browse files Browse the repository at this point in the history
  • Loading branch information
copy committed Jan 1, 2021
1 parent 1c8d11d commit 6abb23c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/rust/cpu2/fpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,14 @@ pub unsafe fn fpu_fistm16p(addr: i32) {
#[no_mangle]
pub unsafe fn fpu_convert_to_i32(f: f64) -> i32 {
let st0 = fpu_integer_round(f);
let i = convert_f64_to_i32(st0);
if i == -0x80000000 {
// XXX: Probably not correct if st0 == 0x80000000
// (input fits, but same value as error value)

if st0 < 0x8000_0000i64 as f64 && st0 >= -0x8000_0000 as f64 {
st0 as i32
}
else {
fpu_invalid_arithmetic();
-0x8000_0000
}
i
}
#[no_mangle]
pub unsafe fn fpu_fistm32(addr: i32) {
Expand Down

0 comments on commit 6abb23c

Please sign in to comment.