invokeNative_em64.asm 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ;
  2. ; Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. ; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. ;
  5. _TEXT SEGMENT
  6. ; rcx func_ptr
  7. ; rdx argv
  8. ; r8 n_stacks
  9. invokeNative PROC
  10. push rbp
  11. mov rbp, rsp
  12. mov r10, rcx ; func_ptr
  13. mov rax, rdx ; argv
  14. mov rcx, r8 ; n_stacks
  15. ; fill all fp args
  16. movsd xmm0, qword ptr [rax + 0]
  17. movsd xmm1, qword ptr [rax + 8]
  18. movsd xmm2, qword ptr [rax + 16]
  19. movsd xmm3, qword ptr [rax + 24]
  20. ; check for stack args
  21. cmp rcx, 0
  22. jz cycle_end
  23. mov rdx, rsp
  24. and rdx, 15
  25. jz no_abort
  26. int 3
  27. no_abort:
  28. mov rdx, rcx
  29. and rdx, 1
  30. shl rdx, 3
  31. sub rsp, rdx
  32. ; store stack args
  33. lea r9, qword ptr [rax + rcx * 8 + 56]
  34. sub r9, rsp ; offset
  35. cycle:
  36. push qword ptr [rsp + r9]
  37. loop cycle
  38. cycle_end:
  39. mov rcx, [rax + 32]
  40. mov rdx, [rax + 40]
  41. mov r8, [rax + 48]
  42. mov r9, [rax + 56]
  43. sub rsp, 32 ; shadow space
  44. call r10
  45. leave
  46. ret
  47. invokeNative ENDP
  48. _TEXT ENDS
  49. END