mirror of
https://github.com/FDOS/kernel.git
synced 2025-07-21 21:04:43 +02:00
Implement suggested instead of minimal fix for ludivmul.
See https://sourceforge.net/p/freedos/bugs/106/ (Gerd Grosse)
This commit is contained in:
parent
5e31e7fe58
commit
8c45af38c7
@ -96,21 +96,15 @@
|
|||||||
pop bx ; get dividend lo-word
|
pop bx ; get dividend lo-word
|
||||||
mov cx, ax ; save quotient
|
mov cx, ax ; save quotient
|
||||||
mul di ; quotient * divisor hi-word (low only)
|
mul di ; quotient * divisor hi-word (low only)
|
||||||
push di ; save divisor hi-word
|
pop dx ; dividend high
|
||||||
mov di, ax ; save in di
|
sub dx,ax ; dividend high - divisor high * quotient, no overflow (carry/borrow) possible here
|
||||||
|
push dx ; save dividend high
|
||||||
mov ax, cx ; ax=quotient
|
mov ax, cx ; ax=quotient
|
||||||
mul si ; quotient * divisor lo-word
|
mul si ; quotient * divisor lo-word
|
||||||
add dx, di ; quotient * divisor !!!! overflow possible !!!!
|
sub bx, ax ; dividend-lo - (quot.*divisor-lo)-lo
|
||||||
pop di ; restore divisor hi-word
|
|
||||||
jnc %%skipcorrection
|
|
||||||
sub ax, si
|
|
||||||
sbb dx, di
|
|
||||||
dec cx ; correct quotient
|
|
||||||
%%skipcorrection:
|
|
||||||
sub bx, ax ; dividend-lo - (quot.*divisor)-lo
|
|
||||||
mov ax, cx ; get quotient
|
mov ax, cx ; get quotient
|
||||||
pop cx ; restore dividend hi-word
|
pop cx ; restore dividend hi-word
|
||||||
sbb cx, dx ; subtract divisor * quot. from dividend
|
sbb cx, dx ; subtract (divisor-lo * quot.)-hi from dividend-hi
|
||||||
sbb dx, dx ; 0 if remainder > 0, else FFFFFFFFh
|
sbb dx, dx ; 0 if remainder > 0, else FFFFFFFFh
|
||||||
and si, dx ; nothing to add
|
and si, dx ; nothing to add
|
||||||
and di, dx ; back if remainder positive di:si := di:si(cx:bx) & dx:dx
|
and di, dx ; back if remainder positive di:si := di:si(cx:bx) & dx:dx
|
||||||
|
Loading…
x
Reference in New Issue
Block a user