prt0.as 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. #
  2. # $Id$
  3. # This file is part of the Free Pascal run time library.
  4. # Copyright (c) 1993,97 by the Free Pascal development team.
  5. #
  6. # See the file COPYING.FPC, included in this distribution,
  7. # for details about the copyright.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. #
  13. # **********************************************************************
  14. #///*
  15. #//** Called as start(argc, argv, envp)
  16. #//*/
  17. #///* gs:edx points to prog_info structure. All other registers are OBSOLETE
  18. #//** but included for backwards compatibility
  19. #//*/
  20. .text
  21. .globl _start
  22. _start:
  23. .globl start
  24. start:
  25. # the first instruction must be movl %eax,
  26. # because that is the way GO32V2 makes the difference between V1 and V2 coff format
  27. movl %eax,__hard_master
  28. movl %esi,___pid
  29. movl %edi,___transfer_buffer
  30. movl %ebx,_ScreenPrimary
  31. movl %ebp,_ScreenSecondary
  32. cmpl $0, %edx
  33. je Lcopy_none
  34. movw %gs,%cx
  35. movw %ds,%ax
  36. cmpw %cx,%ax
  37. je Lcopy_none
  38. # /* set the right size */
  39. movl $40,U_SYSTEM_GO32_INFO_BLOCK
  40. movl %gs:(%edx), %ecx
  41. cmpl U_SYSTEM_GO32_INFO_BLOCK, %ecx
  42. jbe Lcopy_less
  43. movl U_SYSTEM_GO32_INFO_BLOCK, %ecx
  44. Lcopy_less:
  45. movl $U_SYSTEM_GO32_INFO_BLOCK, %edi
  46. addl $3, %ecx
  47. andl $0xfffffffc, %ecx
  48. movl %ecx, (%edi)
  49. addl $4, %edi
  50. addl $4, %edx
  51. subl $4, %ecx
  52. Lcopy_more:
  53. movl %gs:(%edx), %eax
  54. movl %eax, (%edi)
  55. addl $4, %edx
  56. addl $4, %edi
  57. subl $4, %ecx
  58. jnz Lcopy_more
  59. movl U_SYSTEM_GO32_INFO_BLOCK+4, %eax
  60. movl %eax, _ScreenPrimary
  61. movl U_SYSTEM_GO32_INFO_BLOCK+8, %eax
  62. movl %eax, _ScreenSecondary
  63. movl U_SYSTEM_GO32_INFO_BLOCK+12, %eax
  64. movl %eax, ___transfer_buffer
  65. movl U_SYSTEM_GO32_INFO_BLOCK+20, %eax
  66. movl %eax, ___pid
  67. movl U_SYSTEM_GO32_INFO_BLOCK+24, %eax
  68. movl %eax, __hard_master
  69. jmp Lcopy_done
  70. Lcopy_none:
  71. movl %ebx,U_SYSTEM_GO32_INFO_BLOCK+4
  72. movl %ebp,U_SYSTEM_GO32_INFO_BLOCK+8
  73. movl %edi,U_SYSTEM_GO32_INFO_BLOCK+12
  74. movl $4096,U_SYSTEM_GO32_INFO_BLOCK+16
  75. movl %esi,U_SYSTEM_GO32_INFO_BLOCK+20
  76. movl %eax,U_SYSTEM_GO32_INFO_BLOCK+24
  77. movl $28, U_SYSTEM_GO32_INFO_BLOCK
  78. Lcopy_done:
  79. movw U_SYSTEM_GO32_INFO_BLOCK+36,%ax
  80. movw %ax,_run_mode
  81. #/* I need a value for the stack bottom, */
  82. #/* but I don't know how to get it from go32 */
  83. #/* I suppose the stack is 4Ko long, is this true ? */
  84. movl %esp,%eax
  85. subl $0x4000,%eax
  86. movl %eax,__stkbottom
  87. movw U_SYSTEM_GO32_INFO_BLOCK+26,%ax
  88. movw %ax,_core_selector
  89. movl U_SYSTEM_GO32_INFO_BLOCK+28,%eax
  90. movl %eax,U_SYSTEM_STUB_INFO
  91. xorl %esi,%esi
  92. xorl %edi,%edi
  93. xorl %ebp,%ebp
  94. xorl %ebx,%ebx
  95. movl %esp,%ebx
  96. movl $0x0,%ebp
  97. movl %esp,%ebx
  98. movl 8(%ebx),%eax
  99. movl %eax,_environ
  100. movl 4(%ebx),%eax
  101. movl %eax,_args
  102. movl (%ebx),%eax
  103. movl %eax,_argc
  104. call PASCALMAIN
  105. exit_again:
  106. movl $0x4c00,%eax
  107. int $0x21
  108. jmp exit_again
  109. ret
  110. .data
  111. .globl _argc
  112. _argc:
  113. .long 0
  114. .globl _args
  115. _args:
  116. .long 0
  117. .globl _run_mode
  118. _run_mode:
  119. .word 0
  120. .globl _core_selector
  121. _core_selector:
  122. .word 0
  123. .globl _environ
  124. _environ:
  125. .long 0
  126. .globl ___pid
  127. ___pid:
  128. .long 42
  129. .globl ___transfer_buffer
  130. ___transfer_buffer:
  131. .long 0
  132. .globl _ScreenPrimary
  133. _ScreenPrimary:
  134. .long 0
  135. .globl _ScreenSecondary
  136. _ScreenSecondary:
  137. .long 0
  138. .globl __hard_master
  139. .globl __hard_slave
  140. .globl __core_select
  141. __hard_master:
  142. .byte 0
  143. __hard_slave:
  144. .byte 0
  145. __core_select:
  146. .short 0
  147. .globl __stkbottom
  148. __stkbottom:
  149. .long 0
  150. # .globl U_SYSTEM_GO32_INFO_BLOCK
  151. # U_SYSTEM_GO32_INFO_BLOCK:
  152. # .long __go32_end - U_SYSTEM_GO32_INFO_BLOCK #//* size */
  153. # .long 0 #//* offs 4 linear_address_of_primary_screen; */
  154. # .long 0 #//* offs 8 linear_address_of_secondary_screen; */
  155. # .long 0 #//* offs 12 linear_address_of_transfer_buffer; */
  156. # .long 0 #//* offs 16 size_of_transfer_buffer; >= 4k */
  157. # .long 0 #//* offs 20 pid; */
  158. # .byte 0 #//* offs 24 u_char master_interrupt_controller_base; */
  159. # .byte 0 #//* offs 25 u_char slave_interrupt_controller_base; */
  160. # .word 0 #//* offs 26 u_short selector_for_linear_memory; */
  161. # .long 0 #//* offs 28 u_long linear_address_of_stub_info_structure; */
  162. # .long 0 #//* offs 32 u_long linear_address_of_original_psp; */
  163. # .word 0 #//* offs 36 u_short run_mode; */
  164. # .word 0 #//* offs 38 u_short run_mode_info; */
  165. #__go32_end: