github.com/mdempsky/go@v0.0.0-20151201204031-5dd372bd1e70/src/math/floor_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 Ceil(x float64) float64
     8  TEXT ·Ceil(SB),NOSPLIT,$0
     9  	FMOVD   x+0(FP), F0  // F0=x
    10  	FSTCW   -2(SP)       // save old Control Word
    11  	MOVW    -2(SP), AX
    12  	ANDW    $0xf3ff, AX
    13  	ORW     $0x0800, AX  // Rounding Control set to +Inf
    14  	MOVW    AX, -4(SP)   // store new Control Word
    15  	FLDCW   -4(SP)       // load new Control Word
    16  	FRNDINT              // F0=Ceil(x)
    17  	FLDCW   -2(SP)       // load old Control Word
    18  	FMOVDP  F0, ret+8(FP)
    19  	RET
    20  
    21  // func Floor(x float64) float64
    22  TEXT ·Floor(SB),NOSPLIT,$0
    23  	FMOVD   x+0(FP), F0  // F0=x
    24  	FSTCW   -2(SP)       // save old Control Word
    25  	MOVW    -2(SP), AX
    26  	ANDW    $0xf3ff, AX
    27  	ORW     $0x0400, AX  // Rounding Control set to -Inf
    28  	MOVW    AX, -4(SP)   // store new Control Word
    29  	FLDCW   -4(SP)       // load new Control Word
    30  	FRNDINT              // F0=Floor(x)
    31  	FLDCW   -2(SP)       // load old Control Word
    32  	FMOVDP  F0, ret+8(FP)
    33  	RET
    34  
    35  // func Trunc(x float64) float64
    36  TEXT ·Trunc(SB),NOSPLIT,$0
    37  	FMOVD   x+0(FP), F0  // F0=x
    38  	FSTCW   -2(SP)       // save old Control Word
    39  	MOVW    -2(SP), AX
    40  	ORW     $0x0c00, AX  // Rounding Control set to truncate
    41  	MOVW    AX, -4(SP)   // store new Control Word
    42  	FLDCW   -4(SP)       // load new Control Word
    43  	FRNDINT              // F0=Trunc(x)
    44  	FLDCW   -2(SP)       // load old Control Word
    45  	FMOVDP  F0, ret+8(FP)
    46  	RET