mpih-lshift.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* AMD64 (x86_64) lshift -- Left shift a limb vector and store
  2. * result in a second limb vector.
  3. *
  4. * Copyright (C) 1992, 1994, 1995, 1998,
  5. * 2001, 2002, 2006 Free Software Foundation, Inc.
  6. *
  7. * This file is part of Libgcrypt.
  8. *
  9. * Libgcrypt is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU Lesser General Public License as
  11. * published by the Free Software Foundation; either version 2.1 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * Libgcrypt is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  22. *
  23. * Note: This code is heavily based on the GNU MP Library.
  24. * Actually it's the same code with only minor changes in the
  25. * way the data is stored; this is to support the abstraction
  26. * of an optional secure memory allocation which may be used
  27. * to avoid revealing of sensitive data due to paging etc.
  28. */
  29. #include "sysdep.h"
  30. #include "asm-syntax.h"
  31. /*******************
  32. * mpi_limb_t
  33. * _gcry_mpih_lshift( mpi_ptr_t wp, rdi
  34. * mpi_ptr_t up, rsi
  35. * mpi_size_t usize, rdx
  36. * unsigned cnt) rcx
  37. */
  38. .text
  39. .globl C_SYMBOL_NAME(_gcry_mpih_lshift)
  40. C_SYMBOL_NAME(_gcry_mpih_lshift:)
  41. movq -8(%rsi,%rdx,8), %mm7
  42. movd %ecx, %mm1
  43. movl $64, %eax
  44. subl %ecx, %eax
  45. movd %eax, %mm0
  46. movq %mm7, %mm3
  47. psrlq %mm0, %mm7
  48. movd %mm7, %rax
  49. subq $2, %rdx
  50. jl .Lendo
  51. ALIGN(4) /* minimal alignment for claimed speed */
  52. .Loop: movq (%rsi,%rdx,8), %mm6
  53. movq %mm6, %mm2
  54. psrlq %mm0, %mm6
  55. psllq %mm1, %mm3
  56. por %mm6, %mm3
  57. movq %mm3, 8(%rdi,%rdx,8)
  58. je .Lende
  59. movq -8(%rsi,%rdx,8), %mm7
  60. movq %mm7, %mm3
  61. psrlq %mm0, %mm7
  62. psllq %mm1, %mm2
  63. por %mm7, %mm2
  64. movq %mm2, (%rdi,%rdx,8)
  65. subq $2, %rdx
  66. jge .Loop
  67. .Lendo: movq %mm3, %mm2
  68. .Lende: psllq %mm1, %mm2
  69. movq %mm2, (%rdi)
  70. emms
  71. ret