blob: 68caab0bdd948ea9ffaa8216aeaddee5ffd6370c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
! bcc 386 floating point routines (version 2) -- dtof, Fpushd, Fneg, Fnegd
! authors: Timothy Murphy (tim@maths.tcd.ie), Bruce Evans
#include "fplib.h"
.extern Fpullf
! dtof converts the double at [ebx] to a float and pushes the float onto
! the stack (D_SIZE bytes are allocated for the float although only the bottom
! F_SIZE are used).
! This is a quickly-written slowish version.
.globl dtof
.align ALIGNMENT
dtof:
pop eax
sub esp,#D_SIZE ! build result here
push eax ! put back return address
call Fpushd
lea ebx,D_SIZE+PC_SIZE[esp]
call Fpullf
ret
! Push double at address [ebx] onto stack
.globl Fpushd
.align ALIGNMENT
Fpushd:
pop ecx
push dword D_HIGH[ebx]
push dword D_LOW[ebx]
jmp ecx ! return
! Push double at address [ebx] onto stack, negating it on the way.
! Don't worry about generating -0 because other routines have to allow for
! it anyway.
! Perhaps this and Fneg should check for denormals and illegal operands
! (I think only signalling NaNs are illegal).
! fchs doesn't check, but fld does.
! Our Fpushd is not quite like fld because no conversions are involved.
.globl Fnegd
.align ALIGNMENT
Fnegd:
pop ecx
mov eax,D_HIGH[ebx]
xor eax,#D_SIGN_MASK ! toggle sign
push eax
push dword D_LOW[ebx]
jmp ecx ! return
! Negate double on stack
.globl Fneg
.align ALIGNMENT
Fneg:
xorb PC_SIZE+D_SIZE-1[esp],D_SIGN_MASK >> (REG_BIT-CHAR_BIT) ! toggle sign
ret
|