blob: 5ccab9812ba00ce6bbf6ca3cb4a1f222810e13a5 [file] [log] [blame]
Charles L. Dorian04217ee2010-02-05 00:41:30 -08001// 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// func Modf(x float64) (int float64, frac float64)
6TEXT ·Modf(SB),7,$0
7 FMOVD x+0(FP), F0 // F0=x
8 FMOVD F0, F1 // F0=x, F1=x
9 FSTCW -2(SP) // save old Control Word
10 MOVW -2(SP), AX
11 ORW $0x0c00, AX // Rounding Control set to truncate
12 MOVW AX, -4(SP) // store new Control Word
13 FLDCW -4(SP) // load new Control Word
14 FRNDINT // F0=trunc(x), F1=x
15 FLDCW -2(SP) // load old Control Word
16 FSUBD F0, F1 // F0=trunc(x), F1=x-trunc(x)
17 FMOVDP F0, i+8(FP) // F0=x-trunc(x)
18 FMOVDP F0, f+16(FP)
19 RET