Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

103 righe
1.5 KiB

  1. .intel_syntax noprefix
  2. .section .rodata
  3. .global u512_1
  4. u512_1: .quad 1, 0, 0, 0, 0, 0, 0, 0
  5. .section .text
  6. .global u512_set
  7. u512_set:
  8. cld
  9. mov rax, rsi
  10. stosq
  11. xor rax, rax
  12. mov rcx, 7
  13. rep stosq
  14. ret
  15. .global u512_bit
  16. u512_bit:
  17. mov rcx, rsi
  18. and rcx, 0x3f
  19. shr rsi, 6
  20. mov rax, [rdi + 8*rsi]
  21. shr rax, cl
  22. and rax, 1
  23. ret
  24. .global u512_add3
  25. u512_add3:
  26. mov rax, [rsi + 0]
  27. add rax, [rdx + 0]
  28. mov [rdi + 0], rax
  29. .set k, 1
  30. .rept 7
  31. mov rax, [rsi + 8*k]
  32. adc rax, [rdx + 8*k]
  33. mov [rdi + 8*k], rax
  34. .set k, k+1
  35. .endr
  36. setc al
  37. movzx rax, al
  38. ret
  39. .global u512_sub3
  40. u512_sub3:
  41. mov rax, [rsi + 0]
  42. sub rax, [rdx + 0]
  43. mov [rdi + 0], rax
  44. .set k, 1
  45. .rept 7
  46. mov rax, [rsi + 8*k]
  47. sbb rax, [rdx + 8*k]
  48. mov [rdi + 8*k], rax
  49. .set k, k+1
  50. .endr
  51. setc al
  52. movzx rax, al
  53. ret
  54. .global u512_mul3_64
  55. u512_mul3_64:
  56. mulx r10, rax, [rsi + 0]
  57. mov [rdi + 0], rax
  58. mulx r11, rax, [rsi + 8]
  59. add rax, r10
  60. mov [rdi + 8], rax
  61. mulx r10, rax, [rsi + 16]
  62. adcx rax, r11
  63. mov [rdi + 16], rax
  64. mulx r11, rax, [rsi + 24]
  65. adcx rax, r10
  66. mov [rdi + 24], rax
  67. mulx r10, rax, [rsi + 32]
  68. adcx rax, r11
  69. mov [rdi + 32],rax
  70. mulx r11, rax, [rsi + 40]
  71. adcx rax, r10
  72. mov [rdi + 40],rax
  73. mulx r10, rax, [rsi + 48]
  74. adcx rax, r11
  75. mov [rdi + 48],rax
  76. mulx r11, rax, [rsi + 56]
  77. adcx rax, r10
  78. mov [rdi + 56],rax
  79. ret