nwpre.as 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #
  2. # $Id: nwpre.as,v 1.3 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 (nwpre-like) startup code for netware
  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. #
  23. _pasStart_:
  24. pushl $_nlm_main
  25. call _SetupArgV_411
  26. addl $4,%esp
  27. ret
  28. # this is a hack to avoid that FPC_NW_CHECKFUNCTION will be
  29. # eleminated by the linker (with smartlinking)
  30. call FPC_NW_CHECKFUNCTION
  31. #
  32. # this will be called by the loader, we pass the address of _pasStart_ and
  33. # _kNLMInfo (needed by clib) and netware is doing the work
  34. #
  35. .globl _Prelude
  36. _Prelude:
  37. pushl %ebp
  38. movl %esp,%ebp
  39. pushl %edi
  40. pushl %esi
  41. pushl %ebx
  42. movl 0x14(%ebp),%edi
  43. movl 0x18(%ebp),%esi
  44. movl %esi, __uninitializedDataSize
  45. movl 0x1c(%ebp),%ebx
  46. movl 0x20(%ebp),%ecx
  47. movl 0x28(%ebp),%eax
  48. pushl $_pasStart_
  49. pushl $_kNLMInfo
  50. pushl %eax
  51. movl 0x24(%ebp),%edx # 1b7f6
  52. pushl %edx
  53. pushl %ecx
  54. pushl %ebx
  55. pushl %esi # uninitialized data size
  56. pushl %edi
  57. movl 0x10(%ebp),%edx
  58. pushl %edx
  59. movl 0xc(%ebp),%edx
  60. pushl %edx
  61. movl 0x8(%ebp),%edx
  62. pushl %edx
  63. call _StartNLM
  64. test %eax,%eax
  65. jne x1
  66. xorl %eax,%eax # dont know why this is needed ?
  67. x1:
  68. lea 0xfffffff4(%ebp),%esp
  69. popl %ebx
  70. popl %esi
  71. popl %edi
  72. movl %ebp,%esp
  73. popl %ebp
  74. ret
  75. #
  76. # the global stop-function
  77. #
  78. .globl _Stop
  79. _Stop:
  80. pushl $0x5 # TERMINATE_BY_UNLOAD=0, TERMINATE_BY_EXTERNAL_THREAD=0
  81. pushl $0x0
  82. movl _kNLMInfo,%edx
  83. pushl %edx
  84. call _TerminateNLM
  85. addl $0x0c,%esp
  86. ret
  87. .data
  88. # argc is defined in the novell nwpre, i assume it is not needed
  89. #_argc:
  90. # .long 0
  91. # structure needed by clib
  92. # kNLMInfoT =
  93. # PACKED RECORD
  94. # Signature : ARRAY [0..3] OF CHAR; // LONG 'NLMI'
  95. # Flavor : LONGINT; // TRADINIONAL_FLAVOR = 0
  96. # Version : LONGINT; // TRADINIONAL_VERSION = 0, LIBERTY_VERSION = 1
  97. # LongDoubleSize : LONGINT; // gcc nwpre defines 12, watcom 8
  98. # wchar_tSize : LONGINT;
  99. # END;
  100. .globl _kNLMInfo # will be used as data start
  101. _kNLMInfo:
  102. .ascii "NLMI"
  103. .long 0,1,8,2
  104. .text
  105. .globl __getTextStart
  106. __getTextStart:
  107. movl $.text,%eax
  108. ret
  109. .text
  110. .globl __getDataStart
  111. __getDataStart:
  112. movl $.data,%eax
  113. ret
  114. .text
  115. .globl __getBssStart
  116. __getBssStart:
  117. movl $.bss,%eax
  118. ret
  119. .data
  120. __uninitializedDataSize: .long
  121. .text
  122. .globl __getUninitializedDataSize
  123. __getUninitializedDataSize:
  124. movl __uninitializedDataSize, %eax
  125. ret