diff options
author | yi1 li <yi1.li@intel.com> | 2022-04-13 15:02:00 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-04-14 03:16:59 +0000 |
commit | 1a49e2aa3c2b80f7e988c6cf5d7ae65e700d1d19 (patch) | |
tree | 14bcc0dc89a365c841163c66f946ec8706a5b883 /CryptoPkg/Library/IntrinsicLib/Ia32/MathLlmul.asm | |
parent | 8a5727c7a82a371649419daddc2c52554ff29b16 (diff) | |
download | edk2-1a49e2aa3c2b80f7e988c6cf5d7ae65e700d1d19.tar.gz edk2-1a49e2aa3c2b80f7e988c6cf5d7ae65e700d1d19.tar.bz2 edk2-1a49e2aa3c2b80f7e988c6cf5d7ae65e700d1d19.zip |
CryptoPkg: Add instrinsics to support building ECC on IA32 windows
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3679
This dependency is needed to build openssl lib with ECC ciphers
under IA32 Windows and adds implementation for _allmul and _allshr
instrinsics.
It is taken from Project Mu:
microsoft/mu_basecore@b55b341
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: yi1 li <yi1.li@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Diffstat (limited to 'CryptoPkg/Library/IntrinsicLib/Ia32/MathLlmul.asm')
-rw-r--r-- | CryptoPkg/Library/IntrinsicLib/Ia32/MathLlmul.asm | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/CryptoPkg/Library/IntrinsicLib/Ia32/MathLlmul.asm b/CryptoPkg/Library/IntrinsicLib/Ia32/MathLlmul.asm new file mode 100644 index 0000000000..341ea8a7bc --- /dev/null +++ b/CryptoPkg/Library/IntrinsicLib/Ia32/MathLlmul.asm @@ -0,0 +1,98 @@ +;***
+;llmul.asm - long multiply routine
+;
+; Copyright (c) Microsoft Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+;Purpose:
+; Defines long multiply routine
+; Both signed and unsigned routines are the same, since multiply's
+; work out the same in 2's complement
+; creates the following routine:
+; __allmul
+;
+;Original Implemenation: MSVC 14.12.25827
+;
+;*******************************************************************************
+ .686
+ .model flat,C
+ .code
+
+
+;***
+;llmul - long multiply routine
+;
+;Purpose:
+; Does a long multiply (same for signed/unsigned)
+; Parameters are not changed.
+;
+;Entry:
+; Parameters are passed on the stack:
+; 1st pushed: multiplier (QWORD)
+; 2nd pushed: multiplicand (QWORD)
+;
+;Exit:
+; EDX:EAX - product of multiplier and multiplicand
+; NOTE: parameters are removed from the stack
+;
+;Uses:
+; ECX
+;
+;Exceptions:
+;
+;*******************************************************************************
+_allmul PROC NEAR
+
+A EQU [esp + 4] ; stack address of a
+B EQU [esp + 12] ; stack address of b
+
+HIGH_PART EQU [4] ;
+LOW_PART EQU [0]
+
+;
+; AHI, BHI : upper 32 bits of A and B
+; ALO, BLO : lower 32 bits of A and B
+;
+; ALO * BLO
+; ALO * BHI
+; + BLO * AHI
+; ---------------------
+;
+
+ mov eax,HIGH_PART(A)
+ mov ecx,HIGH_PART(B)
+ or ecx,eax ;test for both high dwords zero.
+ mov ecx,LOW_PART(B)
+ jnz short hard ;both are zero, just mult ALO and BLO
+
+ mov eax,LOW_PART(A)
+ mul ecx
+
+ ret 16 ; callee restores the stack
+
+hard:
+ push ebx
+
+; must redefine A and B since esp has been altered
+
+A2 EQU [esp + 8] ; stack address of a
+B2 EQU [esp + 16] ; stack address of b
+
+ mul ecx ;eax has AHI, ecx has BLO, so AHI * BLO
+ mov ebx,eax ;save result
+
+ mov eax,LOW_PART(A2)
+ mul dword ptr HIGH_PART(B2) ;ALO * BHI
+ add ebx,eax ;ebx = ((ALO * BHI) + (AHI * BLO))
+
+ mov eax,LOW_PART(A2);ecx = BLO
+ mul ecx ;so edx:eax = ALO*BLO
+ add edx,ebx ;now edx has all the LO*HI stuff
+
+ pop ebx
+
+ ret 16 ; callee restores the stack
+
+_allmul ENDP
+
+ end
|