3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 This is the code that supports IA32-optimized ZeroMem service
31 Input: VOID *Buffer - Pointer to buffer to clear
32 UINTN Count - Number of bytes to clear
40 Description: This function is an optimized zero-memory function.
42 Notes: This function tries to zero memory 8 bytes at a time. As a result,
43 it first picks up any misaligned bytes, then words, before getting
44 in the main loop that does the 8-byte clears.
53 ; Pick up misaligned start
bytes (get pointer
4-byte aligned
)
56 and al
, 3 ; check lower
2 bits of address
58 je _ZeroBlocks
; already aligned
?
62 ; Clear the byte memory location
68 jmp _StartByteZero
; back to top of loop
72 ; Compute how many
64-byte blocks we can clear
74 shr ecx
, 6 ; convert to
64-byte count
75 shl ecx
, 6 ; convert back to bytes
76 sub edx
, ecx
; subtract from the original count
77 shr ecx
, 6 ; and this is how many
64-byte blocks
79 ; If no
64-byte blocks
, then skip
86 pxor mm0
, mm0
; Clear mm0
89 movq QWORD PTR ds
:[edi
], mm0
90 movq QWORD PTR ds
:[edi
+8], mm0
91 movq QWORD PTR ds
:[edi
+16], mm0
92 movq QWORD PTR ds
:[edi
+24], mm0
93 movq QWORD PTR ds
:[edi
+32], mm0
94 movq QWORD PTR ds
:[edi
+40], mm0
95 movq QWORD PTR ds
:[edi
+48], mm0
96 movq QWORD PTR ds
:[edi
+56], mm0
104 emms
; Exit MMX Instruction
107 ; Zero out as many DWORDS as possible
114 ; Zero out remaining as bytes