You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
938 B

  1. ;;;;;;;;;;;;;;;;;;;;;;
  2. ; rawCopyS2L
  3. ;;;;;;;;;;;;;;;;;;;;;;
  4. ; Convert a 64 bit integer to a long format field element
  5. ; Params:
  6. ; rsi <= the integer
  7. ; rdi <= Pointer to the overwritted element
  8. ;
  9. ; Nidified registers:
  10. ; rax
  11. ;;;;;;;;;;;;;;;;;;;;;;;
  12. rawCopyS2L:
  13. mov al, 0x80
  14. shl rax, 56
  15. mov [rdi], rax ; set the result to LONG normal
  16. cmp rsi, 0
  17. js u64toLong_adjust_neg
  18. mov [rdi + 8], rsi
  19. xor rax, rax
  20. <% for (let i=1; i<n64; i++) { %>
  21. mov [rdi + <%= 8+i*8 %>], rax
  22. <% } %>
  23. ret
  24. u64toLong_adjust_neg:
  25. add rsi, [q] ; Set the first digit
  26. mov [rdi + 8], rsi ;
  27. mov rsi, -1 ; all ones
  28. <% for (let i=1; i<n64; i++) { %>
  29. mov rax, rsi ; Add to q
  30. adc rax, [q + <%= i*8 %> ]
  31. mov [rdi + <%= (i+1)*8 %>], rax
  32. <% } %>
  33. ret