• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#------------------------------------------------------------------------------
2#
3# Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4# 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.
8#
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.
11#
12# Module Name:
13#
14#   SetMem.asm
15#
16# Abstract:
17#
18#   SetMem function
19#
20# Notes:
21#
22#------------------------------------------------------------------------------
23
24ASM_GLOBAL ASM_PFX(InternalMemSetMem)
25
26#------------------------------------------------------------------------------
27#  VOID *
28#  InternalMemSetMem (
29#    IN VOID   *Buffer,
30#    IN UINTN  Count,
31#    IN UINT8  Value
32#    )
33#------------------------------------------------------------------------------
34ASM_PFX(InternalMemSetMem):
35    push    %edi
36    movb    16(%esp), %al
37    movb    %al, %ah
38    shrdl   $16, %eax, %edx
39    shldl   $16, %edx, %eax
40    movl    12(%esp), %ecx              # ecx <- Count
41    movl    8(%esp), %edi               # edi <- Buffer
42    movl    %ecx, %edx
43    andl    $7, %edx
44    shrl    $3, %ecx                    # # of Qwords to set
45    jz      L1
46    addl    $-16, %esp
47    movq    %mm0, (%esp)                # save mm0
48    movq    %mm1, 8(%esp)               # save mm1
49    movd    %eax, %mm0
50    movd    %eax, %mm1
51    psllq   $32, %mm0
52    por     %mm1, %mm0                  # fill mm0 with 8 Value's
53L0:
54    movq    %mm0, (%edi)
55    addl    $8, %edi
56    loop    L0
57    movq    (%esp), %mm0                # restore mm0
58    movq    8(%esp), %mm1               # restore mm1
59    addl    $0x10, %esp                 # stack cleanup
60L1:
61    movl    %edx, %ecx
62    rep
63    stosb
64    movl    8(%esp), %eax               # eax <- Buffer as return value
65    pop     %edi
66    ret
67