From eb227e96bd06a5b0f2f933187a679e7fb3382cd9 Mon Sep 17 00:00:00 2001 From: bxing Date: Fri, 28 Jul 2006 07:28:19 +0000 Subject: 1. Updated function headers for all assembly function 2. Optimized register usage in SetMemXX functions in all lib instances 3. Fixed a logical error in CopyMem for all lib instances git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1139 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Library/BaseMemoryLibRepStr/Ia32/CompareMem.S | 21 ++++++---- .../BaseMemoryLibRepStr/Ia32/CompareMem.asm | 9 +++++ MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.S | 45 +++++++++++++--------- .../Library/BaseMemoryLibRepStr/Ia32/CopyMem.asm | 16 ++++++-- .../Library/BaseMemoryLibRepStr/Ia32/ScanMem16.S | 21 ++++++---- .../Library/BaseMemoryLibRepStr/Ia32/ScanMem16.asm | 9 +++++ .../Library/BaseMemoryLibRepStr/Ia32/ScanMem32.S | 21 ++++++---- .../Library/BaseMemoryLibRepStr/Ia32/ScanMem32.asm | 9 +++++ .../Library/BaseMemoryLibRepStr/Ia32/ScanMem64.S | 30 +++++++++------ .../Library/BaseMemoryLibRepStr/Ia32/ScanMem64.asm | 9 +++++ MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.S | 21 ++++++---- .../Library/BaseMemoryLibRepStr/Ia32/ScanMem8.asm | 9 +++++ MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.S | 13 ++++++- MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.asm | 8 ++++ MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.S | 20 ++++++---- .../Library/BaseMemoryLibRepStr/Ia32/SetMem16.asm | 8 ++++ MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.S | 12 ++++-- .../Library/BaseMemoryLibRepStr/Ia32/SetMem32.asm | 8 ++++ MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.S | 19 +++++---- .../Library/BaseMemoryLibRepStr/Ia32/SetMem64.asm | 8 ++++ MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.S | 11 ++++-- .../Library/BaseMemoryLibRepStr/Ia32/ZeroMem.asm | 7 ++++ .../Library/BaseMemoryLibRepStr/ZeroMemWrapper.c | 4 +- .../Library/BaseMemoryLibRepStr/x64/CompareMem.asm | 9 +++++ MdePkg/Library/BaseMemoryLibRepStr/x64/CopyMem.asm | 15 ++++++-- .../Library/BaseMemoryLibRepStr/x64/ScanMem16.asm | 9 +++++ .../Library/BaseMemoryLibRepStr/x64/ScanMem32.asm | 9 +++++ .../Library/BaseMemoryLibRepStr/x64/ScanMem64.asm | 9 +++++ .../Library/BaseMemoryLibRepStr/x64/ScanMem8.asm | 9 +++++ MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem.asm | 9 +++++ .../Library/BaseMemoryLibRepStr/x64/SetMem16.asm | 9 +++++ .../Library/BaseMemoryLibRepStr/x64/SetMem32.asm | 9 +++++ .../Library/BaseMemoryLibRepStr/x64/SetMem64.asm | 8 ++++ MdePkg/Library/BaseMemoryLibRepStr/x64/ZeroMem.asm | 7 ++++ 34 files changed, 350 insertions(+), 90 deletions(-) (limited to 'MdePkg/Library/BaseMemoryLibRepStr') diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.S index b48b8f0f1c..7901b82a44 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.S +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.S @@ -27,20 +27,27 @@ # #------------------------------------------------------------------------------ - .686: - .code: - .global _InternalMemCompareMem + +#------------------------------------------------------------------------------ +# INTN +# EFIAPI +# InternalMemCompareMem ( +# IN CONST VOID *DestinationBuffer, +# IN CONST VOID *SourceBuffer, +# IN UINTN Length +# ); +#------------------------------------------------------------------------------ _InternalMemCompareMem: push %esi push %edi - movl 12(%esp),%esi - movl 16(%esp),%edi - movl 20(%esp),%ecx + movl 12(%esp), %esi + movl 16(%esp), %edi + movl 20(%esp), %ecx repe cmpsb movzbl -1(%esi), %eax movzbl -1(%edi), %edx - subl %edx,%eax + subl %edx, %eax pop %edi pop %esi ret diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.asm index 3cf6fe7f73..1d0e7fad39 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CompareMem.asm @@ -31,6 +31,15 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; INTN +; EFIAPI +; InternalMemCompareMem ( +; IN CONST VOID *DestinationBuffer, +; IN CONST VOID *SourceBuffer, +; IN UINTN Length +; ); +;------------------------------------------------------------------------------ InternalMemCompareMem PROC USES esi edi mov esi, [esp + 12] mov edi, [esp + 16] diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.S index e80a00deb4..42695b28c4 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.S +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.S @@ -21,38 +21,45 @@ # #------------------------------------------------------------------------------ - .386: - .code: - .global _InternalMemCopyMem + +#------------------------------------------------------------------------------ +# VOID * +# EFIAPI +# InternalMemCopyMem ( +# IN VOID *Destination, +# IN VOID *Source, +# IN UINTN Count +# ); +#------------------------------------------------------------------------------ _InternalMemCopyMem: push %esi push %edi - movl 16(%esp),%esi # esi <- Source - movl 12(%esp),%edi # edi <- Destination - movl 20(%esp),%edx # edx <- Count - leal -1(%edi,%edx),%eax # eax <- End of Destination - cmpl %edi,%esi + movl 16(%esp), %esi # esi <- Source + movl 12(%esp), %edi # edi <- Destination + movl 20(%esp), %edx # edx <- Count + leal -1(%esi, %edx), %eax # eax <- End of Source + cmpl %edi, %esi jae L0 - cmpl %esi,%eax + cmpl %edi, %eax jae @CopyBackward # Copy backward if overlapped -L0: - movl %edx,%ecx - andl $3,%edx - shrl $2,%ecx +L0: + movl %edx, %ecx + andl $3, %edx + shrl $2, %ecx rep movsl # Copy as many Dwords as possible jmp @CopyBytes -@CopyBackward: - movl %eax,%edi # edi <- End of Destination - leal -1(%esi,%edx),%esi # esi <- End of Source +@CopyBackward: + movl %eax, %esi # esi <- End of Source + leal -1(%edi, %edx), %edi # edi <- End of Destination std -@CopyBytes: - movl %edx,%ecx +@CopyBytes: + movl %edx, %ecx rep movsb # Copy bytes backward cld - movl 12(%esp),%eax # eax <- Destination as return value + movl 12(%esp), %eax # eax <- Destination as return value pop %edi pop %esi ret diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.asm index 7b3e5eafee..86677ef614 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/CopyMem.asm @@ -25,14 +25,22 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; VOID * +; InternalMemCopyMem ( +; IN VOID *Destination, +; IN VOID *Source, +; IN UINTN Count +; ) +;------------------------------------------------------------------------------ InternalMemCopyMem PROC USES esi edi mov esi, [esp + 16] ; esi <- Source mov edi, [esp + 12] ; edi <- Destination mov edx, [esp + 20] ; edx <- Count - lea eax, [edi + edx - 1] ; eax <- End of Destination + lea eax, [esi + edx - 1] ; eax <- End of Source cmp esi, edi jae @F - cmp eax, esi + cmp eax, edi jae @CopyBackward ; Copy backward if overlapped @@: mov ecx, edx @@ -41,8 +49,8 @@ InternalMemCopyMem PROC USES esi edi rep movsd ; Copy as many Dwords as possible jmp @CopyBytes @CopyBackward: - mov edi, eax ; edi <- End of Destination - lea esi, [esi + edx - 1] ; esi <- End of Source + mov esi, eax ; esi <- End of Source + lea edi, [edi + edx - 1] ; edi <- End of Destination std @CopyBytes: mov ecx, edx diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.S index ec1095a5fb..1e83064573 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.S +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.S @@ -27,17 +27,24 @@ # #------------------------------------------------------------------------------ - .686: - .code: - .global _InternalMemScanMem16 + +#------------------------------------------------------------------------------ +# CONST VOID * +# EFIAPI +# InternalMemScanMem16 ( +# IN CONST VOID *Buffer, +# IN UINTN Length, +# IN UINT16 Value +# ); +#------------------------------------------------------------------------------ _InternalMemScanMem16: push %edi - movl 12(%esp),%ecx - movl 8(%esp),%edi - movl 16(%esp),%eax + movl 12(%esp), %ecx + movl 8(%esp), %edi + movl 16(%esp), %eax repne scasw - leal -2(%edi),%eax + leal -2(%edi), %eax cmovnz %ecx, %eax pop %edi ret diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.asm index 7071942ede..57fab61b77 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem16.asm @@ -31,6 +31,15 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; CONST VOID * +; EFIAPI +; InternalMemScanMem16 ( +; IN CONST VOID *Buffer, +; IN UINTN Length, +; IN UINT16 Value +; ); +;------------------------------------------------------------------------------ InternalMemScanMem16 PROC USES edi mov ecx, [esp + 12] mov edi, [esp + 8] diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.S index b51b4fecdf..b7b93d9c0c 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.S +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.S @@ -27,17 +27,24 @@ # #------------------------------------------------------------------------------ - .686: - .code: - .global _InternalMemScanMem32 + +#------------------------------------------------------------------------------ +# CONST VOID * +# EFIAPI +# InternalMemScanMem32 ( +# IN CONST VOID *Buffer, +# IN UINTN Length, +# IN UINT32 Value +# ); +#------------------------------------------------------------------------------ _InternalMemScanMem32: push %edi - movl 12(%esp),%ecx - movl 8(%esp),%edi - movl 16(%esp),%eax + movl 12(%esp), %ecx + movl 8(%esp), %edi + movl 16(%esp), %eax repne scasl - leal -4(%edi),%eax + leal -4(%edi), %eax cmovnz %ecx, %eax pop %edi ret diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.asm index e6aaf02bc3..6ac857ce16 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem32.asm @@ -31,6 +31,15 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; CONST VOID * +; EFIAPI +; InternalMemScanMem32 ( +; IN CONST VOID *Buffer, +; IN UINTN Length, +; IN UINT32 Value +; ); +;------------------------------------------------------------------------------ InternalMemScanMem32 PROC USES edi mov ecx, [esp + 12] mov edi, [esp + 8] diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.S index 49e9e07cf7..6bbb18a334 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.S +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.S @@ -27,27 +27,33 @@ # #------------------------------------------------------------------------------ - .686: - .code: - .global _InternalMemScanMem64 + +#------------------------------------------------------------------------------ +# CONST VOID * +# EFIAPI +# InternalMemScanMem64 ( +# IN CONST VOID *Buffer, +# IN UINTN Length, +# IN UINT64 Value +# ); +#------------------------------------------------------------------------------ _InternalMemScanMem64: push %edi - movl 12(%esp),%ecx - movl 16(%esp),%eax - movl 20(%esp),%edx - movl 8(%esp),%edi + movl 12(%esp), %ecx + movl 16(%esp), %eax + movl 20(%esp), %edx + movl 8(%esp), %edi L0: - cmpl (%edi),%eax - leal 8(%edi),%edi + cmpl (%edi), %eax + leal 8(%edi), %edi loopne L0 jne L1 - cmpl -4(%edi),%edx + cmpl -4(%edi), %edx jecxz L1 jne L0 L1: - leal -8(%edi),%eax + leal -8(%edi), %eax cmovne %ecx, %eax pop %edi ret - diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.asm index f9725a4a5d..ca54f13738 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem64.asm @@ -31,6 +31,15 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; CONST VOID * +; EFIAPI +; InternalMemScanMem64 ( +; IN CONST VOID *Buffer, +; IN UINTN Length, +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ InternalMemScanMem64 PROC USES edi mov ecx, [esp + 12] mov eax, [esp + 16] diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.S index da40c149e9..fe678fac26 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.S +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.S @@ -27,17 +27,24 @@ # #------------------------------------------------------------------------------ - .686: - .code: - .global _InternalMemScanMem8 + +#------------------------------------------------------------------------------ +# CONST VOID * +# EFIAPI +# InternalMemScanMem8 ( +# IN CONST VOID *Buffer, +# IN UINTN Length, +# IN UINT8 Value +# ); +#------------------------------------------------------------------------------ _InternalMemScanMem8: push %edi - movl 12(%esp),%ecx - movl 8(%esp),%edi - movb 16(%esp),%al + movl 12(%esp), %ecx + movl 8(%esp), %edi + movb 16(%esp), %al repne scasb - leal -1(%edi),%eax + leal -1(%edi), %eax cmovnz %ecx, %eax pop %edi ret diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.asm index 6ae1900189..a3f65b64fa 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ScanMem8.asm @@ -31,6 +31,15 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; CONST VOID * +; EFIAPI +; InternalMemScanMem8 ( +; IN CONST VOID *Buffer, +; IN UINTN Length, +; IN UINT8 Value +; ); +;------------------------------------------------------------------------------ InternalMemScanMem8 PROC USES edi mov ecx, [esp + 12] mov edi, [esp + 8] diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.S index 1e59587317..9dbfa284c0 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.S +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.S @@ -21,10 +21,19 @@ # #------------------------------------------------------------------------------ - .386: - .code: + .386: + .code: .global _InternalMemSetMem + +#------------------------------------------------------------------------------ +# VOID * +# InternalMemSetMem ( +# IN VOID *Buffer, +# IN UINTN Count, +# IN UINT8 Value +# ) +#------------------------------------------------------------------------------ _InternalMemSetMem: push %edi movl 16(%esp),%eax diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.asm index 495dd3f4ba..98b1ed84c2 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem.asm @@ -25,6 +25,14 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; VOID * +; InternalMemSetMem ( +; IN VOID *Buffer, +; IN UINTN Count, +; IN UINT8 Value +; ) +;------------------------------------------------------------------------------ InternalMemSetMem PROC USES edi mov eax, [esp + 16] mov edi, [esp + 8] diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.S index 3871c5c183..23860092af 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.S +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.S @@ -21,17 +21,23 @@ # #------------------------------------------------------------------------------ - .386: - .code: - .global _InternalMemSetMem16 + +#------------------------------------------------------------------------------ +# VOID * +# InternalMemSetMem16 ( +# IN VOID *Buffer, +# IN UINTN Count, +# IN UINT16 Value +# ) +#------------------------------------------------------------------------------ _InternalMemSetMem16: push %edi - movl 16(%esp),%eax - movl 8(%esp),%edi - movl 12(%esp),%ecx + movl 16(%esp), %eax + movl 8(%esp), %edi + movl 12(%esp), %ecx rep stosw - movl 8(%esp),%eax + movl 8(%esp), %eax pop %edi ret diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.asm index 483e26e2b6..7f4a8955f9 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem16.asm @@ -25,6 +25,14 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; VOID * +; InternalMemSetMem16 ( +; IN VOID *Buffer, +; IN UINTN Count, +; IN UINT16 Value +; ) +;------------------------------------------------------------------------------ InternalMemSetMem16 PROC USES edi mov eax, [esp + 16] mov edi, [esp + 8] diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.S index d7dd928c85..c11214f6d6 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.S +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.S @@ -21,10 +21,16 @@ # #------------------------------------------------------------------------------ - .386: - .code: - .global _InternalMemSetMem32 + +#------------------------------------------------------------------------------ +# VOID * +# InternalMemSetMem32 ( +# IN VOID *Buffer, +# IN UINTN Count, +# IN UINT32 Value +# ) +#------------------------------------------------------------------------------ _InternalMemSetMem32: push %edi movl 16(%esp),%eax diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.asm index 18b77ce183..5876f4a741 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem32.asm @@ -25,6 +25,14 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; VOID * +; InternalMemSetMem32 ( +; IN VOID *Buffer, +; IN UINTN Count, +; IN UINT32 Value +; ) +;------------------------------------------------------------------------------ InternalMemSetMem32 PROC USES edi mov eax, [esp + 16] mov edi, [esp + 8] diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.S index 5172c306b1..c76bbae020 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.S +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.S @@ -21,20 +21,25 @@ # #------------------------------------------------------------------------------ - .386: - #.MODEL flat,C - .code: - .global _InternalMemSetMem64 + +#------------------------------------------------------------------------------ +# VOID * +# InternalMemSetMem64 ( +# IN VOID *Buffer, +# IN UINTN Count, +# IN UINT64 Value +# ) +#------------------------------------------------------------------------------ _InternalMemSetMem64: push %edi movl 12(%esp), %ecx movl 16(%esp), %eax movl 20(%esp), %edx movl 8(%esp), %edi -L0: - mov %eax,-8(%edi,%ecx,8) - mov %edx,-4(%edi,%ecx,8) +L0: + mov %eax, -8(%edi, %ecx, 8) + mov %edx, -4(%edi, %ecx, 8) loop L0 movl %edi, %eax pop %edi diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.asm index 4679a384c6..687c18f312 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/SetMem64.asm @@ -25,6 +25,14 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; VOID * +; InternalMemSetMem64 ( +; IN VOID *Buffer, +; IN UINTN Count, +; IN UINT64 Value +; ) +;------------------------------------------------------------------------------ InternalMemSetMem64 PROC USES edi mov ecx, [esp + 12] mov eax, [esp + 16] diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.S b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.S index c3165bdc7e..7a01471ebb 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.S +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.S @@ -21,10 +21,15 @@ # #------------------------------------------------------------------------------ - .386: - .code: - .global _InternalMemZeroMem + +#------------------------------------------------------------------------------ +# VOID * +# InternalMemZeroMem ( +# IN VOID *Buffer, +# IN UINTN Count +# ); +#------------------------------------------------------------------------------ _InternalMemZeroMem: push %edi xorl %eax,%eax diff --git a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.asm b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.asm index f892250d16..b3b8b5d1f1 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/Ia32/ZeroMem.asm @@ -25,6 +25,13 @@ .model flat,C .code +;------------------------------------------------------------------------------ +; VOID * +; InternalMemZeroMem ( +; IN VOID *Buffer, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ InternalMemZeroMem PROC USES edi xor eax, eax mov edi, [esp + 8] diff --git a/MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c index 08247681c5..e2ffb5c3c2 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/ZeroMemWrapper.c @@ -30,7 +30,7 @@ This function fills Length bytes of Buffer with zeros, and returns Buffer. If Length > 0 and Buffer is NULL, then ASSERT(). - If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS – Buffer + 1), then ASSERT(). @param Buffer Pointer to the target buffer to fill with zeros. @param Length Number of bytes in Buffer to fill with zeros. @@ -47,5 +47,5 @@ ZeroMem ( { ASSERT (!(Buffer == NULL && Length > 0)); ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1)); - return InternalMemSetMem (Buffer, Length, 0); + return InternalMemZeroMem (Buffer, Length); } diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/CompareMem.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/CompareMem.asm index b8e289bb27..554bc07c64 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/x64/CompareMem.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/CompareMem.asm @@ -29,6 +29,15 @@ .code +;------------------------------------------------------------------------------ +; INTN +; EFIAPI +; InternalMemCompareMem ( +; IN CONST VOID *DestinationBuffer, +; IN CONST VOID *SourceBuffer, +; IN UINTN Length +; ); +;------------------------------------------------------------------------------ InternalMemCompareMem PROC USES rsi rdi mov rsi, rcx mov rdi, rdx diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/CopyMem.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/CopyMem.asm index 43630715cb..a2e04056fd 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/x64/CopyMem.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/CopyMem.asm @@ -23,10 +23,19 @@ .code +;------------------------------------------------------------------------------ +; VOID * +; EFIAPI +; InternalMemCopyMem ( +; IN VOID *Destination, +; IN VOID *Source, +; IN UINTN Count +; ) +;------------------------------------------------------------------------------ InternalMemCopyMem PROC USES rsi rdi mov rsi, rdx ; rsi <- Source mov rdi, rcx ; rdi <- Destination - lea r9, [rdi + r8 - 1] ; r9 <- End of Destination + lea r9, [rsi + r8 - 1] ; r9 <- End of Source cmp rsi, rdi mov rax, rdi ; rax <- Destination as return value jae @F @@ -39,8 +48,8 @@ InternalMemCopyMem PROC USES rsi rdi rep movsq ; Copy as many Qwords as possible jmp @CopyBytes @CopyBackward: - mov rdi, r9 ; rdi <- End of Destination - lea rsi, [rsi + r8 - 1] ; esi <- End of Source + mov rsi, r9 ; rsi <- End of Source + lea rdi, [rdi + r8 - 1] ; esi <- End of Destination std ; set direction flag @CopyBytes: mov rcx, r8 diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem16.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem16.asm index 6af88fae5b..a2538c2cca 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem16.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem16.asm @@ -29,6 +29,15 @@ .code +;------------------------------------------------------------------------------ +; CONST VOID * +; EFIAPI +; InternalMemScanMem16 ( +; IN CONST VOID *Buffer, +; IN UINTN Length, +; IN UINT16 Value +; ); +;------------------------------------------------------------------------------ InternalMemScanMem16 PROC USES rdi mov rdi, rcx mov rax, r8 diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem32.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem32.asm index f9c9feb00e..e0523d8547 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem32.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem32.asm @@ -29,6 +29,15 @@ .code +;------------------------------------------------------------------------------ +; CONST VOID * +; EFIAPI +; InternalMemScanMem32 ( +; IN CONST VOID *Buffer, +; IN UINTN Length, +; IN UINT32 Value +; ); +;------------------------------------------------------------------------------ InternalMemScanMem32 PROC USES rdi mov rdi, rcx mov rax, r8 diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem64.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem64.asm index 2f286c9e2f..0e7e9c782f 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem64.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem64.asm @@ -29,6 +29,15 @@ .code +;------------------------------------------------------------------------------ +; CONST VOID * +; EFIAPI +; InternalMemScanMem64 ( +; IN CONST VOID *Buffer, +; IN UINTN Length, +; IN UINT64 Value +; ); +;------------------------------------------------------------------------------ InternalMemScanMem64 PROC USES rdi mov rdi, rcx mov rax, r8 diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem8.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem8.asm index 4027ece768..879273f960 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem8.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/ScanMem8.asm @@ -29,6 +29,15 @@ .code +;------------------------------------------------------------------------------ +; CONST VOID * +; EFIAPI +; InternalMemScanMem8 ( +; IN CONST VOID *Buffer, +; IN UINTN Length, +; IN UINT8 Value +; ); +;------------------------------------------------------------------------------ InternalMemScanMem8 PROC USES rdi mov rdi, rcx mov rcx, rdx diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem.asm index b9108c750e..5306520169 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem.asm @@ -23,6 +23,15 @@ .code +;------------------------------------------------------------------------------ +; VOID * +; EFIAPI +; InternalMemSetMem ( +; IN VOID *Buffer, +; IN UINTN Count, +; IN UINT8 Value +; ) +;------------------------------------------------------------------------------ InternalMemSetMem PROC USES rdi mov rax, r8 mov rdi, rcx diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem16.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem16.asm index 3a9fd47fc3..fce9ed7ed5 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem16.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem16.asm @@ -23,6 +23,15 @@ .code +;------------------------------------------------------------------------------ +; VOID * +; EFIAPI +; InternalMemSetMem16 ( +; IN VOID *Buffer, +; IN UINTN Count, +; IN UINT16 Value +; ) +;------------------------------------------------------------------------------ InternalMemSetMem16 PROC USES rdi mov rdi, rcx mov rax, r8 diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem32.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem32.asm index 2020d19065..ce9e54da85 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem32.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem32.asm @@ -23,6 +23,15 @@ .code +;------------------------------------------------------------------------------ +; VOID * +; EFIAPI +; InternalMemSetMem32 ( +; IN VOID *Buffer, +; IN UINTN Count, +; IN UINT32 Value +; ); +;------------------------------------------------------------------------------ InternalMemSetMem32 PROC USES rdi mov rdi, rcx mov rax, r8 diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem64.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem64.asm index 70ca4fb75a..97884a36fe 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem64.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/SetMem64.asm @@ -23,6 +23,14 @@ .code +;------------------------------------------------------------------------------ +; VOID * +; InternalMemSetMem64 ( +; IN VOID *Buffer, +; IN UINTN Count, +; IN UINT64 Value +; ) +;------------------------------------------------------------------------------ InternalMemSetMem64 PROC USES rdi mov rdi, rcx mov rax, r8 diff --git a/MdePkg/Library/BaseMemoryLibRepStr/x64/ZeroMem.asm b/MdePkg/Library/BaseMemoryLibRepStr/x64/ZeroMem.asm index c18a2e27c1..c01af8e6e4 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/x64/ZeroMem.asm +++ b/MdePkg/Library/BaseMemoryLibRepStr/x64/ZeroMem.asm @@ -23,6 +23,13 @@ .code +;------------------------------------------------------------------------------ +; VOID * +; InternalMemZeroMem ( +; IN VOID *Buffer, +; IN UINTN Count +; ); +;------------------------------------------------------------------------------ InternalMemZeroMem PROC USES rdi push rcx xor rax, rax -- cgit v1.2.3