prelude.as 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #
  2. # $Id: prelude.as,v 1.2 2003/03/25 18:17:54 armin Exp $
  3. # This file is part of the Free Pascal run time library.
  4. # Copyright (c) 1999-2002 by the Free Pascal development team
  5. # Copyright (c) 2002 Armin Diehl
  6. #
  7. # This is the (prelude-like) startup code for netware before 4.11
  8. #
  9. # See the file COPYING.FPC, included in this distribution,
  10. # for details about the copyright.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. #
  16. #**********************************************************************
  17. .file "nwpre.as"
  18. .text
  19. #
  20. # This is the main program (not loader) Entry-Point that will be called by netware
  21. # it sets up the argc and argv and calls _nlm_main (in system.pp)
  22. # This version uses the old _SetupArgv and not the newer _SetupArvV_411
  23. #
  24. .globl _pas_Start_
  25. _pasStart_:
  26. pushl $_nlm_main
  27. call _SetupArgv
  28. addl $4,%esp
  29. ret
  30. # this is a hack to avoid that FPC_NW_CHECKFUNCTION will be
  31. # eleminated by the linker (with smartlinking)
  32. call FPC_NW_CHECKFUNCTION
  33. #
  34. # this will be called by the loader, we pass the address of _pasStart_ and
  35. # _NLMID (needed by clib) and netware is doing the work
  36. #
  37. .globl _Prelude
  38. _Prelude:
  39. pushl %ebp
  40. movl %esp,%ebp
  41. pushl %edi
  42. pushl %esi
  43. pushl %ebx
  44. movl 0x14(%ebp),%edi
  45. movl 0x18(%ebp),%esi
  46. movl %esi, __uninitializedDataSize
  47. movl 0x1c(%ebp),%ebx
  48. movl 0x20(%ebp),%ecx
  49. movl 0x28(%ebp),%eax
  50. pushl $_pasStart_
  51. pushl $_NLMID
  52. pushl %eax
  53. movl 0x24(%ebp),%edx
  54. pushl %edx
  55. pushl %ecx
  56. pushl %ebx
  57. pushl %esi
  58. pushl %edi
  59. movl 0x10(%ebp),%edx
  60. pushl %edx
  61. movl 0xc(%ebp),%edx
  62. pushl %edx
  63. movl 0x8(%ebp),%edx
  64. pushl %edx
  65. call _StartNLM
  66. test %eax,%eax
  67. jne x1
  68. xorl %eax,%eax # dont know why this is needed ?
  69. x1:
  70. lea 0xfffffff4(%ebp),%esp
  71. popl %ebx
  72. popl %esi
  73. popl %edi
  74. movl %ebp,%esp
  75. popl %ebp
  76. ret
  77. #
  78. # the global stop-function
  79. #
  80. .globl _Stop
  81. _Stop:
  82. pushl $0x5 # TERMINATE_BY_UNLOAD=0, TERMINATE_BY_EXTERNAL_THREAD=0
  83. pushl $0x0
  84. movl _NLMID,%edx
  85. pushl %edx
  86. call _TerminateNLM
  87. addl $0x0c,%esp
  88. ret
  89. .data
  90. # argc is defined in the novell prelude, i assume it is not needed
  91. #_argc:
  92. # .long 0
  93. _NLMID:
  94. .long 0
  95. .text
  96. .globl __getTextStart
  97. __getTextStart:
  98. movl $.text,%eax
  99. ret
  100. .text
  101. .globl __getDataStart
  102. __getDataStart:
  103. movl $.data,%eax
  104. ret
  105. .text
  106. .globl __getBssStart
  107. __getBssStart:
  108. movl $.bss,%eax
  109. ret
  110. .data
  111. __uninitializedDataSize: .long
  112. .text
  113. .globl __getUninitializedDataSize
  114. __getUninitializedDataSize:
  115. movl __uninitializedDataSize, %eax
  116. ret