From 9252fc0e1a9050fc07eaeb862c3943bfbbf0e201 Mon Sep 17 00:00:00 2001 From: Savva Mitrofanov Date: Mon, 6 Feb 2023 23:06:26 +0600 Subject: [PATCH] CryptoPkg/IntrinsicLib: Corrects __ashrdi3 and adds __lshrdi3 The ashrdi3 function should do arithmetic shift instead of logic using sar instruction. Also adds __lshrdi3 implementation to correct build using LLVM Signed-off-by: Savva Mitrofanov --- .../IntrinsicLib/Ia32/MathRShiftU64.nasm | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/CryptoPkg/Library/IntrinsicLib/Ia32/MathRShiftU64.nasm b/CryptoPkg/Library/IntrinsicLib/Ia32/MathRShiftU64.nasm index 1d51a4dfa3..25a7296648 100644 --- a/CryptoPkg/Library/IntrinsicLib/Ia32/MathRShiftU64.nasm +++ b/CryptoPkg/Library/IntrinsicLib/Ia32/MathRShiftU64.nasm @@ -23,6 +23,31 @@ ;------------------------------------------------------------------------------ global ASM_PFX(__ashrdi3) ASM_PFX(__ashrdi3): + cmp cl,0x40 + jnc ReturnZero + cmp cl,0x20 + jnc CounterMore32 + shrd eax,edx,cl + sar edx,cl + ret +CounterMore32: + mov eax,edx + xor edx,edx + and cl,0x1f + sar eax,cl + ret +ReturnZero: + xor eax,eax + xor edx,edx + ret + +;------------------------------------------------------------------------------ +; +; void __cdecl __lshrdi3 (void) +; +;------------------------------------------------------------------------------ +global ASM_PFX(__lshrdi3) +ASM_PFX(__lshrdi3): cmp cl,0x40 jnc _Exit cmp cl,0x20 @@ -40,4 +65,3 @@ _Exit: xor eax,eax xor edx,edx ret -