1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-27 09:31:18 +00:00

Improved division waiting

This commit is contained in:
jespergravgaard 2021-04-04 11:20:42 +02:00
parent ba2fdf58c5
commit 87f0b6d526

View File

@ -88,13 +88,8 @@ unsigned int m65_div16u_frac(unsigned int dividend, unsigned int divisor) {
*MATH_MULTINB_INT0 = (signed int)divisor;
*MATH_MULTINA_INT1 = 0;
*MATH_MULTINB_INT1 = 0;
// Wait 16 cycles (only neeeded for some values)
asm {
lda MATH_DIVOUT_FRAC_INT1 @nooptimize
lda MATH_DIVOUT_FRAC_INT1 @nooptimize
lda MATH_DIVOUT_FRAC_INT1 @nooptimize
lda MATH_DIVOUT_FRAC_INT1 @nooptimize
}
// Wait for the result to be ready
while(*MATH_BUSY) ;
// Return the most significant bytes of the fractional part of the division result
return (unsigned int)*MATH_DIVOUT_FRAC_INT1;
}