github.com/tcnksm/go@v0.0.0-20141208075154-439b32936367/src/math/modf_386.s (about)

     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  	FMOVD   f+0(FP), F0  // F0=f
    10  	FMOVD   F0, F1       // F0=f, F1=f
    11  	FSTCW   -2(SP)       // save old Control Word
    12  	MOVW    -2(SP), AX
    13  	ORW     $0x0c00, AX  // Rounding Control set to truncate
    14  	MOVW    AX, -4(SP)   // store new Control Word
    15  	FLDCW   -4(SP)       // load new Control Word
    16  	FRNDINT              // F0=trunc(f), F1=f
    17  	FLDCW   -2(SP)       // load old Control Word
    18  	FSUBD   F0, F1       // F0=trunc(f), F1=f-trunc(f)
    19  	FMOVDP  F0, int+8(FP)  // F0=f-trunc(f)
    20  	FMOVDP  F0, frac+16(FP)
    21  	RET