From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web12.8354.1651227631626895885 for ; Fri, 29 Apr 2022 03:20:32 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JuwgT+WW; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651227630; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j1HHJxTn2Kvox2cftFiBVFQqIPRQkZB0Bn0NT865b1k=; b=JuwgT+WWyXK+A6Aqg21I9R3WCdd7wZH1trEO6uPFPyx2/O+k7MgROqG6ezDcSKNBMRuaBd 7z2oZavgr6jsx6wFVawskEVo2oODcsp9BKLvoHXfKd/vBj93Y4gyz95BaXfYMY6kasl/4P vrFUW+9ud5untdOjMN4eJMsHKrDJAgM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-640-S-l0eJdIP8mjMI_fnQqt3w-1; Fri, 29 Apr 2022 06:20:27 -0400 X-MC-Unique: S-l0eJdIP8mjMI_fnQqt3w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8526F3C0FA80; Fri, 29 Apr 2022 10:20:25 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.13]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C4B49407E1C1; Fri, 29 Apr 2022 10:20:24 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 09DF61800622; Fri, 29 Apr 2022 12:20:20 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Erdem Aktas , Maciej Rabeda , Abner Chang , Peter Grehan , Gerd Hoffmann , Yuwei Chen , Jiaxin Wu , Siyuan Fu , Sean Brogan , Anthony Perard , Benjamin You , Guomin Jiang , Leif Lindholm , Rebecca Cran , Wei6 Xu , Nickle Wang , Xiaoyu Lu , Zhichao Gao , kilian_kegel@hotmail.com, Liming Gao , Jordan Justen , Sami Mujawar , Andrew Fish , Sami Mujawar , Oliver Steffen , Alexei Fedorov , Guo Dong , Brijesh Singh , Jian J Wang , Supreeth Venkatesh , Min Xu , Bret Barkelew , Maurice Ma , Pawel Polawski , Daniel Schaefer , Bob Feng , James Bottomley , Jiewen Yao , Ray Ni , Julien Grall , Michael D Kinney , Sebastien Boeuf , Zhiguang Liu , Tom Lendacky Subject: [PATCH v3 05/10] MdePkg/CompilerIntrinsicsLib: copy over intrinsics from edk2-libc repo Date: Fri, 29 Apr 2022 12:20:14 +0200 Message-Id: <20220429102019.1375348-6-kraxel@redhat.com> In-Reply-To: <20220429102019.1375348-1-kraxel@redhat.com> References: <20220429102019.1375348-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Copy over unmodified (except for running through uncrustify), from https://github.com/tianocore/edk2-libc/tree/master/StdLib/LibC/CRT Signed-off-by: Gerd Hoffmann Acked-by: Liming Gao --- .../Library/CompilerIntrinsicsLib/Ia32/Gcc.c | 283 ++++++++++++++++++ .../CompilerIntrinsicsLib/Ia32/lldiv.c | 98 ++++++ .../CompilerIntrinsicsLib/Ia32/lldvrm.c | 102 +++++++ .../CompilerIntrinsicsLib/Ia32/llmul.c | 82 +++++ .../CompilerIntrinsicsLib/Ia32/llrem.c | 95 ++++++ .../CompilerIntrinsicsLib/Ia32/llshl.c | 57 ++++ .../CompilerIntrinsicsLib/Ia32/llshr.c | 61 ++++ .../CompilerIntrinsicsLib/Ia32/ulldiv.c | 89 ++++++ .../CompilerIntrinsicsLib/Ia32/ulldvrm.c | 102 +++++++ .../CompilerIntrinsicsLib/Ia32/ullrem.c | 95 ++++++ .../CompilerIntrinsicsLib/Ia32/ullshr.c | 60 ++++ .../CompilerIntrinsicsLib/Ia32/ashrdi3.S | 66 ++++ .../CompilerIntrinsicsLib/Ia32/mulll.S | 77 +++++ .../CompilerIntrinsicsLib/Ia32/shldi3.S | 62 ++++ .../CompilerIntrinsicsLib/Ia32/udivdi3.S | 83 +++++ .../CompilerIntrinsicsLib/Ia32/umoddi3.S | 89 ++++++ 16 files changed, 1501 insertions(+) create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshr.c create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldiv.c create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldvrm.c create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullrem.c create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullshr.c create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ashrdi3.S create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/mulll.S create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/shldi3.S create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/udivdi3.S create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/umoddi3.S diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c new file mode 100644 index 000000000000..430139fc5ee0 --- /dev/null +++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c @@ -0,0 +1,283 @@ +/** @file + Integer Arithmetic Run-time support functions for GCC. + The integer arithmetic routines are used on platforms that don't provide + hardware support for arithmetic operations on some modes.. + + Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +#include +#include +#include + +#include + +// Shift Datum left by Count bits. +// =========================================================================== +int +__ashlsi3 ( + int Datum, + int Count + ) +{ + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + return (int)LShiftU64 ((UINT64)Datum, (UINTN)Count); +} + +long +__ashldi3 ( + long Datum, + int Count + ) +{ + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + return (long)LShiftU64 ((UINT64)Datum, (UINTN)Count); +} + +long long +__ashlti3 ( + long long Datum, + int Count + ) +{ + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + return (long long)LShiftU64 ((UINT64)Datum, (UINTN)Count); +} + +// Arithmetically shift Datum right by Count bits. +// =========================================================================== +int +__ashrsi3 ( + int Datum, + int Count + ) +{ + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + return (int)ARShiftU64 ((UINT64)Datum, (UINTN)Count); +} + +long +__ashrdi3 ( + long Datum, + int Count + ) +{ + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + return (long)ARShiftU64 ((UINT64)Datum, (UINTN)Count); +} + +long long +__ashrti3 ( + long long Datum, + int Count + ) +{ + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + return (long long)ARShiftU64 ((UINT64)Datum, (UINTN)Count); +} + +// Return the quotient of the signed division of Dividend and Divisor +// =========================================================================== +int +__divsi3 ( + int Dividend, + int Divisor + ) +{ + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + return (int)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, NULL); +} + +INT64 +__divdi3 ( + INT64 Dividend, + INT64 Divisor + ) +{ + INT64 Quotient; + + Quotient = DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, NULL); + DEBUG ((DEBUG_INFO, "%a: %Ld / %Ld = %Ld\n", __func__, Dividend, Divisor, Quotient)); + + return Quotient; +} + +long long +__divti3 ( + long long Dividend, + long long Divisor + ) +{ + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + return (long long)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, NULL); +} + +// Logically shift Datum right by Count bits +// =========================================================================== +int +__lshrsi3 ( + int Datum, + int Count + ) +{ + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + return (int)RShiftU64 ((UINT64)Datum, (UINTN)Count); +} + +long +__lshrdi3 ( + int Datum, + int Count + ) +{ + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + return (long)RShiftU64 ((UINT64)Datum, (UINTN)Count); +} + +long long +__lshrti3 ( + int Datum, + int Count + ) +{ + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + return (long long)RShiftU64 ((UINT64)Datum, (UINTN)Count); +} + +// Return the remainder of the signed division of Dividend and Divisor +// =========================================================================== +int +__modsi3 ( + int Dividend, + int Divisor + ) +{ + INT64 Remainder; + + (void)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, &Remainder); + DEBUG ((DEBUG_INFO, "modsi3: %d %% %d = %d\n", Dividend, Divisor, (int)Remainder)); + + return (int)Remainder; +} + +INT64 +__moddi3 ( + INT64 Dividend, + INT64 Divisor + ) +{ + INT64 Remainder; + + (void)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, &Remainder); + DEBUG ((DEBUG_INFO, "moddi3: %Ld %% %Ld = %Ld\n", (INT64)Dividend, (INT64)Divisor, Remainder)); + + return Remainder; +} + +long long +__modti3 ( + long long Dividend, + long long Divisor + ) +{ + INT64 Remainder; + + (void)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, &Remainder); + DEBUG ((DEBUG_INFO, "modti3: %Ld %% %Ld = %Ld\n", (INT64)Dividend, (INT64)Divisor, Remainder)); + + return (long long)Remainder; +} + +// These functions return the product of the Multiplicand and Multiplier. +// =========================================================================== +long long +__multi3 ( + long long Multiplicand, + long long Multiplier + ) +{ + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + return (long long)MultS64x64 ((INT64)Multiplicand, (INT64)Multiplier); +} + +// Return the quotient of the unsigned division of a and b. +// =========================================================================== +unsigned int +__udivsi3 ( + unsigned int Dividend, + unsigned int Divisor + ) +{ + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + return (int)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, NULL); +} + +unsigned long +__udivdi3 ( + unsigned long Dividend, + unsigned long Divisor + ) +{ + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + return (long)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, NULL); +} + +unsigned long long +__udivti3 ( + unsigned long long Dividend, + unsigned long long Divisor + ) +{ + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + return (long long)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, NULL); +} + +// =========================================================================== +unsigned int +__umodsi3 ( + unsigned int Dividend, + unsigned int Divisor + ) +{ + UINT64 Remainder; + + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + (void)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, &Remainder); + + return (unsigned int)Remainder; +} + +unsigned long +__umoddi3 ( + unsigned long Dividend, + unsigned long Divisor + ) +{ + UINT64 Remainder; + + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + (void)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, &Remainder); + + return (unsigned long)Remainder; +} + +unsigned long long +__umodti3 ( + unsigned long long Dividend, + unsigned long long Divisor + ) +{ + UINT64 Remainder; + + DEBUG ((DEBUG_INFO, "%a:\n", __func__)); + (void)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, &Remainder); + + return (unsigned long long)Remainder; +} diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c new file mode 100644 index 000000000000..792974d7b119 --- /dev/null +++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c @@ -0,0 +1,98 @@ +/** @file + 64-bit Math Worker Function. + The 32-bit versions of C compiler generate calls to library routines + to handle 64-bit math. These functions use non-standard calling conventions. + + Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +/* + * Divides a 64-bit signed value with a 64-bit signed value and returns + * a 64-bit signed result. + */ +__declspec(naked) void __cdecl +_alldiv ( + void + ) +{ + // + // Wrapper Implementation over EDKII DivS64x64Remainder() routine + // INT64 + // EFIAPI + // DivS64x64Remainder ( + // IN UINT64 Dividend, + // IN UINT64 Divisor, + // OUT UINT64 *Remainder OPTIONAL + // ) + // + _asm { + ;Entry: + ; Arguments are passed on the stack: + ; 1st pushed: divisor (QWORD) + ; 2nd pushed: dividend (QWORD) + ; + ;Exit: + ; EDX:EAX contains the quotient (dividend/ divisor) + ; NOTE: this routine removes the parameters from the stack. + ; + ; Original local stack when calling _alldiv + ; ----------------- + ; | | + ; |---------------| + ; | | + ; |-- Divisor --| + ; | | + ; |---------------| + ; | | + ; |-- Dividend --| + ; | | + ; |---------------| + ; | ReturnAddr** | + ; ESP---->|---------------| + ; + + ; + ; Set up the local stack for NULL Reminder pointer + ; + xor eax, eax + push eax + + ; + ; Set up the local stack for Divisor parameter + ; + mov eax, [esp + 20] + push eax + mov eax, [esp + 20] + push eax + + ; + ; Set up the local stack for Dividend parameter + ; + mov eax, [esp + 20] + push eax + mov eax, [esp + 20] + push eax + + ; + ; Call native DivS64x64Remainder of BaseLib + ; + call DivS64x64Remainder + + ; + ; Adjust stack + ; + add esp, 20 + + ret 16 + } +} diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c new file mode 100644 index 000000000000..a1f87f6af5c3 --- /dev/null +++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c @@ -0,0 +1,102 @@ +/** @file + 64-bit Math Worker Function. + The 32-bit versions of C compiler generate calls to library routines + to handle 64-bit math. These functions use non-standard calling conventions. + + Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +/* + * Divides a 64-bit signed value by another 64-bit signed value and returns + * the 64-bit signed result and the 64-bit signed remainder. + */ +__declspec(naked) void __cdecl +_alldvrm ( + void + ) +{ + // + // Wrapper Implementation over EDKII DivS64x64Remainder() routine + // INT64 + // EFIAPI + // DivS64x64Remainder ( + // IN INT64 Dividend, + // IN INT64 Divisor, + // OUT INT64 *Remainder + // ) + // + _asm { + ; Original local stack when calling _alldvrm + ; ----------------- + ; | | + ; |---------------| + ; | | + ; |-- Divisor --| + ; | | + ; |---------------| + ; | | + ; |-- Dividend --| + ; | | + ; |---------------| + ; | ReturnAddr** | + ; ESP---->|---------------| + ; + ; + ; On Exit: + ; EDX:EAX contains the quotient (dividend/ divisor) + ; EBX:ECX contains the remainder (divided % divisor) + ; NOTE: this routine removes the parameters from the stack. + ; + + ; + ; Set up the local stack for Reminder pointer + ; + sub esp, 8 + push esp + + ; + ; Set up the local stack for Divisor parameter + ; + mov eax, [esp + 28] + push eax + mov eax, [esp + 28] + push eax + + ; + ; Set up the local stack for Dividend parameter + ; + mov eax, [esp + 28] + push eax + mov eax, [esp + 28] + push eax + + ; + ; Call native DivS64x64Remainder of BaseLib + ; + call DivS64x64Remainder + + ; + ; EDX:EAX contains the quotient (dividend/ divisor) + ; Put the Remainder in EBX:ECX + ; + mov ecx, [esp + 20] + mov ebx, [esp + 24] + + ; + ; Adjust stack + ; + add esp, 28 + + ret 16 + } +} diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c new file mode 100644 index 000000000000..61a5c416b912 --- /dev/null +++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c @@ -0,0 +1,82 @@ +/** @file + 64-bit Math Worker Function. + The 32-bit versions of C compiler generate calls to library routines + to handle 64-bit math. These functions use non-standard calling conventions. + + Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +/* + * Multiplies a 64-bit signed or unsigned value by a 64-bit signed or unsigned value + * and returns a 64-bit result. + */ +__declspec(naked) void __cdecl +_allmul ( + void + ) +{ + // + // Wrapper Implementation over EDKII MultS64x64() routine + // INT64 + // EFIAPI + // MultS64x64 ( + // IN INT64 Multiplicand, + // IN INT64 Multiplier + // ) + // + _asm { + ; Original local stack when calling _allmul + ; ----------------- + ; | | + ; |---------------| + ; | | + ; |--Multiplier --| + ; | | + ; |---------------| + ; | | + ; |--Multiplicand-| + ; | | + ; |---------------| + ; | ReturnAddr** | + ; ESP---->|---------------| + ; + + ; + ; Set up the local stack for Multiplicand parameter + ; + mov eax, [esp + 16] + push eax + mov eax, [esp + 16] + push eax + + ; + ; Set up the local stack for Multiplier parameter + ; + mov eax, [esp + 16] + push eax + mov eax, [esp + 16] + push eax + + ; + ; Call native MulS64x64 of BaseLib + ; + call MultS64x64 + + ; + ; Adjust stack + ; + add esp, 16 + + ret 16 + } +} diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c new file mode 100644 index 000000000000..f415fe82dd59 --- /dev/null +++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c @@ -0,0 +1,95 @@ +/** @file + 64-bit Math Worker Function. + The 32-bit versions of C compiler generate calls to library routines + to handle 64-bit math. These functions use non-standard calling conventions. + + Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +/* + * Divides a 64-bit signed value by another 64-bit signed value and returns + * the 64-bit signed remainder. + */ +__declspec(naked) void __cdecl +_allrem ( + void + ) +{ + // + // Wrapper Implementation over EDKII DivS64x64Remainder() routine + // UINT64 + // EFIAPI + // DivS64x64Remainder ( + // IN UINT64 Dividend, + // IN UINT64 Divisor, + // OUT UINT64 *Remainder + // ) + // + _asm { + ; Original local stack when calling _allrem + ; ----------------- + ; | | + ; |---------------| + ; | | + ; |-- Divisor --| + ; | | + ; |---------------| + ; | | + ; |-- Dividend --| + ; | | + ; |---------------| + ; | ReturnAddr** | + ; ESP---->|---------------| + ; + + ; + ; Set up the local stack for Reminder pointer + ; + sub esp, 8 + push esp + + ; + ; Set up the local stack for Divisor parameter + ; + mov eax, [esp + 28] + push eax + mov eax, [esp + 28] + push eax + + ; + ; Set up the local stack for Dividend parameter + ; + mov eax, [esp + 28] + push eax + mov eax, [esp + 28] + push eax + + ; + ; Call native DivS64x64Remainder of BaseLib + ; + call DivS64x64Remainder + + ; + ; Put the Reminder in EDX:EAX as return value + ; + mov eax, [esp + 20] + mov edx, [esp + 24] + + ; + ; Adjust stack + ; + add esp, 28 + + ret 16 + } +} diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c new file mode 100644 index 000000000000..f2121a713bd7 --- /dev/null +++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c @@ -0,0 +1,57 @@ +/** @file + 64-bit Math Worker Function. + The 32-bit versions of C compiler generate calls to library routines + to handle 64-bit math. These functions use non-standard calling conventions. + + Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +/* + * Shifts a 64-bit signed value left by a particular number of bits. + */ +__declspec(naked) void __cdecl +_allshl ( + void + ) +{ + _asm { + ; + ; Handle shifting of 64 or more bits (return 0) + ; + + cmp cl, 64 + jae short ReturnZero + + ; + ; Handle shifting of between 0 and 31 bits + ; + cmp cl, 32 + jae short More32 + shld edx, eax, cl + shl eax, cl + ret + + ; + ; Handle shifting of between 32 and 63 bits + ; +More32: + mov edx, eax + xor eax, eax + and cl, 31 + shl edx, cl + ret + +ReturnZero: + xor eax,eax + xor edx,edx + ret + } +} diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshr.c b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshr.c new file mode 100644 index 000000000000..ba60aaafada5 --- /dev/null +++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshr.c @@ -0,0 +1,61 @@ +/** @file + 64-bit Math Worker Function. + The 32-bit versions of C compiler generate calls to library routines + to handle 64-bit math. These functions use non-standard calling conventions. + + Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +/* + * Shifts a 64-bit signed value right by a particular number of bits. + */ +__declspec(naked) void __cdecl +_allshr ( + void + ) +{ + _asm { + ; + ; Handle shifts of 64 bits or more (if shifting 64 bits or more, the result + ; depends only on the high order bit of edx). + ; + + cmp cl,64 + jae short SIGNRETURN + + ; + ; Handle shifts of between 0 and 31 bits + ; + cmp cl, 32 + jae short MORE32 + shrd eax,edx,cl + sar edx,cl + ret + + ; + ; Handle shifts of between 32 and 63 bits + ; +MORE32: + mov eax,edx + sar edx,31 + and cl,31 + sar eax,cl + ret + + ; + ; Return double precision 0 or -1, depending on the sign of edx + ; +SIGNRETURN: + sar edx,31 + mov eax,edx + ret + } +} diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldiv.c b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldiv.c new file mode 100644 index 000000000000..287af8562839 --- /dev/null +++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldiv.c @@ -0,0 +1,89 @@ +/** @file + 64-bit Math Worker Function. + The 32-bit versions of C compiler generate calls to library routines + to handle 64-bit math. These functions use non-standard calling conventions. + + Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +/* + * Divides a 64-bit unsigned value with a 64-bit unsigned value and returns + * a 64-bit unsigned result. + */ +__declspec(naked) void __cdecl +_aulldiv ( + void + ) +{ + // + // Wrapper Implementation over EDKII DivU64x64Reminder() routine + // UINT64 + // EFIAPI + // DivU64x64Remainder ( + // IN UINT64 Dividend, + // IN UINT64 Divisor, + // OUT UINT64 *Remainder OPTIONAL + // ) + // + _asm { + ; Original local stack when calling _aulldiv + ; ----------------- + ; | | + ; |---------------| + ; | | + ; |-- Divisor --| + ; | | + ; |---------------| + ; | | + ; |-- Dividend --| + ; | | + ; |---------------| + ; | ReturnAddr** | + ; ESP---->|---------------| + ; + + ; + ; Set up the local stack for NULL Reminder pointer + ; + xor eax, eax + push eax + + ; + ; Set up the local stack for Divisor parameter + ; + mov eax, [esp + 20] + push eax + mov eax, [esp + 20] + push eax + + ; + ; Set up the local stack for Dividend parameter + ; + mov eax, [esp + 20] + push eax + mov eax, [esp + 20] + push eax + + ; + ; Call native DivU64x64Remainder of BaseLib + ; + call DivU64x64Remainder + + ; + ; Adjust stack + ; + add esp, 20 + + ret 16 + } +} diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldvrm.c b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldvrm.c new file mode 100644 index 000000000000..378cdec115e5 --- /dev/null +++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldvrm.c @@ -0,0 +1,102 @@ +/** @file + 64-bit Math Worker Function. + The 32-bit versions of C compiler generate calls to library routines + to handle 64-bit math. These functions use non-standard calling conventions. + + Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +/* + * Divides a 64-bit signed value by another 64-bit signed value and returns + * the 64-bit signed result and the 64-bit signed remainder. + */ +__declspec(naked) void __cdecl +_aulldvrm ( + void + ) +{ + // + // Wrapper Implementation over EDKII DivU64x64Remainder() routine + // UINT64 + // EFIAPI + // DivU64x64Remainder ( + // IN UINT64 Dividend, + // IN UINT64 Divisor, + // OUT UINT64 *Remainder + // ) + // + _asm { + ; Original local stack when calling _aulldvrm + ; ----------------- + ; | | + ; |---------------| + ; | | + ; |-- Divisor --| + ; | | + ; |---------------| + ; | | + ; |-- Dividend --| + ; | | + ; |---------------| + ; | ReturnAddr** | + ; ESP---->|---------------| + ; + ; + ; On Exit: + ; EDX:EAX contains the quotient (dividend/ divisor) + ; EBX:ECX contains the remainder (divided % divisor) + ; NOTE: this routine removes the parameters from the stack. + ; + + ; + ; Set up the local stack for Remainder pointer + ; + sub esp, 8 + push esp + + ; + ; Set up the local stack for Divisor parameter + ; + mov eax, [esp + 28] + push eax + mov eax, [esp + 28] + push eax + + ; + ; Set up the local stack for Dividend parameter + ; + mov eax, [esp + 28] + push eax + mov eax, [esp + 28] + push eax + + ; + ; Call native DivU64x64Remainder of BaseLib + ; + call DivU64x64Remainder + + ; + ; EDX:EAX contains the quotient (dividend/ divisor) + ; Put the Remainder in EBX:ECX + ; + mov ecx, [esp + 20] + mov ebx, [esp + 24] + + ; + ; Adjust stack + ; + add esp, 28 + + ret 16 + } +} diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullrem.c b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullrem.c new file mode 100644 index 000000000000..49d0064b0f03 --- /dev/null +++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullrem.c @@ -0,0 +1,95 @@ +/** @file + 64-bit Math Worker Function. + The 32-bit versions of C compiler generate calls to library routines + to handle 64-bit math. These functions use non-standard calling conventions. + + Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +/* + * Divides a 64-bit unsigned value by another 64-bit unsigned value and returns + * the 64-bit unsigned remainder. + */ +__declspec(naked) void __cdecl +_aullrem ( + void + ) +{ + // + // Wrapper Implementation over EDKII DivU64x64Remainder() routine + // UINT64 + // EFIAPI + // DivU64x64Remainder ( + // IN UINT64 Dividend, + // IN UINT64 Divisor, + // OUT UINT64 *Remainder OPTIONAL + // ) + // + _asm { + ; Original local stack when calling _aullrem + ; ----------------- + ; | | + ; |---------------| + ; | | + ; |-- Divisor --| + ; | | + ; |---------------| + ; | | + ; |-- Dividend --| + ; | | + ; |---------------| + ; | ReturnAddr** | + ; ESP---->|---------------| + ; + + ; + ; Set up the local stack for Reminder pointer + ; + sub esp, 8 + push esp + + ; + ; Set up the local stack for Divisor parameter + ; + mov eax, [esp + 28] + push eax + mov eax, [esp + 28] + push eax + + ; + ; Set up the local stack for Dividend parameter + ; + mov eax, [esp + 28] + push eax + mov eax, [esp + 28] + push eax + + ; + ; Call native DivU64x64Remainder of BaseLib + ; + call DivU64x64Remainder + + ; + ; Put the Reminder in EDX:EAX as return value + ; + mov eax, [esp + 20] + mov edx, [esp + 24] + + ; + ; Adjust stack + ; + add esp, 28 + + ret 16 + } +} diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullshr.c b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullshr.c new file mode 100644 index 000000000000..3c21b45941a1 --- /dev/null +++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullshr.c @@ -0,0 +1,60 @@ +/** @file + 64-bit Math Worker Function. + The 32-bit versions of C compiler generate calls to library routines + to handle 64-bit math. These functions use non-standard calling conventions. + + Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +/* + * Shifts a 64-bit unsigned value right by a certain number of bits. + */ +__declspec(naked) void __cdecl +_aullshr ( + void + ) +{ + _asm { + ; + ; Checking: Only handle 64bit shifting or more + ; + cmp cl, 64 + jae _Exit + + ; + ; Handle shifting between 0 and 31 bits + ; + cmp cl, 32 + jae More32 + shrd eax, edx, cl + shr edx, cl + ret + + ; + ; Handle shifting of 32-63 bits + ; +More32: + mov eax, edx + xor edx, edx + and cl, 31 + shr eax, cl + ret + + ; + ; Invalid number (less then 32bits), return 0 + ; + +_Exit: + xor eax, eax + xor edx, edx + ret + } +} diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/ashrdi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/ashrdi3.S new file mode 100644 index 000000000000..1c629dc23bf5 --- /dev/null +++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/ashrdi3.S @@ -0,0 +1,66 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+# This program and the accompanying materials are licensed and made available +# under the terms and conditions of the BSD License which accompanies this +# distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# MathRShiftU64.S +# +# Abstract: +# +# 64-bit Math Worker Function. +# Shifts a 64-bit unsigned value right by a certain number of bits. +# +#------------------------------------------------------------------------------ + + + .686: + .code: + +ASM_GLOBAL ASM_PFX(__ashrdi3) + +#------------------------------------------------------------------------------ +# +# void __cdecl __ashrdi3 (void) +# +#------------------------------------------------------------------------------ +ASM_PFX(__ashrdi3): + # + # Checking: Only handle 64bit shifting or more + # + cmpb $64, %cl + jae _Exit + + # + # Handle shifting between 0 and 31 bits + # + cmpb $32, %cl + jae More32 + shrd %cl, %edx, %eax + shr %cl, %edx + ret + + # + # Handle shifting of 32-63 bits + # +More32: + movl %edx, %eax + xor %edx, %edx + and $32, %cl + shr %cl, %eax + ret + + # + # Invalid number (less then 32bits), return 0 + # +_Exit: + xor %eax, %eax + xor %edx, %edx + ret diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/mulll.S b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/mulll.S new file mode 100644 index 000000000000..333fdfbb9f58 --- /dev/null +++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/mulll.S @@ -0,0 +1,77 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+# This program and the accompanying materials are licensed and made available +# under the terms and conditions of the BSD License which accompanies this +# distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# MathMultS64x64.S +# +# Abstract: +# +# 64-bit Math Worker Function. +# Multiplies a 64-bit signed or unsigned value by a 64-bit signed or unsigned value +# and returns a 64-bit result +# +#------------------------------------------------------------------------------ + + .686: + .code: + +ASM_GLOBAL ASM_PFX(_mulll), ASM_PFX(MultS64x64) + +#------------------------------------------------------------------------------ +# +# void __cdecl __mulll (void) +# +#------------------------------------------------------------------------------ +ASM_PFX(__mulll): + # Original local stack when calling __mulll + # ----------------- + # | | + # |---------------| + # | | + # |--Multiplier --| + # | | + # |---------------| + # | | + # |--Multiplicand-| + # | | + # |---------------| + # | ReturnAddr** | + # ESP---->|---------------| + # + + # + # Set up the local stack for Multiplicand parameter + # + movl 16(%esp), %eax + push %eax + movl 16(%esp), %eax + push %eax + + # + # Set up the local stack for Multiplier parameter + # + movl 16(%esp), %eax + push %eax + movl 16(%esp), %eax + push %eax + + # + # Call native MulS64x64 of BaseLib + # + jmp ASM_PFX(MultS64x64) + + # + # Adjust stack + # + add $16, %esp + + ret $16 diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/shldi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/shldi3.S new file mode 100644 index 000000000000..b2a03d98337e --- /dev/null +++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/shldi3.S @@ -0,0 +1,62 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+# This program and the accompanying materials are licensed and made available +# under the terms and conditions of the BSD License which accompanies this +# distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# MathLShiftS64.S +# +# Abstract: +# +# 64-bit Math Worker Function. +# Shifts a 64-bit signed value left by a certain number of bits. +# +#------------------------------------------------------------------------------ + + .686: + .code: + +ASM_GLOBAL ASM_PFX(__ashldi3) + +#------------------------------------------------------------------------------ +# +# void __cdecl __ashldi3 (void) +# +#------------------------------------------------------------------------------ +ASM_PFX(__ashldi3): + # + # Handle shifting of 64 or more bits (return 0) + # + cmpb $64, %cl + jae ReturnZero + + # + # Handle shifting of between 0 and 31 bits + # + cmpb $32, %cl + jae More32 + shld %cl, %eax, %edx + shl %cl, %eax + ret + + # + # Handle shifting of between 32 and 63 bits + # +More32: + movl %eax, %edx + xor %eax, %eax + and $31, %cl + shl %cl, %edx + ret + +ReturnZero: + xor %eax, %eax + xor %edx, %edx + ret diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/udivdi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/udivdi3.S new file mode 100644 index 000000000000..336d75ee7c30 --- /dev/null +++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/udivdi3.S @@ -0,0 +1,83 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+# This program and the accompanying materials are licensed and made available +# under the terms and conditions of the BSD License which accompanies this +# distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# MathDivU64x64.S +# +# Abstract: +# +# 64-bit Math Worker Function. +# Divides a 64-bit unsigned value with a 64-bit unsigned value and returns +# a 64-bit unsigned result. +# +#------------------------------------------------------------------------------ + + .686: + .code: + +ASM_GLOBAL ASM_PFX(__udivdi3), ASM_PFX(DivU64x64Remainder) + +#------------------------------------------------------------------------------ +# +# void __cdecl __udivdi3 (void) +# +#------------------------------------------------------------------------------ +ASM_PFX(__udivdi3): + # Original local stack when calling __udivdi3 + # ----------------- + # | | + # |---------------| + # | | + # |-- Divisor --| + # | | + # |---------------| + # | | + # |-- Dividend --| + # | | + # |---------------| + # | ReturnAddr** | + # ESP---->|---------------| + # + + # + # Set up the local stack for NULL Reminder pointer + # + xorl %eax, %eax + push %eax + + # + # Set up the local stack for Divisor parameter + # + movl 20(%esp), %eax + push %eax + movl 20(%esp), %eax + push %eax + + # + # Set up the local stack for Dividend parameter + # + movl 20(%esp), %eax + push %eax + movl 20(%esp), %eax + push %eax + + # + # Call native DivU64x64Remainder of BaseLib + # + jmp ASM_PFX(DivU64x64Remainder) + + # + # Adjust stack + # + addl $20, %esp + + ret $16 diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/umoddi3.S b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/umoddi3.S new file mode 100644 index 000000000000..9b72e918a4ba --- /dev/null +++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/umoddi3.S @@ -0,0 +1,89 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+# This program and the accompanying materials are licensed and made available +# under the terms and conditions of the BSD License which accompanies this +# distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +# Module Name: +# +# MathReminderU64x64.S +# +# Abstract: +# +# 64-bit Math Worker Function. +# Divides a 64-bit unsigned value by another 64-bit unsigned value and returns +# the 64-bit unsigned remainder +# +#------------------------------------------------------------------------------ + + .686: + .code: + +ASM_GLOBAL ASM_PFX(__umoddi3), ASM_PFX(DivU64x64Remainder) + +#------------------------------------------------------------------------------ +# +# void __cdecl __umoddi3 (void) +# +#------------------------------------------------------------------------------ +ASM_PFX(__umoddi3): + # Original local stack when calling __umoddi3 + # ----------------- + # | | + # |---------------| + # | | + # |-- Divisor --| + # | | + # |---------------| + # | | + # |-- Dividend --| + # | | + # |---------------| + # | ReturnAddr** | + # ESP---->|---------------| + # + + # + # Set up the local stack for Reminder pointer + # + sub $8, %esp + push %esp + + # + # Set up the local stack for Divisor parameter + # + movl 28(%esp), %eax + push %eax + movl 28(%esp), %eax + push %eax + + # + # Set up the local stack for Dividend parameter + # + movl 28(%esp), %eax + push %eax + movl 28(%esp), %eax + push %eax + + # + # Call native DivU64x64Remainder of BaseLib + # + jmp ASM_PFX(DivU64x64Remainder) + + # + # Put the Reminder in EDX:EAX as return value + # + movl 20(%esp), %eax + movl 24(%esp), %edx + + # + # Adjust stack + # + add $28, %esp + + ret $16 -- 2.35.1