SetMem.S 2.4 KB

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