]>
Commit | Line | Data |
---|---|---|
b1ff428c | 1 | #\r |
2 | # ConvertAsm.py: Automatically generated from SetMem.asm\r | |
3 | #\r | |
4 | #------------------------------------------------------------------------------\r | |
5 | #\r | |
373ade0e | 6 | # Copyright (c) 2006 - 2008, Intel Corporation\r |
b1ff428c | 7 | # All rights reserved. This program and the accompanying materials\r |
8 | # are licensed and made available under the terms and conditions of the BSD License\r | |
9 | # which accompanies this distribution. The full text of the license may be found at\r | |
10 | # http://opensource.org/licenses/bsd-license.php\r | |
11 | #\r | |
12 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | #\r | |
15 | # Module Name:\r | |
16 | #\r | |
17 | # SetMem.S\r | |
18 | #\r | |
19 | # Abstract:\r | |
20 | #\r | |
21 | # SetMem function\r | |
22 | #\r | |
23 | # Notes:\r | |
24 | #\r | |
25 | #------------------------------------------------------------------------------\r | |
26 | \r | |
27 | \r | |
28 | #------------------------------------------------------------------------------\r | |
29 | # VOID *\r | |
30 | # EFIAPI\r | |
31 | # InternalMemSetMem (\r | |
32 | # IN VOID *Buffer,\r | |
33 | # IN UINTN Count,\r | |
34 | # IN UINT8 Value\r | |
35 | # )\r | |
36 | #------------------------------------------------------------------------------\r | |
37 | .intel_syntax noprefix\r | |
38 | .globl ASM_PFX(InternalMemSetMem)\r | |
39 | ASM_PFX(InternalMemSetMem):\r | |
40 | push rdi\r | |
41 | mov rdi, rcx # rdi <- Buffer\r | |
42 | mov al, r8b # al <- Value\r | |
43 | mov r9, rdi # r9 <- Buffer as return value\r | |
44 | xor rcx, rcx\r | |
45 | sub rcx, rdi\r | |
46 | and rcx, 15 # rcx + rdi aligns on 16-byte boundary\r | |
47 | jz L0\r | |
48 | cmp rcx, rdx\r | |
49 | cmova rcx, rdx\r | |
50 | sub rdx, rcx\r | |
51 | rep stosb\r | |
52 | L0:\r | |
53 | mov rcx, rdx\r | |
54 | and rdx, 15\r | |
55 | shr rcx, 4\r | |
56 | jz L_SetBytes\r | |
57 | mov ah, al # ax <- Value repeats twice\r | |
58 | movdqa [rsp + 0x10], xmm0 # save xmm0\r | |
59 | movd xmm0, eax # xmm0[0..16] <- Value repeats twice\r | |
60 | pshuflw xmm0, xmm0, 0 # xmm0[0..63] <- Value repeats 8 times\r | |
61 | movlhps xmm0, xmm0 # xmm0 <- Value repeats 16 times\r | |
62 | L1:\r | |
63 | movntdq [rdi], xmm0 # rdi should be 16-byte aligned\r | |
64 | add rdi, 16\r | |
65 | loop L1\r | |
66 | mfence\r | |
67 | movdqa xmm0, [rsp + 0x10] # restore xmm0\r | |
68 | L_SetBytes:\r | |
69 | mov ecx, edx # high 32 bits of rcx are always zero\r | |
70 | rep stosb\r | |
71 | mov rax, r9 # rax <- Return value\r | |
72 | pop rdi\r | |
73 | ret\r |