mirror of
https://github.com/libretro/oberon-risc-emu.git
synced 2024-12-04 07:00:52 +00:00
Update FP division to match 2016-09-16 FPDivider.v
This commit is contained in:
parent
2b7399067f
commit
52bd02f198
@ -99,25 +99,26 @@ uint32_t fp_div(uint32_t x, uint32_t y) {
|
||||
|
||||
uint32_t xm = (x & 0x7FFFFF) | 0x800000;
|
||||
uint32_t ym = (y & 0x7FFFFF) | 0x800000;
|
||||
uint32_t q1 = (uint32_t)(xm * (1ULL << 24) / ym);
|
||||
uint32_t q1 = (uint32_t)(xm * (1ULL << 25) / ym);
|
||||
|
||||
uint32_t e1 = (xe - ye) + 126;
|
||||
uint32_t q2;
|
||||
if ((q1 & (1 << 24)) != 0) {
|
||||
if ((q1 & (1 << 25)) != 0) {
|
||||
e1++;
|
||||
q2 = (q1 >> 1) & 0x7FFFFF;
|
||||
q2 = (q1 >> 1) & 0xFFFFFF;
|
||||
} else {
|
||||
q2 = q1 & 0x7FFFFF;
|
||||
q2 = q1 & 0xFFFFFF;
|
||||
}
|
||||
uint32_t q3 = q2 + 1;
|
||||
|
||||
if (xe == 0) {
|
||||
return 0;
|
||||
} else if (ye == 0) {
|
||||
return sign | (0xFF << 23);
|
||||
} else if ((e1 & 0x100) == 0) {
|
||||
return sign | ((e1 & 0xFF) << 23) | q2;
|
||||
return sign | ((e1 & 0xFF) << 23) | (q3 >> 1);
|
||||
} else if ((e1 & 0x80) == 0) {
|
||||
return sign | (0xFF << 23) | q2;
|
||||
return sign | (0xFF << 23) | (q2 >> 1);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user