blob: 5ed55c53c67a11b7acebfd594406e253fe093c06 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
%include "defs.asm"
; ROUND64.ASM
; Author: Agner Fog
; Date created: 2007-06-15
; Last modified: 2008-10-16
; Description:
; Round function
; Copyright (c) 2009 GNU General Public License www.gnu.org/licenses
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
default rel
global RoundD: function
global RoundF: function
SECTION .text align=16
; ********** round function **********
; C++ prototype:
; extern "C" int RoundD (double x);
; extern "C" int RoundF (float x);
; This function converts a single or double precision floating point number
; to an integer, rounding to nearest or even. Does not check for overflow.
; This function is much faster than the default conversion method in C++
; which uses truncation.
RoundD:
cvtsd2si eax, xmm0 ; Round xmm0 to eax
ret
;RoundD ENDP
RoundF:
cvtss2si eax, xmm0 ; Round xmm0 to eax
ret
;RoundF ENDP
|