cprt0.as 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. .bss
  58. .comm operatingsystem_parameter_envp,4
  59. .comm operatingsystem_parameter_argc,4
  60. .comm operatingsystem_parameter_argv,4