cprt0.as 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. .file "cprt0.s"
  2. .data
  3. .align 4
  4. default_environ:
  5. .long 0
  6. .text
  7. .globl _start
  8. .type _start,@function
  9. _start:
  10. pushl %ebp
  11. movl %esp,%ebp
  12. subl $4,%esp
  13. pushl %ebx
  14. call .L6
  15. .L6:
  16. popl %ebx
  17. addl $_GLOBAL_OFFSET_TABLE_+[.-.L6],%ebx
  18. movl argv_save@GOT(%ebx),%eax
  19. movl 12(%ebp),%edi
  20. movl %edi,(%eax)
  21. movl environ@GOT(%ebx),%eax
  22. movl 16(%ebp),%esi
  23. movl %esi,(%eax)
  24. test %esi,%esi
  25. jnz .L4
  26. movl environ@GOT(%ebx),%eax
  27. movl %ebx,%ecx
  28. addl $default_environ@GOTOFF,%ecx
  29. movl %ecx,%edx
  30. movl %edx,(%eax)
  31. .L4:
  32. /* movl %fs:0x4,%eax this doesn't work on BeOS 4.0, let's use find_thread instead */
  33. pushl $0x0
  34. call find_thread
  35. movl __main_thread_id@GOT(%ebx),%edx
  36. movl %eax,(%edx)
  37. pushl %esi
  38. pushl %edi
  39. movl 8(%ebp),%eax
  40. pushl %eax
  41. call _init_c_library_
  42. call _call_init_routines_
  43. movl 8(%ebp),%eax
  44. movl %eax,operatingsystem_parameter_argc
  45. movl %edi,operatingsystem_parameter_argv
  46. movl %esi,operatingsystem_parameter_envp
  47. xorl %ebp,%ebp
  48. call PASCALMAIN
  49. .globl _haltproc
  50. .type _haltproc,@function
  51. _haltproc:
  52. call _thread_do_exit_notification
  53. xorl %ebx,%ebx
  54. movw operatingsystem_result,%bx
  55. pushl %ebx
  56. call exit
  57. /* int sys_open (int=0xFF000000, char * name, int mode, int=0, int close_on_exec=0); */
  58. .globl sys_open
  59. .type sys_open,@function
  60. sys_open:
  61. xorl %eax,%eax
  62. int $0x25
  63. ret
  64. /* int sys_close (int handle) */
  65. .globl sys_close
  66. .type sys_close,@function
  67. sys_close:
  68. mov $0x01,%eax
  69. int $0x25
  70. ret
  71. /* int sys_read (int handle, void * buffer, int length) */
  72. .globl sys_read
  73. .type sys_read,@function
  74. sys_read:
  75. movl $0x02,%eax
  76. int $0x25
  77. ret
  78. /* int sys_write (int handle, void * buffer, int length) */
  79. .globl sys_write
  80. .type sys_write,@function
  81. sys_write:
  82. movl $0x3,%eax
  83. int $0x25
  84. ret
  85. /* int sys_lseek (int handle, long long pos, int whence) */
  86. .globl sys_lseek
  87. .type sys_lseek,@function
  88. sys_lseek:
  89. movl $0x5,%eax
  90. int $0x25
  91. ret
  92. /* int sys_time(void) */
  93. .globl sys_time
  94. .type sys_time,@function
  95. sys_time:
  96. movl $0x7,%eax
  97. int $0x25
  98. ret
  99. /* int sys_resize_area */
  100. .globl sys_resize_area
  101. .type sys_resize_area,@function
  102. sys_resize_area:
  103. movl $0x8,%eax
  104. int $0x25
  105. ret
  106. /* int sys_opendir (0xFF000000, chra * name, 0) */
  107. .globl sys_opendir
  108. .type sys_opendir,@function
  109. sys_opendir:
  110. movl $0xC,%eax
  111. int $0x25
  112. ret
  113. /* int sys_create_area */
  114. .globl sys_create_area
  115. .type sys_create_area,@function
  116. sys_create_area:
  117. movl $0x14,%eax
  118. int $0x25
  119. ret
  120. /* int sys_readdir (int handle, void * dirent, 0x11C, 0x01000000) */
  121. .globl sys_readdir
  122. .type sys_readdir,@function
  123. sys_readdir:
  124. movl $0x1C,%eax
  125. int $0x25
  126. ret
  127. /* int sys_mkdir (char=0xFF, char * name, int mode) */
  128. .globl sys_mkdir
  129. .type sys_mkdir,@function
  130. sys_mkdir:
  131. movl $0x1E,%eax
  132. int $0x25
  133. ret
  134. /* int sys_wait_for_thread */
  135. .globl sys_wait_for_thread
  136. .type sys_wait_for_thread,@function
  137. sys_wait_for_thread:
  138. movl $0x22,%eax
  139. int $0x25
  140. ret
  141. /* int sys_rename (int=0xFF000000, char * name, int=0xFF000000, char * newname) */
  142. .globl sys_rename
  143. .type sys_rename,@function
  144. sys_rename:
  145. movl $0x26,%eax
  146. int $0x25
  147. ret
  148. /* int sys_unlink (int=0xFF000000, char * name) */
  149. .globl sys_unlink
  150. .type sys_unlink,@function
  151. sys_unlink:
  152. movl $0x27,%eax
  153. int $0x25
  154. ret
  155. /* int sys_stat (int=0xFF000000, char * name, struct stat * s, int=0) */
  156. .globl sys_stat
  157. .type sys_stat,@function
  158. sys_stat:
  159. movl $0x30,%eax
  160. int $0x25
  161. ret
  162. /* int sys_load_image */
  163. .globl sys_load_image
  164. .type sys_load_image,@function
  165. sys_load_image:
  166. movl $0x34,%eax
  167. int $0x25
  168. ret
  169. /* void sys_exit (int exitcode) */
  170. .globl sys_exit
  171. .type sys_exit,@function
  172. sys_exit:
  173. movl $0x3F,%eax
  174. int $0x25
  175. /* void sys_chdir (char 0xFF, char * name) */
  176. .globl sys_chdir
  177. .type sys_chdir,@function
  178. sys_chdir:
  179. movl $0x57,%eax
  180. int $0x25
  181. ret
  182. /* void sys_rmdir (char 0xFF, char * name) */
  183. .globl sys_rmdir
  184. .type sys_rmdir,@function
  185. sys_rmdir:
  186. movl $0x60,%eax
  187. int $0x25
  188. ret
  189. /* actual syscall */
  190. .globl sys_call
  191. .type sys_call,@function
  192. sys_call:
  193. int $0x25
  194. ret
  195. .bss
  196. .comm operatingsystem_parameter_envp,4
  197. .comm operatingsystem_parameter_argc,4
  198. .comm operatingsystem_parameter_argv,4