mirror of
https://github.com/byteworksinc/ORCALib.git
synced 2024-11-19 08:31:26 +00:00
Fix div() and ldiv() to return properly-signed remainders.
They could previously give the wrong sign on the remainder in certain cases where one or both of the arguments were negative, because they were using the wrong condition to decide whether to negate it.
This commit is contained in:
parent
efab82784d
commit
27fc6836cc
@ -282,7 +282,7 @@ addr equ 1
|
||||
jsl ~DIV2
|
||||
sta div_t save the results
|
||||
stx div_t+2
|
||||
tay if the result is negative then
|
||||
lda n if the numerator is negative then
|
||||
bpl lb1
|
||||
sub2 #0,div_t+2,div_t+2 make the remainder negative
|
||||
lb1 lla addr,div_t return the address
|
||||
@ -427,7 +427,7 @@ addr equ 1
|
||||
jsl ~DIV4
|
||||
pl4 div_t
|
||||
pl4 div_t+4
|
||||
lda div_t+2 if the result is negative then
|
||||
lda n+2 if the numerator is negative then
|
||||
bpl lb1
|
||||
sub4 #0,div_t+4,div_t+4 make the remainder negative
|
||||
lb1 lla addr,div_t return the result
|
||||
|
Loading…
Reference in New Issue
Block a user