nwpre.as 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #
  2. # $Id$
  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 0x1c(%ebp),%ebx
  45. movl 0x20(%ebp),%ecx
  46. movl 0x28(%ebp),%eax
  47. pushl $_pasStart_
  48. pushl $_kNLMInfo
  49. pushl %eax
  50. movl 0x24(%ebp),%edx
  51. pushl %edx
  52. pushl %ecx
  53. pushl %ebx
  54. pushl %esi
  55. pushl %edi
  56. movl 0x10(%ebp),%edx
  57. pushl %edx
  58. movl 0xc(%ebp),%edx
  59. pushl %edx
  60. movl 0x8(%ebp),%edx
  61. pushl %edx
  62. call _StartNLM
  63. test %eax,%eax
  64. jne x1
  65. xorl %eax,%eax # dont know why this is needed ?
  66. x1:
  67. lea 0xfffffff4(%ebp),%esp
  68. popl %ebx
  69. popl %esi
  70. popl %edi
  71. movl %ebp,%esp
  72. popl %ebp
  73. ret
  74. #
  75. # the global stop-function
  76. #
  77. .globl _Stop
  78. _Stop:
  79. pushl $0x5 # TERMINATE_BY_UNLOAD=0, TERMINATE_BY_EXTERNAL_THREAD=0
  80. pushl $0x0
  81. movl _kNLMInfo,%edx
  82. pushl %edx
  83. call _TerminateNLM
  84. addl $0x0c,%esp
  85. ret
  86. .data
  87. # argc is defined in the novell nwpre, i assume it is not needed
  88. #_argc:
  89. # .long 0
  90. # structure needed by clib
  91. # kNLMInfoT =
  92. # PACKED RECORD
  93. # Signature : ARRAY [0..3] OF CHAR; // LONG 'NLMI'
  94. # Flavor : LONGINT; // TRADINIONAL_FLAVOR = 0
  95. # Version : LONGINT; // TRADINIONAL_VERSION = 0, LIBERTY_VERSION = 1
  96. # LongDoubleSize : LONGINT; // gcc nwpre defines 12, watcom 8
  97. # wchar_tSize : LONGINT;
  98. # END;
  99. _kNLMInfo:
  100. .ascii "NLMI"
  101. .long 0,1,8,2