invokeNative_ia32.s 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // Licensed to the Apache Software Foundation (ASF) under one or more
  15. // contributor license agreements. See the NOTICE file distributed with
  16. // this work for additional information regarding copyright ownership.
  17. // The ASF licenses this file to You under the Apache License, Version 2.0
  18. // (the "License"); you may not use this file except in compliance with
  19. // the License. You may obtain a copy of the License at
  20. //
  21. // http://www.apache.org/licenses/LICENSE-2.0
  22. //
  23. // Unless required by applicable law or agreed to in writing, software
  24. // distributed under the License is distributed on an "AS IS" BASIS,
  25. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  26. // See the License for the specific language governing permissions and
  27. // limitations under the License.
  28. //
  29. // Author: Ivan Volosyuk
  30. //
  31. .text
  32. .align 2
  33. .globl invokeNative
  34. .type invokeNative, @function
  35. invokeNative:
  36. push %ebp
  37. movl %esp, %ebp
  38. push %ecx
  39. movl 8(%ebp), %eax /* eax = argv */
  40. movl 12(%ebp), %ecx /* ecx = argc */
  41. test %ecx, %ecx
  42. je restore_ecx /* if ecx == 0, skip pushing arguments */
  43. leal -4(%eax,%ecx,4), %eax /* eax = eax + ecx * 4 - 4 */
  44. subl %esp, %eax /* eax = eax - esp */
  45. 1:
  46. push 0(%esp,%eax)
  47. loop 1b /* loop ecx counts */
  48. restore_ecx:
  49. movl -4(%ebp), %ecx /* restore ecx */
  50. movl 16(%ebp), %eax /* eax = func_ptr */
  51. call *%eax
  52. leave
  53. ret