si_prc.pp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2016 by the Free Pascal development team
  4. System Entry point for Atari/TOS
  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. unit si_prc;
  12. interface
  13. implementation
  14. {$i gemdos.inc}
  15. var
  16. procdesc: PPD; public name '__base';
  17. tpasize: longint;
  18. stacktop: pointer;
  19. stklen: longint; external name '__stklen';
  20. procedure PascalMain; external name 'PASCALMAIN';
  21. { this function must be the first in this unit which contains code }
  22. {$OPTIMIZATION OFF}
  23. procedure _FPC_proc_start(pd: PPD); cdecl; public name '_start';
  24. begin
  25. procdesc:=pd;
  26. tpasize:=align(sizeof(pd^) + pd^.p_tlen + pd^.p_dlen + pd^.p_blen + stklen, sizeof(pointer));
  27. if gemdos_mshrink(0, pd, tpasize) < 0 then
  28. begin
  29. gemdos_cconws('Not enough memory.'#13#10);
  30. gemdos_pterm(-39);
  31. end
  32. else
  33. begin
  34. stacktop:=pd^.p_lowtpa + tpasize;
  35. asm
  36. move.l stacktop, sp
  37. end;
  38. PascalMain;
  39. { this should be unreachable... }
  40. gemdos_pterm(-1);
  41. end;
  42. end;
  43. procedure _FPC_proc_halt(_ExitCode: longint); cdecl; public name '_haltproc';
  44. begin
  45. gemdos_pterm(_ExitCode);
  46. end;
  47. end.