Closed FrenkelS closed 6 months ago
#define FixedReciprocal(v) 0xffffffff/(v) calls __udivsi3 which goes to https://github.com/tkchia/gcc-ia16/blob/gcc-6_3_0-ia16-tkchia/libgcc/config/ia16/ia16-ldivmodu.S, see also https://github.com/FDOS/kernel/blob/master/kernel/ludivmul.inc
#define FixedReciprocal(v) 0xffffffff/(v)
__udivsi3
The numerator is constant (0xffffffff), so that assembly function can probably be optimized a bit. Also when de denominator is 0, the function can return INT32_MAX.
It's not that much faster :( https://github.com/FrenkelS/Doom8088/pull/39
#define FixedReciprocal(v) 0xffffffff/(v)
calls__udivsi3
which goes to https://github.com/tkchia/gcc-ia16/blob/gcc-6_3_0-ia16-tkchia/libgcc/config/ia16/ia16-ldivmodu.S, see also https://github.com/FDOS/kernel/blob/master/kernel/ludivmul.incThe numerator is constant (0xffffffff), so that assembly function can probably be optimized a bit. Also when de denominator is 0, the function can return INT32_MAX.