瀏覽代碼

+ Proper startup code for Amiga/m68k (for the first time in history)

git-svn-id: trunk@1951 -
Károly Balogh 19 年之前
父節點
當前提交
d5aa345bb3
共有 3 個文件被更改,包括 96 次插入57 次删除
  1. 1 1
      .gitattributes
  2. 95 0
      rtl/amiga/m68k/prt0.as
  3. 0 56
      rtl/amiga/prt0.as

+ 1 - 1
.gitattributes

@@ -3551,9 +3551,9 @@ rtl/amiga/Makefile.fpc svneol=native#text/plain
 rtl/amiga/crt.pp svneol=native#text/plain
 rtl/amiga/dos.pp svneol=native#text/plain
 rtl/amiga/graph.pp svneol=native#text/plain
+rtl/amiga/m68k/prt0.as -text
 rtl/amiga/os.inc svneol=native#text/plain
 rtl/amiga/printer.pp svneol=native#text/plain
-rtl/amiga/prt0.as -text
 rtl/amiga/readme -text
 rtl/arm/arm.inc svneol=native#text/plain
 rtl/arm/int64p.inc svneol=native#text/plain

+ 95 - 0
rtl/amiga/m68k/prt0.as

@@ -0,0 +1,95 @@
+|
+|  This file is part of the Free Pascal run time library.
+|  Copyright (c) 2005 by Karoly Balogh
+|
+|  Startup code for Amiga/m68k RTL
+|
+|  See the file COPYING.FPC, included in this distribution,
+|  for details about the copyright.
+|
+|  This program is distributed in the hope that it will be useful,
+|  but WITHOUT ANY WARRANTY; without even the implied warranty of
+|  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+|
+
+   .text
+   .align 4
+
+| This symbol is required for lineinfo support!
+.globl __EXESTART
+__EXESTART:
+
+   .globl _start
+   .globl start
+_start:
+start:
+   movem.l  d0-d7/a0-a6,-(sp)
+   
+   | Get ExecBase
+   move.l   0x4,a6
+   move.l   a6,_ExecBase
+   
+   | Allocating new stack
+   move.l   __stklen,d0
+   moveq.l  #0,d1            | MEMF_ANY
+   jsr      -684(a6)         | AllocVec()
+   tst.l    d0
+   beq      __exit  
+   move.l   d0,stackArea
+
+   | Setting up StackSwap structure, and do the StackSwap
+   lea.l    stackSwap,a0
+   move.l   d0,(a0)          | Bottom of the stack
+   add.l    __stklen,d0
+   move.l   d0,4(a0)         | Top of the stack
+   move.l   d0,8(a0)         | Initial stackpointer
+   jsr      -732(a6)         | StackSwap()
+
+   jsr PASCALMAIN
+
+   .globl _haltproc 
+_haltproc:
+   move.l   d0,returnValue
+
+   | Swapping the stack back
+   move.l   _ExecBase,a6
+   lea.l    stackSwap,a0
+   jsr      -732(a6)         | StackSwap()
+
+   | Freeing up stack area
+   move.l   stackArea,a1
+   jsr      -690(a6)         | FreeVec()
+
+__exit:
+   movem.l  (sp)+,d0-d7/a0-a6
+   move.l   returnValue,d0
+   rts
+
+   .data
+   .align 4
+__stklen:
+   .long 262144
+
+   .globl _ExecBase
+   .globl SysBase
+   .align 4
+SysBase:
+_ExecBase:
+   .long 0
+
+   .globl returnValue
+   .align 4
+returnValue:
+   .long 0
+
+   .globl stackArea
+   .align 4
+stackArea:
+   .long 0
+
+   .globl stackSwap
+   .align 4
+stackSwap:
+   .long 0
+   .long 0
+   .long 0

+ 0 - 56
rtl/amiga/prt0.as

@@ -1,56 +0,0 @@
-
-   .text
-
-   .align 4
-
-   .globl _start
-   .globl start
-_start:
-start:
-|	Save stack pointer for exit() routine
-
-	movel	   sp,STKPTR	| save stack pointer
-| This was wrong compared to PCQ
-|	addl	   #4,STKPTR	| account for this jsr to get to original
-
-|	Save the command line pointer to CommandLine
-
-    movel	a0,__ARGS
-    beq    .Ldont_nullit
-
-
-| Remove $0a character from end of string
-    movew  d0,d1
-    subqw  #1,d1
-    cmpb   #0x0a,a0@(0,d1:w)
-    bne    .Lcontt
-| Decrement count by one to remove the $0a character
-    movew  d1,d0
- .Lcontt:
-	 moveb  #0,a0@(0,d0:w)	   | null terminate it
-    movew  d0,__ARGC
- .Ldont_nullit:
-
-    jsr PASCALMAIN
-
-    movel  STKPTR,sp
-    rts
-
-    .data
-
-    .align 4
-
-    .globl __ARGS
- __ARGS:                   | pointer to the arguments
-      .long 0
-    .globl  __ARGC
- __ARGC:                    | number of arguments
-      .word 0
-    .globl STKPTR          | Used to terminate the program, initial SP
- STKPTR:
-      .long 0
-
-
-
-
-