ArtemisLe 18/08/2023 à 14:03
the 68000 can do 32bits/16bits division, with a result in 16.16bits format (16 bits remainder)
let's say you want do to 1.75/0.25 (result 7), you have those numbers in 8.8 fixed point, so you have 448/64
all you need to do is shift 448 by 8 (448 << 8 in C), you get 114688, and divide it by 64. you get 1792 which is the fixed point for the result 7.
quick C code:
int fixed_a = (int)(1.75 * 256.0); // 448
int fixed_b = (int)(0.25 * 256.0); // 64
int fixed_result = (a << 8) / b;
float float_result = fixed_result / 256.0; (don't use float, of course, if you want speed)