FrenkelS / Doom8088

Doom for 16-bit DOS computers
GNU General Public License v2.0
140 stars 5 forks source link

Math functions in assembly #31

Closed FrenkelS closed 6 months ago

FrenkelS commented 8 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

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.

FrenkelS commented 6 months ago

It's not that much faster :( https://github.com/FrenkelS/Doom8088/pull/39