2014-11-09 00:11:04 +00:00
|
|
|
; *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 segment declarations (for obvious reasons)
|
|
|
|
; * the Fcall and Ncall labels being replaced with LPROG
|
|
|
|
|
|
|
|
;[]------------------------------------------------------------[]
|
|
|
|
;| FTOL.ASM -- Float to Long conversion |
|
|
|
|
;[]------------------------------------------------------------[]
|
|
|
|
|
|
|
|
;
|
|
|
|
; C/C++ Run Time Library - Version 5.0
|
|
|
|
;
|
|
|
|
; Copyright (c) 1987, 1992 by Borland International
|
|
|
|
; All Rights Reserved.
|
|
|
|
;
|
|
|
|
|
|
|
|
NAME Ftol
|
|
|
|
|
2014-11-21 10:24:47 +00:00
|
|
|
option emulator ; generate emulated '87 code
|
2014-11-09 00:11:04 +00:00
|
|
|
|
|
|
|
; FTOL@
|
|
|
|
; Calls to FTOL@ are generated by the compiler for code
|
|
|
|
; that needs to convert a floating point type to an integral type.
|
|
|
|
; Input: floating point number on the top of the '87.
|
|
|
|
; Output: a (signed or unsigned) long in AX, DX.
|
|
|
|
; All other registers preserved.
|
|
|
|
; Proc is far, independent of memory model.
|
|
|
|
|
|
|
|
; Caution: Overflows are ignored.
|
|
|
|
|
|
|
|
temp1 equ [bp-2]
|
|
|
|
temp2 equ [bp-10]
|
|
|
|
|
|
|
|
ifdef LPROG
|
|
|
|
|
|
|
|
PubSym@ FTOL@, <PROC FAR>, __PASCAL__
|
|
|
|
PubSym@ F_FTOL@, <LABEL FAR>, __PASCAL__
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
PubSym@ N_FTOL@, <PROC NEAR>, __PASCAL__
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
push bp
|
|
|
|
mov bp, sp
|
|
|
|
sub sp, 10
|
|
|
|
fstcw temp1 ; save the control word
|
|
|
|
fwait
|
2014-11-19 06:15:10 +00:00
|
|
|
mov al, byte ptr temp1 + 1
|
|
|
|
or byte ptr temp1 + 1, 0Ch
|
2014-11-09 00:11:04 +00:00
|
|
|
fldcw temp1
|
|
|
|
fistp qword ptr temp2 ; convert to 64-bit integer
|
2014-11-19 06:15:10 +00:00
|
|
|
mov byte ptr temp1 + 1, al
|
2014-11-09 00:11:04 +00:00
|
|
|
fldcw temp1 ; restore the control word
|
2014-11-19 06:15:10 +00:00
|
|
|
mov ax, word ptr temp2 ; return LS 32 bits
|
|
|
|
mov dx, word ptr temp2 + 2
|
2014-11-09 00:11:04 +00:00
|
|
|
mov sp, bp
|
|
|
|
pop bp
|
|
|
|
ret
|
|
|
|
|
|
|
|
ifdef LPROG
|
|
|
|
EndProc@ FTOL@, __PASCAL__
|
|
|
|
else
|
|
|
|
EndProc@ N_FTOL@, __PASCAL__
|
|
|
|
endif
|