[Reduction] #42: Long shift right

This commit is contained in:
nmlgc 2014-08-14 19:49:23 +02:00
parent 554d0325d5
commit d5a80ee363
3 changed files with 53 additions and 66 deletions

49
libs/BorlandC/H_LRSH.ASM Normal file
View File

@ -0,0 +1,49 @@
; *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)
;[]-----------------------------------------------------------------[]
;| H_LRSH.ASM -- long shift right |
;[]-----------------------------------------------------------------[]
;
; C/C++ Run Time Library - Version 5.0
;
; Copyright (c) 1987, 1992 by Borland International
; All Rights Reserved.
;
public LXRSH@
public F_LXRSH@
public N_LXRSH@
N_LXRSH@:
pop bx ;fix up for far return
push cs
push bx
LXRSH@:
F_LXRSH@:
cmp cl,16
jae @@lsh@small
mov bx,dx ; save the high bits
shr ax,cl ; now shift each half
sar dx,cl
;
; We now have a hole in AX where the lower bits of
; DX should have been shifted. So we must take our
; copy of DX and do a reverse shift to get the proper
; bits to be or'ed into AX.
;
neg cl
add cl,16
shl bx,cl
or ax,bx
retf
@@lsh@small:
sub cl,16 ; for shifts more than 15, do this
; short sequence.
xchg ax,dx ;
cwd ; We have now done a shift by 16.
sar ax,cl ; Now shift the remainder.
retf

View File

@ -3816,37 +3816,7 @@ __c_exit proc near
retn
__c_exit endp
; =============== S U B R O U T I N E =======================================
; Attributes: library function
N_LXRSH@ proc far
pop bx
push cs
push bx
LXRSH@:
cmp cl, 10h
jnb short loc_17F0
mov bx, dx
shr ax, cl
sar dx, cl
neg cl
add cl, 10h
shl bx, cl
or ax, bx
retf
; ---------------------------------------------------------------------------
loc_17F0:
sub cl, 10h
xchg ax, dx
cwd
sar ax, cl
retf
N_LXRSH@ endp ; sp-analysis failed
include libs/BorlandC/H_LRSH.ASM
include libs/BorlandC/__IOERROR.ASM
include libs/BorlandC/_isatty.asm

View File

@ -7768,39 +7768,7 @@ _setvect endp
include libs/BorlandC/H_LDIV.ASM
include libs/BorlandC/H_LLSH.ASM
; ---------------------------------------------------------------------------
N_LXRSH@:
pop bx
push cs
push bx
; =============== S U B R O U T I N E =======================================
; Attributes: library function
LXRSH@ proc far
cmp cl, 10h
jnb short loc_37A4
mov bx, dx
shr ax, cl
sar dx, cl
neg cl
add cl, 10h
shl bx, cl
or ax, bx
retf
; ---------------------------------------------------------------------------
loc_37A4:
sub cl, 10h
xchg ax, dx
cwd
sar ax, cl
retf
LXRSH@ endp
include libs/BorlandC/H_LRSH.ASM
include libs/BorlandC/H_PADD.ASM
include libs/BorlandC/__IOERROR.ASM
include libs/BorlandC/_isatty.asm
@ -25861,7 +25829,7 @@ loc_C124:
pop bx
call LXMUL@
mov cl, 8
call LXRSH@
call far ptr LXRSH@
add ax, [bp+arg_8]
mov bx, [bp+var_2]
shl bx, 2
@ -25879,7 +25847,7 @@ loc_C124:
pop bx
call LXMUL@
mov cl, 8
call LXRSH@
call far ptr LXRSH@
add ax, [bp+arg_6]
mov bx, [bp+var_2]
shl bx, 2