prt0.as 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. |
  2. | This file is part of the Free Pascal run time library.
  3. | Copyright (c) 2005 by Karoly Balogh
  4. |
  5. | Startup code for Amiga/m68k RTL
  6. |
  7. | See the file COPYING.FPC, included in this distribution,
  8. | for details about the copyright.
  9. |
  10. | This program is distributed in the hope that it will be useful,
  11. | but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. |
  14. .text
  15. .align 4
  16. | This symbol is required for lineinfo support!
  17. .globl __EXESTART
  18. __EXESTART:
  19. .globl _start
  20. .globl start
  21. _start:
  22. start:
  23. movem.l d0-d7/a0-a6,-(sp)
  24. | Get ExecBase
  25. move.l 0x4,a6
  26. move.l a6,_ExecBase
  27. | Allocating new stack
  28. move.l __stklen,d0
  29. moveq.l #0,d1 | MEMF_ANY
  30. jsr -684(a6) | AllocVec()
  31. tst.l d0
  32. beq __exit
  33. move.l d0,stackArea
  34. | Setting up StackSwap structure, and do the StackSwap
  35. lea.l stackSwap,a0
  36. move.l d0,(a0) | Bottom of the stack
  37. add.l __stklen,d0
  38. move.l d0,4(a0) | Top of the stack
  39. move.l d0,8(a0) | Initial stackpointer
  40. jsr -732(a6) | StackSwap()
  41. jsr PASCALMAIN
  42. .globl _haltproc
  43. _haltproc:
  44. move.l d0,returnValue
  45. | Swapping the stack back
  46. move.l _ExecBase,a6
  47. lea.l stackSwap,a0
  48. jsr -732(a6) | StackSwap()
  49. | Freeing up stack area
  50. move.l stackArea,a1
  51. jsr -690(a6) | FreeVec()
  52. __exit:
  53. movem.l (sp)+,d0-d7/a0-a6
  54. move.l returnValue,d0
  55. rts
  56. .data
  57. .globl _ExecBase
  58. .globl SysBase
  59. .align 4
  60. SysBase:
  61. _ExecBase:
  62. .long 0
  63. .globl returnValue
  64. .align 4
  65. returnValue:
  66. .long 0
  67. .globl stackArea
  68. .align 4
  69. stackArea:
  70. .long 0
  71. .globl stackSwap
  72. .align 4
  73. stackSwap:
  74. .long 0
  75. .long 0
  76. .long 0