si_prc.inc 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2005 by Michael Van Canneyt, Peter Vreman,
  4. & Daniel Mantione, members of the Free Pascal development team.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {******************************************************************************
  12. Process start/halt
  13. ******************************************************************************}
  14. var
  15. dlexitproc : pointer;
  16. function fpc_getgot : pointer; [external name 'FPC_GETGOT'];
  17. procedure _FPC_proc_start; assembler; nostackframe; public name '_start';
  18. asm
  19. { first stack frame }
  20. mov %g0, %fp
  21. { space for arguments }
  22. sub %sp, 6*8, %sp
  23. {$ifdef FPC_PIC}
  24. sethi %hi(_GLOBAL_OFFSET_TABLE_-8),%l7
  25. or %l7,%lo(_GLOBAL_OFFSET_TABLE_-4),%l7
  26. call FPC_GETGOT
  27. nop
  28. {$endif FPC_PIC}
  29. { extract argc }
  30. ldx [%sp+STACK_BIAS+22*8], %o2
  31. sethi %hi(operatingsystem_parameter_argc),%o1
  32. or %o1,%lo(operatingsystem_parameter_argc),%o1
  33. {$ifdef FPC_PIC}
  34. ldx [%o1+%l7],%o1
  35. {$endif FPC_PIC}
  36. st %o2, [%o1]
  37. { extract argv }
  38. add %sp, STACK_BIAS+23*8, %o0
  39. sethi %hi(operatingsystem_parameter_argv),%o1
  40. or %o1,%lo(operatingsystem_parameter_argv),%o1
  41. {$ifdef FPC_PIC}
  42. ldx [%o1+%l7], %o1
  43. {$endif FPC_PIC}
  44. stx %o0, [%o1]
  45. { envp=argv+(argc+1)*8 }
  46. inc %o2
  47. sllx %o2, 3, %o2
  48. add %o2, %o0, %o2
  49. sethi %hi(operatingsystem_parameter_envp),%o1
  50. or %o1,%lo(operatingsystem_parameter_envp),%o1
  51. {$ifdef FPC_PIC}
  52. ldx [%o1+%l7], %o1
  53. {$endif FPC_PIC}
  54. stx %o2, [%o1]
  55. { Save initial stackpointer }
  56. sethi %hi(initialstkptr),%o1
  57. or %o1,%lo(initialstkptr),%o1
  58. {$ifdef FPC_PIC}
  59. ldx [%o1+%l7], %o1
  60. {$endif FPC_PIC}
  61. stx %sp, [%o1]
  62. { Call main program }
  63. call PASCALMAIN
  64. nop
  65. { we shuld never return here }
  66. unimp
  67. end;
  68. procedure _FPC_dynamic_proc_start; assembler; nostackframe; public name '_dynamic_start';
  69. asm
  70. end;
  71. procedure _FPC_proc_haltproc(e:longint); cdecl; public name '_haltproc';
  72. begin
  73. if assigned(dlexitproc) then
  74. TProcedure(dlexitproc);
  75. { try to exit_group }
  76. while true do
  77. asm
  78. ld e,%o0
  79. mov 188, %g1
  80. ta 0x6d
  81. end;
  82. end;