mirror of https://github.com/nmlgc/ReC98.git
[Reduction] #467: Far long multiplication
Yeah, the code is identical to the near version, with the only difference being the PROC directive declaring the function as either near or far. Now, I could either turn the function body into some kind of macro stored in a separate file and then instantiate it from both near and far functions... or I could just copy the original structure. Who cares, anyway.
This commit is contained in:
parent
ccc560ab37
commit
84b7d0f1ab
|
@ -0,0 +1,62 @@
|
|||
; *Not* the original file, but an edit to turn it into an includable slice.
|
||||
; Changes include:
|
||||
; * removal of RULES.ASI to eliminate redundancy
|
||||
; * removal of the 'CODE' segment declaration (for obvious reasons)
|
||||
; * the @@ prefix on any local labels
|
||||
|
||||
;[]-----------------------------------------------------------------[]
|
||||
;| F_LXMUL.ASM -- long multiply routine |
|
||||
;[]-----------------------------------------------------------------[]
|
||||
|
||||
;
|
||||
; C/C++ Run Time Library - Version 5.0
|
||||
;
|
||||
; Copyright (c) 1987, 1992 by Borland International
|
||||
; All Rights Reserved.
|
||||
;
|
||||
; calls to this routine are generated by the compiler to perform
|
||||
; long multiplications.
|
||||
|
||||
; There is no check for overflow. Consequently, the same routine
|
||||
; is used for both signed and unsigned long multiplies.
|
||||
|
||||
;
|
||||
; in:
|
||||
; (dx:ax) - 32bit arg1
|
||||
; (cx:bx) - 32bit arg2
|
||||
; out:
|
||||
; (dx:ax) - 32bit product
|
||||
;
|
||||
; reg use: bx,cx destroyed, all others preserved or contain result.
|
||||
;
|
||||
; hi(result) := lo(hi(arg1) * lo(arg2)) +
|
||||
; lo(hi(arg2) * lo(arg1)) +
|
||||
; hi(lo(arg1) * lo(arg2))
|
||||
; lo(result) := lo(lo(arg1) * lo(arg2))
|
||||
;
|
||||
;
|
||||
|
||||
public LXMUL@
|
||||
public F_LXMUL@
|
||||
|
||||
LXMUL@ PROC FAR
|
||||
F_LXMUL@:
|
||||
push si
|
||||
xchg si,ax ; save lo1
|
||||
xchg ax,dx
|
||||
test ax,ax ; skip mul if hi1==0
|
||||
jz @@nohi1
|
||||
mul bx ; hi1 * lo2
|
||||
|
||||
@@nohi1: ; if we jumped here, ax==0 so the following swap works
|
||||
jcxz @@nohi2 ; skip mul if hi2==0
|
||||
xchg cx, ax ; result <-> hi2
|
||||
mul si ; lo1 * hi2
|
||||
add ax, cx ; ax = hi1*lo2 + hi2*lo1
|
||||
@@nohi2:
|
||||
xchg ax,si
|
||||
mul bx ; lo1 * lo2
|
||||
add dx,si ; hi order result += partials
|
||||
pop si
|
||||
ret
|
||||
LXMUL@ ENDP
|
|
@ -3465,33 +3465,7 @@ __dos_setfileattr endp
|
|||
include libs/BorlandC/dosgdriv.asm
|
||||
include libs/BorlandC/errormsg.asm
|
||||
include libs/BorlandC/exit.asm
|
||||
|
||||
; =============== S U B R O U T I N E =======================================
|
||||
|
||||
; Attributes: library function
|
||||
|
||||
LXMUL@ proc far
|
||||
push si
|
||||
xchg ax, si
|
||||
xchg ax, dx
|
||||
test ax, ax
|
||||
jz short loc_1F0F
|
||||
mul bx
|
||||
|
||||
loc_1F0F:
|
||||
jcxz short loc_1F16
|
||||
xchg ax, cx
|
||||
mul si
|
||||
add ax, cx
|
||||
|
||||
loc_1F16:
|
||||
xchg ax, si
|
||||
mul bx
|
||||
add dx, si
|
||||
pop si
|
||||
retf
|
||||
LXMUL@ endp
|
||||
|
||||
include libs/BorlandC/f_lxmul.asm
|
||||
include libs/BorlandC/f_scopy.asm
|
||||
include libs/BorlandC/getvect.asm
|
||||
include libs/BorlandC/H_LDIV.ASM
|
||||
|
|
|
@ -4933,33 +4933,7 @@ __dos_setfileattr endp
|
|||
include libs/BorlandC/dosgdriv.asm
|
||||
include libs/BorlandC/errormsg.asm
|
||||
include libs/BorlandC/exit.asm
|
||||
|
||||
; =============== S U B R O U T I N E =======================================
|
||||
|
||||
; Attributes: library function
|
||||
|
||||
LXMUL@ proc far
|
||||
push si
|
||||
xchg ax, si
|
||||
xchg ax, dx
|
||||
test ax, ax
|
||||
jz short loc_2749
|
||||
mul bx
|
||||
|
||||
loc_2749:
|
||||
jcxz short loc_2750
|
||||
xchg ax, cx
|
||||
mul si
|
||||
add ax, cx
|
||||
|
||||
loc_2750:
|
||||
xchg ax, si
|
||||
mul bx
|
||||
add dx, si
|
||||
pop si
|
||||
retf
|
||||
LXMUL@ endp
|
||||
|
||||
include libs/BorlandC/f_lxmul.asm
|
||||
include libs/BorlandC/f_scopy.asm
|
||||
include libs/BorlandC/getvect.asm
|
||||
include libs/BorlandC/H_LDIV.ASM
|
||||
|
|
28
th02_op.asm
28
th02_op.asm
|
@ -695,33 +695,7 @@ include libs/BorlandC/dosenv.asm
|
|||
include libs/BorlandC/dosgdriv.asm
|
||||
include libs/BorlandC/errormsg.asm
|
||||
include libs/BorlandC/exit.asm
|
||||
|
||||
; =============== S U B R O U T I N E =======================================
|
||||
|
||||
; Attributes: library function
|
||||
|
||||
LXMUL@ proc far
|
||||
push si
|
||||
xchg ax, si
|
||||
xchg ax, dx
|
||||
test ax, ax
|
||||
jz short loc_366B
|
||||
mul bx
|
||||
|
||||
loc_366B:
|
||||
jcxz short loc_3672
|
||||
xchg ax, cx
|
||||
mul si
|
||||
add ax, cx
|
||||
|
||||
loc_3672:
|
||||
xchg ax, si
|
||||
mul bx
|
||||
add dx, si
|
||||
pop si
|
||||
retf
|
||||
LXMUL@ endp
|
||||
|
||||
include libs/BorlandC/f_lxmul.asm
|
||||
include libs/BorlandC/f_scopy.asm
|
||||
include libs/BorlandC/getvect.asm
|
||||
include libs/BorlandC/H_LDIV.ASM
|
||||
|
|
Loading…
Reference in New Issue