invokeNative_ia32.s 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. .text
  17. .align 2
  18. .globl invokeNative
  19. .type invokeNative, @function
  20. invokeNative:
  21. push %ebp
  22. movl %esp, %ebp
  23. movl 16(%ebp), %ecx /* ecx = argc */
  24. movl 12(%ebp), %edx /* edx = argv */
  25. test %ecx, %ecx
  26. jz skip_push_args /* if ecx == 0, skip pushing arguments */
  27. leal -4(%edx,%ecx,4), %edx /* edx = edx + ecx * 4 - 4 */
  28. subl %esp, %edx /* edx = edx - esp */
  29. 1:
  30. push 0(%esp,%edx)
  31. loop 1b /* loop ecx counts */
  32. skip_push_args:
  33. movl 8(%ebp), %edx /* edx = func_ptr */
  34. call *%edx
  35. leave
  36. ret