2010-02-05 01:41:30 -07:00
|
|
|
// Copyright 2010 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2014-08-12 18:04:45 -06:00
|
|
|
#include "textflag.h"
|
2013-08-12 11:25:18 -06:00
|
|
|
|
2012-09-20 22:35:56 -06:00
|
|
|
// func Modf(f float64) (int float64, frac float64)
|
2013-08-12 11:25:18 -06:00
|
|
|
TEXT ·Modf(SB),NOSPLIT,$0
|
2012-09-20 22:35:56 -06:00
|
|
|
FMOVD f+0(FP), F0 // F0=f
|
|
|
|
FMOVD F0, F1 // F0=f, F1=f
|
2010-02-05 01:41:30 -07:00
|
|
|
FSTCW -2(SP) // save old Control Word
|
|
|
|
MOVW -2(SP), AX
|
|
|
|
ORW $0x0c00, AX // Rounding Control set to truncate
|
|
|
|
MOVW AX, -4(SP) // store new Control Word
|
|
|
|
FLDCW -4(SP) // load new Control Word
|
2012-09-20 22:35:56 -06:00
|
|
|
FRNDINT // F0=trunc(f), F1=f
|
2010-02-05 01:41:30 -07:00
|
|
|
FLDCW -2(SP) // load old Control Word
|
2012-09-20 22:35:56 -06:00
|
|
|
FSUBD F0, F1 // F0=trunc(f), F1=f-trunc(f)
|
|
|
|
FMOVDP F0, int+8(FP) // F0=f-trunc(f)
|
|
|
|
FMOVDP F0, frac+16(FP)
|
2010-02-05 01:41:30 -07:00
|
|
|
RET
|