972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; $Id$
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync;; @file
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; IPRT - RTUInt128MulByU64 - AMD64 implementation.
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync;
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync;
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; Copyright (C) 2006-2014 Oracle Corporation
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync;
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; This file is part of VirtualBox Open Source Edition (OSE), as
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; available from http://www.virtualbox.org. This file is free software;
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; you can redistribute it and/or modify it under the terms of the GNU
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; General Public License (GPL) as published by the Free Software
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; Foundation, in version 2 as it comes in the "COPYING" file of the
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync;
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; The contents of this file may alternatively be used under the terms
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; of the Common Development and Distribution License Version 1.0
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; VirtualBox OSE distribution, in which case the provisions of the
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; CDDL are applicable instead of those of the GPL.
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync;
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; You may elect to license modified versions of this file under the
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; terms and conditions of either the GPL or the CDDL or both.
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync;
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync%define RT_ASM_WITH_SEH64
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync%include "iprt/asmdefs.mac"
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync%include "internal/bignum.mac"
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsyncBEGINCODE
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync;;
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; Multiplies a 128-bit number with a 64-bit one.
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync;
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; @returns puResult.
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; @param puResult x86:[ebp + 8] gcc:rdi msc:rcx
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; @param puValue1 x86:[ebp + 12] gcc:rsi msc:rdx
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; @param uValue2 x86:[ebp + 16] gcc:rdx msc:r8
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync;
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsyncBEGINPROC_EXPORTED RTUInt128MulByU64
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync; SEH64_SET_FRAME_xSP 0
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsyncSEH64_END_PROLOGUE
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync%ifdef RT_ARCH_AMD64
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync %ifdef ASM_CALL64_GCC
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync %define puResult rdi
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync %define puValue1 rsi
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync %define uValue2 r8
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync mov r8, rdx
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync %else
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync %define puResult rcx
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync %define puValue1 r9
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync %define uValue2 r8
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync mov r9, rdx
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync %endif
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync ; puValue1->s.Lo * uValue2
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync mov rax, [puValue1]
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync mul uValue2
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync mov [puResult], rax
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync mov r11, rdx ; Store the lower half of the result.
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync ; puValue1->s.Hi * uValue2
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync mov rax, [puValue1 + 8]
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync mul uValue2
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync add r11, rax ; Calc the second half of the result.
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync mov [puResult + 8], r11 ; Store the high half of the result.
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync mov rax, puResult
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync;%elifdef RT_ARCH_X86
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync%else
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync %error "unsupported arch"
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync%endif
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync ret
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsyncENDPROC RTUInt128MulByU64
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync
972c3ecf2c929440ce70e51af38ba021101c8f7bvboxsync