# HG changeset patch # User William Astle # Date 1703652609 25200 # Node ID 98b0646360e198a2d3b5092599a1b9ff578012b5 # Parent b10f6c8979a597907ad3547a85582c56adc1783d Fix division by zero detection to actually work for integer division diff -r b10f6c8979a5 -r 98b0646360e1 src/int.s --- a/src/int.s Tue Dec 26 21:44:10 2023 -0700 +++ b/src/int.s Tue Dec 26 21:50:09 2023 -0700 @@ -357,15 +357,14 @@ sbcb fpa0+fpa.sig+1 sbca fpa0+fpa.sig std fpa0+fpa.sig -int32_div1 ldb fpa1+fpa.sig ; check for division by zero - orb fpa1+fpa.sig+1 - orb fpa1+fpa.sig+2 - orb fpa1+fpa.sig+3 - lbne DIV0ERROR ; brif division by zero - bsr util_div32 ; do the actual division +int32_div1 ldd fpa1+fpa.sig ; is MSW zero? + bne int32_div1a ; brif not - not division by zero + ldd fpa1+fpa.sig+2 + lbeq DIV0ERROR ; brif LSW is zero - division by zero +int32_div1a bsr util_div32 ; do the actual division lda ,s+ ; get desired sign bmi int32_div2 ; brif want negative - we can't overflow in that case - ldb fpaextra ; get high byte of result + ldb fpaextra ; get high byte of result lbmi OVERROR2 ; brif we ended up with 0x80000000 positive bra int32_div3 ; go return result int32_div2 ldd zero ; negate result to correct sign