comparison src/int.s @ 112:98b0646360e1

Fix division by zero detection to actually work for integer division
author William Astle <lost@l-w.ca>
date Tue, 26 Dec 2023 21:50:09 -0700
parents b10f6c8979a5
children 0aac26453849
comparison
equal deleted inserted replaced
111:b10f6c8979a5 112:98b0646360e1
355 std fpa0+fpa.sig+2 355 std fpa0+fpa.sig+2
356 ldd zero 356 ldd zero
357 sbcb fpa0+fpa.sig+1 357 sbcb fpa0+fpa.sig+1
358 sbca fpa0+fpa.sig 358 sbca fpa0+fpa.sig
359 std fpa0+fpa.sig 359 std fpa0+fpa.sig
360 int32_div1 ldb fpa1+fpa.sig ; check for division by zero 360 int32_div1 ldd fpa1+fpa.sig ; is MSW zero?
361 orb fpa1+fpa.sig+1 361 bne int32_div1a ; brif not - not division by zero
362 orb fpa1+fpa.sig+2 362 ldd fpa1+fpa.sig+2
363 orb fpa1+fpa.sig+3 363 lbeq DIV0ERROR ; brif LSW is zero - division by zero
364 lbne DIV0ERROR ; brif division by zero 364 int32_div1a bsr util_div32 ; do the actual division
365 bsr util_div32 ; do the actual division
366 lda ,s+ ; get desired sign 365 lda ,s+ ; get desired sign
367 bmi int32_div2 ; brif want negative - we can't overflow in that case 366 bmi int32_div2 ; brif want negative - we can't overflow in that case
368 ldb fpaextra ; get high byte of result 367 ldb fpaextra ; get high byte of result
369 lbmi OVERROR2 ; brif we ended up with 0x80000000 positive 368 lbmi OVERROR2 ; brif we ended up with 0x80000000 positive
370 bra int32_div3 ; go return result 369 bra int32_div3 ; go return result
371 int32_div2 ldd zero ; negate result to correct sign 370 int32_div2 ldd zero ; negate result to correct sign
372 subd fpaextra+2 371 subd fpaextra+2
373 std fpaextra+2 372 std fpaextra+2