si_prc.pp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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; public name '__stktop';
  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; cdecl; public name '_start';
  24. var pd: PPD;
  25. begin
  26. asm
  27. move.l a0,d0
  28. beq @Lapp
  29. moveq #0,d1
  30. bra @Lacc
  31. @Lapp:
  32. move.l 8(a6),a0
  33. moveq #1,d1
  34. @Lacc:
  35. move.b d1,AppFlag
  36. move.l a0,procdesc
  37. end;
  38. pd:=procdesc;
  39. tpasize:=align(sizeof(pd^) + pd^.p_tlen + pd^.p_dlen + pd^.p_blen + stklen, sizeof(pointer));
  40. if gemdos_mshrink(0, pd, tpasize) < 0 then
  41. begin
  42. gemdos_cconws('Not enough memory.'#13#10);
  43. gemdos_pterm(-39);
  44. end
  45. else
  46. begin
  47. stacktop:=pd^.p_lowtpa + tpasize;
  48. asm
  49. move.l stacktop, sp
  50. end;
  51. PascalMain;
  52. { this should be unreachable... }
  53. gemdos_pterm(-1);
  54. end;
  55. end;
  56. procedure _FPC_proc_halt(_ExitCode: longint); cdecl; public name '_haltproc';
  57. begin
  58. gemdos_pterm(_ExitCode);
  59. end;
  60. end.