trunc.asm revision 7db630a55be9d955c8ac125da609b304cbcc6010
78a072e1b56619e3230735ae073668311232ec94vboxsync; $Id$
78a072e1b56619e3230735ae073668311232ec94vboxsync;; @file
78a072e1b56619e3230735ae073668311232ec94vboxsync; IPRT - No-CRT trunc - AMD64 & X86.
78a072e1b56619e3230735ae073668311232ec94vboxsync;
78a072e1b56619e3230735ae073668311232ec94vboxsync
78a072e1b56619e3230735ae073668311232ec94vboxsync;
78a072e1b56619e3230735ae073668311232ec94vboxsync; Copyright (C) 2006-2007 Sun Microsystems, Inc.
78a072e1b56619e3230735ae073668311232ec94vboxsync;
78a072e1b56619e3230735ae073668311232ec94vboxsync; This file is part of VirtualBox Open Source Edition (OSE), as
78a072e1b56619e3230735ae073668311232ec94vboxsync; available from http://www.virtualbox.org. This file is free software;
78a072e1b56619e3230735ae073668311232ec94vboxsync; you can redistribute it and/or modify it under the terms of the GNU
78a072e1b56619e3230735ae073668311232ec94vboxsync; General Public License (GPL) as published by the Free Software
78a072e1b56619e3230735ae073668311232ec94vboxsync; Foundation, in version 2 as it comes in the "COPYING" file of the
78a072e1b56619e3230735ae073668311232ec94vboxsync; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
78a072e1b56619e3230735ae073668311232ec94vboxsync; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
78a072e1b56619e3230735ae073668311232ec94vboxsync;
78a072e1b56619e3230735ae073668311232ec94vboxsync; The contents of this file may alternatively be used under the terms
78a072e1b56619e3230735ae073668311232ec94vboxsync; of the Common Development and Distribution License Version 1.0
78a072e1b56619e3230735ae073668311232ec94vboxsync; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
78a072e1b56619e3230735ae073668311232ec94vboxsync; VirtualBox OSE distribution, in which case the provisions of the
78a072e1b56619e3230735ae073668311232ec94vboxsync; CDDL are applicable instead of those of the GPL.
78a072e1b56619e3230735ae073668311232ec94vboxsync;
78a072e1b56619e3230735ae073668311232ec94vboxsync; You may elect to license modified versions of this file under the
78a072e1b56619e3230735ae073668311232ec94vboxsync; terms and conditions of either the GPL or the CDDL or both.
78a072e1b56619e3230735ae073668311232ec94vboxsync;
78a072e1b56619e3230735ae073668311232ec94vboxsync; Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
78a072e1b56619e3230735ae073668311232ec94vboxsync; Clara, CA 95054 USA or visit http://www.sun.com if you need
78a072e1b56619e3230735ae073668311232ec94vboxsync; additional information or have any questions.
78a072e1b56619e3230735ae073668311232ec94vboxsync;
78a072e1b56619e3230735ae073668311232ec94vboxsync
78a072e1b56619e3230735ae073668311232ec94vboxsync
78a072e1b56619e3230735ae073668311232ec94vboxsync%include "iprt/asmdefs.mac"
78a072e1b56619e3230735ae073668311232ec94vboxsync
78a072e1b56619e3230735ae073668311232ec94vboxsyncBEGINCODE
78a072e1b56619e3230735ae073668311232ec94vboxsync
78a072e1b56619e3230735ae073668311232ec94vboxsync%ifdef RT_ARCH_AMD64
78a072e1b56619e3230735ae073668311232ec94vboxsync %define _SP rsp
78a072e1b56619e3230735ae073668311232ec94vboxsync %define _BP rbp
78a072e1b56619e3230735ae073668311232ec94vboxsync %define _S 8
78a072e1b56619e3230735ae073668311232ec94vboxsync%else
78a072e1b56619e3230735ae073668311232ec94vboxsync %define _SP esp
78a072e1b56619e3230735ae073668311232ec94vboxsync %define _BP ebp
78a072e1b56619e3230735ae073668311232ec94vboxsync %define _S 4
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync%endif
78a072e1b56619e3230735ae073668311232ec94vboxsync
78a072e1b56619e3230735ae073668311232ec94vboxsync;;
78a072e1b56619e3230735ae073668311232ec94vboxsync; Round to truncated integer value.
78a072e1b56619e3230735ae073668311232ec94vboxsync; @returns 32-bit: st(0) 64-bit: xmm0
78a072e1b56619e3230735ae073668311232ec94vboxsync; @param rd 32-bit: [ebp + 8] 64-bit: xmm0
78a072e1b56619e3230735ae073668311232ec94vboxsyncBEGINPROC RT_NOCRT(trunc)
78a072e1b56619e3230735ae073668311232ec94vboxsync push _BP
78a072e1b56619e3230735ae073668311232ec94vboxsync mov _BP, _SP
78a072e1b56619e3230735ae073668311232ec94vboxsync sub _SP, 10h
78a072e1b56619e3230735ae073668311232ec94vboxsync
78a072e1b56619e3230735ae073668311232ec94vboxsync%ifdef RT_ARCH_AMD64
78a072e1b56619e3230735ae073668311232ec94vboxsync movsd [_SP], xmm0
78a072e1b56619e3230735ae073668311232ec94vboxsync fld qword [_SP]
78a072e1b56619e3230735ae073668311232ec94vboxsync%else
78a072e1b56619e3230735ae073668311232ec94vboxsync fld qword [_BP + _S*2]
78a072e1b56619e3230735ae073668311232ec94vboxsync%endif
78a072e1b56619e3230735ae073668311232ec94vboxsync
78a072e1b56619e3230735ae073668311232ec94vboxsync ; Make it truncate up by modifying the fpu control word.
78a072e1b56619e3230735ae073668311232ec94vboxsync fstcw [_BP - 10h]
78a072e1b56619e3230735ae073668311232ec94vboxsync mov eax, [_BP - 10h]
78a072e1b56619e3230735ae073668311232ec94vboxsync or eax, 00c00h
78a072e1b56619e3230735ae073668311232ec94vboxsync mov [_BP - 08h], eax
78a072e1b56619e3230735ae073668311232ec94vboxsync fldcw [_BP - 08h]
78a072e1b56619e3230735ae073668311232ec94vboxsync
78a072e1b56619e3230735ae073668311232ec94vboxsync ; Round ST(0) to integer.
78a072e1b56619e3230735ae073668311232ec94vboxsync frndint
78a072e1b56619e3230735ae073668311232ec94vboxsync
78a072e1b56619e3230735ae073668311232ec94vboxsync ; Restore the fpu control word.
78a072e1b56619e3230735ae073668311232ec94vboxsync fldcw [_BP - 10h]
78a072e1b56619e3230735ae073668311232ec94vboxsync
78a072e1b56619e3230735ae073668311232ec94vboxsync%ifdef RT_ARCH_AMD64
78a072e1b56619e3230735ae073668311232ec94vboxsync fstp qword [_SP]
78a072e1b56619e3230735ae073668311232ec94vboxsync movsd xmm0, [_SP]
78a072e1b56619e3230735ae073668311232ec94vboxsync%endif
78a072e1b56619e3230735ae073668311232ec94vboxsync leave
78a072e1b56619e3230735ae073668311232ec94vboxsync ret
78a072e1b56619e3230735ae073668311232ec94vboxsyncENDPROC RT_NOCRT(trunc)
78a072e1b56619e3230735ae073668311232ec94vboxsync
78a072e1b56619e3230735ae073668311232ec94vboxsync