VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/math/RTUInt128MulByU64Ex.asm@ 96240

Last change on this file since 96240 was 94511, checked in by vboxsync, 3 years ago

IPRT: Added RTUInt128MulEx and RTUInt128MulU64Ex as well as a limited RTUInt256Xxx Api. bugref:9898

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1; $Id: RTUInt128MulByU64Ex.asm 94511 2022-04-07 13:17:57Z vboxsync $
2;; @file
3; IPRT - RTUInt128MulByU64 - AMD64 implementation.
4;
5
6;
7; Copyright (C) 2006-2022 Oracle Corporation
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.virtualbox.org. This file is free software;
11; you can redistribute it and/or modify it under the terms of the GNU
12; General Public License (GPL) as published by the Free Software
13; Foundation, in version 2 as it comes in the "COPYING" file of the
14; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17; The contents of this file may alternatively be used under the terms
18; of the Common Development and Distribution License Version 1.0
19; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20; VirtualBox OSE distribution, in which case the provisions of the
21; CDDL are applicable instead of those of the GPL.
22;
23; You may elect to license modified versions of this file under the
24; terms and conditions of either the GPL or the CDDL or both.
25;
26
27
28%define RT_ASM_WITH_SEH64
29%include "iprt/asmdefs.mac"
30%include "internal/bignum.mac"
31
32
33BEGINCODE
34
35;;
36; Multiplies a 128-bit number with a 64-bit one, returning a 256-bit result.
37;
38; @returns puResult.
39; @param puResult x86:[ebp + 8] gcc:rdi msc:rcx
40; @param puValue1 x86:[ebp + 12] gcc:rsi msc:rdx
41; @param uValue2 x86:[ebp + 16] gcc:rdx msc:r8
42;
43RT_BEGINPROC RTUInt128MulByU64Ex
44; SEH64_SET_FRAME_xSP 0
45SEH64_END_PROLOGUE
46
47%ifdef RT_ARCH_AMD64
48 %ifdef ASM_CALL64_GCC
49 %define puResult rdi
50 %define puValue1 rsi
51 %define uValue2 r8
52 mov r8, rdx
53 %else
54 %define puResult rcx
55 %define puValue1 r9
56 %define uValue2 r8
57 mov r9, rdx
58 %endif
59
60 ; puValue1->s.Lo * uValue2
61 mov rax, [puValue1]
62 mul uValue2
63 mov [puResult], rax ; Store the 1st 64-bit part of the result.
64 mov r11, rdx ; Save the upper 64 bits for later.
65
66 ; puValue1->s.Hi * uValue2
67 mov rax, [puValue1 + 8]
68 mul uValue2
69 add r11, rax ; Calc the second half of the result.
70 adc rdx, 0
71 mov [puResult + 8], r11 ; Store the 2nd 64-bit part of the result.
72 mov [puResult + 16], rdx ; Store the 3rd 64-bit part of the result.
73 xor r10, r10
74 mov [puResult + 24], r10 ; Store the 4th 64-bit part of the result.
75
76 mov rax, puResult
77
78;%elifdef RT_ARCH_X86
79%else
80 %error "unsupported arch"
81%endif
82
83 ret
84ENDPROC RTUInt128MulByU64Ex
85
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette