prt0.as 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. / prt0.s (emx+fpc) -- Made from crt0.s,
  2. / Copyright (c) 1990-1999-2001 by Eberhard Mattes.
  3. / Changed for Free Pascal in 1997 Daniel Mantione.
  4. / This code is _not_ under the Library GNU Public
  5. / License, because the original is not. See copying.emx
  6. / for details. You should have received it with this
  7. / product, write the author if you haven't.
  8. .globl __text
  9. .globl ___SYSCALL
  10. .globl __data
  11. .globl __init
  12. .globl __dos_init
  13. .globl __dos_syscall
  14. .comm _excptregptr, 4
  15. .text
  16. __text:
  17. push $__data
  18. call __dos_init
  19. jmp __init
  20. ___SYSCALL:
  21. call __dos_syscall
  22. ret
  23. .space 6, 0x90
  24. __init: cld
  25. pushl %eax
  26. pushl %eax
  27. pushl %eax
  28. movl %esp,%eax
  29. addl $4,%eax
  30. movl %eax, _excptregptr
  31. popl %eax
  32. call _main
  33. movb $0x4c,%ah
  34. call ___SYSCALL
  35. 2: jmp 2b
  36. / In executables created with emxbind, the call to _dos_init will
  37. / be fixed up at load time to _emx_init of emx.dll. Under DOS,
  38. / this dummy is called instead as there is no fixup. This module
  39. / must be linked statically to avoid having two fixups for the
  40. / same location.
  41. __dos_init:
  42. ret $4
  43. .align 2, 0x90
  44. __dos_syscall:
  45. int $0x21
  46. ret
  47. .data
  48. / The data segment starts with a table containing the start and end
  49. / addresses of the text, data and bss segments
  50. __data:
  51. .long __text
  52. .long __etext
  53. .long __data
  54. .long __edata
  55. .long __edata
  56. .long __end
  57. __heap_base:
  58. .long 0
  59. __heap_end:
  60. .long 0
  61. __heap_brk:
  62. .long 0
  63. .long 0
  64. .long __os2dll
  65. .long 0
  66. .long 0
  67. .long 0x02000000
  68. .long 0
  69. .long 0
  70. .byte 0
  71. .space 63, 0
  72. / Don't touch this. It's EMX vodoo. In short, this causes the __os2dll symbol
  73. / point to table of DLL data that the linker includes in the executable.
  74. .stabs "__os2dll", 21, 0, 0, 0xffffffff
  75. .stabs "___CTOR_LIST__", 21, 0, 0, 0xffffffff
  76. .stabs "___DTOR_LIST__", 21, 0, 0, 0xffffffff
  77. .stabs "___crtinit1__", 21, 0, 0, 0xffffffff
  78. .stabs "___crtexit1__", 21, 0, 0, 0xffffffff
  79. .stabs "___eh_frame__", 21, 0, 0, 0xffffffff