ns-eel-addfuncs.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. Nullsoft Expression Evaluator Library (NS-EEL)
  3. Copyright (C) 1999-2003 Nullsoft, Inc.
  4. ns-eel-addfuncs.h: defines macros useful for adding functions to the compiler
  5. This software is provided 'as-is', without any express or implied
  6. warranty. In no event will the authors be held liable for any damages
  7. arising from the use of this software.
  8. Permission is granted to anyone to use this software for any purpose,
  9. including commercial applications, and to alter it and redistribute it
  10. freely, subject to the following restrictions:
  11. 1. The origin of this software must not be misrepresented; you must not
  12. claim that you wrote the original software. If you use this software
  13. in a product, an acknowledgment in the product documentation would be
  14. appreciated but is not required.
  15. 2. Altered source versions must be plainly marked as such, and must not be
  16. misrepresented as being the original software.
  17. 3. This notice may not be removed or altered from any source distribution.
  18. */
  19. #ifndef __NS_EEL_ADDFUNCS_H__
  20. #define __NS_EEL_ADDFUNCS_H__
  21. typedef void (*NSEEL_PPPROC)(void *data, int data_size, void **userfunc_data);
  22. // these are used for making your own naked functions in C.
  23. /*
  24. For example:
  25. static double (*__acos)(double) = &acos;
  26. __declspec ( naked ) void _asm_acos(void)
  27. {
  28. FUNC1_ENTER
  29. *__nextBlock = __acos(*parm_a);
  30. FUNC_LEAVE
  31. }
  32. __declspec ( naked ) void _asm_acos_end(void) {}
  33. If you want to do straight asm, then , well, you can use your imagination
  34. (eax, ebx, ecx are input, eax is output, all points to "double")
  35. if you need 8 bytes of temp space for your output, use esi and increment esi by 8
  36. be sure to preserve edi, too.
  37. */
  38. #define FUNC1_ENTER \
  39. double *parm_a, *__nextBlock; \
  40. __asm { mov ebp, esp } \
  41. __asm { sub esp, __LOCAL_SIZE } \
  42. __asm { mov dword ptr parm_a, eax } \
  43. __asm { mov __nextBlock, esi }
  44. #define FUNC2_ENTER \
  45. double *parm_a,*parm_b,*__nextBlock; \
  46. __asm { mov ebp, esp } \
  47. __asm { sub esp, __LOCAL_SIZE } \
  48. __asm { mov dword ptr parm_a, eax } \
  49. __asm { mov dword ptr parm_b, ebx } \
  50. __asm { mov __nextBlock, esi }
  51. #define FUNC3_ENTER \
  52. double *parm_a,*parm_b,*parm_c,*__nextBlock; \
  53. __asm { mov ebp, esp } \
  54. __asm { sub esp, __LOCAL_SIZE } \
  55. __asm { mov dword ptr parm_a, eax } \
  56. __asm { mov dword ptr parm_b, ebx } \
  57. __asm { mov dword ptr parm_c, ecx } \
  58. __asm { mov __nextBlock, esi }
  59. #define FUNC_LEAVE \
  60. __asm { mov eax, esi } \
  61. __asm { add esi, 8 } \
  62. __asm { mov esp, ebp }
  63. #define NSEEL_CGEN_CALL __fastcall
  64. #endif//__NS_EEL_ADDFUNCS_H__