...
Text file src/pkg/math/modf_386.s
1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 #include "textflag.h"
6
7 // func Modf(f float64) (int float64, frac float64)
8 TEXT ·Modf(SB),NOSPLIT,$0
9 // special case for f == -0.0
10 MOVL f_hi+4(FP), DX // high word
11 MOVL f_lo+0(FP), AX // low word
12 CMPL DX, $(1<<31) // beginning of -0.0
13 JNE notNegativeZero
14 CMPL AX, $0 // could be denormalized
15 JNE notNegativeZero
16 MOVL AX, int_lo+8(FP)
17 MOVL DX, int_hi+12(FP)
18 MOVL AX, frac_lo+16(FP)
19 MOVL DX, frac_hi+20(FP)
20 RET
21 notNegativeZero:
22 FMOVD f+0(FP), F0 // F0=f
23 FMOVD F0, F1 // F0=f, F1=f
24 FSTCW -2(SP) // save old Control Word
25 MOVW -2(SP), AX
26 ORW $0x0c00, AX // Rounding Control set to truncate
27 MOVW AX, -4(SP) // store new Control Word
28 FLDCW -4(SP) // load new Control Word
29 FRNDINT // F0=trunc(f), F1=f
30 FLDCW -2(SP) // load old Control Word
31 FSUBD F0, F1 // F0=trunc(f), F1=f-trunc(f)
32 FMOVDP F0, int+8(FP) // F0=f-trunc(f)
33 FMOVDP F0, frac+16(FP)
34 RET
View as plain text