8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; $Id$
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync;; @file
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; IPRT - Assembly Functions, ASMMultU32ByU32DivByU32.
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync;
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync;
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; Copyright (C) 2006-2010 Oracle Corporation
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync;
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; This file is part of VirtualBox Open Source Edition (OSE), as
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; available from http://www.virtualbox.org. This file is free software;
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; you can redistribute it and/or modify it under the terms of the GNU
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; General Public License (GPL) as published by the Free Software
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; Foundation, in version 2 as it comes in the "COPYING" file of the
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync;
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; The contents of this file may alternatively be used under the terms
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; of the Common Development and Distribution License Version 1.0
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; VirtualBox OSE distribution, in which case the provisions of the
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; CDDL are applicable instead of those of the GPL.
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync;
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; You may elect to license modified versions of this file under the
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; terms and conditions of either the GPL or the CDDL or both.
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync;
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync%include "iprt/asmdefs.mac"
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync;;
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; Multiple a 32-bit by a 32-bit integer and divide the result by a 32-bit integer
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; using a 64 bit intermediate result.
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync;
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; @returns (u32A * u32B) / u32C.
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; @param u32A/ecx/edi The 32-bit value (A).
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; @param u32B/edx/esi The 32-bit value to multiple by A.
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; @param u32C/r8d/edx The 32-bit value to divide A*B by.
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync;
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync; @cproto DECLASM(uint32_t) ASMMultU32ByU32DivByU32(uint32_t u32A, uint32_t u32B, uint32_t u32C);
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync;
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsyncBEGINPROC_EXPORTED ASMMultU32ByU32DivByU32
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync%ifdef RT_ARCH_AMD64
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync %ifdef ASM_CALL64_MSC
f802270e337850f2c4f97274098ba921a34af551vboxsync mov eax, ecx
f802270e337850f2c4f97274098ba921a34af551vboxsync mul edx
f802270e337850f2c4f97274098ba921a34af551vboxsync div r8d
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync %else
f802270e337850f2c4f97274098ba921a34af551vboxsync mov eax, edi
f802270e337850f2c4f97274098ba921a34af551vboxsync mov ecx, edx
f802270e337850f2c4f97274098ba921a34af551vboxsync mul esi
f802270e337850f2c4f97274098ba921a34af551vboxsync div ecx
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync %endif
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync
f802270e337850f2c4f97274098ba921a34af551vboxsync%elifdef RT_ARCH_X86
f802270e337850f2c4f97274098ba921a34af551vboxsync mov eax, [esp + 04h]
f802270e337850f2c4f97274098ba921a34af551vboxsync mul dword [esp + 08h]
f802270e337850f2c4f97274098ba921a34af551vboxsync div dword [esp + 0ch]
f802270e337850f2c4f97274098ba921a34af551vboxsync%else
f802270e337850f2c4f97274098ba921a34af551vboxsync %error "Unsupported arch."
f802270e337850f2c4f97274098ba921a34af551vboxsync unsupported arch
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsync%endif
f802270e337850f2c4f97274098ba921a34af551vboxsync
f802270e337850f2c4f97274098ba921a34af551vboxsync ret
8f02c0ae2a7b9e498a1807c45ea850503d8bff44vboxsyncENDPROC ASMMultU32ByU32DivByU32