浏览代码

Merged revisions 8209-8211 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r8209 | florian | 2007-08-02 09:38:09 +0200 (Do, 02 Aug 2007) | 1 line

* properties set
........
r8210 | florian | 2007-08-02 09:40:03 +0200 (Do, 02 Aug 2007) | 1 line

* more properties fixed
........
r8211 | florian | 2007-08-02 09:44:32 +0200 (Do, 02 Aug 2007) | 1 line

* fix by Carsten Bager
........

git-svn-id: branches/fixes_2_2@8212 -

florian 18 年之前
父节点
当前提交
4bb997fa5f

+ 71 - 71
.gitattributes

@@ -4292,7 +4292,7 @@ rtl/arm/setjumph.inc svneol=native#text/plain
 rtl/arm/strings.inc svneol=native#text/plain
 rtl/arm/stringss.inc svneol=native#text/plain
 rtl/atari/os.inc svneol=native#text/plain
-rtl/atari/prt0.as -text
+rtl/atari/prt0.as svneol=native#text/plain
 rtl/atari/readme -text
 rtl/atari/sysatari.pas svneol=native#text/plain
 rtl/atari/system.pas svneol=native#text/plain
@@ -4303,11 +4303,11 @@ rtl/beos/beos.pp svneol=native#text/plain
 rtl/beos/dos.pp svneol=native#text/plain
 rtl/beos/dos_beos.inc svneol=native#text/plain
 rtl/beos/errno.inc svneol=native#text/plain
-rtl/beos/i386/cprt0.as -text
-rtl/beos/i386/dllprt.as -text
+rtl/beos/i386/cprt0.as svneol=native#text/plain
+rtl/beos/i386/dllprt.as svneol=native#text/plain
 rtl/beos/i386/dllprt.cpp -text
-rtl/beos/i386/func.as -text
-rtl/beos/i386/prt0.as -text
+rtl/beos/i386/func.as svneol=native#text/plain
+rtl/beos/i386/prt0.as svneol=native#text/plain
 rtl/beos/objinc.inc svneol=native#text/plain
 rtl/beos/osposix.inc svneol=native#text/plain
 rtl/beos/osposixh.inc svneol=native#text/plain
@@ -4380,8 +4380,8 @@ rtl/emx/emx.imp -text
 rtl/emx/emx.pas svneol=native#text/plain
 rtl/emx/emxwrap.imp -text
 rtl/emx/ports.pas svneol=native#text/plain
-rtl/emx/prt0.as -text
-rtl/emx/prt1.as -text
+rtl/emx/prt0.as svneol=native#text/plain
+rtl/emx/prt1.as svneol=native#text/plain
 rtl/emx/sysdir.inc svneol=native#text/plain
 rtl/emx/sysemx.pas svneol=native#text/plain
 rtl/emx/sysfile.inc svneol=native#text/plain
@@ -4401,9 +4401,9 @@ rtl/freebsd/errno.inc svneol=native#text/plain
 rtl/freebsd/errnostr.inc -text
 rtl/freebsd/freebsd.pas -text
 rtl/freebsd/i386/bsyscall.inc svneol=native#text/plain
-rtl/freebsd/i386/cprt0.as -text
-rtl/freebsd/i386/gprt0.as -text
-rtl/freebsd/i386/prt0.as -text
+rtl/freebsd/i386/cprt0.as svneol=native#text/plain
+rtl/freebsd/i386/gprt0.as svneol=native#text/plain
+rtl/freebsd/i386/prt0.as svneol=native#text/plain
 rtl/freebsd/i386/sighnd.inc svneol=native#text/plain
 rtl/freebsd/i386/x86.inc svneol=native#text/plain
 rtl/freebsd/i386/x86h.inc svneol=native#text/plain
@@ -4423,17 +4423,17 @@ rtl/freebsd/unxfunc.inc svneol=native#text/plain
 rtl/freebsd/unxsockh.inc svneol=native#text/plain
 rtl/freebsd/unxsysc.inc svneol=native#text/plain
 rtl/freebsd/x86_64/bsyscall.inc svneol=native#text/plain
-rtl/freebsd/x86_64/prt0.as -text
+rtl/freebsd/x86_64/prt0.as svneol=native#text/plain
 rtl/freebsd/x86_64/sighnd.inc svneol=native#text/plain
 rtl/gba/Makefile svneol=native#text/plain
 rtl/gba/Makefile.fpc svneol=native#text/plain
 rtl/gba/classes.pp svneol=native#text/plain
-rtl/gba/cprt0.as -text
+rtl/gba/cprt0.as svneol=native#text/plain
 rtl/gba/dos.pp svneol=native#text/plain
 rtl/gba/gbabios.inc svneol=native#text/plain
 rtl/gba/gbabiosh.inc svneol=native#text/plain
 rtl/gba/lnkscript -text
-rtl/gba/prt0.as -text
+rtl/gba/prt0.as svneol=native#text/plain
 rtl/gba/sysdir.inc svneol=native#text/plain
 rtl/gba/sysfile.inc svneol=native#text/plain
 rtl/gba/sysheap.inc svneol=native#text/plain
@@ -4454,10 +4454,10 @@ rtl/go32v2/dpmiexcp.pp svneol=native#text/plain
 rtl/go32v2/dxeload.pp svneol=native#text/plain
 rtl/go32v2/dxetype.pp svneol=native#text/plain
 rtl/go32v2/emu387.pp svneol=native#text/plain
-rtl/go32v2/exceptn.as -text
+rtl/go32v2/exceptn.as svneol=native#text/plain
 rtl/go32v2/exit16.ah -text
 rtl/go32v2/exit16.asm -text
-rtl/go32v2/fpu.as -text
+rtl/go32v2/fpu.as svneol=native#text/plain
 rtl/go32v2/go32.pp svneol=native#text/plain
 rtl/go32v2/initc.pp svneol=native#text/plain
 rtl/go32v2/keyboard.pp svneol=native#text/plain
@@ -4477,7 +4477,7 @@ rtl/go32v2/system.pp svneol=native#text/plain
 rtl/go32v2/systhrd.inc svneol=native#text/plain
 rtl/go32v2/sysutils.pp svneol=native#text/plain
 rtl/go32v2/tthread.inc svneol=native#text/plain
-rtl/go32v2/v2prt0.as -text
+rtl/go32v2/v2prt0.as svneol=native#text/plain
 rtl/go32v2/varutils.pp svneol=native#text/plain
 rtl/go32v2/vesamode.pp svneol=native#text/plain
 rtl/go32v2/video.pp svneol=native#text/plain
@@ -4584,10 +4584,10 @@ rtl/inc/wstrings.inc svneol=native#text/plain
 rtl/linux/Makefile svneol=native#text/plain
 rtl/linux/Makefile.fpc svneol=native#text/plain
 rtl/linux/arm/bsyscall.inc svneol=native#text/plain
-rtl/linux/arm/cprt0.as -text
-rtl/linux/arm/dllprt0.as -text
-rtl/linux/arm/gprt0.as -text
-rtl/linux/arm/prt0.as -text
+rtl/linux/arm/cprt0.as svneol=native#text/plain
+rtl/linux/arm/dllprt0.as svneol=native#text/plain
+rtl/linux/arm/gprt0.as svneol=native#text/plain
+rtl/linux/arm/prt0.as svneol=native#text/plain
 rtl/linux/arm/sighnd.inc svneol=native#text/plain
 rtl/linux/arm/sighndh.inc svneol=native#text/plain
 rtl/linux/arm/stat.inc svneol=native#text/plain
@@ -4601,12 +4601,12 @@ rtl/linux/fpcylix.pp svneol=native#text/plain
 rtl/linux/fpmake.inc svneol=native#text/plain
 rtl/linux/gpm.pp svneol=native#text/plain
 rtl/linux/i386/bsyscall.inc svneol=native#text/plain
-rtl/linux/i386/cprt0.as -text
-rtl/linux/i386/cprt21.as -text
-rtl/linux/i386/dllprt0.as -text
-rtl/linux/i386/gprt0.as -text
-rtl/linux/i386/gprt21.as -text
-rtl/linux/i386/prt0.as -text
+rtl/linux/i386/cprt0.as svneol=native#text/plain
+rtl/linux/i386/cprt21.as svneol=native#text/plain
+rtl/linux/i386/dllprt0.as svneol=native#text/plain
+rtl/linux/i386/gprt0.as svneol=native#text/plain
+rtl/linux/i386/gprt21.as svneol=native#text/plain
+rtl/linux/i386/prt0.as svneol=native#text/plain
 rtl/linux/i386/si_c.inc svneol=native#text/plain
 rtl/linux/i386/si_c21.inc svneol=native#text/plain
 rtl/linux/i386/si_c21g.inc svneol=native#text/plain
@@ -4624,13 +4624,13 @@ rtl/linux/ipcsys.inc svneol=native#text/plain
 rtl/linux/linux.pp svneol=native#text/plain
 rtl/linux/linuxvcs.pp -text
 rtl/linux/m68k/bsyscall.inc svneol=native#text/plain
-rtl/linux/m68k/cprt0.as -text
-rtl/linux/m68k/cprt21.as -text
-rtl/linux/m68k/dllprt0.as -text
-rtl/linux/m68k/gprt0.as -text
-rtl/linux/m68k/gprt21.as -text
-rtl/linux/m68k/prt0.as -text
-rtl/linux/m68k/prt1.as -text
+rtl/linux/m68k/cprt0.as svneol=native#text/plain
+rtl/linux/m68k/cprt21.as svneol=native#text/plain
+rtl/linux/m68k/dllprt0.as svneol=native#text/plain
+rtl/linux/m68k/gprt0.as svneol=native#text/plain
+rtl/linux/m68k/gprt21.as svneol=native#text/plain
+rtl/linux/m68k/prt0.as svneol=native#text/plain
+rtl/linux/m68k/prt1.as svneol=native#text/plain
 rtl/linux/m68k/sighnd.inc svneol=native#text/plain
 rtl/linux/m68k/sighndh.inc svneol=native#text/plain
 rtl/linux/m68k/stat.inc svneol=native#text/plain
@@ -4643,10 +4643,10 @@ rtl/linux/osmacro.inc svneol=native#text/plain
 rtl/linux/ossysc.inc svneol=native#text/plain
 rtl/linux/ostypes.inc svneol=native#text/plain
 rtl/linux/powerpc/bsyscall.inc svneol=native#text/plain
-rtl/linux/powerpc/cprt0.as -text
-rtl/linux/powerpc/dllprt0.as -text
-rtl/linux/powerpc/gprt0.as -text
-rtl/linux/powerpc/prt0.as -text
+rtl/linux/powerpc/cprt0.as svneol=native#text/plain
+rtl/linux/powerpc/dllprt0.as svneol=native#text/plain
+rtl/linux/powerpc/gprt0.as svneol=native#text/plain
+rtl/linux/powerpc/prt0.as svneol=native#text/plain
 rtl/linux/powerpc/sighnd.inc svneol=native#text/plain
 rtl/linux/powerpc/sighndh.inc svneol=native#text/plain
 rtl/linux/powerpc/stat.inc svneol=native#text/plain
@@ -4654,10 +4654,10 @@ rtl/linux/powerpc/syscall.inc svneol=native#text/plain
 rtl/linux/powerpc/syscallh.inc svneol=native#text/plain
 rtl/linux/powerpc/sysnr.inc svneol=native#text/plain
 rtl/linux/powerpc64/bsyscall.inc svneol=native#text/plain
-rtl/linux/powerpc64/cprt0.as -text
-rtl/linux/powerpc64/dllprt0.as -text
-rtl/linux/powerpc64/gprt0.as -text
-rtl/linux/powerpc64/prt0.as -text
+rtl/linux/powerpc64/cprt0.as svneol=native#text/plain
+rtl/linux/powerpc64/dllprt0.as svneol=native#text/plain
+rtl/linux/powerpc64/gprt0.as svneol=native#text/plain
+rtl/linux/powerpc64/prt0.as svneol=native#text/plain
 rtl/linux/powerpc64/sighnd.inc svneol=native#text/plain
 rtl/linux/powerpc64/sighndh.inc svneol=native#text/plain
 rtl/linux/powerpc64/stat.inc svneol=native#text/plain
@@ -4675,10 +4675,10 @@ rtl/linux/si_intf.inc svneol=native#text/plain
 rtl/linux/si_prc.pp svneol=native#text/plain
 rtl/linux/signal.inc svneol=native#text/plain
 rtl/linux/sparc/bsyscall.inc svneol=native#text/plain
-rtl/linux/sparc/cprt0.as -text
-rtl/linux/sparc/dllprt0.as -text
-rtl/linux/sparc/gprt0.as -text
-rtl/linux/sparc/prt0.as -text
+rtl/linux/sparc/cprt0.as svneol=native#text/plain
+rtl/linux/sparc/dllprt0.as svneol=native#text/plain
+rtl/linux/sparc/gprt0.as svneol=native#text/plain
+rtl/linux/sparc/prt0.as svneol=native#text/plain
 rtl/linux/sparc/sighnd.inc svneol=native#text/plain
 rtl/linux/sparc/sighndh.inc svneol=native#text/plain
 rtl/linux/sparc/stat.inc svneol=native#text/plain
@@ -4699,10 +4699,10 @@ rtl/linux/unxsockh.inc svneol=native#text/plain
 rtl/linux/unxsysc.inc svneol=native#text/plain
 rtl/linux/unxsysch.inc svneol=native#text/plain
 rtl/linux/x86_64/bsyscall.inc svneol=native#text/plain
-rtl/linux/x86_64/cprt0.as -text
-rtl/linux/x86_64/dllprt0.as -text
-rtl/linux/x86_64/gprt0.as -text
-rtl/linux/x86_64/prt0.as -text
+rtl/linux/x86_64/cprt0.as svneol=native#text/plain
+rtl/linux/x86_64/dllprt0.as svneol=native#text/plain
+rtl/linux/x86_64/gprt0.as svneol=native#text/plain
+rtl/linux/x86_64/prt0.as svneol=native#text/plain
 rtl/linux/x86_64/si_c.inc svneol=native#text/plain
 rtl/linux/x86_64/si_prc.inc svneol=native#text/plain
 rtl/linux/x86_64/sighnd.inc svneol=native#text/plain
@@ -4767,7 +4767,7 @@ rtl/morphos/layers.pas svneol=native#text/plain
 rtl/morphos/mouse.pp svneol=native#text/plain
 rtl/morphos/mui.pas -text
 rtl/morphos/muihelper.pas -text
-rtl/morphos/prt0.as -text
+rtl/morphos/prt0.as svneol=native#text/plain
 rtl/morphos/sysdir.inc svneol=native#text/plain
 rtl/morphos/sysfile.inc svneol=native#text/plain
 rtl/morphos/sysheap.inc svneol=native#text/plain
@@ -4791,13 +4791,13 @@ rtl/morphos/videodata.inc svneol=native#text/plain
 rtl/nds/Makefile svneol=native#text/plain
 rtl/nds/Makefile.fpc -text
 rtl/nds/classes.pp -text
-rtl/nds/cprt07.as -text
-rtl/nds/cprt09.as -text
+rtl/nds/cprt07.as svneol=native#text/plain
+rtl/nds/cprt09.as svneol=native#text/plain
 rtl/nds/dos.pp -text
 rtl/nds/ndsbios.inc -text
 rtl/nds/ndsbiosh.inc -text
-rtl/nds/prt07.as -text
-rtl/nds/prt09.as -text
+rtl/nds/prt07.as svneol=native#text/plain
+rtl/nds/prt09.as svneol=native#text/plain
 rtl/nds/sysdir.inc -text
 rtl/nds/sysfile.inc -text
 rtl/nds/sysheap.inc -text
@@ -4812,13 +4812,13 @@ rtl/netbsd/Makefile.fpc svneol=native#text/plain
 rtl/netbsd/errno.inc svneol=native#text/plain
 rtl/netbsd/errnostr.inc -text
 rtl/netbsd/i386/bsyscall.inc svneol=native#text/plain
-rtl/netbsd/i386/cprt0.as -text
-rtl/netbsd/i386/prt0.as -text
-rtl/netbsd/i386/prt0_10.as -text
+rtl/netbsd/i386/cprt0.as svneol=native#text/plain
+rtl/netbsd/i386/prt0.as svneol=native#text/plain
+rtl/netbsd/i386/prt0_10.as svneol=native#text/plain
 rtl/netbsd/i386/sighnd.inc svneol=native#text/plain
 rtl/netbsd/pmutext.inc svneol=native#text/plain
-rtl/netbsd/powerpc/cprt0.as -text
-rtl/netbsd/powerpc/prt0.as -text
+rtl/netbsd/powerpc/cprt0.as svneol=native#text/plain
+rtl/netbsd/powerpc/prt0.as svneol=native#text/plain
 rtl/netbsd/powerpc/sighnd.inc svneol=native#text/plain
 rtl/netbsd/ptypes.inc svneol=native#text/plain
 rtl/netbsd/signal.inc svneol=native#text/plain
@@ -4874,7 +4874,7 @@ rtl/netware/npackoff.inc svneol=native#text/plain
 rtl/netware/npackon.inc svneol=native#text/plain
 rtl/netware/nwcalls.pp svneol=native#text/plain
 rtl/netware/nwnit.pp svneol=native#text/plain
-rtl/netware/nwpre.as -text
+rtl/netware/nwpre.as svneol=native#text/plain
 rtl/netware/nwpre.pp svneol=native#text/plain
 rtl/netware/nwprot.pp svneol=native#text/plain
 rtl/netware/nwpsrv.imp -text
@@ -4884,7 +4884,7 @@ rtl/netware/nwsnut.imp -text
 rtl/netware/nwsnut.pp svneol=native#text/plain
 rtl/netware/nwsock.inc svneol=native#text/plain
 rtl/netware/nwsys.inc svneol=native#text/plain
-rtl/netware/prelude.as -text
+rtl/netware/prelude.as svneol=native#text/plain
 rtl/netware/qos.inc svneol=native#text/plain
 rtl/netware/requestr.imp -text
 rtl/netware/sockets.pp svneol=native#text/plain
@@ -4925,8 +4925,8 @@ rtl/netwlibc/libcclib.imp -text
 rtl/netwlibc/mouse.pp svneol=native#text/plain
 rtl/netwlibc/netware.imp -text
 rtl/netwlibc/netwsockh.inc svneol=native#text/plain
-rtl/netwlibc/nwl_dlle.as -text
-rtl/netwlibc/nwl_main.as -text
+rtl/netwlibc/nwl_dlle.as svneol=native#text/plain
+rtl/netwlibc/nwl_main.as svneol=native#text/plain
 rtl/netwlibc/nwsnut.imp -text
 rtl/netwlibc/nwsnut.pp svneol=native#text/plain
 rtl/netwlibc/pre/libcpre.gcc.o -text
@@ -5023,8 +5023,8 @@ rtl/openbsd/Makefile svneol=native#text/plain
 rtl/openbsd/Makefile.fpc svneol=native#text/plain
 rtl/openbsd/classes.pp svneol=native#text/plain
 rtl/openbsd/errno.inc svneol=native#text/plain
-rtl/openbsd/i386/cprt0.as -text
-rtl/openbsd/i386/prt0.as -text
+rtl/openbsd/i386/cprt0.as svneol=native#text/plain
+rtl/openbsd/i386/prt0.as svneol=native#text/plain
 rtl/openbsd/i386/sighnd.inc svneol=native#text/plain
 rtl/openbsd/pmutext.inc svneol=native#text/plain
 rtl/openbsd/ptypes.inc svneol=native#text/plain
@@ -5069,7 +5069,7 @@ rtl/os2/pmwp.pas svneol=native#text/plain
 rtl/os2/pmwsock.pas svneol=native#text/plain
 rtl/os2/ports.pas svneol=native#text/plain
 rtl/os2/printer.pas svneol=native#text/plain
-rtl/os2/prt0.as -text
+rtl/os2/prt0.as svneol=native#text/plain
 rtl/os2/so32dll.pas svneol=native#text/plain
 rtl/os2/sockets.pas svneol=native#text/plain
 rtl/os2/sysdir.inc svneol=native#text/plain
@@ -5117,7 +5117,7 @@ rtl/palmos/api/sysall.pp svneol=native#text/plain
 rtl/palmos/api/systraps.inc svneol=native#text/plain
 rtl/palmos/api/systraps.pp svneol=native#text/plain
 rtl/palmos/api/ui.pp svneol=native#text/plain
-rtl/palmos/arm/prt0.as -text
+rtl/palmos/arm/prt0.as svneol=native#text/plain
 rtl/palmos/os.inc svneol=native#text/plain
 rtl/palmos/pilot.pp svneol=native#text/plain
 rtl/palmos/readme -text
@@ -5341,7 +5341,7 @@ rtl/win32/Makefile svneol=native#text/plain
 rtl/win32/Makefile.fpc svneol=native#text/plain
 rtl/win32/buildrtl.pp svneol=native#text/plain
 rtl/win32/classes.pp svneol=native#text/plain
-rtl/win32/gprt0.as -text
+rtl/win32/gprt0.as svneol=native#text/plain
 rtl/win32/initc.pp svneol=native#text/plain
 rtl/win32/objinc.inc svneol=native#text/plain
 rtl/win32/signals.pp svneol=native#text/plain
@@ -5349,11 +5349,11 @@ rtl/win32/sysinitcyg.pp svneol=native#text/plain
 rtl/win32/sysinitgprof.pp svneol=native#text/plain
 rtl/win32/sysinitpas.pp svneol=native#text/plain
 rtl/win32/system.pp svneol=native#text/plain
-rtl/win32/wcygprt0.as -text
-rtl/win32/wdllprt0.as -text
+rtl/win32/wcygprt0.as svneol=native#text/plain
+rtl/win32/wdllprt0.as svneol=native#text/plain
 rtl/win32/windows.pp svneol=native#text/plain
 rtl/win32/winsysut.pp svneol=native#text/plain
-rtl/win32/wprt0.as -text
+rtl/win32/wprt0.as svneol=native#text/plain
 rtl/win64/Makefile svneol=native#text/plain
 rtl/win64/Makefile.fpc svneol=native#text/plain
 rtl/win64/buildrtl.pp svneol=native#text/plain

+ 244 - 244
rtl/gba/cprt0.as

@@ -1,244 +1,244 @@
-@ (c) 2006 by devkitPro (http://www.devkitpro.org)
-
-
-	.section	".init"
-	.global     _start
-	.align
-	.arm
-@---------------------------------------------------------------------------------
-_start:
-@---------------------------------------------------------------------------------
-	b	rom_header_end
-
-	.fill   156,1,0			@ Nintendo Logo Character Data (8000004h)
-	.fill	16,1,0			@ Game Title
-	.byte   0x30,0x31		@ Maker Code (80000B0h)
-	.byte   0x96			@ Fixed Value (80000B2h)
-	.byte   0x00			@ Main Unit Code (80000B3h)
-	.byte   0x00			@ Device Type (80000B4h)
-	.fill	7,1,0			@ unused
-	.byte	0x00			@ Software Version No (80000BCh)
-	.byte	0xf0			@ Complement Check (80000BDh)
-	.byte	0x00,0x00    		@ Checksum (80000BEh)
-
-@---------------------------------------------------------------------------------
-rom_header_end:
-@---------------------------------------------------------------------------------
-	b	start_vector			@ This branch must be here for proper
-						@ positioning of the following header.
-
-	.GLOBAL	__boot_method, __slave_number
-@---------------------------------------------------------------------------------
-__boot_method:
-@---------------------------------------------------------------------------------
-	.byte   0				@ boot method (0=ROM boot, 3=Multiplay boot)
-@---------------------------------------------------------------------------------
-__slave_number:
-@---------------------------------------------------------------------------------
-	.byte   0				@ slave # (1=slave#1, 2=slave#2, 3=slave#3)
-
-	.byte   0 				@ reserved
-	.byte   0 				@ reserved
-	.word   0    				@ reserved
-	.word   0				@ reserved
-	.word   0    				@ reserved
-	.word   0    				@ reserved
-	.word   0    				@ reserved
-	.word   0    				@ reserved
-
-    .global     start_vector
-    .align
-@---------------------------------------------------------------------------------
-start_vector:
-@---------------------------------------------------------------------------------
-	mov	r0, #0x4000000			@ REG_BASE
-	str	r0, [r0, #0x208]
-
-	mov	r0, #0x12			@ Switch to IRQ Mode
-	msr	cpsr, r0
-	ldr	sp, =__sp_irq			@ Set IRQ stack
-	mov	r0, #0x1f			@ Switch to System Mode
-	msr	cpsr, r0
-	ldr	sp, =__sp_usr			@ Set user stack
-
-@---------------------------------------------------------------------------------
-@ Enter Thumb mode
-@---------------------------------------------------------------------------------
-	add	r0, pc, #1
-	bx	r0
-
-	.thumb
-
-	ldr	r0, =__text_start
-	lsl	r0, #5				@ Was code compiled at 0x08000000 or higher?
-	bcs     DoEWRAMClear			@ yes, you can not run it in external WRAM
-
-	mov     r0, pc
-	lsl     r0, #5				@ Are we running from ROM (0x8000000 or higher) ?
-	bcc     SkipEWRAMClear			@ No, so no need to do a copy.
-
-@---------------------------------------------------------------------------------
-@ We were started in ROM, silly emulators. :P
-@ So we need to copy to ExWRAM.
-@---------------------------------------------------------------------------------
-	mov	r2, #2
-	lsl	r2, r2, #24			@ r2= 0x02000000
-	ldr	r3, =__end__			@ last ewram address
-	sub	r3, r2				@ r3= actual binary size
-	mov	r6, r2				@ r6= 0x02000000
-	lsl	r1, r2, #2			@ r1= 0x08000000
-
-	bl	CopyMem
-
-	bx	r6				@ Jump to the code to execute
-
-@---------------------------------------------------------------------------------
-DoEWRAMClear:					@ Clear External WRAM to 0x00
-@---------------------------------------------------------------------------------
-	mov	r1, #0x40
-	lsl	r1, #12				@ r1 = 0x40000
-	lsl	r0, r1, #7			@ r0 = 0x2000000
-	bl	ClearMem
-
-@---------------------------------------------------------------------------------
-SkipEWRAMClear:					@ Clear Internal WRAM to 0x00
-@---------------------------------------------------------------------------------
-
-@---------------------------------------------------------------------------------
-@ Clear BSS section to 0x00
-@---------------------------------------------------------------------------------
-	ldr	r0, =__bss_start
-	ldr	r1, =__bss_end
-	sub	r1, r0
-	bl	ClearMem
-
-@---------------------------------------------------------------------------------
-@ Clear SBSS section to 0x00
-@---------------------------------------------------------------------------------
-	ldr	r0, =__sbss_start
-	ldr	r1, =__sbss_end
-	sub	r1, r0
-	bl	ClearMem
-
-@---------------------------------------------------------------------------------
-@ Copy initialized data (data section) from LMA to VMA (ROM to RAM)
-@---------------------------------------------------------------------------------
-	ldr	r1, =__data_lma
-	ldr	r2, =__data_start
-	ldr	r4, =__data_end
-	bl	CopyMemChk
-
-@---------------------------------------------------------------------------------
-@ Copy internal work ram (iwram section) from LMA to VMA (ROM to RAM)
-@---------------------------------------------------------------------------------
-	ldr	r1,= __iwram_lma
-	ldr	r2,= __iwram_start
-	ldr	r4,= __iwram_end
-	bl	CopyMemChk
-
-@---------------------------------------------------------------------------------
-@ Copy internal work ram overlay 0 (iwram0 section) from LMA to VMA (ROM to RAM)
-@---------------------------------------------------------------------------------
-	ldr	r2,= __load_stop_iwram0
-	ldr	r1,= __load_start_iwram0
-	sub	r3, r2, r1			@ Is there any data to copy?
-	beq	CIW0Skip			@ no
-
-	ldr	r2,= __iwram_overlay_start
-	bl	CopyMem
-@---------------------------------------------------------------------------------
-CIW0Skip:
-@---------------------------------------------------------------------------------
-@ Copy external work ram (ewram section) from LMA to VMA (ROM to RAM)
-@---------------------------------------------------------------------------------
-	ldr	r1, =__ewram_lma
-	ldr	r2, =__ewram_start
-	ldr	r4, =__ewram_end
-	bl	CopyMemChk
-
-@---------------------------------------------------------------------------------
-CEW0Skip:
-@---------------------------------------------------------------------------------
-@ set heap end
-@---------------------------------------------------------------------------------
-	ldr	r1, =fake_heap_end
-	ldr	r0, =__eheap_end
-	str	r0, [r1]
-@---------------------------------------------------------------------------------
-@ global constructors
-@---------------------------------------------------------------------------------
-	ldr	r3, =__libc_init_array
-	bl	_call_via_r3
-@---------------------------------------------------------------------------------
-@ Jump to user code
-@---------------------------------------------------------------------------------
-	mov	r0, #0				@ int argc
-	mov	r1, #0				@ char	*argv[]
-	ldr	r3, =main
-	bl	_call_via_r3
-@---------------------------------------------------------------------------------
-@ Clear memory to 0x00 if length != 0
-@---------------------------------------------------------------------------------
-@ r0 = Start Address
-@ r1 = Length
-@---------------------------------------------------------------------------------
-ClearMem:
-@---------------------------------------------------------------------------------
-	mov	r2,#3				@ These	commands are used in cases where
-	add	r1,r2				@ the length is	not a multiple of 4,
-	bic	r1,r2				@ even though it should be.
-
-	beq	ClearMX				@ Length is zero so exit
-
-	mov	r2,#0
-@---------------------------------------------------------------------------------
-ClrLoop:
-@---------------------------------------------------------------------------------
-	stmia	r0!, {r2}
-	sub	r1,#4
-	bne	ClrLoop
-@---------------------------------------------------------------------------------
-ClearMX:
-@---------------------------------------------------------------------------------
-	bx	lr
-
-@---------------------------------------------------------------------------------
-@ Copy memory if length	!= 0
-@---------------------------------------------------------------------------------
-@ r1 = Source Address
-@ r2 = Dest Address
-@ r4 = Dest Address + Length
-@---------------------------------------------------------------------------------
-CopyMemChk:
-@---------------------------------------------------------------------------------
-	sub	r3, r4, r2			@ Is there any data to copy?
-@---------------------------------------------------------------------------------
-@ Copy memory
-@---------------------------------------------------------------------------------
-@ r1 = Source Address
-@ r2 = Dest Address
-@ r3 = Length
-@---------------------------------------------------------------------------------
-CopyMem:
-@---------------------------------------------------------------------------------
-	mov	r0, #3				@ These commands are used in cases where
-	add	r3, r0				@ the length is not a multiple	of 4,
-	bic	r3, r0				@ even	though it should be.
-	beq	CIDExit				@ Length is zero so exit
-
-@---------------------------------------------------------------------------------
-CIDLoop:
-@---------------------------------------------------------------------------------
-	ldmia	r1!, {r0}
-	stmia	r2!, {r0}
-	sub	r3, #4
-	bne	CIDLoop
-@---------------------------------------------------------------------------------
-CIDExit:
-@---------------------------------------------------------------------------------
-	bx	lr
-
-	.align
-	.pool
-	.end
-
+@ (c) 2006 by devkitPro (http://www.devkitpro.org)
+
+
+	.section	".init"
+	.global     _start
+	.align
+	.arm
+@---------------------------------------------------------------------------------
+_start:
+@---------------------------------------------------------------------------------
+	b	rom_header_end
+
+	.fill   156,1,0			@ Nintendo Logo Character Data (8000004h)
+	.fill	16,1,0			@ Game Title
+	.byte   0x30,0x31		@ Maker Code (80000B0h)
+	.byte   0x96			@ Fixed Value (80000B2h)
+	.byte   0x00			@ Main Unit Code (80000B3h)
+	.byte   0x00			@ Device Type (80000B4h)
+	.fill	7,1,0			@ unused
+	.byte	0x00			@ Software Version No (80000BCh)
+	.byte	0xf0			@ Complement Check (80000BDh)
+	.byte	0x00,0x00    		@ Checksum (80000BEh)
+
+@---------------------------------------------------------------------------------
+rom_header_end:
+@---------------------------------------------------------------------------------
+	b	start_vector			@ This branch must be here for proper
+						@ positioning of the following header.
+
+	.GLOBAL	__boot_method, __slave_number
+@---------------------------------------------------------------------------------
+__boot_method:
+@---------------------------------------------------------------------------------
+	.byte   0				@ boot method (0=ROM boot, 3=Multiplay boot)
+@---------------------------------------------------------------------------------
+__slave_number:
+@---------------------------------------------------------------------------------
+	.byte   0				@ slave # (1=slave#1, 2=slave#2, 3=slave#3)
+
+	.byte   0 				@ reserved
+	.byte   0 				@ reserved
+	.word   0    				@ reserved
+	.word   0				@ reserved
+	.word   0    				@ reserved
+	.word   0    				@ reserved
+	.word   0    				@ reserved
+	.word   0    				@ reserved
+
+    .global     start_vector
+    .align
+@---------------------------------------------------------------------------------
+start_vector:
+@---------------------------------------------------------------------------------
+	mov	r0, #0x4000000			@ REG_BASE
+	str	r0, [r0, #0x208]
+
+	mov	r0, #0x12			@ Switch to IRQ Mode
+	msr	cpsr, r0
+	ldr	sp, =__sp_irq			@ Set IRQ stack
+	mov	r0, #0x1f			@ Switch to System Mode
+	msr	cpsr, r0
+	ldr	sp, =__sp_usr			@ Set user stack
+
+@---------------------------------------------------------------------------------
+@ Enter Thumb mode
+@---------------------------------------------------------------------------------
+	add	r0, pc, #1
+	bx	r0
+
+	.thumb
+
+	ldr	r0, =__text_start
+	lsl	r0, #5				@ Was code compiled at 0x08000000 or higher?
+	bcs     DoEWRAMClear			@ yes, you can not run it in external WRAM
+
+	mov     r0, pc
+	lsl     r0, #5				@ Are we running from ROM (0x8000000 or higher) ?
+	bcc     SkipEWRAMClear			@ No, so no need to do a copy.
+
+@---------------------------------------------------------------------------------
+@ We were started in ROM, silly emulators. :P
+@ So we need to copy to ExWRAM.
+@---------------------------------------------------------------------------------
+	mov	r2, #2
+	lsl	r2, r2, #24			@ r2= 0x02000000
+	ldr	r3, =__end__			@ last ewram address
+	sub	r3, r2				@ r3= actual binary size
+	mov	r6, r2				@ r6= 0x02000000
+	lsl	r1, r2, #2			@ r1= 0x08000000
+
+	bl	CopyMem
+
+	bx	r6				@ Jump to the code to execute
+
+@---------------------------------------------------------------------------------
+DoEWRAMClear:					@ Clear External WRAM to 0x00
+@---------------------------------------------------------------------------------
+	mov	r1, #0x40
+	lsl	r1, #12				@ r1 = 0x40000
+	lsl	r0, r1, #7			@ r0 = 0x2000000
+	bl	ClearMem
+
+@---------------------------------------------------------------------------------
+SkipEWRAMClear:					@ Clear Internal WRAM to 0x00
+@---------------------------------------------------------------------------------
+
+@---------------------------------------------------------------------------------
+@ Clear BSS section to 0x00
+@---------------------------------------------------------------------------------
+	ldr	r0, =__bss_start
+	ldr	r1, =__bss_end
+	sub	r1, r0
+	bl	ClearMem
+
+@---------------------------------------------------------------------------------
+@ Clear SBSS section to 0x00
+@---------------------------------------------------------------------------------
+	ldr	r0, =__sbss_start
+	ldr	r1, =__sbss_end
+	sub	r1, r0
+	bl	ClearMem
+
+@---------------------------------------------------------------------------------
+@ Copy initialized data (data section) from LMA to VMA (ROM to RAM)
+@---------------------------------------------------------------------------------
+	ldr	r1, =__data_lma
+	ldr	r2, =__data_start
+	ldr	r4, =__data_end
+	bl	CopyMemChk
+
+@---------------------------------------------------------------------------------
+@ Copy internal work ram (iwram section) from LMA to VMA (ROM to RAM)
+@---------------------------------------------------------------------------------
+	ldr	r1,= __iwram_lma
+	ldr	r2,= __iwram_start
+	ldr	r4,= __iwram_end
+	bl	CopyMemChk
+
+@---------------------------------------------------------------------------------
+@ Copy internal work ram overlay 0 (iwram0 section) from LMA to VMA (ROM to RAM)
+@---------------------------------------------------------------------------------
+	ldr	r2,= __load_stop_iwram0
+	ldr	r1,= __load_start_iwram0
+	sub	r3, r2, r1			@ Is there any data to copy?
+	beq	CIW0Skip			@ no
+
+	ldr	r2,= __iwram_overlay_start
+	bl	CopyMem
+@---------------------------------------------------------------------------------
+CIW0Skip:
+@---------------------------------------------------------------------------------
+@ Copy external work ram (ewram section) from LMA to VMA (ROM to RAM)
+@---------------------------------------------------------------------------------
+	ldr	r1, =__ewram_lma
+	ldr	r2, =__ewram_start
+	ldr	r4, =__ewram_end
+	bl	CopyMemChk
+
+@---------------------------------------------------------------------------------
+CEW0Skip:
+@---------------------------------------------------------------------------------
+@ set heap end
+@---------------------------------------------------------------------------------
+	ldr	r1, =fake_heap_end
+	ldr	r0, =__eheap_end
+	str	r0, [r1]
+@---------------------------------------------------------------------------------
+@ global constructors
+@---------------------------------------------------------------------------------
+	ldr	r3, =__libc_init_array
+	bl	_call_via_r3
+@---------------------------------------------------------------------------------
+@ Jump to user code
+@---------------------------------------------------------------------------------
+	mov	r0, #0				@ int argc
+	mov	r1, #0				@ char	*argv[]
+	ldr	r3, =main
+	bl	_call_via_r3
+@---------------------------------------------------------------------------------
+@ Clear memory to 0x00 if length != 0
+@---------------------------------------------------------------------------------
+@ r0 = Start Address
+@ r1 = Length
+@---------------------------------------------------------------------------------
+ClearMem:
+@---------------------------------------------------------------------------------
+	mov	r2,#3				@ These	commands are used in cases where
+	add	r1,r2				@ the length is	not a multiple of 4,
+	bic	r1,r2				@ even though it should be.
+
+	beq	ClearMX				@ Length is zero so exit
+
+	mov	r2,#0
+@---------------------------------------------------------------------------------
+ClrLoop:
+@---------------------------------------------------------------------------------
+	stmia	r0!, {r2}
+	sub	r1,#4
+	bne	ClrLoop
+@---------------------------------------------------------------------------------
+ClearMX:
+@---------------------------------------------------------------------------------
+	bx	lr
+
+@---------------------------------------------------------------------------------
+@ Copy memory if length	!= 0
+@---------------------------------------------------------------------------------
+@ r1 = Source Address
+@ r2 = Dest Address
+@ r4 = Dest Address + Length
+@---------------------------------------------------------------------------------
+CopyMemChk:
+@---------------------------------------------------------------------------------
+	sub	r3, r4, r2			@ Is there any data to copy?
+@---------------------------------------------------------------------------------
+@ Copy memory
+@---------------------------------------------------------------------------------
+@ r1 = Source Address
+@ r2 = Dest Address
+@ r3 = Length
+@---------------------------------------------------------------------------------
+CopyMem:
+@---------------------------------------------------------------------------------
+	mov	r0, #3				@ These commands are used in cases where
+	add	r3, r0				@ the length is not a multiple	of 4,
+	bic	r3, r0				@ even	though it should be.
+	beq	CIDExit				@ Length is zero so exit
+
+@---------------------------------------------------------------------------------
+CIDLoop:
+@---------------------------------------------------------------------------------
+	ldmia	r1!, {r0}
+	stmia	r2!, {r0}
+	sub	r3, #4
+	bne	CIDLoop
+@---------------------------------------------------------------------------------
+CIDExit:
+@---------------------------------------------------------------------------------
+	bx	lr
+
+	.align
+	.pool
+	.end
+

+ 243 - 243
rtl/gba/prt0.as

@@ -1,243 +1,243 @@
-@ (c) 2006 by devkitPro (http://www.devkitpro.org)
-
-
-	.section	".init"
-	.global     _start
-	.align
-	.arm
-@---------------------------------------------------------------------------------
-_start:
-@---------------------------------------------------------------------------------
-	b	rom_header_end
-
-	.fill   156,1,0			@ Nintendo Logo Character Data (8000004h)
-	.fill	16,1,0			@ Game Title
-	.byte   0x30,0x31		@ Maker Code (80000B0h)
-	.byte   0x96			@ Fixed Value (80000B2h)
-	.byte   0x00			@ Main Unit Code (80000B3h)
-	.byte   0x00			@ Device Type (80000B4h)
-	.fill	7,1,0			@ unused
-	.byte	0x00			@ Software Version No (80000BCh)
-	.byte	0xf0			@ Complement Check (80000BDh)
-	.byte	0x00,0x00    		@ Checksum (80000BEh)
-
-@---------------------------------------------------------------------------------
-rom_header_end:
-@---------------------------------------------------------------------------------
-	b	start_vector			@ This branch must be here for proper
-						@ positioning of the following header.
-
-	.GLOBAL	__boot_method, __slave_number
-@---------------------------------------------------------------------------------
-__boot_method:
-@---------------------------------------------------------------------------------
-	.byte   0				@ boot method (0=ROM boot, 3=Multiplay boot)
-@---------------------------------------------------------------------------------
-__slave_number:
-@---------------------------------------------------------------------------------
-	.byte   0				@ slave # (1=slave#1, 2=slave#2, 3=slave#3)
-
-	.byte   0 				@ reserved
-	.byte   0 				@ reserved
-	.word   0    				@ reserved
-	.word   0				@ reserved
-	.word   0    				@ reserved
-	.word   0    				@ reserved
-	.word   0    				@ reserved
-	.word   0    				@ reserved
-
-    .global     start_vector
-    .align
-@---------------------------------------------------------------------------------
-start_vector:
-@---------------------------------------------------------------------------------
-	mov	r0, #0x4000000			@ REG_BASE
-	str	r0, [r0, #0x208]
-
-	mov	r0, #0x12			@ Switch to IRQ Mode
-	msr	cpsr, r0
-	ldr	sp, =__sp_irq			@ Set IRQ stack
-	mov	r0, #0x1f			@ Switch to System Mode
-	msr	cpsr, r0
-	ldr	sp, =__sp_usr			@ Set user stack
-
-@---------------------------------------------------------------------------------
-@ Enter Thumb mode
-@---------------------------------------------------------------------------------
-	add	r0, pc, #1
-	bx	r0
-
-	.thumb
-
-	ldr	r0, =__text_start
-	lsl	r0, #5				@ Was code compiled at 0x08000000 or higher?
-	bcs     DoEWRAMClear			@ yes, you can not run it in external WRAM
-
-	mov     r0, pc
-	lsl     r0, #5				@ Are we running from ROM (0x8000000 or higher) ?
-	bcc     SkipEWRAMClear			@ No, so no need to do a copy.
-
-@---------------------------------------------------------------------------------
-@ We were started in ROM, silly emulators. :P
-@ So we need to copy to ExWRAM.
-@---------------------------------------------------------------------------------
-	mov	r2, #2
-	lsl	r2, r2, #24			@ r2= 0x02000000
-	ldr	r3, =__end__			@ last ewram address
-	sub	r3, r2				@ r3= actual binary size
-	mov	r6, r2				@ r6= 0x02000000
-	lsl	r1, r2, #2			@ r1= 0x08000000
-
-	bl	CopyMem
-
-	bx	r6				@ Jump to the code to execute
-
-@---------------------------------------------------------------------------------
-DoEWRAMClear:					@ Clear External WRAM to 0x00
-@---------------------------------------------------------------------------------
-	mov	r1, #0x40
-	lsl	r1, #12				@ r1 = 0x40000
-	lsl	r0, r1, #7			@ r0 = 0x2000000
-	bl	ClearMem
-
-@---------------------------------------------------------------------------------
-SkipEWRAMClear:					@ Clear Internal WRAM to 0x00
-@---------------------------------------------------------------------------------
-
-@---------------------------------------------------------------------------------
-@ Clear BSS section to 0x00
-@---------------------------------------------------------------------------------
-	ldr	r0, =__bss_start
-	ldr	r1, =__bss_end
-	sub	r1, r0
-	bl	ClearMem
-
-@---------------------------------------------------------------------------------
-@ Clear SBSS section to 0x00
-@---------------------------------------------------------------------------------
-	ldr	r0, =__sbss_start
-	ldr	r1, =__sbss_end
-	sub	r1, r0
-	bl	ClearMem
-
-@---------------------------------------------------------------------------------
-@ Copy initialized data (data section) from LMA to VMA (ROM to RAM)
-@---------------------------------------------------------------------------------
-	ldr	r1, =__data_lma
-	ldr	r2, =__data_start
-	ldr	r4, =__data_end
-	bl	CopyMemChk
-
-@---------------------------------------------------------------------------------
-@ Copy internal work ram (iwram section) from LMA to VMA (ROM to RAM)
-@---------------------------------------------------------------------------------
-	ldr	r1,= __iwram_lma
-	ldr	r2,= __iwram_start
-	ldr	r4,= __iwram_end
-	bl	CopyMemChk
-
-@---------------------------------------------------------------------------------
-@ Copy internal work ram overlay 0 (iwram0 section) from LMA to VMA (ROM to RAM)
-@---------------------------------------------------------------------------------
-	ldr	r2,= __load_stop_iwram0
-	ldr	r1,= __load_start_iwram0
-	sub	r3, r2, r1			@ Is there any data to copy?
-	beq	CIW0Skip			@ no
-
-	ldr	r2,= __iwram_overlay_start
-	bl	CopyMem
-@---------------------------------------------------------------------------------
-CIW0Skip:
-@---------------------------------------------------------------------------------
-@ Copy external work ram (ewram section) from LMA to VMA (ROM to RAM)
-@---------------------------------------------------------------------------------
-	ldr	r1, =__ewram_lma
-	ldr	r2, =__ewram_start
-	ldr	r4, =__ewram_end
-	bl	CopyMemChk
-
-@---------------------------------------------------------------------------------
-CEW0Skip:
-@---------------------------------------------------------------------------------
-@ set heap end
-@---------------------------------------------------------------------------------
-	ldr	r1, =fake_heap_end
-	ldr	r0, =__eheap_end
-	str	r0, [r1]
-@---------------------------------------------------------------------------------
-@ Jump to user code
-@---------------------------------------------------------------------------------
-	mov	r0, #0				@ int argc
-	mov	r1, #0				@ char	*argv[]
-	ldr     r3,=main
-	bx      r3
-	nop								@ This nop is here to allow unmapped memory to be used as
-                    @ as a delay of almost 1 sec with a 1 cycle resolution.
-                    @ Read this for technical info:
-                    @  http://www.devrs.com/gba/files/gbadevfaqs.php#RepeatUses
-@---------------------------------------------------------------------------------
-@ Clear memory to 0x00 if length != 0
-@---------------------------------------------------------------------------------
-@ r0 = Start Address
-@ r1 = Length
-@---------------------------------------------------------------------------------
-ClearMem:
-@---------------------------------------------------------------------------------
-	mov	r2,#3				@ These	commands are used in cases where
-	add	r1,r2				@ the length is	not a multiple of 4,
-	bic	r1,r2				@ even though it should be.
-
-	beq	ClearMX				@ Length is zero so exit
-
-	mov	r2,#0
-@---------------------------------------------------------------------------------
-ClrLoop:
-@---------------------------------------------------------------------------------
-	stmia	r0!, {r2}
-	sub	r1,#4
-	bne	ClrLoop
-@---------------------------------------------------------------------------------
-ClearMX:
-@---------------------------------------------------------------------------------
-	bx	lr
-
-@---------------------------------------------------------------------------------
-@ Copy memory if length	!= 0
-@---------------------------------------------------------------------------------
-@ r1 = Source Address
-@ r2 = Dest Address
-@ r4 = Dest Address + Length
-@---------------------------------------------------------------------------------
-CopyMemChk:
-@---------------------------------------------------------------------------------
-	sub	r3, r4, r2			@ Is there any data to copy?
-@---------------------------------------------------------------------------------
-@ Copy memory
-@---------------------------------------------------------------------------------
-@ r1 = Source Address
-@ r2 = Dest Address
-@ r3 = Length
-@---------------------------------------------------------------------------------
-CopyMem:
-@---------------------------------------------------------------------------------
-	mov	r0, #3				@ These commands are used in cases where
-	add	r3, r0				@ the length is not a multiple	of 4,
-	bic	r3, r0				@ even	though it should be.
-	beq	CIDExit				@ Length is zero so exit
-
-@---------------------------------------------------------------------------------
-CIDLoop:
-@---------------------------------------------------------------------------------
-	ldmia	r1!, {r0}
-	stmia	r2!, {r0}
-	sub	r3, #4
-	bne	CIDLoop
-@---------------------------------------------------------------------------------
-CIDExit:
-@---------------------------------------------------------------------------------
-	bx	lr
-
-	.align
-	.pool
-	.end
-
+@ (c) 2006 by devkitPro (http://www.devkitpro.org)
+
+
+	.section	".init"
+	.global     _start
+	.align
+	.arm
+@---------------------------------------------------------------------------------
+_start:
+@---------------------------------------------------------------------------------
+	b	rom_header_end
+
+	.fill   156,1,0			@ Nintendo Logo Character Data (8000004h)
+	.fill	16,1,0			@ Game Title
+	.byte   0x30,0x31		@ Maker Code (80000B0h)
+	.byte   0x96			@ Fixed Value (80000B2h)
+	.byte   0x00			@ Main Unit Code (80000B3h)
+	.byte   0x00			@ Device Type (80000B4h)
+	.fill	7,1,0			@ unused
+	.byte	0x00			@ Software Version No (80000BCh)
+	.byte	0xf0			@ Complement Check (80000BDh)
+	.byte	0x00,0x00    		@ Checksum (80000BEh)
+
+@---------------------------------------------------------------------------------
+rom_header_end:
+@---------------------------------------------------------------------------------
+	b	start_vector			@ This branch must be here for proper
+						@ positioning of the following header.
+
+	.GLOBAL	__boot_method, __slave_number
+@---------------------------------------------------------------------------------
+__boot_method:
+@---------------------------------------------------------------------------------
+	.byte   0				@ boot method (0=ROM boot, 3=Multiplay boot)
+@---------------------------------------------------------------------------------
+__slave_number:
+@---------------------------------------------------------------------------------
+	.byte   0				@ slave # (1=slave#1, 2=slave#2, 3=slave#3)
+
+	.byte   0 				@ reserved
+	.byte   0 				@ reserved
+	.word   0    				@ reserved
+	.word   0				@ reserved
+	.word   0    				@ reserved
+	.word   0    				@ reserved
+	.word   0    				@ reserved
+	.word   0    				@ reserved
+
+    .global     start_vector
+    .align
+@---------------------------------------------------------------------------------
+start_vector:
+@---------------------------------------------------------------------------------
+	mov	r0, #0x4000000			@ REG_BASE
+	str	r0, [r0, #0x208]
+
+	mov	r0, #0x12			@ Switch to IRQ Mode
+	msr	cpsr, r0
+	ldr	sp, =__sp_irq			@ Set IRQ stack
+	mov	r0, #0x1f			@ Switch to System Mode
+	msr	cpsr, r0
+	ldr	sp, =__sp_usr			@ Set user stack
+
+@---------------------------------------------------------------------------------
+@ Enter Thumb mode
+@---------------------------------------------------------------------------------
+	add	r0, pc, #1
+	bx	r0
+
+	.thumb
+
+	ldr	r0, =__text_start
+	lsl	r0, #5				@ Was code compiled at 0x08000000 or higher?
+	bcs     DoEWRAMClear			@ yes, you can not run it in external WRAM
+
+	mov     r0, pc
+	lsl     r0, #5				@ Are we running from ROM (0x8000000 or higher) ?
+	bcc     SkipEWRAMClear			@ No, so no need to do a copy.
+
+@---------------------------------------------------------------------------------
+@ We were started in ROM, silly emulators. :P
+@ So we need to copy to ExWRAM.
+@---------------------------------------------------------------------------------
+	mov	r2, #2
+	lsl	r2, r2, #24			@ r2= 0x02000000
+	ldr	r3, =__end__			@ last ewram address
+	sub	r3, r2				@ r3= actual binary size
+	mov	r6, r2				@ r6= 0x02000000
+	lsl	r1, r2, #2			@ r1= 0x08000000
+
+	bl	CopyMem
+
+	bx	r6				@ Jump to the code to execute
+
+@---------------------------------------------------------------------------------
+DoEWRAMClear:					@ Clear External WRAM to 0x00
+@---------------------------------------------------------------------------------
+	mov	r1, #0x40
+	lsl	r1, #12				@ r1 = 0x40000
+	lsl	r0, r1, #7			@ r0 = 0x2000000
+	bl	ClearMem
+
+@---------------------------------------------------------------------------------
+SkipEWRAMClear:					@ Clear Internal WRAM to 0x00
+@---------------------------------------------------------------------------------
+
+@---------------------------------------------------------------------------------
+@ Clear BSS section to 0x00
+@---------------------------------------------------------------------------------
+	ldr	r0, =__bss_start
+	ldr	r1, =__bss_end
+	sub	r1, r0
+	bl	ClearMem
+
+@---------------------------------------------------------------------------------
+@ Clear SBSS section to 0x00
+@---------------------------------------------------------------------------------
+	ldr	r0, =__sbss_start
+	ldr	r1, =__sbss_end
+	sub	r1, r0
+	bl	ClearMem
+
+@---------------------------------------------------------------------------------
+@ Copy initialized data (data section) from LMA to VMA (ROM to RAM)
+@---------------------------------------------------------------------------------
+	ldr	r1, =__data_lma
+	ldr	r2, =__data_start
+	ldr	r4, =__data_end
+	bl	CopyMemChk
+
+@---------------------------------------------------------------------------------
+@ Copy internal work ram (iwram section) from LMA to VMA (ROM to RAM)
+@---------------------------------------------------------------------------------
+	ldr	r1,= __iwram_lma
+	ldr	r2,= __iwram_start
+	ldr	r4,= __iwram_end
+	bl	CopyMemChk
+
+@---------------------------------------------------------------------------------
+@ Copy internal work ram overlay 0 (iwram0 section) from LMA to VMA (ROM to RAM)
+@---------------------------------------------------------------------------------
+	ldr	r2,= __load_stop_iwram0
+	ldr	r1,= __load_start_iwram0
+	sub	r3, r2, r1			@ Is there any data to copy?
+	beq	CIW0Skip			@ no
+
+	ldr	r2,= __iwram_overlay_start
+	bl	CopyMem
+@---------------------------------------------------------------------------------
+CIW0Skip:
+@---------------------------------------------------------------------------------
+@ Copy external work ram (ewram section) from LMA to VMA (ROM to RAM)
+@---------------------------------------------------------------------------------
+	ldr	r1, =__ewram_lma
+	ldr	r2, =__ewram_start
+	ldr	r4, =__ewram_end
+	bl	CopyMemChk
+
+@---------------------------------------------------------------------------------
+CEW0Skip:
+@---------------------------------------------------------------------------------
+@ set heap end
+@---------------------------------------------------------------------------------
+	ldr	r1, =fake_heap_end
+	ldr	r0, =__eheap_end
+	str	r0, [r1]
+@---------------------------------------------------------------------------------
+@ Jump to user code
+@---------------------------------------------------------------------------------
+	mov	r0, #0				@ int argc
+	mov	r1, #0				@ char	*argv[]
+	ldr     r3,=main
+	bx      r3
+	nop								@ This nop is here to allow unmapped memory to be used as
+                    @ as a delay of almost 1 sec with a 1 cycle resolution.
+                    @ Read this for technical info:
+                    @  http://www.devrs.com/gba/files/gbadevfaqs.php#RepeatUses
+@---------------------------------------------------------------------------------
+@ Clear memory to 0x00 if length != 0
+@---------------------------------------------------------------------------------
+@ r0 = Start Address
+@ r1 = Length
+@---------------------------------------------------------------------------------
+ClearMem:
+@---------------------------------------------------------------------------------
+	mov	r2,#3				@ These	commands are used in cases where
+	add	r1,r2				@ the length is	not a multiple of 4,
+	bic	r1,r2				@ even though it should be.
+
+	beq	ClearMX				@ Length is zero so exit
+
+	mov	r2,#0
+@---------------------------------------------------------------------------------
+ClrLoop:
+@---------------------------------------------------------------------------------
+	stmia	r0!, {r2}
+	sub	r1,#4
+	bne	ClrLoop
+@---------------------------------------------------------------------------------
+ClearMX:
+@---------------------------------------------------------------------------------
+	bx	lr
+
+@---------------------------------------------------------------------------------
+@ Copy memory if length	!= 0
+@---------------------------------------------------------------------------------
+@ r1 = Source Address
+@ r2 = Dest Address
+@ r4 = Dest Address + Length
+@---------------------------------------------------------------------------------
+CopyMemChk:
+@---------------------------------------------------------------------------------
+	sub	r3, r4, r2			@ Is there any data to copy?
+@---------------------------------------------------------------------------------
+@ Copy memory
+@---------------------------------------------------------------------------------
+@ r1 = Source Address
+@ r2 = Dest Address
+@ r3 = Length
+@---------------------------------------------------------------------------------
+CopyMem:
+@---------------------------------------------------------------------------------
+	mov	r0, #3				@ These commands are used in cases where
+	add	r3, r0				@ the length is not a multiple	of 4,
+	bic	r3, r0				@ even	though it should be.
+	beq	CIDExit				@ Length is zero so exit
+
+@---------------------------------------------------------------------------------
+CIDLoop:
+@---------------------------------------------------------------------------------
+	ldmia	r1!, {r0}
+	stmia	r2!, {r0}
+	sub	r3, #4
+	bne	CIDLoop
+@---------------------------------------------------------------------------------
+CIDExit:
+@---------------------------------------------------------------------------------
+	bx	lr
+
+	.align
+	.pool
+	.end
+

+ 50 - 50
rtl/linux/arm/cprt0.as

@@ -20,58 +20,58 @@
 /* This is the canonical entry point, usually the first thing in the text
    segment.
 
-	Note that the code in the .init section has already been run.
-	This includes _init and _libc_init
+        Note that the code in the .init section has already been run.
+        This includes _init and _libc_init
 
 
-	At this entry point, most registers' values are unspecified, except:
+        At this entry point, most registers' values are unspecified, except:
 
-   a1		Contains a function pointer to be registered with `atexit'.
-		This is how the dynamic linker arranges to have DT_FINI
-		functions called for shared libraries that have been loaded
-		before this code runs.
+   a1           Contains a function pointer to be registered with `atexit'.
+                This is how the dynamic linker arranges to have DT_FINI
+                functions called for shared libraries that have been loaded
+                before this code runs.
 
-   sp		The stack contains the arguments and environment:
-		0(sp)			argc
-		4(sp)			argv[0]
-		...
-		(4*argc)(sp)		NULL
-		(4*(argc+1))(sp)	envp[0]
-		...
-					NULL
+   sp           The stack contains the arguments and environment:
+                0(sp)                   argc
+                4(sp)                   argv[0]
+                ...
+                (4*argc)(sp)            NULL
+                (4*(argc+1))(sp)        envp[0]
+                ...
+                                        NULL
 */
 
-	.text
-	.globl _start
-	.type _start,#function
+        .text
+        .globl _start
+        .type _start,#function
 _start:
-	/* Clear the frame pointer since this is the outermost frame.  */
-	mov fp, #0
-	ldmia   sp!, {a2}
+        /* Clear the frame pointer since this is the outermost frame.  */
+        mov fp, #0
+        ldmia   sp!, {a2}
 
-	/* Pop argc off the stack and save a pointer to argv */
-	ldr ip,=operatingsystem_parameter_argc
-	ldr a3,=operatingsystem_parameter_argv
-	str a2,[ip]
+        /* Pop argc off the stack and save a pointer to argv */
+        ldr ip,=operatingsystem_parameter_argc
+        ldr a3,=operatingsystem_parameter_argv
+        str a2,[ip]
 
-	/* calc envp */
-	add a4,a2,#1
-	add a4,sp,a4,LSL #2
-	ldr ip,=operatingsystem_parameter_envp
+        /* calc envp */
+        add a4,a2,#1
+        add a4,sp,a4,LSL #2
+        ldr ip,=operatingsystem_parameter_envp
 
-	str sp,[a3]
-    	str a4,[ip]
+        str sp,[a3]
+        str a4,[ip]
 
-    /* Save initial stackpointer */
-	ldr ip,=__stkptr
-	str sp,[ip]
+        /* Save initial stackpointer */
+        ldr ip,=__stkptr
+        str sp,[ip]
 
         /* Fetch address of fini */
         ldr ip, =_fini
 
         /* argc already loaded to a2*/
 
-        /* load argv
+        /* load argv */
         mov a3, sp
 
         /* Push stack limit */
@@ -95,21 +95,21 @@ _start:
         /* should never get here....*/
         bl abort
 
-	.globl  _haltproc
+        .globl  _haltproc
     .type   _haltproc,#function
 _haltproc:
-	ldr r0,=operatingsystem_result
-	ldrb r0,[r0]
-	swi 0x900001
-	b _haltproc
-
-	/* Define a symbol for the first piece of initialized data.  */
-	.data
-	.globl __data_start
+        ldr r0,=operatingsystem_result
+        ldrb r0,[r0]
+        swi 0x900001
+        b _haltproc
+
+        /* Define a symbol for the first piece of initialized data.  */
+        .data
+        .globl __data_start
 __data_start:
-	.long 0
-	.weak data_start
-	data_start = __data_start
+        .long 0
+        .weak data_start
+        data_start = __data_start
 
 .bss
         .comm __stkptr,4
@@ -118,9 +118,9 @@ __data_start:
         .comm operatingsystem_parameter_argc,4
         .comm operatingsystem_parameter_argv,4
 
-	.section ".comment"
-	.byte 0
-	.ascii "generated by FPC http://www.freepascal.org\0"
+        .section ".comment"
+        .byte 0
+        .ascii "generated by FPC http://www.freepascal.org\0"
 
 /* We need this stuff to make gdb behave itself, otherwise
    gdb will chokes with SIGILL when trying to debug apps.

+ 75 - 75
rtl/linux/m68k/cprt0.as

@@ -1,75 +1,75 @@
-|
-|   $Id: cprt0.as,v 1.1.2.2 2001/08/01 13:26:17 pierre Exp $
-|   This file is part of the Free Pascal run time library.
-|   Copyright (c) 2001 by Free Pascal Core Team
-|
-|   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.
-|
-|**********************************************************************}
-|
-| Linux m68k ELF startup code for linking with C lib for Free Pascal
-|
-        .file   "cprt0.as"
-	.text
-        .globl  _start
-        .type   _start,@function
-_start:
-        .globl  __entry
-        .type   __entry,@function
-__entry:
-        move.l   8(%sp),%d0
-        move.l   %d0,U_SYSLINUX_ENVP
-        move.l   %d0,__environ
-        move.l   4(%sp),%d0
-        move.l   %d0,U_SYSLINUX_ARGV
-        move.l   (%sp),%d0
-        move.l   %d0,U_SYSLINUX_ARGC
-|       The arguments should be in correct order for
-|       calling __libc_init
-|       This code is untested for now PM
-        jsr     __libc_init
-|       insert _fini in atexit chain
-        move.l   _fini,-(%sp)
-        jsr      atexit
-        addq.l   #4,%sp
-|       call _init function
-        jsr      _init
-
-        jsr      PASCALMAIN
-
-|       Used by System_exit procedure
-        .globl  _haltproc
-_haltproc:
-|       Call C exit function
-        move.w   U_SYSLINUX_EXITCODE,%d1
-        move.l   %d1,-(%sp)
-        jsr      exit
-        moveq.l  #1,%d0
-        move.l   (%sp)+,%d1
-        trap     #0
-        bra      _haltproc
-
-
-|       Is this still needed ??
-|        .data
-|        .align	4
-|        .globl	___fpc_brk_addr
-|___fpc_brk_addr:
-|       .long	0
-
-
-|
-| $Log: cprt0.as,v $
-| Revision 1.1.2.2  2001/08/01 13:26:17  pierre
-|  * syntax adapted to GNU as
-|
-| Revision 1.1.2.1  2001/07/13 15:29:32  pierre
-|  first version of cprt0.as
-|
-|
-
+|
+|   $Id: cprt0.as,v 1.1.2.2 2001/08/01 13:26:17 pierre Exp $
+|   This file is part of the Free Pascal run time library.
+|   Copyright (c) 2001 by Free Pascal Core Team
+|
+|   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.
+|
+|**********************************************************************}
+|
+| Linux m68k ELF startup code for linking with C lib for Free Pascal
+|
+        .file   "cprt0.as"
+	.text
+        .globl  _start
+        .type   _start,@function
+_start:
+        .globl  __entry
+        .type   __entry,@function
+__entry:
+        move.l   8(%sp),%d0
+        move.l   %d0,U_SYSLINUX_ENVP
+        move.l   %d0,__environ
+        move.l   4(%sp),%d0
+        move.l   %d0,U_SYSLINUX_ARGV
+        move.l   (%sp),%d0
+        move.l   %d0,U_SYSLINUX_ARGC
+|       The arguments should be in correct order for
+|       calling __libc_init
+|       This code is untested for now PM
+        jsr     __libc_init
+|       insert _fini in atexit chain
+        move.l   _fini,-(%sp)
+        jsr      atexit
+        addq.l   #4,%sp
+|       call _init function
+        jsr      _init
+
+        jsr      PASCALMAIN
+
+|       Used by System_exit procedure
+        .globl  _haltproc
+_haltproc:
+|       Call C exit function
+        move.w   U_SYSLINUX_EXITCODE,%d1
+        move.l   %d1,-(%sp)
+        jsr      exit
+        moveq.l  #1,%d0
+        move.l   (%sp)+,%d1
+        trap     #0
+        bra      _haltproc
+
+
+|       Is this still needed ??
+|        .data
+|        .align	4
+|        .globl	___fpc_brk_addr
+|___fpc_brk_addr:
+|       .long	0
+
+
+|
+| $Log: cprt0.as,v $
+| Revision 1.1.2.2  2001/08/01 13:26:17  pierre
+|  * syntax adapted to GNU as
+|
+| Revision 1.1.2.1  2001/07/13 15:29:32  pierre
+|  first version of cprt0.as
+|
+|
+

+ 144 - 144
rtl/linux/m68k/cprt21.as

@@ -1,144 +1,144 @@
-|
-|   $Id: cprt21.as,v 1.1.2.5 2002/02/28 22:44:44 pierre Exp $
-|   This file is part of the Free Pascal run time library.
-|   Copyright (c) 1999-2000 by Michael Van Canneyt and Peter Vreman
-|   members of the Free Pascal development team.
-|
-|   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.
-|
-|**********************************************************************}
-|
-| Linux ELF startup code for Free Pascal
-|
-
-        .file   "prt1.as"
-        .text
-        .globl  _start
-        .type   _start,@function
-_start:
-        /* First locate the start of the environment variables */
-        move.l    (%sp)+,%d3
-        move.l    %d0,%d4
-
-        move.l    %sp,%d1               /* Points to the arguments */
-        move.l    %d3,%d0
-        addq.l    #1,%d0
-        lsl.l     #2,%d0
-        add.l     %sp,%d0
-
-        move.l    %sp,%d7
-        and.l     #0xfffffff8,%d7        /* Align stack */
-        move.l    %d7,%sp
-
-        move.l    %d0,U_SYSLINUX_ENVP    /* Move the environment pointer */
-        move.l    %d3,U_SYSLINUX_ARGC    /* Move the argument counter    */
-        move.l    %d1,U_SYSLINUX_ARGV    /* Move the argument pointer    */
-
-        move.l   #0,%fp                  /* Zero frame pointer to end call stack */
-
-|
-|       Start of args for __libc_start_main
-|
-|
-        move.l   %d4,-(%sp)
-        move.l   %sp,-(%sp)
-        move.l   %a1,-(%sp)
-        pea.l    _fini_dummy
-        pea.l    _init_dummy
-        move.l   %d1,-(%sp)
-        move.l   %d3,-(%sp)
-        pea.l    main
-        jsr      __libc_start_main
-        trap     #0
-
-/* fake main routine which will be run from libc */
-main:
-        /* save return address */
-        move.l    (%sp)+,%d0
-        move.l    %d0,___fpc_ret
-        move.l    %d1,___fpc_ret_d1
-        move.l    %fp,___fpc_ret_fp
-        move.l    %d0,-(%sp)
-
-        /* start the program */
-        move.l   #0,%fp
-        jsr      PASCALMAIN
-
-        .globl _haltproc
-        .type _haltproc,@function
-_haltproc:
-        eor.l    %d0,%d0               /* load and save exitcode */
-        move.w   U_SYSLINUX_EXITCODE,%d0
-
-        move.l    ___fpc_ret,%d3         /* return to libc */
-        move.l    ___fpc_ret_fp,%fp
-        move.l    ___fpc_ret_d1,%d1
-        move.l    %d3,-(%sp)
-_init_dummy:
-_fini_dummy:
-        rts
-
-.data
-        .align  4
-
-        .globl  ___fpc_brk_addr         /* heap management */
-        .type   ___fpc_brk_addr,@object
-        .size   ___fpc_brk_addr,4
-___fpc_brk_addr:
-        .long   0
-
-___fpc_ret:                             /* return address to libc */
-        .long   0
-___fpc_ret_d1:
-        .long   0
-___fpc_ret_fp:
-        .long   0
-
-
-|
-| $Log: cprt21.as,v $
-| Revision 1.1.2.5  2002/02/28 22:44:44  pierre
-|  + add some comments
-|
-| Revision 1.1.2.4  2001/08/02 21:23:59  pierre
-|  * fix the args to __libc_start_main
-|
-| Revision 1.1.2.3  2001/07/30 20:05:07  pierre
-|  * fix a assembler syntax eror in last commit
-|
-| Revision 1.1.2.2  2001/07/30 16:18:53  pierre
-|  * converted from i386 code
-|
-| Revision 1.1.2.2  2001/06/04 18:04:32  peter
-|   * use own dummies for _init and _fini
-|
-| Revision 1.1.2.1  2001/02/14 22:18:45  pierre
-|  * fix Sebastian's problem with HeapTrace
-|
-| Revision 1.1  2000/07/13 06:30:55  michael
-| + Initial import
-|
-| Revision 1.3  2000/01/07 16:41:42  daniel
-|   * copyright 2000
-|
-| Revision 1.2  2000/01/07 16:32:28  daniel
-|   * copyright 2000 added
-|
-| Revision 1.1  1999/05/03 21:29:36  peter
-|   + glibc 2.1 support
-|
-| Revision 1.3  1998/11/04 10:16:25  peter
-|   + xorl fp,fp to indicate end of backtrace
-|
-| Revision 1.2  1998/10/14 21:28:46  peter
-|   * initialize fpu so sigfpe is finally generated for fpu errors
-|
-| Revision 1.1  1998/08/12 19:16:09  peter
-|   + loader including libc init and exit
-|
-|
+|
+|   $Id: cprt21.as,v 1.1.2.5 2002/02/28 22:44:44 pierre Exp $
+|   This file is part of the Free Pascal run time library.
+|   Copyright (c) 1999-2000 by Michael Van Canneyt and Peter Vreman
+|   members of the Free Pascal development team.
+|
+|   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.
+|
+|**********************************************************************}
+|
+| Linux ELF startup code for Free Pascal
+|
+
+        .file   "prt1.as"
+        .text
+        .globl  _start
+        .type   _start,@function
+_start:
+        /* First locate the start of the environment variables */
+        move.l    (%sp)+,%d3
+        move.l    %d0,%d4
+
+        move.l    %sp,%d1               /* Points to the arguments */
+        move.l    %d3,%d0
+        addq.l    #1,%d0
+        lsl.l     #2,%d0
+        add.l     %sp,%d0
+
+        move.l    %sp,%d7
+        and.l     #0xfffffff8,%d7        /* Align stack */
+        move.l    %d7,%sp
+
+        move.l    %d0,U_SYSLINUX_ENVP    /* Move the environment pointer */
+        move.l    %d3,U_SYSLINUX_ARGC    /* Move the argument counter    */
+        move.l    %d1,U_SYSLINUX_ARGV    /* Move the argument pointer    */
+
+        move.l   #0,%fp                  /* Zero frame pointer to end call stack */
+
+|
+|       Start of args for __libc_start_main
+|
+|
+        move.l   %d4,-(%sp)
+        move.l   %sp,-(%sp)
+        move.l   %a1,-(%sp)
+        pea.l    _fini_dummy
+        pea.l    _init_dummy
+        move.l   %d1,-(%sp)
+        move.l   %d3,-(%sp)
+        pea.l    main
+        jsr      __libc_start_main
+        trap     #0
+
+/* fake main routine which will be run from libc */
+main:
+        /* save return address */
+        move.l    (%sp)+,%d0
+        move.l    %d0,___fpc_ret
+        move.l    %d1,___fpc_ret_d1
+        move.l    %fp,___fpc_ret_fp
+        move.l    %d0,-(%sp)
+
+        /* start the program */
+        move.l   #0,%fp
+        jsr      PASCALMAIN
+
+        .globl _haltproc
+        .type _haltproc,@function
+_haltproc:
+        eor.l    %d0,%d0               /* load and save exitcode */
+        move.w   U_SYSLINUX_EXITCODE,%d0
+
+        move.l    ___fpc_ret,%d3         /* return to libc */
+        move.l    ___fpc_ret_fp,%fp
+        move.l    ___fpc_ret_d1,%d1
+        move.l    %d3,-(%sp)
+_init_dummy:
+_fini_dummy:
+        rts
+
+.data
+        .align  4
+
+        .globl  ___fpc_brk_addr         /* heap management */
+        .type   ___fpc_brk_addr,@object
+        .size   ___fpc_brk_addr,4
+___fpc_brk_addr:
+        .long   0
+
+___fpc_ret:                             /* return address to libc */
+        .long   0
+___fpc_ret_d1:
+        .long   0
+___fpc_ret_fp:
+        .long   0
+
+
+|
+| $Log: cprt21.as,v $
+| Revision 1.1.2.5  2002/02/28 22:44:44  pierre
+|  + add some comments
+|
+| Revision 1.1.2.4  2001/08/02 21:23:59  pierre
+|  * fix the args to __libc_start_main
+|
+| Revision 1.1.2.3  2001/07/30 20:05:07  pierre
+|  * fix a assembler syntax eror in last commit
+|
+| Revision 1.1.2.2  2001/07/30 16:18:53  pierre
+|  * converted from i386 code
+|
+| Revision 1.1.2.2  2001/06/04 18:04:32  peter
+|   * use own dummies for _init and _fini
+|
+| Revision 1.1.2.1  2001/02/14 22:18:45  pierre
+|  * fix Sebastian's problem with HeapTrace
+|
+| Revision 1.1  2000/07/13 06:30:55  michael
+| + Initial import
+|
+| Revision 1.3  2000/01/07 16:41:42  daniel
+|   * copyright 2000
+|
+| Revision 1.2  2000/01/07 16:32:28  daniel
+|   * copyright 2000 added
+|
+| Revision 1.1  1999/05/03 21:29:36  peter
+|   + glibc 2.1 support
+|
+| Revision 1.3  1998/11/04 10:16:25  peter
+|   + xorl fp,fp to indicate end of backtrace
+|
+| Revision 1.2  1998/10/14 21:28:46  peter
+|   * initialize fpu so sigfpe is finally generated for fpu errors
+|
+| Revision 1.1  1998/08/12 19:16:09  peter
+|   + loader including libc init and exit
+|
+|

+ 66 - 66
rtl/linux/m68k/dllprt0.as

@@ -1,66 +1,66 @@
-|
-|   $Id: dllprt0.as,v 1.1.2.4 2001/08/01 13:26:17 pierre Exp $
-|   This file is part of the Free Pascal run time library.
-|   Copyright (c) 2001 by Pierre Muller
-|
-|   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.
-|
-|**********************************************************************}
-|
-| Linux m68k ELF shared library startup code for Free Pascal
-|
-        .file "dllprt0.as"
-	.text
-        .globl  _startlib
-        .type   _startlib,@function
-_startlib:
-        .globl  FPC_LIB_START
-        .type   FPC_LIB_START,@function
-FPC_LIB_START:
-|
-|       The args and envs are not tested yet
-|
-        move.l   (%sp)+, %d0
-        lea      4(%sp,%d0*4),%a0
-        move.l   %a0, U_SYSLINUX_ENVP
-        move.l   %sp,U_SYSLINUX_ARGV
-        move.l   %d0,U_SYSLINUX_ARGC
-        jsr      PASCALMAIN
-        rts
-
-        .globl  _haltproc
-        .type   _haltproc,@function
-haltproc:
-        moveq.l   #1,%d0
-        move.w    U_SYSLINUX_EXITCODE,%d1
-        trap      #0
-        bra       _haltproc
-
-
-        .data
-	.align  4
-	.globl  ___fpc_brk_addr
-___fpc_brk_addr:
-        .long   0
-
-|
-| $Log: dllprt0.as,v $
-| Revision 1.1.2.4  2001/08/01 13:26:17  pierre
-|  * syntax adapted to GNU as
-|
-| Revision 1.1.2.3  2001/07/13 15:13:47  pierre
-|  + add and fix some comments
-|
-| Revision 1.1.2.2  2001/07/13 15:04:35  pierre
-|  * correct assembler error
-|
-| Revision 1.1.2.1  2001/07/13 15:03:02  pierre
-|  + New file converted from i386 version
-|
-|
-
+|
+|   $Id: dllprt0.as,v 1.1.2.4 2001/08/01 13:26:17 pierre Exp $
+|   This file is part of the Free Pascal run time library.
+|   Copyright (c) 2001 by Pierre Muller
+|
+|   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.
+|
+|**********************************************************************}
+|
+| Linux m68k ELF shared library startup code for Free Pascal
+|
+        .file "dllprt0.as"
+	.text
+        .globl  _startlib
+        .type   _startlib,@function
+_startlib:
+        .globl  FPC_LIB_START
+        .type   FPC_LIB_START,@function
+FPC_LIB_START:
+|
+|       The args and envs are not tested yet
+|
+        move.l   (%sp)+, %d0
+        lea      4(%sp,%d0*4),%a0
+        move.l   %a0, U_SYSLINUX_ENVP
+        move.l   %sp,U_SYSLINUX_ARGV
+        move.l   %d0,U_SYSLINUX_ARGC
+        jsr      PASCALMAIN
+        rts
+
+        .globl  _haltproc
+        .type   _haltproc,@function
+haltproc:
+        moveq.l   #1,%d0
+        move.w    U_SYSLINUX_EXITCODE,%d1
+        trap      #0
+        bra       _haltproc
+
+
+        .data
+	.align  4
+	.globl  ___fpc_brk_addr
+___fpc_brk_addr:
+        .long   0
+
+|
+| $Log: dllprt0.as,v $
+| Revision 1.1.2.4  2001/08/01 13:26:17  pierre
+|  * syntax adapted to GNU as
+|
+| Revision 1.1.2.3  2001/07/13 15:13:47  pierre
+|  + add and fix some comments
+|
+| Revision 1.1.2.2  2001/07/13 15:04:35  pierre
+|  * correct assembler error
+|
+| Revision 1.1.2.1  2001/07/13 15:03:02  pierre
+|  + New file converted from i386 version
+|
+|
+

+ 92 - 92
rtl/linux/m68k/gprt0.as

@@ -1,92 +1,92 @@
-|
-|   $Id: gprt0.as,v 1.1.2.3 2001/08/01 13:26:17 pierre Exp $
-|   This file is part of the Free Pascal run time library.
-|   Copyright (c) 2001 by Free Pascal Core Team
-|
-|   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.
-|
-|**********************************************************************}
-|
-| Linux m68k ELF startup code with profiling support for Free Pascal
-| Note: Needs linking with -lgmon and -lc
-|
-        .file   "gprt0.as"
-	.text
-        .globl  _start
-        .type   _start,@function
-_start:
-        .globl  __entry
-        .type   __entry,@function
-__entry:
-        move.l   8(%sp),%d0
-        move.l   %d0,U_SYSLINUX_ENVP
-        move.l   %d0,__environ
-        move.l   4(%sp),%d0
-        move.l   %d0,U_SYSLINUX_ARGV
-        move.l   (%sp),%d0
-        move.l   %d0,U_SYSLINUX_ARGC
-|       Initialize gmon
-|       Should this be done before or after __libc_init call ??
-|
-        move.l   _etext,-(%sp)                 /* Initialize gmon */
-        move.l   _start,-(%sp)
-        jsr      monstartup
-        addq.l   #8,%sp
-        move.l   _mcleanup,-(%sp)
-        jsr      atexit
-        addq.l   #4,%sp
-
-
-|       The arguments should be in correct order for
-|       calling __libc_init
-|       This code is untested for now PM
-        jsr     __libc_init
-|       insert _fini in atexit chain
-        move.l   _fini,-(%sp)
-        jsr      atexit
-        addq.l     #4,%sp
-|       call _init function
-        jsr      _init
-
-        jsr     PASCALMAIN
-
-|       Used by System_exit procedure
-        .globl  _haltproc
-_haltproc:
-|       Call C exit function
-        move.w   U_SYSLINUX_EXITCODE,%d1
-        move.l   %d1,-(%sp)
-        jsr      exit
-        moveq.l  #1,%d0
-        move.l   (%sp)+,%d1
-        trap     #0
-        bra      _haltproc
-
-
-|       Is this still needed ??
-|        .data
-|        .align	4
-|        .globl	___fpc_brk_addr
-|___fpc_brk_addr:
-|       .long	0
-
-
-|
-| $Log: gprt0.as,v $
-| Revision 1.1.2.3  2001/08/01 13:26:17  pierre
-|  * syntax adapted to GNU as
-|
-| Revision 1.1.2.2  2001/07/13 15:43:22  pierre
-|  assembler error corrected
-|
-| Revision 1.1.2.1  2001/07/13 15:38:54  pierre
-|  first version of gprt0.as file
-|
-|
-|
-
+|
+|   $Id: gprt0.as,v 1.1.2.3 2001/08/01 13:26:17 pierre Exp $
+|   This file is part of the Free Pascal run time library.
+|   Copyright (c) 2001 by Free Pascal Core Team
+|
+|   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.
+|
+|**********************************************************************}
+|
+| Linux m68k ELF startup code with profiling support for Free Pascal
+| Note: Needs linking with -lgmon and -lc
+|
+        .file   "gprt0.as"
+	.text
+        .globl  _start
+        .type   _start,@function
+_start:
+        .globl  __entry
+        .type   __entry,@function
+__entry:
+        move.l   8(%sp),%d0
+        move.l   %d0,U_SYSLINUX_ENVP
+        move.l   %d0,__environ
+        move.l   4(%sp),%d0
+        move.l   %d0,U_SYSLINUX_ARGV
+        move.l   (%sp),%d0
+        move.l   %d0,U_SYSLINUX_ARGC
+|       Initialize gmon
+|       Should this be done before or after __libc_init call ??
+|
+        move.l   _etext,-(%sp)                 /* Initialize gmon */
+        move.l   _start,-(%sp)
+        jsr      monstartup
+        addq.l   #8,%sp
+        move.l   _mcleanup,-(%sp)
+        jsr      atexit
+        addq.l   #4,%sp
+
+
+|       The arguments should be in correct order for
+|       calling __libc_init
+|       This code is untested for now PM
+        jsr     __libc_init
+|       insert _fini in atexit chain
+        move.l   _fini,-(%sp)
+        jsr      atexit
+        addq.l     #4,%sp
+|       call _init function
+        jsr      _init
+
+        jsr     PASCALMAIN
+
+|       Used by System_exit procedure
+        .globl  _haltproc
+_haltproc:
+|       Call C exit function
+        move.w   U_SYSLINUX_EXITCODE,%d1
+        move.l   %d1,-(%sp)
+        jsr      exit
+        moveq.l  #1,%d0
+        move.l   (%sp)+,%d1
+        trap     #0
+        bra      _haltproc
+
+
+|       Is this still needed ??
+|        .data
+|        .align	4
+|        .globl	___fpc_brk_addr
+|___fpc_brk_addr:
+|       .long	0
+
+
+|
+| $Log: gprt0.as,v $
+| Revision 1.1.2.3  2001/08/01 13:26:17  pierre
+|  * syntax adapted to GNU as
+|
+| Revision 1.1.2.2  2001/07/13 15:43:22  pierre
+|  assembler error corrected
+|
+| Revision 1.1.2.1  2001/07/13 15:38:54  pierre
+|  first version of gprt0.as file
+|
+|
+|
+

+ 95 - 95
rtl/linux/m68k/gprt21.as

@@ -1,95 +1,95 @@
-|
-|   $Id: gprt21.as,v 1.1.2.2 2001/08/01 13:26:17 pierre Exp $
-|   This file is part of the Free Pascal run time library.
-|   Copyright (c) 2001 by Free Pascal Core Team
-|
-|   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.
-|
-|**********************************************************************}
-|
-| Linux m68k ELF startup code with profiling support for Free Pascal
-| Note: Needs linking with -lgmon and -lc
-|
-        .file   "gprt0.as"
-	.text
-        .globl   _start
-        .type    _start,@function
-_start:
-        .globl   __entry
-        .type    __entry,@function
-__entry:
-        move.l   8(%sp),%d0
-        move.l   %d0,U_SYSLINUX_ENVP
-        move.l   %d0,__environ
-        move.l   4(%sp),%d0
-        move.l   %d0,U_SYSLINUX_ARGV
-        move.l   (%sp),%d0
-        move.l   %d0,U_SYSLINUX_ARGC
-|       Initialize gmon
-|       Should this be done before or after __libc_init call ??
-|
-        move.l   _etext,-(%sp)                 /* Initialize gmon */
-        move.l   _start,-(%sp)
-        jsr      monstartup
-        addq.l   #8,%sp
-        move.l   _mcleanup,-(%sp)
-        jsr      atexit
-        addq.l   #4,%sp
-
-
-|       The arguments should be in correct order for
-|       calling __libc_init
-|       This code is untested for now PM
-        jsr      __libc_init
-|       insert _fini in atexit chain
-        move.l   _fini,-(%sp)
-        jsr      atexit
-        addq.l   #4,%sp
-|       call _init function
-        jsr      _init
-
-        jsr      PASCALMAIN
-
-|       Used by System_exit procedure
-        .globl  _haltproc
-_haltproc:
-|       Call C exit function
-        move.w   U_SYSLINUX_EXITCODE,%d1
-        move.l   %d1,-(%sp)
-        jsr      exit
-        moveq.l  #1,%d0
-        move.l   (%sp)+,%d1
-        trap     #0
-        bra      _haltproc
-
-
-|       Is this still needed ??
-|        .data
-|        .align	4
-|        .globl	___fpc_brk_addr
-|___fpc_brk_addr:
-|       .long	0
-
-
-|
-| $Log: gprt21.as,v $
-| Revision 1.1.2.2  2001/08/01 13:26:17  pierre
-|  * syntax adapted to GNU as
-|
-| Revision 1.1.2.1  2001/07/13 15:45:40  pierre
-|  simple copies of cprt0 and gprt0 added
-|
-| Revision 1.1.2.2  2001/07/13 15:43:22  pierre
-|  assembler error corrected
-|
-| Revision 1.1.2.1  2001/07/13 15:38:54  pierre
-|  first version of gprt0.as file
-|
-|
-|
-
+|
+|   $Id: gprt21.as,v 1.1.2.2 2001/08/01 13:26:17 pierre Exp $
+|   This file is part of the Free Pascal run time library.
+|   Copyright (c) 2001 by Free Pascal Core Team
+|
+|   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.
+|
+|**********************************************************************}
+|
+| Linux m68k ELF startup code with profiling support for Free Pascal
+| Note: Needs linking with -lgmon and -lc
+|
+        .file   "gprt0.as"
+	.text
+        .globl   _start
+        .type    _start,@function
+_start:
+        .globl   __entry
+        .type    __entry,@function
+__entry:
+        move.l   8(%sp),%d0
+        move.l   %d0,U_SYSLINUX_ENVP
+        move.l   %d0,__environ
+        move.l   4(%sp),%d0
+        move.l   %d0,U_SYSLINUX_ARGV
+        move.l   (%sp),%d0
+        move.l   %d0,U_SYSLINUX_ARGC
+|       Initialize gmon
+|       Should this be done before or after __libc_init call ??
+|
+        move.l   _etext,-(%sp)                 /* Initialize gmon */
+        move.l   _start,-(%sp)
+        jsr      monstartup
+        addq.l   #8,%sp
+        move.l   _mcleanup,-(%sp)
+        jsr      atexit
+        addq.l   #4,%sp
+
+
+|       The arguments should be in correct order for
+|       calling __libc_init
+|       This code is untested for now PM
+        jsr      __libc_init
+|       insert _fini in atexit chain
+        move.l   _fini,-(%sp)
+        jsr      atexit
+        addq.l   #4,%sp
+|       call _init function
+        jsr      _init
+
+        jsr      PASCALMAIN
+
+|       Used by System_exit procedure
+        .globl  _haltproc
+_haltproc:
+|       Call C exit function
+        move.w   U_SYSLINUX_EXITCODE,%d1
+        move.l   %d1,-(%sp)
+        jsr      exit
+        moveq.l  #1,%d0
+        move.l   (%sp)+,%d1
+        trap     #0
+        bra      _haltproc
+
+
+|       Is this still needed ??
+|        .data
+|        .align	4
+|        .globl	___fpc_brk_addr
+|___fpc_brk_addr:
+|       .long	0
+
+
+|
+| $Log: gprt21.as,v $
+| Revision 1.1.2.2  2001/08/01 13:26:17  pierre
+|  * syntax adapted to GNU as
+|
+| Revision 1.1.2.1  2001/07/13 15:45:40  pierre
+|  simple copies of cprt0 and gprt0 added
+|
+| Revision 1.1.2.2  2001/07/13 15:43:22  pierre
+|  assembler error corrected
+|
+| Revision 1.1.2.1  2001/07/13 15:38:54  pierre
+|  first version of gprt0.as file
+|
+|
+|
+

+ 119 - 119
rtl/linux/powerpc/cprt0.as

@@ -1,119 +1,119 @@
-/*
- * Startup code for programs linked with GNU libc, PowerPC
- * version.
- *
- * Adapted from the glibc-sources (2.3.5) in the file
- *
- *     sysdeps/powerpc/powerpc32/elf/start.S
- *
- * Original header follows.
- */
-
-/* Startup code for programs linked with GNU libc.
-   Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library 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.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
-*/
-
-/* These are the various addresses we require.  */
-    .section ".rodata"
-    .align    2
-start_addresses:
-    .long     _SDA_BASE_
-    .long     main_stub
-    .long     __libc_csu_init
-    .long     __libc_csu_fini
-    .size   start_adresses, .-start_addresses
-
-    .section ".text"
-    .globl  _start
-_start:
-    /* save stack pointer for later use */
-    mr     9, 1
- /* Set up an initial stack frame, and clear the LR.  */
-    clrrwi 1, 1, 4
-    li     0, 0
-    stwu   1, -16(1)
-    mtlr   0
-    stw    0, 0(1)
- /* Set r13 to point at the 'small data area', and put the address of
-    start_addresses in r8...  */
-    lis    8,  start_addresses@ha
-    lwzu   13, start_addresses@l(8)
- /* and continue in libc-start, in glibc.  */
-    b      __libc_start_main
-
-    .globl  main_stub
-    .type   main_stub, @function
-main_stub:
- /* save link register and setup stack frame */
-    mflr    0
-    stw     0, 0(1)
-    stwu    1, -16(1)
-
-    lis     11, operatingsystem_parameter_argc@ha
-    stw      3, operatingsystem_parameter_argc@l(11);
-
-    lis     11, operatingsystem_parameter_argv@ha
-    stw      4, operatingsystem_parameter_argv@l(11);
-
-    lis     11, operatingsystem_parameter_envp@ha
-    stw      5, operatingsystem_parameter_envp@l(11);
-
-    lis 	11,__stkptr@ha
-	stw 	1,__stkptr@l(11);
-
-    lis     11, ___fpc_ret@ha
-    stw     1, ___fpc_ret@l(11)
-
-    lis     11, __stkptr@ha
-    stw     1, __stkptr@l(11)
-
-    bl      PASCALMAIN
-
-    .globl  _haltproc
-    .type   _haltproc, @function
-_haltproc:
-    lis     11, ___fpc_ret@ha
-    lwz     1, ___fpc_ret@l(11)
-    addi    1, 1, 16
-    lwz     0, 0(1)
-    mtlr    0
-    blr
-
-#    li      0, 1       /* exit call */
-#    lis     3, operatingsystem_result@h
-#    stw     3, operatingsystem_result@l(3)
-#    sc
-#    b       _haltproc
-
- /* Define a symbol for the first piece of initialized data.  */
-    .section ".data"
-    .globl   __data_start
-__data_start:
-data_start:
-
-___fpc_ret:                            /* return address to libc */
-    .long   0
-
-.text
-    .comm __stkptr, 4
-
-    .comm operatingsystem_parameter_envp, 4
-    .comm operatingsystem_parameter_argc, 4
-    .comm operatingsystem_parameter_argv, 4
-
+/*
+ * Startup code for programs linked with GNU libc, PowerPC
+ * version.
+ *
+ * Adapted from the glibc-sources (2.3.5) in the file
+ *
+ *     sysdeps/powerpc/powerpc32/elf/start.S
+ *
+ * Original header follows.
+ */
+
+/* Startup code for programs linked with GNU libc.
+   Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.
+*/
+
+/* These are the various addresses we require.  */
+    .section ".rodata"
+    .align    2
+start_addresses:
+    .long     _SDA_BASE_
+    .long     main_stub
+    .long     __libc_csu_init
+    .long     __libc_csu_fini
+    .size   start_adresses, .-start_addresses
+
+    .section ".text"
+    .globl  _start
+_start:
+    /* save stack pointer for later use */
+    mr     9, 1
+ /* Set up an initial stack frame, and clear the LR.  */
+    clrrwi 1, 1, 4
+    li     0, 0
+    stwu   1, -16(1)
+    mtlr   0
+    stw    0, 0(1)
+ /* Set r13 to point at the 'small data area', and put the address of
+    start_addresses in r8...  */
+    lis    8,  start_addresses@ha
+    lwzu   13, start_addresses@l(8)
+ /* and continue in libc-start, in glibc.  */
+    b      __libc_start_main
+
+    .globl  main_stub
+    .type   main_stub, @function
+main_stub:
+ /* save link register and setup stack frame */
+    mflr    0
+    stw     0, 0(1)
+    stwu    1, -16(1)
+
+    lis     11, operatingsystem_parameter_argc@ha
+    stw      3, operatingsystem_parameter_argc@l(11);
+
+    lis     11, operatingsystem_parameter_argv@ha
+    stw      4, operatingsystem_parameter_argv@l(11);
+
+    lis     11, operatingsystem_parameter_envp@ha
+    stw      5, operatingsystem_parameter_envp@l(11);
+
+    lis 	11,__stkptr@ha
+	stw 	1,__stkptr@l(11);
+
+    lis     11, ___fpc_ret@ha
+    stw     1, ___fpc_ret@l(11)
+
+    lis     11, __stkptr@ha
+    stw     1, __stkptr@l(11)
+
+    bl      PASCALMAIN
+
+    .globl  _haltproc
+    .type   _haltproc, @function
+_haltproc:
+    lis     11, ___fpc_ret@ha
+    lwz     1, ___fpc_ret@l(11)
+    addi    1, 1, 16
+    lwz     0, 0(1)
+    mtlr    0
+    blr
+
+#    li      0, 1       /* exit call */
+#    lis     3, operatingsystem_result@h
+#    stw     3, operatingsystem_result@l(3)
+#    sc
+#    b       _haltproc
+
+ /* Define a symbol for the first piece of initialized data.  */
+    .section ".data"
+    .globl   __data_start
+__data_start:
+data_start:
+
+___fpc_ret:                            /* return address to libc */
+    .long   0
+
+.text
+    .comm __stkptr, 4
+
+    .comm operatingsystem_parameter_envp, 4
+    .comm operatingsystem_parameter_argc, 4
+    .comm operatingsystem_parameter_argv, 4
+

+ 435 - 435
rtl/linux/powerpc64/cprt0.as

@@ -1,435 +1,435 @@
-/*
- * Startup code for programs linked with GNU libc, PowerPC64
- * version.
- *
- * Adapted from the glibc-sources (2.3.5) in the file
- *
- *     sysdeps/powerpc/powerpc64/elf/start.S
- *
- * Original header follows.
- */
-
-/* Startup code for programs linked with GNU libc.  PowerPC64 version.
-   Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library 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.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-/* some macros which simplify the startup code */
-
-/* load the 64 bit value "value" into register ra */
-.macro LOAD_64BIT_VAL ra, value
-    lis       \ra,\value@highest
-    ori       \ra,\ra,\value@higher
-    sldi      \ra,\ra,32
-    oris      \ra,\ra,\value@h
-    ori       \ra,\ra,\value@l
-.endm
-
-/* create function prolog for symbol "fn" */
-.macro FUNCTION_PROLOG fn
-    .section  ".text"
-    .align    2
-    .globl    \fn
-    .section  ".opd", "aw"
-    .align    3
-\fn:
-    .quad     .\fn, .TOC.@tocbase, 0
-    .previous
-    .size     \fn, 24
-    .type     \fn, @function
-    .globl    .\fn
-.\fn:
-.endm
-
-/*
- * "ptrgl" glue code for calls via pointer. This function
- * sequence loads the data from the function descriptor
- * referenced by R11 into the CTR register (function address),
- * R2 (GOT/TOC pointer), and R11 (the outer frame pointer).
- *
- * On entry, R11 must be set to point to the function descriptor.
- *
- * See also the 64-bit PowerPC ABI specification for more
- * information, chapter 3.5.11 (in v1.7).
- */
-.section ".text"
-.align 3
-.globl .ptrgl
-.ptrgl:
-    ld	    0, 0(11)
-    std     2, 40(1)
-    mtctr   0
-    ld      2, 8(11)
-    ld      11, 8(11)
-    bctr
-.long 0
-.byte 0, 12, 128, 0, 0, 0, 0, 0
-.type .ptrgl, @function
-.size .ptrgl, . - .ptrgl
-
-/*
- * Function prolog/epilog helpers, which are part of the 64-bit
- * PowerPC ABI.
- *
- * See also the 64-bit PowerPC ABI specification for more
- * information, chapter 3.5.5, "Register saving and restoring
- * function" (in v1.7).
- */
-
-/* Each _savegpr0_N routine saves the general registers from rN to r31,
- * inclusive. When the routine is called, r1 must point to the start
- * of the general register save area. R0 must contain the old LR on
- * entry.
- */
-_savegpr0_14: std 14,-144(1)
-_savegpr0_15: std 15,-136(1)
-_savegpr0_16: std 16,-128(1)
-_savegpr0_17: std 17,-120(1)
-_savegpr0_18: std 18,-112(1)
-_savegpr0_19: std 19,-104(1)
-_savegpr0_20: std 20,-96(1)
-_savegpr0_21: std 21,-88(1)
-_savegpr0_22: std 22,-80(1)
-_savegpr0_23: std 23,-72(1)
-_savegpr0_24: std 24,-64(1)
-_savegpr0_25: std 25,-56(1)
-_savegpr0_26: std 26,-48(1)
-_savegpr0_27: std 27,-40(1)
-_savegpr0_28: std 28,-32(1)
-_savegpr0_29: std 29,-24(1)
-_savegpr0_30: std 30,-16(1)
-_savegpr0_31:
-    std 31,-8(1)
-    std 0, 16(1)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-/* Each _restgpr0_N routine restores the general registers from rN to r31,
- * inclusive. When the routine is called, r1 must point to the start
- * of the general register save area.
- */
-_restgpr0_14: ld 14,-144(1)
-_restgpr0_15: ld 15,-136(1)
-_restgpr0_16: ld 16,-128(1)
-_restgpr0_17: ld 17,-120(1)
-_restgpr0_18: ld 18,-112(1)
-_restgpr0_19: ld 19,-104(1)
-_restgpr0_20: ld 20,-96(1)
-_restgpr0_21: ld 21,-88(1)
-_restgpr0_22: ld 22,-80(1)
-_restgpr0_23: ld 23,-72(1)
-_restgpr0_24: ld 24,-64(1)
-_restgpr0_25: ld 25,-56(1)
-_restgpr0_26: ld 26,-48(1)
-_restgpr0_27: ld 27,-40(1)
-_restgpr0_28: ld 28,-32(1)
-_restgpr0_29:
-    ld 0, 16(1)
-    ld 29,-24(1)
-    mtlr 0
-    ld 30,-16(1)
-    ld 31,-8(1)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-_restgpr0_30: ld 30,-16(1)
-_restgpr0_31: ld 0, 16(1)
-    ld 31,-8(1)
-    mtlr 0
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-/* Each _savegpr1_N routine saves the general registers from rN to r31,
- * inclusive. When the routine is called, r12
- * must point to the start of the general register save area.
- */
-_savegpr1_14: std 14,-144(12)
-_savegpr1_15: std 15,-136(12)
-_savegpr1_16: std 16,-128(12)
-_savegpr1_17: std 17,-120(12)
-_savegpr1_18: std 18,-112(12)
-_savegpr1_19: std 19,-104(12)
-_savegpr1_20: std 20,-96(12)
-_savegpr1_21: std 21,-88(12)
-_savegpr1_22: std 22,-80(12)
-_savegpr1_23: std 23,-72(12)
-_savegpr1_24: std 24,-64(12)
-_savegpr1_25: std 25,-56(12)
-_savegpr1_26: std 26,-48(12)
-_savegpr1_27: std 27,-40(12)
-_savegpr1_28: std 28,-32(12)
-_savegpr1_29: std 29,-24(12)
-_savegpr1_30: std 30,-16(12)
-_savegpr1_31: std 31,-8(12)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-/* The _restgpr1_N routines restore the general registers from rN to r31.
- * When the routine is called, r12 must point to the start of the general
- * register save area.
- */
-_restgpr1_14: ld 14,-144(12)
-_restgpr1_15: ld 15,-136(12)
-_restgpr1_16: ld 16,-128(12)
-_restgpr1_17: ld 17,-120(12)
-_restgpr1_18: ld 18,-112(12)
-_restgpr1_19: ld 19,-104(12)
-_restgpr1_20: ld 20,-96(12)
-_restgpr1_21: ld 21,-88(12)
-_restgpr1_22: ld 22,-80(12)
-_restgpr1_23: ld 23,-72(12)
-_restgpr1_24: ld 24,-64(12)
-_restgpr1_25: ld 25,-56(12)
-_restgpr1_26: ld 26,-48(12)
-_restgpr1_27: ld 27,-40(12)
-_restgpr1_28: ld 28,-32(12)
-_restgpr1_29: ld 29,-24(12)
-_restgpr1_30: ld 30,-16(12)
-_restgpr1_31: ld 31,-8(12)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-/* Each _savefpr_M routine saves the floating point registers from fM to f31,
- * inclusive. When the routine is called, r1 must point to the start of the
- * floating point register save area, and r0 must contain the value of LR on
- * function entry.
- */
-_savefpr_14: stfd 14,-144(1)
-_savefpr_15: stfd 15,-136(1)
-_savefpr_16: stfd 16,-128(1)
-_savefpr_17: stfd 17,-120(1)
-_savefpr_18: stfd 18,-112(1)
-_savefpr_19: stfd 19,-104(1)
-_savefpr_20: stfd 20,-96(1)
-_savefpr_21: stfd 21,-88(1)
-_savefpr_22: stfd 22,-80(1)
-_savefpr_23: stfd 23,-72(1)
-_savefpr_24: stfd 24,-64(1)
-_savefpr_25: stfd 25,-56(1)
-_savefpr_26: stfd 26,-48(1)
-_savefpr_27: stfd 27,-40(1)
-_savefpr_28: stfd 28,-32(1)
-_savefpr_29: stfd 29,-24(1)
-_savefpr_30: stfd 30,-16(1)
-_savefpr_31: stfd 31,-8(1)
-    std 0, 16(1)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-/* The _restfpr_M routines restore the floating point registers from fM to f31.
- * When the routine is called, r1 must point to the start of the floating point
- * register save area.
- */
-_restfpr_14: lfd 14,-144(1)
-_restfpr_15: lfd 15,-136(1)
-_restfpr_16: lfd 16,-128(1)
-_restfpr_17: lfd 17,-120(1)
-_restfpr_18: lfd 18,-112(1)
-_restfpr_19: lfd 19,-104(1)
-_restfpr_20: lfd 20,-96(1)
-_restfpr_21: lfd 21,-88(1)
-_restfpr_22: lfd 22,-80(1)
-_restfpr_23: lfd 23,-72(1)
-_restfpr_24: lfd 24,-64(1)
-_restfpr_25: lfd 25,-56(1)
-_restfpr_26: lfd 26,-48(1)
-_restfpr_27: lfd 27,-40(1)
-_restfpr_28: lfd 28,-32(1)
-_restfpr_29:
-    ld 0, 16(1)
-    lfd 29,-24(1)
-    mtlr 0
-    lfd 30,-16(1)
-    lfd 31,-8(1)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-_restfpr_30: lfd 30,-16(1)
-_restfpr_31:
-    ld 0, 16(1)
-    lfd 31,-8(1)
-    mtlr 0
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-/* Each _savevr_M routine saves the vector registers from vM to v31, inclusive.
- * When the routine is called, r0 must point to the word just beyound the end
- * of the vector register save area. On return the value of r0 is unchanged
- * while r12 may be modified.
- */
-/* commented out for now, unused
-_savevr_20: addi r12,r0,-192
-    stvx v20,r12,r0
-_savevr_21: addi r12,r0,-176
-    stvx v21,r12,r0
-_savevr_22: addi r12,r0,-160
-    stvx v22,r12,r0
-_savevr_23: addi r12,r0,-144
-    stvx v23,r12,r0
-_savevr_24: addi r12,r0,-128
-    stvx v24,r12,r0
-_savevr_25: addi r12,r0,-112
-    stvx v25,r12,r0
-_savevr_26: addi r12,r0,-96
-    stvx v26,r12,r0
-_savevr_27: addi r12,r0,-80
-    stvx v27,r12,r0
-_savevr_28: addi r12,r0,-64
-    stvx v28,r12,r0
-_savevr_29: addi r12,r0,-48
-    stvx v29,r12,r0
-_savevr_30: addi r12,r0,-32
-    stvx v30,r12,r0
-_savevr_31: addi r12,r0,-16
-    stvx v31,r12,r0
-    blr
-*/
-/* The _restvr_M routines restore the vector registers from vM to v31. When the
- * routine is called, r0 must point to the word just beyound the end of the
- * vector register save area. On return the value of r0 is unchanged while r12
- * may be modified.
- */
-/* commented out for now, unused
-_restvr_20: addi r12,r0,-192
-    lvx v20,r12,r0
-_restvr_21: addi r12,r0,-176
-    lvx v21,r12,r0
-_restvr_22: addi r12,r0,-160
-    lvx v22,r12,r0
-_restvr_23: addi r12,r0,-144
-    lvx v23,r12,r0
-_restvr_24: addi r12,r0,-128
-    lvx v24,r12,r0
-_restvr_25: addi r12,r0,-112
-    lvx v25,r12,r0
-_restvr_26: addi r12,r0,-96
-    lvx v26,r12,r0
-_restvr_27: addi r12,r0,-80
-    lvx v27,r12,r0
-_restvr_28: addi r12,r0,-64
-    lvx v28,r12,r0
-_restvr_29: addi r12,r0,-48
-    lvx v29,r12,r0
-_restvr_30: addi r12,r0,-32
-    lvx v30,r12,r0
-_restvr_31: addi r12,r0,-16
-    lvx v31,r12,r0
-    blr
-*/
-
-/*
- * start_addresses is a structure containing the real
- * entry point (next to other things not interesting to
- * us here).
- *
- * All references in the struct are function descriptors
- *
- */
-    .section ".rodata"
-    .align  3
-start_addresses:
-    .quad   0 /* was _SDA_BASE_  but not in 64-bit ABI*/
-    .quad   main_stub
-    .quad   __libc_csu_init
-    .quad   __libc_csu_fini
-    .size   start_adresses, .-start_addresses
-
-/*
- * the real entry point for the program
- */
-FUNCTION_PROLOG _start
-    mr  9,1                   /* save the stack pointer */
-
-    /* Set up an initial stack frame, and clear the LR.  */
-
-    clrrdi  1,1,4
-    li      0,0
-    stdu    1,-128(1)
-    mtlr    0
-    std     0,0(1)
-
-    /* put the address of start_addresses in r8...  */
-    /* PPC64 ABI uses R13 for thread local, so we leave it alone */
-    LOAD_64BIT_VAL 8, start_addresses
-
-    b   .__libc_start_main
-    nop                      /* a NOP for the linker */
-
-/*
- * This is our FreePascal main procedure which is called by
- * libc after initializing.
- */
-
-FUNCTION_PROLOG main_stub
-    mflr    0
-    std     0,16(1)
-    stdu    1,-128(1)
-
-    LOAD_64BIT_VAL 8, operatingsystem_parameter_argc
-    stw     3,0(8)
-
-    LOAD_64BIT_VAL 8, operatingsystem_parameter_argv
-    std     4,0(8)
-
-    LOAD_64BIT_VAL 8, operatingsystem_parameter_envp
-    std     5,0(8)
-
-    LOAD_64BIT_VAL 8, __stkptr
-    std     1,0(8)
-
-    LOAD_64BIT_VAL 8, ___fpc_ret
-    std     1,0(8)
-
-    bl  .PASCALMAIN
-    nop
-
-    b   ._haltproc
-
-FUNCTION_PROLOG _haltproc
-    LOAD_64BIT_VAL 8, ___fpc_ret
-    ld      1, 0(8)
-    addi    1, 1, 128
-    ld      0, 16(1)
-    mtlr    0
-    blr
-
-#    li      0,1          /* exit call */
-#    sc
-#    b  ._haltproc
-
-    /* Define a symbol for the first piece of initialized data.  */
-    .section ".data"
-    .globl  __data_start
-__data_start:
-data_start:
-
-___fpc_ret:                            /* return address to libc */
-    .quad   0
-
-.text
-    .comm __stkptr, 8
-
-    .comm operatingsystem_parameter_argc, 4
-    .comm operatingsystem_parameter_argv, 8
-    .comm operatingsystem_parameter_envp, 8
+/*
+ * Startup code for programs linked with GNU libc, PowerPC64
+ * version.
+ *
+ * Adapted from the glibc-sources (2.3.5) in the file
+ *
+ *     sysdeps/powerpc/powerpc64/elf/start.S
+ *
+ * Original header follows.
+ */
+
+/* Startup code for programs linked with GNU libc.  PowerPC64 version.
+   Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* some macros which simplify the startup code */
+
+/* load the 64 bit value "value" into register ra */
+.macro LOAD_64BIT_VAL ra, value
+    lis       \ra,\value@highest
+    ori       \ra,\ra,\value@higher
+    sldi      \ra,\ra,32
+    oris      \ra,\ra,\value@h
+    ori       \ra,\ra,\value@l
+.endm
+
+/* create function prolog for symbol "fn" */
+.macro FUNCTION_PROLOG fn
+    .section  ".text"
+    .align    2
+    .globl    \fn
+    .section  ".opd", "aw"
+    .align    3
+\fn:
+    .quad     .\fn, .TOC.@tocbase, 0
+    .previous
+    .size     \fn, 24
+    .type     \fn, @function
+    .globl    .\fn
+.\fn:
+.endm
+
+/*
+ * "ptrgl" glue code for calls via pointer. This function
+ * sequence loads the data from the function descriptor
+ * referenced by R11 into the CTR register (function address),
+ * R2 (GOT/TOC pointer), and R11 (the outer frame pointer).
+ *
+ * On entry, R11 must be set to point to the function descriptor.
+ *
+ * See also the 64-bit PowerPC ABI specification for more
+ * information, chapter 3.5.11 (in v1.7).
+ */
+.section ".text"
+.align 3
+.globl .ptrgl
+.ptrgl:
+    ld	    0, 0(11)
+    std     2, 40(1)
+    mtctr   0
+    ld      2, 8(11)
+    ld      11, 8(11)
+    bctr
+.long 0
+.byte 0, 12, 128, 0, 0, 0, 0, 0
+.type .ptrgl, @function
+.size .ptrgl, . - .ptrgl
+
+/*
+ * Function prolog/epilog helpers, which are part of the 64-bit
+ * PowerPC ABI.
+ *
+ * See also the 64-bit PowerPC ABI specification for more
+ * information, chapter 3.5.5, "Register saving and restoring
+ * function" (in v1.7).
+ */
+
+/* Each _savegpr0_N routine saves the general registers from rN to r31,
+ * inclusive. When the routine is called, r1 must point to the start
+ * of the general register save area. R0 must contain the old LR on
+ * entry.
+ */
+_savegpr0_14: std 14,-144(1)
+_savegpr0_15: std 15,-136(1)
+_savegpr0_16: std 16,-128(1)
+_savegpr0_17: std 17,-120(1)
+_savegpr0_18: std 18,-112(1)
+_savegpr0_19: std 19,-104(1)
+_savegpr0_20: std 20,-96(1)
+_savegpr0_21: std 21,-88(1)
+_savegpr0_22: std 22,-80(1)
+_savegpr0_23: std 23,-72(1)
+_savegpr0_24: std 24,-64(1)
+_savegpr0_25: std 25,-56(1)
+_savegpr0_26: std 26,-48(1)
+_savegpr0_27: std 27,-40(1)
+_savegpr0_28: std 28,-32(1)
+_savegpr0_29: std 29,-24(1)
+_savegpr0_30: std 30,-16(1)
+_savegpr0_31:
+    std 31,-8(1)
+    std 0, 16(1)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+/* Each _restgpr0_N routine restores the general registers from rN to r31,
+ * inclusive. When the routine is called, r1 must point to the start
+ * of the general register save area.
+ */
+_restgpr0_14: ld 14,-144(1)
+_restgpr0_15: ld 15,-136(1)
+_restgpr0_16: ld 16,-128(1)
+_restgpr0_17: ld 17,-120(1)
+_restgpr0_18: ld 18,-112(1)
+_restgpr0_19: ld 19,-104(1)
+_restgpr0_20: ld 20,-96(1)
+_restgpr0_21: ld 21,-88(1)
+_restgpr0_22: ld 22,-80(1)
+_restgpr0_23: ld 23,-72(1)
+_restgpr0_24: ld 24,-64(1)
+_restgpr0_25: ld 25,-56(1)
+_restgpr0_26: ld 26,-48(1)
+_restgpr0_27: ld 27,-40(1)
+_restgpr0_28: ld 28,-32(1)
+_restgpr0_29:
+    ld 0, 16(1)
+    ld 29,-24(1)
+    mtlr 0
+    ld 30,-16(1)
+    ld 31,-8(1)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+_restgpr0_30: ld 30,-16(1)
+_restgpr0_31: ld 0, 16(1)
+    ld 31,-8(1)
+    mtlr 0
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+/* Each _savegpr1_N routine saves the general registers from rN to r31,
+ * inclusive. When the routine is called, r12
+ * must point to the start of the general register save area.
+ */
+_savegpr1_14: std 14,-144(12)
+_savegpr1_15: std 15,-136(12)
+_savegpr1_16: std 16,-128(12)
+_savegpr1_17: std 17,-120(12)
+_savegpr1_18: std 18,-112(12)
+_savegpr1_19: std 19,-104(12)
+_savegpr1_20: std 20,-96(12)
+_savegpr1_21: std 21,-88(12)
+_savegpr1_22: std 22,-80(12)
+_savegpr1_23: std 23,-72(12)
+_savegpr1_24: std 24,-64(12)
+_savegpr1_25: std 25,-56(12)
+_savegpr1_26: std 26,-48(12)
+_savegpr1_27: std 27,-40(12)
+_savegpr1_28: std 28,-32(12)
+_savegpr1_29: std 29,-24(12)
+_savegpr1_30: std 30,-16(12)
+_savegpr1_31: std 31,-8(12)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+/* The _restgpr1_N routines restore the general registers from rN to r31.
+ * When the routine is called, r12 must point to the start of the general
+ * register save area.
+ */
+_restgpr1_14: ld 14,-144(12)
+_restgpr1_15: ld 15,-136(12)
+_restgpr1_16: ld 16,-128(12)
+_restgpr1_17: ld 17,-120(12)
+_restgpr1_18: ld 18,-112(12)
+_restgpr1_19: ld 19,-104(12)
+_restgpr1_20: ld 20,-96(12)
+_restgpr1_21: ld 21,-88(12)
+_restgpr1_22: ld 22,-80(12)
+_restgpr1_23: ld 23,-72(12)
+_restgpr1_24: ld 24,-64(12)
+_restgpr1_25: ld 25,-56(12)
+_restgpr1_26: ld 26,-48(12)
+_restgpr1_27: ld 27,-40(12)
+_restgpr1_28: ld 28,-32(12)
+_restgpr1_29: ld 29,-24(12)
+_restgpr1_30: ld 30,-16(12)
+_restgpr1_31: ld 31,-8(12)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+/* Each _savefpr_M routine saves the floating point registers from fM to f31,
+ * inclusive. When the routine is called, r1 must point to the start of the
+ * floating point register save area, and r0 must contain the value of LR on
+ * function entry.
+ */
+_savefpr_14: stfd 14,-144(1)
+_savefpr_15: stfd 15,-136(1)
+_savefpr_16: stfd 16,-128(1)
+_savefpr_17: stfd 17,-120(1)
+_savefpr_18: stfd 18,-112(1)
+_savefpr_19: stfd 19,-104(1)
+_savefpr_20: stfd 20,-96(1)
+_savefpr_21: stfd 21,-88(1)
+_savefpr_22: stfd 22,-80(1)
+_savefpr_23: stfd 23,-72(1)
+_savefpr_24: stfd 24,-64(1)
+_savefpr_25: stfd 25,-56(1)
+_savefpr_26: stfd 26,-48(1)
+_savefpr_27: stfd 27,-40(1)
+_savefpr_28: stfd 28,-32(1)
+_savefpr_29: stfd 29,-24(1)
+_savefpr_30: stfd 30,-16(1)
+_savefpr_31: stfd 31,-8(1)
+    std 0, 16(1)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+/* The _restfpr_M routines restore the floating point registers from fM to f31.
+ * When the routine is called, r1 must point to the start of the floating point
+ * register save area.
+ */
+_restfpr_14: lfd 14,-144(1)
+_restfpr_15: lfd 15,-136(1)
+_restfpr_16: lfd 16,-128(1)
+_restfpr_17: lfd 17,-120(1)
+_restfpr_18: lfd 18,-112(1)
+_restfpr_19: lfd 19,-104(1)
+_restfpr_20: lfd 20,-96(1)
+_restfpr_21: lfd 21,-88(1)
+_restfpr_22: lfd 22,-80(1)
+_restfpr_23: lfd 23,-72(1)
+_restfpr_24: lfd 24,-64(1)
+_restfpr_25: lfd 25,-56(1)
+_restfpr_26: lfd 26,-48(1)
+_restfpr_27: lfd 27,-40(1)
+_restfpr_28: lfd 28,-32(1)
+_restfpr_29:
+    ld 0, 16(1)
+    lfd 29,-24(1)
+    mtlr 0
+    lfd 30,-16(1)
+    lfd 31,-8(1)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+_restfpr_30: lfd 30,-16(1)
+_restfpr_31:
+    ld 0, 16(1)
+    lfd 31,-8(1)
+    mtlr 0
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+/* Each _savevr_M routine saves the vector registers from vM to v31, inclusive.
+ * When the routine is called, r0 must point to the word just beyound the end
+ * of the vector register save area. On return the value of r0 is unchanged
+ * while r12 may be modified.
+ */
+/* commented out for now, unused
+_savevr_20: addi r12,r0,-192
+    stvx v20,r12,r0
+_savevr_21: addi r12,r0,-176
+    stvx v21,r12,r0
+_savevr_22: addi r12,r0,-160
+    stvx v22,r12,r0
+_savevr_23: addi r12,r0,-144
+    stvx v23,r12,r0
+_savevr_24: addi r12,r0,-128
+    stvx v24,r12,r0
+_savevr_25: addi r12,r0,-112
+    stvx v25,r12,r0
+_savevr_26: addi r12,r0,-96
+    stvx v26,r12,r0
+_savevr_27: addi r12,r0,-80
+    stvx v27,r12,r0
+_savevr_28: addi r12,r0,-64
+    stvx v28,r12,r0
+_savevr_29: addi r12,r0,-48
+    stvx v29,r12,r0
+_savevr_30: addi r12,r0,-32
+    stvx v30,r12,r0
+_savevr_31: addi r12,r0,-16
+    stvx v31,r12,r0
+    blr
+*/
+/* The _restvr_M routines restore the vector registers from vM to v31. When the
+ * routine is called, r0 must point to the word just beyound the end of the
+ * vector register save area. On return the value of r0 is unchanged while r12
+ * may be modified.
+ */
+/* commented out for now, unused
+_restvr_20: addi r12,r0,-192
+    lvx v20,r12,r0
+_restvr_21: addi r12,r0,-176
+    lvx v21,r12,r0
+_restvr_22: addi r12,r0,-160
+    lvx v22,r12,r0
+_restvr_23: addi r12,r0,-144
+    lvx v23,r12,r0
+_restvr_24: addi r12,r0,-128
+    lvx v24,r12,r0
+_restvr_25: addi r12,r0,-112
+    lvx v25,r12,r0
+_restvr_26: addi r12,r0,-96
+    lvx v26,r12,r0
+_restvr_27: addi r12,r0,-80
+    lvx v27,r12,r0
+_restvr_28: addi r12,r0,-64
+    lvx v28,r12,r0
+_restvr_29: addi r12,r0,-48
+    lvx v29,r12,r0
+_restvr_30: addi r12,r0,-32
+    lvx v30,r12,r0
+_restvr_31: addi r12,r0,-16
+    lvx v31,r12,r0
+    blr
+*/
+
+/*
+ * start_addresses is a structure containing the real
+ * entry point (next to other things not interesting to
+ * us here).
+ *
+ * All references in the struct are function descriptors
+ *
+ */
+    .section ".rodata"
+    .align  3
+start_addresses:
+    .quad   0 /* was _SDA_BASE_  but not in 64-bit ABI*/
+    .quad   main_stub
+    .quad   __libc_csu_init
+    .quad   __libc_csu_fini
+    .size   start_adresses, .-start_addresses
+
+/*
+ * the real entry point for the program
+ */
+FUNCTION_PROLOG _start
+    mr  9,1                   /* save the stack pointer */
+
+    /* Set up an initial stack frame, and clear the LR.  */
+
+    clrrdi  1,1,4
+    li      0,0
+    stdu    1,-128(1)
+    mtlr    0
+    std     0,0(1)
+
+    /* put the address of start_addresses in r8...  */
+    /* PPC64 ABI uses R13 for thread local, so we leave it alone */
+    LOAD_64BIT_VAL 8, start_addresses
+
+    b   .__libc_start_main
+    nop                      /* a NOP for the linker */
+
+/*
+ * This is our FreePascal main procedure which is called by
+ * libc after initializing.
+ */
+
+FUNCTION_PROLOG main_stub
+    mflr    0
+    std     0,16(1)
+    stdu    1,-128(1)
+
+    LOAD_64BIT_VAL 8, operatingsystem_parameter_argc
+    stw     3,0(8)
+
+    LOAD_64BIT_VAL 8, operatingsystem_parameter_argv
+    std     4,0(8)
+
+    LOAD_64BIT_VAL 8, operatingsystem_parameter_envp
+    std     5,0(8)
+
+    LOAD_64BIT_VAL 8, __stkptr
+    std     1,0(8)
+
+    LOAD_64BIT_VAL 8, ___fpc_ret
+    std     1,0(8)
+
+    bl  .PASCALMAIN
+    nop
+
+    b   ._haltproc
+
+FUNCTION_PROLOG _haltproc
+    LOAD_64BIT_VAL 8, ___fpc_ret
+    ld      1, 0(8)
+    addi    1, 1, 128
+    ld      0, 16(1)
+    mtlr    0
+    blr
+
+#    li      0,1          /* exit call */
+#    sc
+#    b  ._haltproc
+
+    /* Define a symbol for the first piece of initialized data.  */
+    .section ".data"
+    .globl  __data_start
+__data_start:
+data_start:
+
+___fpc_ret:                            /* return address to libc */
+    .quad   0
+
+.text
+    .comm __stkptr, 8
+
+    .comm operatingsystem_parameter_argc, 4
+    .comm operatingsystem_parameter_argv, 8
+    .comm operatingsystem_parameter_envp, 8

+ 441 - 441
rtl/linux/powerpc64/gprt0.as

@@ -1,441 +1,441 @@
-/*
- * Startup code for programs linked with GNU libc, PowerPC64
- * version.
- *
- * Adapted from the glibc-sources (2.3.5) in the file
- *
- *     sysdeps/powerpc/powerpc64/elf/start.S
- *
- * Original header follows.
- */
-
-/* Startup code for programs linked with GNU libc.  PowerPC64 version.
-   Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library 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.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-/* some macros which simplify the startup code */
-
-/* load the 64 bit value "value" into register ra */
-.macro LOAD_64BIT_VAL ra, value
-    lis       \ra,\value@highest
-    ori       \ra,\ra,\value@higher
-    sldi      \ra,\ra,32
-    oris      \ra,\ra,\value@h
-    ori       \ra,\ra,\value@l
-.endm
-
-/* create function prolog for symbol "fn" */
-.macro FUNCTION_PROLOG fn
-    .section  ".text"
-    .align    2
-    .globl    \fn
-    .section  ".opd", "aw"
-    .align    3
-\fn:
-    .quad     .\fn, .TOC.@tocbase, 0
-    .previous
-    .size     \fn, 24
-    .type     \fn, @function
-    .globl    .\fn
-.\fn:
-.endm
-
-/*
- * "ptrgl" glue code for calls via pointer. This function
- * sequence loads the data from the function descriptor
- * referenced by R11 into the CTR register (function address),
- * R2 (GOT/TOC pointer), and R11 (the outer frame pointer).
- *
- * On entry, R11 must be set to point to the function descriptor.
- *
- * See also the 64-bit PowerPC ABI specification for more
- * information, chapter 3.5.11 (in v1.7).
- */
-.section ".text"
-.align 3
-.globl .ptrgl
-.ptrgl:
-    ld	    0, 0(11)
-    std     2, 40(1)
-    mtctr   0
-    ld      2, 8(11)
-    ld      11, 8(11)
-    bctr
-.long 0
-.byte 0, 12, 128, 0, 0, 0, 0, 0
-.type .ptrgl, @function
-.size .ptrgl, . - .ptrgl
-
-/*
- * Function prolog/epilog helpers, which are part of the 64-bit
- * PowerPC ABI.
- *
- * See also the 64-bit PowerPC ABI specification for more
- * information, chapter 3.5.5, "Register saving and restoring
- * function" (in v1.7).
- */
-
-/* Each _savegpr0_N routine saves the general registers from rN to r31,
- * inclusive. When the routine is called, r1 must point to the start
- * of the general register save area. R0 must contain the old LR on
- * entry.
- */
-_savegpr0_14: std 14,-144(1)
-_savegpr0_15: std 15,-136(1)
-_savegpr0_16: std 16,-128(1)
-_savegpr0_17: std 17,-120(1)
-_savegpr0_18: std 18,-112(1)
-_savegpr0_19: std 19,-104(1)
-_savegpr0_20: std 20,-96(1)
-_savegpr0_21: std 21,-88(1)
-_savegpr0_22: std 22,-80(1)
-_savegpr0_23: std 23,-72(1)
-_savegpr0_24: std 24,-64(1)
-_savegpr0_25: std 25,-56(1)
-_savegpr0_26: std 26,-48(1)
-_savegpr0_27: std 27,-40(1)
-_savegpr0_28: std 28,-32(1)
-_savegpr0_29: std 29,-24(1)
-_savegpr0_30: std 30,-16(1)
-_savegpr0_31:
-    std 31,-8(1)
-    std 0, 16(1)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-/* Each _restgpr0_N routine restores the general registers from rN to r31,
- * inclusive. When the routine is called, r1 must point to the start
- * of the general register save area.
- */
-_restgpr0_14: ld 14,-144(1)
-_restgpr0_15: ld 15,-136(1)
-_restgpr0_16: ld 16,-128(1)
-_restgpr0_17: ld 17,-120(1)
-_restgpr0_18: ld 18,-112(1)
-_restgpr0_19: ld 19,-104(1)
-_restgpr0_20: ld 20,-96(1)
-_restgpr0_21: ld 21,-88(1)
-_restgpr0_22: ld 22,-80(1)
-_restgpr0_23: ld 23,-72(1)
-_restgpr0_24: ld 24,-64(1)
-_restgpr0_25: ld 25,-56(1)
-_restgpr0_26: ld 26,-48(1)
-_restgpr0_27: ld 27,-40(1)
-_restgpr0_28: ld 28,-32(1)
-_restgpr0_29:
-    ld 0, 16(1)
-    ld 29,-24(1)
-    mtlr 0
-    ld 30,-16(1)
-    ld 31,-8(1)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-_restgpr0_30: ld 30,-16(1)
-_restgpr0_31: ld 0, 16(1)
-    ld 31,-8(1)
-    mtlr 0
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-/* Each _savegpr1_N routine saves the general registers from rN to r31,
- * inclusive. When the routine is called, r12
- * must point to the start of the general register save area.
- */
-_savegpr1_14: std 14,-144(12)
-_savegpr1_15: std 15,-136(12)
-_savegpr1_16: std 16,-128(12)
-_savegpr1_17: std 17,-120(12)
-_savegpr1_18: std 18,-112(12)
-_savegpr1_19: std 19,-104(12)
-_savegpr1_20: std 20,-96(12)
-_savegpr1_21: std 21,-88(12)
-_savegpr1_22: std 22,-80(12)
-_savegpr1_23: std 23,-72(12)
-_savegpr1_24: std 24,-64(12)
-_savegpr1_25: std 25,-56(12)
-_savegpr1_26: std 26,-48(12)
-_savegpr1_27: std 27,-40(12)
-_savegpr1_28: std 28,-32(12)
-_savegpr1_29: std 29,-24(12)
-_savegpr1_30: std 30,-16(12)
-_savegpr1_31: std 31,-8(12)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-/* The _restgpr1_N routines restore the general registers from rN to r31.
- * When the routine is called, r12 must point to the start of the general
- * register save area.
- */
-_restgpr1_14: ld 14,-144(12)
-_restgpr1_15: ld 15,-136(12)
-_restgpr1_16: ld 16,-128(12)
-_restgpr1_17: ld 17,-120(12)
-_restgpr1_18: ld 18,-112(12)
-_restgpr1_19: ld 19,-104(12)
-_restgpr1_20: ld 20,-96(12)
-_restgpr1_21: ld 21,-88(12)
-_restgpr1_22: ld 22,-80(12)
-_restgpr1_23: ld 23,-72(12)
-_restgpr1_24: ld 24,-64(12)
-_restgpr1_25: ld 25,-56(12)
-_restgpr1_26: ld 26,-48(12)
-_restgpr1_27: ld 27,-40(12)
-_restgpr1_28: ld 28,-32(12)
-_restgpr1_29: ld 29,-24(12)
-_restgpr1_30: ld 30,-16(12)
-_restgpr1_31: ld 31,-8(12)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-/* Each _savefpr_M routine saves the floating point registers from fM to f31,
- * inclusive. When the routine is called, r1 must point to the start of the
- * floating point register save area, and r0 must contain the value of LR on
- * function entry.
- */
-_savefpr_14: stfd 14,-144(1)
-_savefpr_15: stfd 15,-136(1)
-_savefpr_16: stfd 16,-128(1)
-_savefpr_17: stfd 17,-120(1)
-_savefpr_18: stfd 18,-112(1)
-_savefpr_19: stfd 19,-104(1)
-_savefpr_20: stfd 20,-96(1)
-_savefpr_21: stfd 21,-88(1)
-_savefpr_22: stfd 22,-80(1)
-_savefpr_23: stfd 23,-72(1)
-_savefpr_24: stfd 24,-64(1)
-_savefpr_25: stfd 25,-56(1)
-_savefpr_26: stfd 26,-48(1)
-_savefpr_27: stfd 27,-40(1)
-_savefpr_28: stfd 28,-32(1)
-_savefpr_29: stfd 29,-24(1)
-_savefpr_30: stfd 30,-16(1)
-_savefpr_31: stfd 31,-8(1)
-    std 0, 16(1)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-/* The _restfpr_M routines restore the floating point registers from fM to f31.
- * When the routine is called, r1 must point to the start of the floating point
- * register save area.
- */
-_restfpr_14: lfd 14,-144(1)
-_restfpr_15: lfd 15,-136(1)
-_restfpr_16: lfd 16,-128(1)
-_restfpr_17: lfd 17,-120(1)
-_restfpr_18: lfd 18,-112(1)
-_restfpr_19: lfd 19,-104(1)
-_restfpr_20: lfd 20,-96(1)
-_restfpr_21: lfd 21,-88(1)
-_restfpr_22: lfd 22,-80(1)
-_restfpr_23: lfd 23,-72(1)
-_restfpr_24: lfd 24,-64(1)
-_restfpr_25: lfd 25,-56(1)
-_restfpr_26: lfd 26,-48(1)
-_restfpr_27: lfd 27,-40(1)
-_restfpr_28: lfd 28,-32(1)
-_restfpr_29:
-    ld 0, 16(1)
-    lfd 29,-24(1)
-    mtlr 0
-    lfd 30,-16(1)
-    lfd 31,-8(1)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-_restfpr_30: lfd 30,-16(1)
-_restfpr_31:
-    ld 0, 16(1)
-    lfd 31,-8(1)
-    mtlr 0
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-/* Each _savevr_M routine saves the vector registers from vM to v31, inclusive.
- * When the routine is called, r0 must point to the word just beyound the end
- * of the vector register save area. On return the value of r0 is unchanged
- * while r12 may be modified.
- */
-/* commented out for now, unused
-_savevr_20: addi r12,r0,-192
-    stvx v20,r12,r0
-_savevr_21: addi r12,r0,-176
-    stvx v21,r12,r0
-_savevr_22: addi r12,r0,-160
-    stvx v22,r12,r0
-_savevr_23: addi r12,r0,-144
-    stvx v23,r12,r0
-_savevr_24: addi r12,r0,-128
-    stvx v24,r12,r0
-_savevr_25: addi r12,r0,-112
-    stvx v25,r12,r0
-_savevr_26: addi r12,r0,-96
-    stvx v26,r12,r0
-_savevr_27: addi r12,r0,-80
-    stvx v27,r12,r0
-_savevr_28: addi r12,r0,-64
-    stvx v28,r12,r0
-_savevr_29: addi r12,r0,-48
-    stvx v29,r12,r0
-_savevr_30: addi r12,r0,-32
-    stvx v30,r12,r0
-_savevr_31: addi r12,r0,-16
-    stvx v31,r12,r0
-    blr
-*/
-/* The _restvr_M routines restore the vector registers from vM to v31. When the
- * routine is called, r0 must point to the word just beyound the end of the
- * vector register save area. On return the value of r0 is unchanged while r12
- * may be modified.
- */
-/* commented out for now, unused
-_restvr_20: addi r12,r0,-192
-    lvx v20,r12,r0
-_restvr_21: addi r12,r0,-176
-    lvx v21,r12,r0
-_restvr_22: addi r12,r0,-160
-    lvx v22,r12,r0
-_restvr_23: addi r12,r0,-144
-    lvx v23,r12,r0
-_restvr_24: addi r12,r0,-128
-    lvx v24,r12,r0
-_restvr_25: addi r12,r0,-112
-    lvx v25,r12,r0
-_restvr_26: addi r12,r0,-96
-    lvx v26,r12,r0
-_restvr_27: addi r12,r0,-80
-    lvx v27,r12,r0
-_restvr_28: addi r12,r0,-64
-    lvx v28,r12,r0
-_restvr_29: addi r12,r0,-48
-    lvx v29,r12,r0
-_restvr_30: addi r12,r0,-32
-    lvx v30,r12,r0
-_restvr_31: addi r12,r0,-16
-    lvx v31,r12,r0
-    blr
-*/
-
-/*
- * start_addresses is a structure containing the real
- * entry point (next to other things not interesting to
- * us here).
- *
- * All references in the struct are function descriptors
- *
- */
-    .section ".rodata"
-    .align  3
-start_addresses:
-    .quad   0 /* was _SDA_BASE_  but not in 64-bit ABI*/
-    .quad   main_stub
-    .quad   __libc_csu_init
-    .quad   __libc_csu_fini
-    .size   start_adresses, .-start_addresses
-
-/*
- * the real entry point for the program
- */
-FUNCTION_PROLOG _start
-    mr  9,1                   /* save the stack pointer */
-
-    /* Set up an initial stack frame, and clear the LR.  */
-
-    clrrdi  1,1,4
-    li      0,0
-    stdu    1,-128(1)
-    mtlr    0
-    std     0,0(1)
-
-    /* put the address of start_addresses in r8...  */
-    /* PPC64 ABI uses R13 for thread local, so we leave it alone */
-    LOAD_64BIT_VAL 8, start_addresses
-
-    b   .__libc_start_main
-    nop                      /* a NOP for the linker */
-
-/*
- * This is our FreePascal main procedure which is called by
- * libc after initializing.
- */
-
-FUNCTION_PROLOG main_stub
-    mflr    0
-    std     0,16(1)
-    stdu    1,-128(1)
-
-    LOAD_64BIT_VAL 8, operatingsystem_parameter_argc
-    stw     3,0(8)
-
-    LOAD_64BIT_VAL 8, operatingsystem_parameter_argv
-    std     4,0(8)
-
-    LOAD_64BIT_VAL 8, operatingsystem_parameter_envp
-    std     5,0(8)
-
-    LOAD_64BIT_VAL 8, __stkptr
-    std     1,0(8)
-
-    LOAD_64BIT_VAL 8, ___fpc_ret
-    std     1,0(8)
-
-    LOAD_64BIT_VAL 3, _start
-    ld 3, 0(3)
-    LOAD_64BIT_VAL 4, etext
-    bl  .__monstartup
-    nop
-
-    LOAD_64BIT_VAL 3, _mcleanup
-    bl .atexit
-    nop
-
-    bl  .PASCALMAIN
-    nop
-
-    b   ._haltproc
-
-FUNCTION_PROLOG _haltproc
-    LOAD_64BIT_VAL 8, ___fpc_ret
-    ld      1, 0(8)
-    addi    1, 1, 128
-    ld      0, 16(1)
-    mtlr    0
-    blr
-
-    /* Define a symbol for the first piece of initialized data.  */
-    .section ".data"
-    .globl  __data_start
-__data_start:
-data_start:
-
-___fpc_ret:                            /* return address to libc */
-    .quad   0
-
-.text
-    .comm __stkptr, 8
-
-    .comm operatingsystem_parameter_argc, 4
-    .comm operatingsystem_parameter_argv, 8
-    .comm operatingsystem_parameter_envp, 8
+/*
+ * Startup code for programs linked with GNU libc, PowerPC64
+ * version.
+ *
+ * Adapted from the glibc-sources (2.3.5) in the file
+ *
+ *     sysdeps/powerpc/powerpc64/elf/start.S
+ *
+ * Original header follows.
+ */
+
+/* Startup code for programs linked with GNU libc.  PowerPC64 version.
+   Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* some macros which simplify the startup code */
+
+/* load the 64 bit value "value" into register ra */
+.macro LOAD_64BIT_VAL ra, value
+    lis       \ra,\value@highest
+    ori       \ra,\ra,\value@higher
+    sldi      \ra,\ra,32
+    oris      \ra,\ra,\value@h
+    ori       \ra,\ra,\value@l
+.endm
+
+/* create function prolog for symbol "fn" */
+.macro FUNCTION_PROLOG fn
+    .section  ".text"
+    .align    2
+    .globl    \fn
+    .section  ".opd", "aw"
+    .align    3
+\fn:
+    .quad     .\fn, .TOC.@tocbase, 0
+    .previous
+    .size     \fn, 24
+    .type     \fn, @function
+    .globl    .\fn
+.\fn:
+.endm
+
+/*
+ * "ptrgl" glue code for calls via pointer. This function
+ * sequence loads the data from the function descriptor
+ * referenced by R11 into the CTR register (function address),
+ * R2 (GOT/TOC pointer), and R11 (the outer frame pointer).
+ *
+ * On entry, R11 must be set to point to the function descriptor.
+ *
+ * See also the 64-bit PowerPC ABI specification for more
+ * information, chapter 3.5.11 (in v1.7).
+ */
+.section ".text"
+.align 3
+.globl .ptrgl
+.ptrgl:
+    ld	    0, 0(11)
+    std     2, 40(1)
+    mtctr   0
+    ld      2, 8(11)
+    ld      11, 8(11)
+    bctr
+.long 0
+.byte 0, 12, 128, 0, 0, 0, 0, 0
+.type .ptrgl, @function
+.size .ptrgl, . - .ptrgl
+
+/*
+ * Function prolog/epilog helpers, which are part of the 64-bit
+ * PowerPC ABI.
+ *
+ * See also the 64-bit PowerPC ABI specification for more
+ * information, chapter 3.5.5, "Register saving and restoring
+ * function" (in v1.7).
+ */
+
+/* Each _savegpr0_N routine saves the general registers from rN to r31,
+ * inclusive. When the routine is called, r1 must point to the start
+ * of the general register save area. R0 must contain the old LR on
+ * entry.
+ */
+_savegpr0_14: std 14,-144(1)
+_savegpr0_15: std 15,-136(1)
+_savegpr0_16: std 16,-128(1)
+_savegpr0_17: std 17,-120(1)
+_savegpr0_18: std 18,-112(1)
+_savegpr0_19: std 19,-104(1)
+_savegpr0_20: std 20,-96(1)
+_savegpr0_21: std 21,-88(1)
+_savegpr0_22: std 22,-80(1)
+_savegpr0_23: std 23,-72(1)
+_savegpr0_24: std 24,-64(1)
+_savegpr0_25: std 25,-56(1)
+_savegpr0_26: std 26,-48(1)
+_savegpr0_27: std 27,-40(1)
+_savegpr0_28: std 28,-32(1)
+_savegpr0_29: std 29,-24(1)
+_savegpr0_30: std 30,-16(1)
+_savegpr0_31:
+    std 31,-8(1)
+    std 0, 16(1)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+/* Each _restgpr0_N routine restores the general registers from rN to r31,
+ * inclusive. When the routine is called, r1 must point to the start
+ * of the general register save area.
+ */
+_restgpr0_14: ld 14,-144(1)
+_restgpr0_15: ld 15,-136(1)
+_restgpr0_16: ld 16,-128(1)
+_restgpr0_17: ld 17,-120(1)
+_restgpr0_18: ld 18,-112(1)
+_restgpr0_19: ld 19,-104(1)
+_restgpr0_20: ld 20,-96(1)
+_restgpr0_21: ld 21,-88(1)
+_restgpr0_22: ld 22,-80(1)
+_restgpr0_23: ld 23,-72(1)
+_restgpr0_24: ld 24,-64(1)
+_restgpr0_25: ld 25,-56(1)
+_restgpr0_26: ld 26,-48(1)
+_restgpr0_27: ld 27,-40(1)
+_restgpr0_28: ld 28,-32(1)
+_restgpr0_29:
+    ld 0, 16(1)
+    ld 29,-24(1)
+    mtlr 0
+    ld 30,-16(1)
+    ld 31,-8(1)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+_restgpr0_30: ld 30,-16(1)
+_restgpr0_31: ld 0, 16(1)
+    ld 31,-8(1)
+    mtlr 0
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+/* Each _savegpr1_N routine saves the general registers from rN to r31,
+ * inclusive. When the routine is called, r12
+ * must point to the start of the general register save area.
+ */
+_savegpr1_14: std 14,-144(12)
+_savegpr1_15: std 15,-136(12)
+_savegpr1_16: std 16,-128(12)
+_savegpr1_17: std 17,-120(12)
+_savegpr1_18: std 18,-112(12)
+_savegpr1_19: std 19,-104(12)
+_savegpr1_20: std 20,-96(12)
+_savegpr1_21: std 21,-88(12)
+_savegpr1_22: std 22,-80(12)
+_savegpr1_23: std 23,-72(12)
+_savegpr1_24: std 24,-64(12)
+_savegpr1_25: std 25,-56(12)
+_savegpr1_26: std 26,-48(12)
+_savegpr1_27: std 27,-40(12)
+_savegpr1_28: std 28,-32(12)
+_savegpr1_29: std 29,-24(12)
+_savegpr1_30: std 30,-16(12)
+_savegpr1_31: std 31,-8(12)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+/* The _restgpr1_N routines restore the general registers from rN to r31.
+ * When the routine is called, r12 must point to the start of the general
+ * register save area.
+ */
+_restgpr1_14: ld 14,-144(12)
+_restgpr1_15: ld 15,-136(12)
+_restgpr1_16: ld 16,-128(12)
+_restgpr1_17: ld 17,-120(12)
+_restgpr1_18: ld 18,-112(12)
+_restgpr1_19: ld 19,-104(12)
+_restgpr1_20: ld 20,-96(12)
+_restgpr1_21: ld 21,-88(12)
+_restgpr1_22: ld 22,-80(12)
+_restgpr1_23: ld 23,-72(12)
+_restgpr1_24: ld 24,-64(12)
+_restgpr1_25: ld 25,-56(12)
+_restgpr1_26: ld 26,-48(12)
+_restgpr1_27: ld 27,-40(12)
+_restgpr1_28: ld 28,-32(12)
+_restgpr1_29: ld 29,-24(12)
+_restgpr1_30: ld 30,-16(12)
+_restgpr1_31: ld 31,-8(12)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+/* Each _savefpr_M routine saves the floating point registers from fM to f31,
+ * inclusive. When the routine is called, r1 must point to the start of the
+ * floating point register save area, and r0 must contain the value of LR on
+ * function entry.
+ */
+_savefpr_14: stfd 14,-144(1)
+_savefpr_15: stfd 15,-136(1)
+_savefpr_16: stfd 16,-128(1)
+_savefpr_17: stfd 17,-120(1)
+_savefpr_18: stfd 18,-112(1)
+_savefpr_19: stfd 19,-104(1)
+_savefpr_20: stfd 20,-96(1)
+_savefpr_21: stfd 21,-88(1)
+_savefpr_22: stfd 22,-80(1)
+_savefpr_23: stfd 23,-72(1)
+_savefpr_24: stfd 24,-64(1)
+_savefpr_25: stfd 25,-56(1)
+_savefpr_26: stfd 26,-48(1)
+_savefpr_27: stfd 27,-40(1)
+_savefpr_28: stfd 28,-32(1)
+_savefpr_29: stfd 29,-24(1)
+_savefpr_30: stfd 30,-16(1)
+_savefpr_31: stfd 31,-8(1)
+    std 0, 16(1)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+/* The _restfpr_M routines restore the floating point registers from fM to f31.
+ * When the routine is called, r1 must point to the start of the floating point
+ * register save area.
+ */
+_restfpr_14: lfd 14,-144(1)
+_restfpr_15: lfd 15,-136(1)
+_restfpr_16: lfd 16,-128(1)
+_restfpr_17: lfd 17,-120(1)
+_restfpr_18: lfd 18,-112(1)
+_restfpr_19: lfd 19,-104(1)
+_restfpr_20: lfd 20,-96(1)
+_restfpr_21: lfd 21,-88(1)
+_restfpr_22: lfd 22,-80(1)
+_restfpr_23: lfd 23,-72(1)
+_restfpr_24: lfd 24,-64(1)
+_restfpr_25: lfd 25,-56(1)
+_restfpr_26: lfd 26,-48(1)
+_restfpr_27: lfd 27,-40(1)
+_restfpr_28: lfd 28,-32(1)
+_restfpr_29:
+    ld 0, 16(1)
+    lfd 29,-24(1)
+    mtlr 0
+    lfd 30,-16(1)
+    lfd 31,-8(1)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+_restfpr_30: lfd 30,-16(1)
+_restfpr_31:
+    ld 0, 16(1)
+    lfd 31,-8(1)
+    mtlr 0
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+/* Each _savevr_M routine saves the vector registers from vM to v31, inclusive.
+ * When the routine is called, r0 must point to the word just beyound the end
+ * of the vector register save area. On return the value of r0 is unchanged
+ * while r12 may be modified.
+ */
+/* commented out for now, unused
+_savevr_20: addi r12,r0,-192
+    stvx v20,r12,r0
+_savevr_21: addi r12,r0,-176
+    stvx v21,r12,r0
+_savevr_22: addi r12,r0,-160
+    stvx v22,r12,r0
+_savevr_23: addi r12,r0,-144
+    stvx v23,r12,r0
+_savevr_24: addi r12,r0,-128
+    stvx v24,r12,r0
+_savevr_25: addi r12,r0,-112
+    stvx v25,r12,r0
+_savevr_26: addi r12,r0,-96
+    stvx v26,r12,r0
+_savevr_27: addi r12,r0,-80
+    stvx v27,r12,r0
+_savevr_28: addi r12,r0,-64
+    stvx v28,r12,r0
+_savevr_29: addi r12,r0,-48
+    stvx v29,r12,r0
+_savevr_30: addi r12,r0,-32
+    stvx v30,r12,r0
+_savevr_31: addi r12,r0,-16
+    stvx v31,r12,r0
+    blr
+*/
+/* The _restvr_M routines restore the vector registers from vM to v31. When the
+ * routine is called, r0 must point to the word just beyound the end of the
+ * vector register save area. On return the value of r0 is unchanged while r12
+ * may be modified.
+ */
+/* commented out for now, unused
+_restvr_20: addi r12,r0,-192
+    lvx v20,r12,r0
+_restvr_21: addi r12,r0,-176
+    lvx v21,r12,r0
+_restvr_22: addi r12,r0,-160
+    lvx v22,r12,r0
+_restvr_23: addi r12,r0,-144
+    lvx v23,r12,r0
+_restvr_24: addi r12,r0,-128
+    lvx v24,r12,r0
+_restvr_25: addi r12,r0,-112
+    lvx v25,r12,r0
+_restvr_26: addi r12,r0,-96
+    lvx v26,r12,r0
+_restvr_27: addi r12,r0,-80
+    lvx v27,r12,r0
+_restvr_28: addi r12,r0,-64
+    lvx v28,r12,r0
+_restvr_29: addi r12,r0,-48
+    lvx v29,r12,r0
+_restvr_30: addi r12,r0,-32
+    lvx v30,r12,r0
+_restvr_31: addi r12,r0,-16
+    lvx v31,r12,r0
+    blr
+*/
+
+/*
+ * start_addresses is a structure containing the real
+ * entry point (next to other things not interesting to
+ * us here).
+ *
+ * All references in the struct are function descriptors
+ *
+ */
+    .section ".rodata"
+    .align  3
+start_addresses:
+    .quad   0 /* was _SDA_BASE_  but not in 64-bit ABI*/
+    .quad   main_stub
+    .quad   __libc_csu_init
+    .quad   __libc_csu_fini
+    .size   start_adresses, .-start_addresses
+
+/*
+ * the real entry point for the program
+ */
+FUNCTION_PROLOG _start
+    mr  9,1                   /* save the stack pointer */
+
+    /* Set up an initial stack frame, and clear the LR.  */
+
+    clrrdi  1,1,4
+    li      0,0
+    stdu    1,-128(1)
+    mtlr    0
+    std     0,0(1)
+
+    /* put the address of start_addresses in r8...  */
+    /* PPC64 ABI uses R13 for thread local, so we leave it alone */
+    LOAD_64BIT_VAL 8, start_addresses
+
+    b   .__libc_start_main
+    nop                      /* a NOP for the linker */
+
+/*
+ * This is our FreePascal main procedure which is called by
+ * libc after initializing.
+ */
+
+FUNCTION_PROLOG main_stub
+    mflr    0
+    std     0,16(1)
+    stdu    1,-128(1)
+
+    LOAD_64BIT_VAL 8, operatingsystem_parameter_argc
+    stw     3,0(8)
+
+    LOAD_64BIT_VAL 8, operatingsystem_parameter_argv
+    std     4,0(8)
+
+    LOAD_64BIT_VAL 8, operatingsystem_parameter_envp
+    std     5,0(8)
+
+    LOAD_64BIT_VAL 8, __stkptr
+    std     1,0(8)
+
+    LOAD_64BIT_VAL 8, ___fpc_ret
+    std     1,0(8)
+
+    LOAD_64BIT_VAL 3, _start
+    ld 3, 0(3)
+    LOAD_64BIT_VAL 4, etext
+    bl  .__monstartup
+    nop
+
+    LOAD_64BIT_VAL 3, _mcleanup
+    bl .atexit
+    nop
+
+    bl  .PASCALMAIN
+    nop
+
+    b   ._haltproc
+
+FUNCTION_PROLOG _haltproc
+    LOAD_64BIT_VAL 8, ___fpc_ret
+    ld      1, 0(8)
+    addi    1, 1, 128
+    ld      0, 16(1)
+    mtlr    0
+    blr
+
+    /* Define a symbol for the first piece of initialized data.  */
+    .section ".data"
+    .globl  __data_start
+__data_start:
+data_start:
+
+___fpc_ret:                            /* return address to libc */
+    .quad   0
+
+.text
+    .comm __stkptr, 8
+
+    .comm operatingsystem_parameter_argc, 4
+    .comm operatingsystem_parameter_argv, 8
+    .comm operatingsystem_parameter_envp, 8

+ 378 - 378
rtl/linux/powerpc64/prt0.as

@@ -1,378 +1,378 @@
-/*
- * This file is part of the Free Pascal run time library.
- * Copyright (c) 2005 by Thomas Schatzl,
- * member of the Free Pascal development team.
- *
- * Startup code for normal programs, PowerPC64 version.
- *
- * 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.
- */
-
-.macro LOAD_64BIT_VAL ra, value
-    lis       \ra,\value@highest
-    ori       \ra,\ra,\value@higher
-    sldi      \ra,\ra,32
-    oris      \ra,\ra,\value@h
-    ori       \ra,\ra,\value@l
-.endm
-
-/* create function prolog for symbol "fn" */
-.macro FUNCTION_PROLOG fn
-    .section  ".text"
-    .align    2
-    .globl    \fn
-    .section  ".opd", "aw"
-    .align    3
-\fn:
-    .quad     .\fn, .TOC.@tocbase, 0
-    .previous
-    .size     \fn, 24
-    .type     \fn, @function
-    .globl    .\fn
-.\fn:
-.endm
-
-/*
- * "ptrgl" glue code for calls via pointer. This function
- * sequence loads the data from the function descriptor
- * referenced by R11 into the CTR register (function address),
- * R2 (GOT/TOC pointer), and R11 (the outer frame pointer).
- *
- * On entry, R11 must be set to point to the function descriptor.
- *
- * See also the 64-bit PowerPC ABI specification for more
- * information, chapter 3.5.11 (in v1.7).
- */
-.section ".text"
-.align 3
-.globl .ptrgl
-.ptrgl:
-    ld	    0, 0(11)
-    std     2, 40(1)
-    mtctr   0
-    ld      2, 8(11)
-    ld      11, 8(11)
-    bctr
-.long 0
-.byte 0, 12, 128, 0, 0, 0, 0, 0
-.type .ptrgl, @function
-.size .ptrgl, . - .ptrgl
-
-/*
- * Function prolog/epilog helpers, which are part of the 64-bit
- * PowerPC ABI.
- *
- * See also the 64-bit PowerPC ABI specification for more
- * information, chapter 3.5.5, "Register saving and restoring
- * function" (in v1.7).
- */
-
-/* Each _savegpr0_N routine saves the general registers from rN to r31,
- * inclusive. When the routine is called, r1 must point to the start
- * of the general register save area. R0 must contain the old LR on
- * entry.
- */
-_savegpr0_14: std 14,-144(1)
-_savegpr0_15: std 15,-136(1)
-_savegpr0_16: std 16,-128(1)
-_savegpr0_17: std 17,-120(1)
-_savegpr0_18: std 18,-112(1)
-_savegpr0_19: std 19,-104(1)
-_savegpr0_20: std 20,-96(1)
-_savegpr0_21: std 21,-88(1)
-_savegpr0_22: std 22,-80(1)
-_savegpr0_23: std 23,-72(1)
-_savegpr0_24: std 24,-64(1)
-_savegpr0_25: std 25,-56(1)
-_savegpr0_26: std 26,-48(1)
-_savegpr0_27: std 27,-40(1)
-_savegpr0_28: std 28,-32(1)
-_savegpr0_29: std 29,-24(1)
-_savegpr0_30: std 30,-16(1)
-_savegpr0_31:
-    std 31,-8(1)
-    std 0, 16(1)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-/* Each _restgpr0_N routine restores the general registers from rN to r31,
- * inclusive. When the routine is called, r1 must point to the start
- * of the general register save area.
- */
-_restgpr0_14: ld 14,-144(1)
-_restgpr0_15: ld 15,-136(1)
-_restgpr0_16: ld 16,-128(1)
-_restgpr0_17: ld 17,-120(1)
-_restgpr0_18: ld 18,-112(1)
-_restgpr0_19: ld 19,-104(1)
-_restgpr0_20: ld 20,-96(1)
-_restgpr0_21: ld 21,-88(1)
-_restgpr0_22: ld 22,-80(1)
-_restgpr0_23: ld 23,-72(1)
-_restgpr0_24: ld 24,-64(1)
-_restgpr0_25: ld 25,-56(1)
-_restgpr0_26: ld 26,-48(1)
-_restgpr0_27: ld 27,-40(1)
-_restgpr0_28: ld 28,-32(1)
-_restgpr0_29:
-    ld 0, 16(1)
-    ld 29,-24(1)
-    mtlr 0
-    ld 30,-16(1)
-    ld 31,-8(1)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-_restgpr0_30: ld 30,-16(1)
-_restgpr0_31: ld 0, 16(1)
-    ld 31,-8(1)
-    mtlr 0
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-/* Each _savegpr1_N routine saves the general registers from rN to r31,
- * inclusive. When the routine is called, r12
- * must point to the start of the general register save area.
- */
-_savegpr1_14: std 14,-144(12)
-_savegpr1_15: std 15,-136(12)
-_savegpr1_16: std 16,-128(12)
-_savegpr1_17: std 17,-120(12)
-_savegpr1_18: std 18,-112(12)
-_savegpr1_19: std 19,-104(12)
-_savegpr1_20: std 20,-96(12)
-_savegpr1_21: std 21,-88(12)
-_savegpr1_22: std 22,-80(12)
-_savegpr1_23: std 23,-72(12)
-_savegpr1_24: std 24,-64(12)
-_savegpr1_25: std 25,-56(12)
-_savegpr1_26: std 26,-48(12)
-_savegpr1_27: std 27,-40(12)
-_savegpr1_28: std 28,-32(12)
-_savegpr1_29: std 29,-24(12)
-_savegpr1_30: std 30,-16(12)
-_savegpr1_31: std 31,-8(12)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-/* The _restgpr1_N routines restore the general registers from rN to r31.
- * When the routine is called, r12 must point to the start of the general
- * register save area.
- */
-_restgpr1_14: ld 14,-144(12)
-_restgpr1_15: ld 15,-136(12)
-_restgpr1_16: ld 16,-128(12)
-_restgpr1_17: ld 17,-120(12)
-_restgpr1_18: ld 18,-112(12)
-_restgpr1_19: ld 19,-104(12)
-_restgpr1_20: ld 20,-96(12)
-_restgpr1_21: ld 21,-88(12)
-_restgpr1_22: ld 22,-80(12)
-_restgpr1_23: ld 23,-72(12)
-_restgpr1_24: ld 24,-64(12)
-_restgpr1_25: ld 25,-56(12)
-_restgpr1_26: ld 26,-48(12)
-_restgpr1_27: ld 27,-40(12)
-_restgpr1_28: ld 28,-32(12)
-_restgpr1_29: ld 29,-24(12)
-_restgpr1_30: ld 30,-16(12)
-_restgpr1_31: ld 31,-8(12)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-/* Each _savefpr_M routine saves the floating point registers from fM to f31,
- * inclusive. When the routine is called, r1 must point to the start of the
- * floating point register save area, and r0 must contain the value of LR on
- * function entry.
- */
-_savefpr_14: stfd 14,-144(1)
-_savefpr_15: stfd 15,-136(1)
-_savefpr_16: stfd 16,-128(1)
-_savefpr_17: stfd 17,-120(1)
-_savefpr_18: stfd 18,-112(1)
-_savefpr_19: stfd 19,-104(1)
-_savefpr_20: stfd 20,-96(1)
-_savefpr_21: stfd 21,-88(1)
-_savefpr_22: stfd 22,-80(1)
-_savefpr_23: stfd 23,-72(1)
-_savefpr_24: stfd 24,-64(1)
-_savefpr_25: stfd 25,-56(1)
-_savefpr_26: stfd 26,-48(1)
-_savefpr_27: stfd 27,-40(1)
-_savefpr_28: stfd 28,-32(1)
-_savefpr_29: stfd 29,-24(1)
-_savefpr_30: stfd 30,-16(1)
-_savefpr_31: stfd 31,-8(1)
-    std 0, 16(1)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-/* The _restfpr_M routines restore the floating point registers from fM to f31.
- * When the routine is called, r1 must point to the start of the floating point
- * register save area.
- */
-_restfpr_14: lfd 14,-144(1)
-_restfpr_15: lfd 15,-136(1)
-_restfpr_16: lfd 16,-128(1)
-_restfpr_17: lfd 17,-120(1)
-_restfpr_18: lfd 18,-112(1)
-_restfpr_19: lfd 19,-104(1)
-_restfpr_20: lfd 20,-96(1)
-_restfpr_21: lfd 21,-88(1)
-_restfpr_22: lfd 22,-80(1)
-_restfpr_23: lfd 23,-72(1)
-_restfpr_24: lfd 24,-64(1)
-_restfpr_25: lfd 25,-56(1)
-_restfpr_26: lfd 26,-48(1)
-_restfpr_27: lfd 27,-40(1)
-_restfpr_28: lfd 28,-32(1)
-_restfpr_29:
-    ld 0, 16(1)
-    lfd 29,-24(1)
-    mtlr 0
-    lfd 30,-16(1)
-    lfd 31,-8(1)
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-_restfpr_30: lfd 30,-16(1)
-_restfpr_31:
-    ld 0, 16(1)
-    lfd 31,-8(1)
-    mtlr 0
-    blr
-.long 0
-.byte 0, 12, 64, 0, 0, 0, 0, 0
-
-/* Each _savevr_M routine saves the vector registers from vM to v31, inclusive.
- * When the routine is called, r0 must point to the word just beyound the end
- * of the vector register save area. On return the value of r0 is unchanged
- * while r12 may be modified.
- */
-/* commented out for now, unused
-_savevr_20: addi r12,r0,-192
-    stvx v20,r12,r0
-_savevr_21: addi r12,r0,-176
-    stvx v21,r12,r0
-_savevr_22: addi r12,r0,-160
-    stvx v22,r12,r0
-_savevr_23: addi r12,r0,-144
-    stvx v23,r12,r0
-_savevr_24: addi r12,r0,-128
-    stvx v24,r12,r0
-_savevr_25: addi r12,r0,-112
-    stvx v25,r12,r0
-_savevr_26: addi r12,r0,-96
-    stvx v26,r12,r0
-_savevr_27: addi r12,r0,-80
-    stvx v27,r12,r0
-_savevr_28: addi r12,r0,-64
-    stvx v28,r12,r0
-_savevr_29: addi r12,r0,-48
-    stvx v29,r12,r0
-_savevr_30: addi r12,r0,-32
-    stvx v30,r12,r0
-_savevr_31: addi r12,r0,-16
-    stvx v31,r12,r0
-    blr
-*/
-/* The _restvr_M routines restore the vector registers from vM to v31. When the
- * routine is called, r0 must point to the word just beyound the end of the
- * vector register save area. On return the value of r0 is unchanged while r12
- * may be modified.
- */
-/* commented out for now, unused
-_restvr_20: addi r12,r0,-192
-    lvx v20,r12,r0
-_restvr_21: addi r12,r0,-176
-    lvx v21,r12,r0
-_restvr_22: addi r12,r0,-160
-    lvx v22,r12,r0
-_restvr_23: addi r12,r0,-144
-    lvx v23,r12,r0
-_restvr_24: addi r12,r0,-128
-    lvx v24,r12,r0
-_restvr_25: addi r12,r0,-112
-    lvx v25,r12,r0
-_restvr_26: addi r12,r0,-96
-    lvx v26,r12,r0
-_restvr_27: addi r12,r0,-80
-    lvx v27,r12,r0
-_restvr_28: addi r12,r0,-64
-    lvx v28,r12,r0
-_restvr_29: addi r12,r0,-48
-    lvx v29,r12,r0
-_restvr_30: addi r12,r0,-32
-    lvx v30,r12,r0
-_restvr_31: addi r12,r0,-16
-    lvx v31,r12,r0
-    blr
-*/
-
-/*
- * Main program entry point label (function), called by the loader
- */
-FUNCTION_PROLOG _start
-
-    mr   26, 1            /* save stack pointer */
-    /* Set up an initial stack frame, and clear the LR */
-    clrrdi  1, 1, 5       /* align r1 */
-    li      0, 0
-    stdu    1,-128(1)
-    mtlr    0
-    std     0, 0(1)       /* r1 = pointer to NULL value */
-
-    /* store argument count (= 0(r1) )*/
-    ld      3, 0(26)
-    LOAD_64BIT_VAL 10, operatingsystem_parameter_argc
-    stw     3, 0(10)
-    /* calculate argument vector address and store (= 8(r1) + 8 ) */
-    addi    4, 26, 8
-    LOAD_64BIT_VAL 10, operatingsystem_parameter_argv
-    std     4, 0(10)
-    /* store environment pointer (= argv + (argc+1)* 8 ) */
-    addi    5, 3, 1
-    sldi    5, 5, 3
-    add     5, 4, 5
-    LOAD_64BIT_VAL 10, operatingsystem_parameter_envp
-    std     5, 0(10)
-
-    LOAD_64BIT_VAL 8, __stkptr
-    std     1,0(8)
-
-    bl      .PASCALMAIN
-    nop
-
-    /* directly jump to exit procedure, not via the function pointer */
-    b       ._haltproc
-
-FUNCTION_PROLOG _haltproc
-    /* exit call */
-    li      0, 1
-    sc
-    b       ._haltproc
-
-    /* Define a symbol for the first piece of initialized data.  */
-    .section ".data"
-    .globl  __data_start
-__data_start:
-data_start:
-
-.text
-    .comm __stkptr, 8
-
-    .comm operatingsystem_parameter_argc, 4
-    .comm operatingsystem_parameter_argv, 8
-    .comm operatingsystem_parameter_envp, 8
-
+/*
+ * This file is part of the Free Pascal run time library.
+ * Copyright (c) 2005 by Thomas Schatzl,
+ * member of the Free Pascal development team.
+ *
+ * Startup code for normal programs, PowerPC64 version.
+ *
+ * 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.
+ */
+
+.macro LOAD_64BIT_VAL ra, value
+    lis       \ra,\value@highest
+    ori       \ra,\ra,\value@higher
+    sldi      \ra,\ra,32
+    oris      \ra,\ra,\value@h
+    ori       \ra,\ra,\value@l
+.endm
+
+/* create function prolog for symbol "fn" */
+.macro FUNCTION_PROLOG fn
+    .section  ".text"
+    .align    2
+    .globl    \fn
+    .section  ".opd", "aw"
+    .align    3
+\fn:
+    .quad     .\fn, .TOC.@tocbase, 0
+    .previous
+    .size     \fn, 24
+    .type     \fn, @function
+    .globl    .\fn
+.\fn:
+.endm
+
+/*
+ * "ptrgl" glue code for calls via pointer. This function
+ * sequence loads the data from the function descriptor
+ * referenced by R11 into the CTR register (function address),
+ * R2 (GOT/TOC pointer), and R11 (the outer frame pointer).
+ *
+ * On entry, R11 must be set to point to the function descriptor.
+ *
+ * See also the 64-bit PowerPC ABI specification for more
+ * information, chapter 3.5.11 (in v1.7).
+ */
+.section ".text"
+.align 3
+.globl .ptrgl
+.ptrgl:
+    ld	    0, 0(11)
+    std     2, 40(1)
+    mtctr   0
+    ld      2, 8(11)
+    ld      11, 8(11)
+    bctr
+.long 0
+.byte 0, 12, 128, 0, 0, 0, 0, 0
+.type .ptrgl, @function
+.size .ptrgl, . - .ptrgl
+
+/*
+ * Function prolog/epilog helpers, which are part of the 64-bit
+ * PowerPC ABI.
+ *
+ * See also the 64-bit PowerPC ABI specification for more
+ * information, chapter 3.5.5, "Register saving and restoring
+ * function" (in v1.7).
+ */
+
+/* Each _savegpr0_N routine saves the general registers from rN to r31,
+ * inclusive. When the routine is called, r1 must point to the start
+ * of the general register save area. R0 must contain the old LR on
+ * entry.
+ */
+_savegpr0_14: std 14,-144(1)
+_savegpr0_15: std 15,-136(1)
+_savegpr0_16: std 16,-128(1)
+_savegpr0_17: std 17,-120(1)
+_savegpr0_18: std 18,-112(1)
+_savegpr0_19: std 19,-104(1)
+_savegpr0_20: std 20,-96(1)
+_savegpr0_21: std 21,-88(1)
+_savegpr0_22: std 22,-80(1)
+_savegpr0_23: std 23,-72(1)
+_savegpr0_24: std 24,-64(1)
+_savegpr0_25: std 25,-56(1)
+_savegpr0_26: std 26,-48(1)
+_savegpr0_27: std 27,-40(1)
+_savegpr0_28: std 28,-32(1)
+_savegpr0_29: std 29,-24(1)
+_savegpr0_30: std 30,-16(1)
+_savegpr0_31:
+    std 31,-8(1)
+    std 0, 16(1)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+/* Each _restgpr0_N routine restores the general registers from rN to r31,
+ * inclusive. When the routine is called, r1 must point to the start
+ * of the general register save area.
+ */
+_restgpr0_14: ld 14,-144(1)
+_restgpr0_15: ld 15,-136(1)
+_restgpr0_16: ld 16,-128(1)
+_restgpr0_17: ld 17,-120(1)
+_restgpr0_18: ld 18,-112(1)
+_restgpr0_19: ld 19,-104(1)
+_restgpr0_20: ld 20,-96(1)
+_restgpr0_21: ld 21,-88(1)
+_restgpr0_22: ld 22,-80(1)
+_restgpr0_23: ld 23,-72(1)
+_restgpr0_24: ld 24,-64(1)
+_restgpr0_25: ld 25,-56(1)
+_restgpr0_26: ld 26,-48(1)
+_restgpr0_27: ld 27,-40(1)
+_restgpr0_28: ld 28,-32(1)
+_restgpr0_29:
+    ld 0, 16(1)
+    ld 29,-24(1)
+    mtlr 0
+    ld 30,-16(1)
+    ld 31,-8(1)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+_restgpr0_30: ld 30,-16(1)
+_restgpr0_31: ld 0, 16(1)
+    ld 31,-8(1)
+    mtlr 0
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+/* Each _savegpr1_N routine saves the general registers from rN to r31,
+ * inclusive. When the routine is called, r12
+ * must point to the start of the general register save area.
+ */
+_savegpr1_14: std 14,-144(12)
+_savegpr1_15: std 15,-136(12)
+_savegpr1_16: std 16,-128(12)
+_savegpr1_17: std 17,-120(12)
+_savegpr1_18: std 18,-112(12)
+_savegpr1_19: std 19,-104(12)
+_savegpr1_20: std 20,-96(12)
+_savegpr1_21: std 21,-88(12)
+_savegpr1_22: std 22,-80(12)
+_savegpr1_23: std 23,-72(12)
+_savegpr1_24: std 24,-64(12)
+_savegpr1_25: std 25,-56(12)
+_savegpr1_26: std 26,-48(12)
+_savegpr1_27: std 27,-40(12)
+_savegpr1_28: std 28,-32(12)
+_savegpr1_29: std 29,-24(12)
+_savegpr1_30: std 30,-16(12)
+_savegpr1_31: std 31,-8(12)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+/* The _restgpr1_N routines restore the general registers from rN to r31.
+ * When the routine is called, r12 must point to the start of the general
+ * register save area.
+ */
+_restgpr1_14: ld 14,-144(12)
+_restgpr1_15: ld 15,-136(12)
+_restgpr1_16: ld 16,-128(12)
+_restgpr1_17: ld 17,-120(12)
+_restgpr1_18: ld 18,-112(12)
+_restgpr1_19: ld 19,-104(12)
+_restgpr1_20: ld 20,-96(12)
+_restgpr1_21: ld 21,-88(12)
+_restgpr1_22: ld 22,-80(12)
+_restgpr1_23: ld 23,-72(12)
+_restgpr1_24: ld 24,-64(12)
+_restgpr1_25: ld 25,-56(12)
+_restgpr1_26: ld 26,-48(12)
+_restgpr1_27: ld 27,-40(12)
+_restgpr1_28: ld 28,-32(12)
+_restgpr1_29: ld 29,-24(12)
+_restgpr1_30: ld 30,-16(12)
+_restgpr1_31: ld 31,-8(12)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+/* Each _savefpr_M routine saves the floating point registers from fM to f31,
+ * inclusive. When the routine is called, r1 must point to the start of the
+ * floating point register save area, and r0 must contain the value of LR on
+ * function entry.
+ */
+_savefpr_14: stfd 14,-144(1)
+_savefpr_15: stfd 15,-136(1)
+_savefpr_16: stfd 16,-128(1)
+_savefpr_17: stfd 17,-120(1)
+_savefpr_18: stfd 18,-112(1)
+_savefpr_19: stfd 19,-104(1)
+_savefpr_20: stfd 20,-96(1)
+_savefpr_21: stfd 21,-88(1)
+_savefpr_22: stfd 22,-80(1)
+_savefpr_23: stfd 23,-72(1)
+_savefpr_24: stfd 24,-64(1)
+_savefpr_25: stfd 25,-56(1)
+_savefpr_26: stfd 26,-48(1)
+_savefpr_27: stfd 27,-40(1)
+_savefpr_28: stfd 28,-32(1)
+_savefpr_29: stfd 29,-24(1)
+_savefpr_30: stfd 30,-16(1)
+_savefpr_31: stfd 31,-8(1)
+    std 0, 16(1)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+/* The _restfpr_M routines restore the floating point registers from fM to f31.
+ * When the routine is called, r1 must point to the start of the floating point
+ * register save area.
+ */
+_restfpr_14: lfd 14,-144(1)
+_restfpr_15: lfd 15,-136(1)
+_restfpr_16: lfd 16,-128(1)
+_restfpr_17: lfd 17,-120(1)
+_restfpr_18: lfd 18,-112(1)
+_restfpr_19: lfd 19,-104(1)
+_restfpr_20: lfd 20,-96(1)
+_restfpr_21: lfd 21,-88(1)
+_restfpr_22: lfd 22,-80(1)
+_restfpr_23: lfd 23,-72(1)
+_restfpr_24: lfd 24,-64(1)
+_restfpr_25: lfd 25,-56(1)
+_restfpr_26: lfd 26,-48(1)
+_restfpr_27: lfd 27,-40(1)
+_restfpr_28: lfd 28,-32(1)
+_restfpr_29:
+    ld 0, 16(1)
+    lfd 29,-24(1)
+    mtlr 0
+    lfd 30,-16(1)
+    lfd 31,-8(1)
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+_restfpr_30: lfd 30,-16(1)
+_restfpr_31:
+    ld 0, 16(1)
+    lfd 31,-8(1)
+    mtlr 0
+    blr
+.long 0
+.byte 0, 12, 64, 0, 0, 0, 0, 0
+
+/* Each _savevr_M routine saves the vector registers from vM to v31, inclusive.
+ * When the routine is called, r0 must point to the word just beyound the end
+ * of the vector register save area. On return the value of r0 is unchanged
+ * while r12 may be modified.
+ */
+/* commented out for now, unused
+_savevr_20: addi r12,r0,-192
+    stvx v20,r12,r0
+_savevr_21: addi r12,r0,-176
+    stvx v21,r12,r0
+_savevr_22: addi r12,r0,-160
+    stvx v22,r12,r0
+_savevr_23: addi r12,r0,-144
+    stvx v23,r12,r0
+_savevr_24: addi r12,r0,-128
+    stvx v24,r12,r0
+_savevr_25: addi r12,r0,-112
+    stvx v25,r12,r0
+_savevr_26: addi r12,r0,-96
+    stvx v26,r12,r0
+_savevr_27: addi r12,r0,-80
+    stvx v27,r12,r0
+_savevr_28: addi r12,r0,-64
+    stvx v28,r12,r0
+_savevr_29: addi r12,r0,-48
+    stvx v29,r12,r0
+_savevr_30: addi r12,r0,-32
+    stvx v30,r12,r0
+_savevr_31: addi r12,r0,-16
+    stvx v31,r12,r0
+    blr
+*/
+/* The _restvr_M routines restore the vector registers from vM to v31. When the
+ * routine is called, r0 must point to the word just beyound the end of the
+ * vector register save area. On return the value of r0 is unchanged while r12
+ * may be modified.
+ */
+/* commented out for now, unused
+_restvr_20: addi r12,r0,-192
+    lvx v20,r12,r0
+_restvr_21: addi r12,r0,-176
+    lvx v21,r12,r0
+_restvr_22: addi r12,r0,-160
+    lvx v22,r12,r0
+_restvr_23: addi r12,r0,-144
+    lvx v23,r12,r0
+_restvr_24: addi r12,r0,-128
+    lvx v24,r12,r0
+_restvr_25: addi r12,r0,-112
+    lvx v25,r12,r0
+_restvr_26: addi r12,r0,-96
+    lvx v26,r12,r0
+_restvr_27: addi r12,r0,-80
+    lvx v27,r12,r0
+_restvr_28: addi r12,r0,-64
+    lvx v28,r12,r0
+_restvr_29: addi r12,r0,-48
+    lvx v29,r12,r0
+_restvr_30: addi r12,r0,-32
+    lvx v30,r12,r0
+_restvr_31: addi r12,r0,-16
+    lvx v31,r12,r0
+    blr
+*/
+
+/*
+ * Main program entry point label (function), called by the loader
+ */
+FUNCTION_PROLOG _start
+
+    mr   26, 1            /* save stack pointer */
+    /* Set up an initial stack frame, and clear the LR */
+    clrrdi  1, 1, 5       /* align r1 */
+    li      0, 0
+    stdu    1,-128(1)
+    mtlr    0
+    std     0, 0(1)       /* r1 = pointer to NULL value */
+
+    /* store argument count (= 0(r1) )*/
+    ld      3, 0(26)
+    LOAD_64BIT_VAL 10, operatingsystem_parameter_argc
+    stw     3, 0(10)
+    /* calculate argument vector address and store (= 8(r1) + 8 ) */
+    addi    4, 26, 8
+    LOAD_64BIT_VAL 10, operatingsystem_parameter_argv
+    std     4, 0(10)
+    /* store environment pointer (= argv + (argc+1)* 8 ) */
+    addi    5, 3, 1
+    sldi    5, 5, 3
+    add     5, 4, 5
+    LOAD_64BIT_VAL 10, operatingsystem_parameter_envp
+    std     5, 0(10)
+
+    LOAD_64BIT_VAL 8, __stkptr
+    std     1,0(8)
+
+    bl      .PASCALMAIN
+    nop
+
+    /* directly jump to exit procedure, not via the function pointer */
+    b       ._haltproc
+
+FUNCTION_PROLOG _haltproc
+    /* exit call */
+    li      0, 1
+    sc
+    b       ._haltproc
+
+    /* Define a symbol for the first piece of initialized data.  */
+    .section ".data"
+    .globl  __data_start
+__data_start:
+data_start:
+
+.text
+    .comm __stkptr, 8
+
+    .comm operatingsystem_parameter_argc, 4
+    .comm operatingsystem_parameter_argv, 8
+    .comm operatingsystem_parameter_envp, 8
+

+ 108 - 108
rtl/linux/x86_64/dllprt0.as

@@ -1,108 +1,108 @@
-#
-#   This file is part of the Free Pascal run time library.
-#   Copyright (c) 2006 by Florian Klaempfl
-#   members of the Free Pascal development team.
-#
-#   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.
-#
-#**********************************************************************}
-#
-# Linux ELF startup code for Free Pascal
-#
-
-/* This is the canonical entry point, usually the first thing in the text
-   segment.  The SVR4/i386 ABI (pages 3-31, 3-32) says that when the entry
-   point runs, most registers' values are unspecified, except for:
-
-   %rdx		Contains a function pointer to be registered with `atexit'.
-		This is how the dynamic linker arranges to have DT_FINI
-		functions called for shared libraries that have been loaded
-		before this code runs.
-
-   %rsp		The stack contains the arguments and environment:
-		0(%rsp)			argc
-		8(%rsp)			argv[0]
-		...
-		(8*argc)(%rsp)		NULL
-		(8*(argc+1))(%rsp)	envp[0]
-		...
-					NULL
-*/
-.section .init
-	.align 16
-	.globl FPC_LIB_START
-	.type FPC_LIB_START,@function
-FPC_LIB_START:
-	jmp	_startlib@PLT
-
-        .text
-	.globl _start
-	.type _start,@function
-_startlib:
-#       movq %rdx,%r9                 /* Address of the shared library termination
-#               	                 function.  */
-	pushq	 %rbx
-        movq     operatingsystem_parameter_argc@GOTPCREL(%rip),%rbx
-        movq     %rdi,(%rbx)
-        movq     operatingsystem_parameter_argv@GOTPCREL(%rip),%rbx
-	movq     %rsi,(%rbx)          /* argv starts just at the current stack top.  */
-        movq     operatingsystem_parameter_envp@GOTPCREL(%rip),%rbx
-        movq     %rdx,(%rbx)
-
-        movq    TC_SYSTEM_ISLIBRARY@GOTPCREL(%rip),%rbx
-        movb    $1,(%rbx)
-
-        /* Save initial stackpointer */
-        movq    __stkptr@GOTPCREL(%rip),%rbx
-        movq    %rsp,(%rbx)
-
-        call    PASCALMAIN@PLT
-	popq	%rbx
-	ret
-
-        .globl  _haltproc
-        .type   _haltproc,@function
-_haltproc:
-        movl    $231,%eax                 /* exit_group call */
-        movq    operatingsystem_result@GOTPCREL(%rip),%rbx
-        movzwl  (%rbx),%edi
-        syscall
-        jmp     _haltproc@PLT
-
-/* Define a symbol for the first piece of initialized data.  */
-	.data
-	.globl __data_start
-__data_start:
-	.long 0
-	.weak data_start
-        data_start = __data_start
-
-.bss
-        .comm __stkptr,8
-
-        .comm operatingsystem_parameter_envp,8
-        .comm operatingsystem_parameter_argc,8
-        .comm operatingsystem_parameter_argv,8
-
-
-/* We need this stuff to make gdb behave itself, otherwise
-   gdb will chokes with SIGILL when trying to debug apps.
-
-Makes ld choke:
-        .section ".note.ABI-tag", "a"
-        .align 4
-        .long 1f - 0f
-        .long 3f - 2f
-        .long  1
-0:      .asciz "GNU"
-1:      .align 4
-2:      .long 0
-        .long 2,4,0
-3:      .align 4
-*/
-	.section	.note.GNU-stack,"",@progbits
+#
+#   This file is part of the Free Pascal run time library.
+#   Copyright (c) 2006 by Florian Klaempfl
+#   members of the Free Pascal development team.
+#
+#   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.
+#
+#**********************************************************************}
+#
+# Linux ELF startup code for Free Pascal
+#
+
+/* This is the canonical entry point, usually the first thing in the text
+   segment.  The SVR4/i386 ABI (pages 3-31, 3-32) says that when the entry
+   point runs, most registers' values are unspecified, except for:
+
+   %rdx		Contains a function pointer to be registered with `atexit'.
+		This is how the dynamic linker arranges to have DT_FINI
+		functions called for shared libraries that have been loaded
+		before this code runs.
+
+   %rsp		The stack contains the arguments and environment:
+		0(%rsp)			argc
+		8(%rsp)			argv[0]
+		...
+		(8*argc)(%rsp)		NULL
+		(8*(argc+1))(%rsp)	envp[0]
+		...
+					NULL
+*/
+.section .init
+	.align 16
+	.globl FPC_LIB_START
+	.type FPC_LIB_START,@function
+FPC_LIB_START:
+	jmp	_startlib@PLT
+
+        .text
+	.globl _start
+	.type _start,@function
+_startlib:
+#       movq %rdx,%r9                 /* Address of the shared library termination
+#               	                 function.  */
+	pushq	 %rbx
+        movq     operatingsystem_parameter_argc@GOTPCREL(%rip),%rbx
+        movq     %rdi,(%rbx)
+        movq     operatingsystem_parameter_argv@GOTPCREL(%rip),%rbx
+	movq     %rsi,(%rbx)          /* argv starts just at the current stack top.  */
+        movq     operatingsystem_parameter_envp@GOTPCREL(%rip),%rbx
+        movq     %rdx,(%rbx)
+
+        movq    TC_SYSTEM_ISLIBRARY@GOTPCREL(%rip),%rbx
+        movb    $1,(%rbx)
+
+        /* Save initial stackpointer */
+        movq    __stkptr@GOTPCREL(%rip),%rbx
+        movq    %rsp,(%rbx)
+
+        call    PASCALMAIN@PLT
+	popq	%rbx
+	ret
+
+        .globl  _haltproc
+        .type   _haltproc,@function
+_haltproc:
+        movl    $231,%eax                 /* exit_group call */
+        movq    operatingsystem_result@GOTPCREL(%rip),%rbx
+        movzwl  (%rbx),%edi
+        syscall
+        jmp     _haltproc@PLT
+
+/* Define a symbol for the first piece of initialized data.  */
+	.data
+	.globl __data_start
+__data_start:
+	.long 0
+	.weak data_start
+        data_start = __data_start
+
+.bss
+        .comm __stkptr,8
+
+        .comm operatingsystem_parameter_envp,8
+        .comm operatingsystem_parameter_argc,8
+        .comm operatingsystem_parameter_argv,8
+
+
+/* We need this stuff to make gdb behave itself, otherwise
+   gdb will chokes with SIGILL when trying to debug apps.
+
+Makes ld choke:
+        .section ".note.ABI-tag", "a"
+        .align 4
+        .long 1f - 0f
+        .long 3f - 2f
+        .long  1
+0:      .asciz "GNU"
+1:      .align 4
+2:      .long 0
+        .long 2,4,0
+3:      .align 4
+*/
+	.section	.note.GNU-stack,"",@progbits

文件差异内容过多而无法显示
+ 0 - 0
rtl/nds/cprt09.as


+ 237 - 237
rtl/nds/prt09.as

@@ -1,237 +1,237 @@
-@---------------------------------------------------------------------------------
-	.section ".init"
-	.global _start
-@---------------------------------------------------------------------------------
-	.align	4
-	.arm
-@---------------------------------------------------------------------------------
-_start:
-@---------------------------------------------------------------------------------
-	mov	r0, #0x04000000			@ IME = 0;
-	str	r0, [r0, #0x208]
-	
-@---------------------------------------------------------------------------------
-@ turn the power on for M3
-@---------------------------------------------------------------------------------
-	ldr     r1, =0x8203
-	add	r0,r0,#0x304
-	strh    r1, [r0]
-
-	ldr	r1, =0x00002078			@ disable TCM and protection unit
-	mcr	p15, 0, r1, c1, c0
-
-@---------------------------------------------------------------------------------
-@ Protection Unit Setup added by Sasq
-@---------------------------------------------------------------------------------
-	@ Disable cache
-	mov	r0, #0
-	mcr	p15, 0, r0, c7, c5, 0		@ Instruction cache
-	mcr	p15, 0, r0, c7, c6, 0		@ Data cache
-
-	@ Wait for write buffer to empty 
-	mcr	p15, 0, r0, c7, c10, 4
-
-	ldr	r0, =__dtcm_start
-	orr	r0,r0,#0x0a
-	mcr	p15, 0, r0, c9, c1,0		@ DTCM base = __dtcm_start, size = 16 KB
-
-	mov r0,#0x20
-	mcr	p15, 0, r0, c9, c1,1		@ ITCM base = 0 , size = 32 MB
-
-@---------------------------------------------------------------------------------
-@ Setup memory regions similar to Release Version
-@---------------------------------------------------------------------------------
-
-	@-------------------------------------------------------------------------
-	@ Region 0 - IO registers
-	@-------------------------------------------------------------------------
-	ldr	r0,=( (0b11001 << 1) | 0x04000000 | 1)	
-	mcr	p15, 0, r0, c6, c0, 0
-
-	@-------------------------------------------------------------------------
-	@ Region 1 - Main Memory
-	@-------------------------------------------------------------------------
-	ldr	r0,=( (0b10101 << 1) | 0x02000000 | 1)	
-	mcr	p15, 0, r0, c6, c1, 0
-
-	@-------------------------------------------------------------------------
-	@ Region 2 - iwram
-	@-------------------------------------------------------------------------
-	ldr	r0,=( (0b01110 << 1) | 0x037F8000 | 1)	
-	mcr	p15, 0, r0, c6, c2, 0
-
-	@-------------------------------------------------------------------------
-	@ Region 3 - DS Accessory (GBA Cart)
-	@-------------------------------------------------------------------------
-	ldr	r0,=( (0b11010 << 1) | 0x08000000 | 1)	
-	mcr	p15, 0, r0, c6, c3, 0
-
-	@-------------------------------------------------------------------------
-	@ Region 4 - DTCM
-	@-------------------------------------------------------------------------
-	ldr	r0,=__dtcm_start
-	orr	r0,r0,#((0b01101 << 1) | 1)
-	mcr	p15, 0, r0, c6, c4, 0
-
-	@-------------------------------------------------------------------------
-	@ Region 5 - ITCM
-	@-------------------------------------------------------------------------
-	ldr	r0,=__itcm_start
-	orr	r0,r0,#((0b01110 << 1) | 1)
-	mcr	p15, 0, r0, c6, c5, 0
-
-	@-------------------------------------------------------------------------
-	@ Region 6 - System ROM
-	@-------------------------------------------------------------------------
-	ldr	r0,=( (0b01110 << 1) | 0xFFFF0000 | 1)	
-	mcr	p15, 0, r0, c6, c6, 0
-
-	@-------------------------------------------------------------------------
-	@ Region 7 - non cacheable main ram
-	@-------------------------------------------------------------------------
-	ldr	r0,=( (0b10101 << 1)  | 0x02400000 | 1)	
-	mcr	p15, 0, r0, c6, c7, 0
-
-	@-------------------------------------------------------------------------
-	@ Write buffer enable
-	@-------------------------------------------------------------------------
-	ldr	r0,=0b00000110
-	mcr	p15, 0, r0, c3, c0, 0
-
-	@-------------------------------------------------------------------------
-	@ DCache & ICache enable
-	@-------------------------------------------------------------------------
-	ldr	r0,=0b01000110
-	ldr	r0,=0x42
-	mcr	p15, 0, r0, c2, c0, 0
-	mcr	p15, 0, r0, c2, c0, 1
-
-	@-------------------------------------------------------------------------
-	@ IAccess
-	@-------------------------------------------------------------------------
-	ldr	r0,=0x36636333
-	mcr	p15, 0, r0, c5, c0, 3
-
-	@-------------------------------------------------------------------------
-	@ DAccess
-	@-------------------------------------------------------------------------
-	ldr	r0,=0x36333333
-	mcr     p15, 0, r0, c5, c0, 2
-
-	@-------------------------------------------------------------------------
-	@ Enable ICache, DCache, ITCM & DTCM
-	@-------------------------------------------------------------------------
-	mrc	p15, 0, r0, c1, c0, 0
-	ldr	r1,= (1<<18) | (1<<16) | (1<<12) | (1<<2) | (1<<0)
-	orr	r0,r0,r1
-	mcr	p15, 0, r0, c1, c0, 0
-
-	mov	r0, #0x12		@ Switch to IRQ Mode
-	msr	cpsr, r0
-	ldr	sp, =__sp_irq		@ Set IRQ stack
-
-	mov	r0, #0x13		@ Switch to SVC Mode
-	msr	cpsr, r0
-	ldr	sp, =__sp_svc		@ Set SVC stack
-
-	mov	r0, #0x1F		@ Switch to System Mode
-	msr	cpsr, r0
-	ldr	sp, =__sp_usr		@ Set user stack
-
-	ldr	r1, =__itcm_lma		@ Copy instruction tightly coupled memory (itcm section) from LMA to VMA (ROM to RAM)
-	ldr	r2, =__itcm_start
-	ldr	r4, =__itcm_end
-	bl	CopyMemCheck
-
-	ldr	r1, =__dtcm_lma		@ Copy data tightly coupled memory (dtcm section) from LMA to VMA (ROM to RAM)
-	ldr	r2, =__dtcm_start
-	ldr	r4, =__dtcm_end
-	bl	CopyMemCheck
-
-	ldr	r0, =__bss_start	@ Clear BSS section
-	ldr	r1, =__bss_end
-	sub	r1, r1, r0
-	bl	ClearMem
-
-	ldr	r0, =__sbss_start	@ Clear SBSS section 
-	ldr	r1, =__sbss_end
-	sub	r1, r1, r0
-	bl	ClearMem
-
-	ldr	r1, =fake_heap_end	@ set heap end
-	ldr	r0, =__eheap_end
-	str	r0, [r1]
-
-
-
-
-	mov	r0, #0			@ int argc
-	mov	r1, #0			@ char *argv[]
-	ldr	r3, =main
-  bx	r3
-  nop
-
-	@ If the user ever returns, go to an infinte loop
-	ldr	r0, =ILoop
-	ldr	r0, [r0]
-	ldr	r1, =0x027FFE78
-	str	r0, [r1]
-	bx	r1
-ILoop:
-	b	ILoop
-
-
-@---------------------------------------------------------------------------------
-@---------------------------------------------------------------------------------
-@ Clear memory to 0x00 if length != 0
-@  r0 = Start Address
-@  r1 = Length
-@---------------------------------------------------------------------------------
-ClearMem:
-@---------------------------------------------------------------------------------
-	mov	r2, #3			@ Round down to nearest word boundary
-	add	r1, r1, r2		@ Shouldn't be needed
-	bics	r1, r1, r2		@ Clear 2 LSB (and set Z)
-	bxeq	lr			@ Quit if copy size is 0
-
-	mov	r2, #0
-ClrLoop:
-	stmia	r0!, {r2}
-	subs	r1, r1, #4
-	bne	ClrLoop
-
-	bx	lr
-
-@---------------------------------------------------------------------------------
-@ Copy memory if length	!= 0
-@  r1 = Source Address
-@  r2 = Dest Address
-@  r4 = Dest Address + Length
-@---------------------------------------------------------------------------------
-CopyMemCheck:
-@---------------------------------------------------------------------------------
-	sub	r3, r4, r2		@ Is there any data to copy?
-@---------------------------------------------------------------------------------
-@ Copy memory
-@  r1 = Source Address
-@  r2 = Dest Address
-@  r3 = Length
-@---------------------------------------------------------------------------------
-CopyMem:
-@---------------------------------------------------------------------------------
-	mov	r0, #3			@ These commands are used in cases where
-	add	r3, r3, r0		@ the length is not a multiple of 4,
-	bics	r3, r3, r0		@ even though it should be.
-	bxeq	lr			@ Length is zero, so exit
-CIDLoop:
-	ldmia	r1!, {r0}
-	stmia	r2!, {r0}
-	subs	r3, r3, #4
-	bne	CIDLoop
-
-	bx	lr
-@---------------------------------------------------------------------------------
-	.align
-	.pool
-	.end
-@---------------------------------------------------------------------------------
+@---------------------------------------------------------------------------------
+	.section ".init"
+	.global _start
+@---------------------------------------------------------------------------------
+	.align	4
+	.arm
+@---------------------------------------------------------------------------------
+_start:
+@---------------------------------------------------------------------------------
+	mov	r0, #0x04000000			@ IME = 0;
+	str	r0, [r0, #0x208]
+	
+@---------------------------------------------------------------------------------
+@ turn the power on for M3
+@---------------------------------------------------------------------------------
+	ldr     r1, =0x8203
+	add	r0,r0,#0x304
+	strh    r1, [r0]
+
+	ldr	r1, =0x00002078			@ disable TCM and protection unit
+	mcr	p15, 0, r1, c1, c0
+
+@---------------------------------------------------------------------------------
+@ Protection Unit Setup added by Sasq
+@---------------------------------------------------------------------------------
+	@ Disable cache
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c5, 0		@ Instruction cache
+	mcr	p15, 0, r0, c7, c6, 0		@ Data cache
+
+	@ Wait for write buffer to empty 
+	mcr	p15, 0, r0, c7, c10, 4
+
+	ldr	r0, =__dtcm_start
+	orr	r0,r0,#0x0a
+	mcr	p15, 0, r0, c9, c1,0		@ DTCM base = __dtcm_start, size = 16 KB
+
+	mov r0,#0x20
+	mcr	p15, 0, r0, c9, c1,1		@ ITCM base = 0 , size = 32 MB
+
+@---------------------------------------------------------------------------------
+@ Setup memory regions similar to Release Version
+@---------------------------------------------------------------------------------
+
+	@-------------------------------------------------------------------------
+	@ Region 0 - IO registers
+	@-------------------------------------------------------------------------
+	ldr	r0,=( (0b11001 << 1) | 0x04000000 | 1)	
+	mcr	p15, 0, r0, c6, c0, 0
+
+	@-------------------------------------------------------------------------
+	@ Region 1 - Main Memory
+	@-------------------------------------------------------------------------
+	ldr	r0,=( (0b10101 << 1) | 0x02000000 | 1)	
+	mcr	p15, 0, r0, c6, c1, 0
+
+	@-------------------------------------------------------------------------
+	@ Region 2 - iwram
+	@-------------------------------------------------------------------------
+	ldr	r0,=( (0b01110 << 1) | 0x037F8000 | 1)	
+	mcr	p15, 0, r0, c6, c2, 0
+
+	@-------------------------------------------------------------------------
+	@ Region 3 - DS Accessory (GBA Cart)
+	@-------------------------------------------------------------------------
+	ldr	r0,=( (0b11010 << 1) | 0x08000000 | 1)	
+	mcr	p15, 0, r0, c6, c3, 0
+
+	@-------------------------------------------------------------------------
+	@ Region 4 - DTCM
+	@-------------------------------------------------------------------------
+	ldr	r0,=__dtcm_start
+	orr	r0,r0,#((0b01101 << 1) | 1)
+	mcr	p15, 0, r0, c6, c4, 0
+
+	@-------------------------------------------------------------------------
+	@ Region 5 - ITCM
+	@-------------------------------------------------------------------------
+	ldr	r0,=__itcm_start
+	orr	r0,r0,#((0b01110 << 1) | 1)
+	mcr	p15, 0, r0, c6, c5, 0
+
+	@-------------------------------------------------------------------------
+	@ Region 6 - System ROM
+	@-------------------------------------------------------------------------
+	ldr	r0,=( (0b01110 << 1) | 0xFFFF0000 | 1)	
+	mcr	p15, 0, r0, c6, c6, 0
+
+	@-------------------------------------------------------------------------
+	@ Region 7 - non cacheable main ram
+	@-------------------------------------------------------------------------
+	ldr	r0,=( (0b10101 << 1)  | 0x02400000 | 1)	
+	mcr	p15, 0, r0, c6, c7, 0
+
+	@-------------------------------------------------------------------------
+	@ Write buffer enable
+	@-------------------------------------------------------------------------
+	ldr	r0,=0b00000110
+	mcr	p15, 0, r0, c3, c0, 0
+
+	@-------------------------------------------------------------------------
+	@ DCache & ICache enable
+	@-------------------------------------------------------------------------
+	ldr	r0,=0b01000110
+	ldr	r0,=0x42
+	mcr	p15, 0, r0, c2, c0, 0
+	mcr	p15, 0, r0, c2, c0, 1
+
+	@-------------------------------------------------------------------------
+	@ IAccess
+	@-------------------------------------------------------------------------
+	ldr	r0,=0x36636333
+	mcr	p15, 0, r0, c5, c0, 3
+
+	@-------------------------------------------------------------------------
+	@ DAccess
+	@-------------------------------------------------------------------------
+	ldr	r0,=0x36333333
+	mcr     p15, 0, r0, c5, c0, 2
+
+	@-------------------------------------------------------------------------
+	@ Enable ICache, DCache, ITCM & DTCM
+	@-------------------------------------------------------------------------
+	mrc	p15, 0, r0, c1, c0, 0
+	ldr	r1,= (1<<18) | (1<<16) | (1<<12) | (1<<2) | (1<<0)
+	orr	r0,r0,r1
+	mcr	p15, 0, r0, c1, c0, 0
+
+	mov	r0, #0x12		@ Switch to IRQ Mode
+	msr	cpsr, r0
+	ldr	sp, =__sp_irq		@ Set IRQ stack
+
+	mov	r0, #0x13		@ Switch to SVC Mode
+	msr	cpsr, r0
+	ldr	sp, =__sp_svc		@ Set SVC stack
+
+	mov	r0, #0x1F		@ Switch to System Mode
+	msr	cpsr, r0
+	ldr	sp, =__sp_usr		@ Set user stack
+
+	ldr	r1, =__itcm_lma		@ Copy instruction tightly coupled memory (itcm section) from LMA to VMA (ROM to RAM)
+	ldr	r2, =__itcm_start
+	ldr	r4, =__itcm_end
+	bl	CopyMemCheck
+
+	ldr	r1, =__dtcm_lma		@ Copy data tightly coupled memory (dtcm section) from LMA to VMA (ROM to RAM)
+	ldr	r2, =__dtcm_start
+	ldr	r4, =__dtcm_end
+	bl	CopyMemCheck
+
+	ldr	r0, =__bss_start	@ Clear BSS section
+	ldr	r1, =__bss_end
+	sub	r1, r1, r0
+	bl	ClearMem
+
+	ldr	r0, =__sbss_start	@ Clear SBSS section 
+	ldr	r1, =__sbss_end
+	sub	r1, r1, r0
+	bl	ClearMem
+
+	ldr	r1, =fake_heap_end	@ set heap end
+	ldr	r0, =__eheap_end
+	str	r0, [r1]
+
+
+
+
+	mov	r0, #0			@ int argc
+	mov	r1, #0			@ char *argv[]
+	ldr	r3, =main
+  bx	r3
+  nop
+
+	@ If the user ever returns, go to an infinte loop
+	ldr	r0, =ILoop
+	ldr	r0, [r0]
+	ldr	r1, =0x027FFE78
+	str	r0, [r1]
+	bx	r1
+ILoop:
+	b	ILoop
+
+
+@---------------------------------------------------------------------------------
+@---------------------------------------------------------------------------------
+@ Clear memory to 0x00 if length != 0
+@  r0 = Start Address
+@  r1 = Length
+@---------------------------------------------------------------------------------
+ClearMem:
+@---------------------------------------------------------------------------------
+	mov	r2, #3			@ Round down to nearest word boundary
+	add	r1, r1, r2		@ Shouldn't be needed
+	bics	r1, r1, r2		@ Clear 2 LSB (and set Z)
+	bxeq	lr			@ Quit if copy size is 0
+
+	mov	r2, #0
+ClrLoop:
+	stmia	r0!, {r2}
+	subs	r1, r1, #4
+	bne	ClrLoop
+
+	bx	lr
+
+@---------------------------------------------------------------------------------
+@ Copy memory if length	!= 0
+@  r1 = Source Address
+@  r2 = Dest Address
+@  r4 = Dest Address + Length
+@---------------------------------------------------------------------------------
+CopyMemCheck:
+@---------------------------------------------------------------------------------
+	sub	r3, r4, r2		@ Is there any data to copy?
+@---------------------------------------------------------------------------------
+@ Copy memory
+@  r1 = Source Address
+@  r2 = Dest Address
+@  r3 = Length
+@---------------------------------------------------------------------------------
+CopyMem:
+@---------------------------------------------------------------------------------
+	mov	r0, #3			@ These commands are used in cases where
+	add	r3, r3, r0		@ the length is not a multiple of 4,
+	bics	r3, r3, r0		@ even though it should be.
+	bxeq	lr			@ Length is zero, so exit
+CIDLoop:
+	ldmia	r1!, {r0}
+	stmia	r2!, {r0}
+	subs	r3, r3, #4
+	bne	CIDLoop
+
+	bx	lr
+@---------------------------------------------------------------------------------
+	.align
+	.pool
+	.end
+@---------------------------------------------------------------------------------

+ 163 - 163
rtl/netbsd/i386/prt0.as

@@ -1,163 +1,163 @@
-#
-#   $Id: prt0.as,v 1.2 2004/01/04 01:13:23 marco Exp $
-#   This file is part of the Free Pascal run time library.
-#   Copyright (c) 1999-2000 by Marco van de Voort, Michael Van Canneyt
-#                                                  and Peter Vreman
-#   members of the Free Pascal development team.
-#
-#   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.
-#
-#**********************************************************************}
-#
-# NetBSD standard (static) ELF/i386 startup code for Free Pascal
-#
-
-http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/csu/i386/crt0.c?rev=1.33&content-type=text/x-cvsweb-markup
-
-	.file	"prt0.s"
-	.version	"01.01"
-gcc2_compiled.:
-.globl __progname
-
-.section	.rodata
-.LC0:
-	.ascii "\0"
-.data
-	.align 4
-	.type	 __progname,@object
-	.size	 __progname,4
-__progname:
-	.long .LC0
-.globl __ps_strings
-	.align 4
-	.type	 __ps_strings,@object
-	.size	 __ps_strings,4
-__ps_strings:
-	.long 0
-	.align 4
-___fpucw:
-        .long   0x1332
-
-        .globl  ___fpc_brk_addr         /* heap management */
-        .type   ___fpc_brk_addr,@object
-        .size   ___fpc_brk_addr,4
-___fpc_brk_addr:
-        .long   0
-
-#APP
-	
-	.text
-	.align	4
-	.globl	__start
-	.globl	_start
-_start:
-__start:
-	pushl	%ebx			# ps_strings
-	pushl	%ecx			# obj
-	pushl	%edx			# cleanup
-	movl	12(%esp),%eax
-	leal	20(%esp,%eax,4),%ecx
-	leal	16(%esp),%edx
-	pushl	%ecx
-	pushl	%edx
-	pushl	%eax
-	call	___start
-
-#NO_APP
-.text
-	.align 4
-.globl ___start
-	.type	 ___start,@function
-___start:
-	pushl %ebp
-	movl %esp,%ebp
-	movl 16(%ebp),%eax
-	movl %eax,environ
-	movl %eax,U_SYSTEM_ENVP
-	movl 8(%ebp),%eax
-	movl %eax,U_SYSTEM_ARGC
-	movl 12(%ebp),%eax
-	movl %eax,U_SYSTEM_ARGV
-	movl (%eax),%edx
-	movl %edx,__progname
-	testl %edx,%edx
-	je .L2
-	pushl $47
-	movl __progname,%eax
-	pushl %eax
-	call _strrchr
-	addl $8,%esp
-	movl %eax,%eax
-	movl %eax,__progname
-	cmpl $0,__progname
-	jne .L3
-	movl 12(%ebp),%eax
-	movl (%eax),%edx
-	movl %edx,__progname
-	jmp .L2
-	.align 4
-.L3:
-	incl __progname
-.L4:
-.L2:
-	cmpl $0,28(%ebp)
-	je .L5
-	movl 28(%ebp),%eax
-	movl %eax,__ps_strings
-.L5:
-#	pushl $_fini
-#	call atexit
-#	addl $4,%esp
-#	call _init
-# copied from linux
-
-        finit                           /* initialize fpu */
-        fwait
-        fldcw   ___fpucw
-
-        xorl    %ebp,%ebp
-
-	call _main
-	pushl %eax
-	jmp  _haltproc
-
-.p2align 2,0x90
-.globl _haltproc
-.type _haltproc,@function
-
-_haltproc:
-           mov $1,%eax
-           movzwl U_SYSTEM_EXITCODE,%ebx
-           pushl %ebx
-           call _actualsyscall
-           addl  $4,%esp
-           jmp   _haltproc
-
-_actualsyscall:
-         int $0x80
-         jb .LErrorcode
-         xor %ebx,%ebx
-         ret
-.LErrorcode:
-         mov %eax,%ebx
-         mov $-1,%eax
-         ret
-        .p2align 2,0x90
-
-# This section is needed for NetBSD to recognize a NetBSD binary as such.
-# otherwise it will be startup in Linux emulation mode.
-
-.section ".note.netbsd.ident","a"
-.p2align 2
-
-.long 7
-.long 4
-# ELF NOTE TYPE NETBSD TAG
-.long 1
-.ascii "NetBSD\0\0"
-.long 199905
+#
+#   $Id: prt0.as,v 1.2 2004/01/04 01:13:23 marco Exp $
+#   This file is part of the Free Pascal run time library.
+#   Copyright (c) 1999-2000 by Marco van de Voort, Michael Van Canneyt
+#                                                  and Peter Vreman
+#   members of the Free Pascal development team.
+#
+#   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.
+#
+#**********************************************************************}
+#
+# NetBSD standard (static) ELF/i386 startup code for Free Pascal
+#
+
+http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/csu/i386/crt0.c?rev=1.33&content-type=text/x-cvsweb-markup
+
+	.file	"prt0.s"
+	.version	"01.01"
+gcc2_compiled.:
+.globl __progname
+
+.section	.rodata
+.LC0:
+	.ascii "\0"
+.data
+	.align 4
+	.type	 __progname,@object
+	.size	 __progname,4
+__progname:
+	.long .LC0
+.globl __ps_strings
+	.align 4
+	.type	 __ps_strings,@object
+	.size	 __ps_strings,4
+__ps_strings:
+	.long 0
+	.align 4
+___fpucw:
+        .long   0x1332
+
+        .globl  ___fpc_brk_addr         /* heap management */
+        .type   ___fpc_brk_addr,@object
+        .size   ___fpc_brk_addr,4
+___fpc_brk_addr:
+        .long   0
+
+#APP
+	
+	.text
+	.align	4
+	.globl	__start
+	.globl	_start
+_start:
+__start:
+	pushl	%ebx			# ps_strings
+	pushl	%ecx			# obj
+	pushl	%edx			# cleanup
+	movl	12(%esp),%eax
+	leal	20(%esp,%eax,4),%ecx
+	leal	16(%esp),%edx
+	pushl	%ecx
+	pushl	%edx
+	pushl	%eax
+	call	___start
+
+#NO_APP
+.text
+	.align 4
+.globl ___start
+	.type	 ___start,@function
+___start:
+	pushl %ebp
+	movl %esp,%ebp
+	movl 16(%ebp),%eax
+	movl %eax,environ
+	movl %eax,U_SYSTEM_ENVP
+	movl 8(%ebp),%eax
+	movl %eax,U_SYSTEM_ARGC
+	movl 12(%ebp),%eax
+	movl %eax,U_SYSTEM_ARGV
+	movl (%eax),%edx
+	movl %edx,__progname
+	testl %edx,%edx
+	je .L2
+	pushl $47
+	movl __progname,%eax
+	pushl %eax
+	call _strrchr
+	addl $8,%esp
+	movl %eax,%eax
+	movl %eax,__progname
+	cmpl $0,__progname
+	jne .L3
+	movl 12(%ebp),%eax
+	movl (%eax),%edx
+	movl %edx,__progname
+	jmp .L2
+	.align 4
+.L3:
+	incl __progname
+.L4:
+.L2:
+	cmpl $0,28(%ebp)
+	je .L5
+	movl 28(%ebp),%eax
+	movl %eax,__ps_strings
+.L5:
+#	pushl $_fini
+#	call atexit
+#	addl $4,%esp
+#	call _init
+# copied from linux
+
+        finit                           /* initialize fpu */
+        fwait
+        fldcw   ___fpucw
+
+        xorl    %ebp,%ebp
+
+	call _main
+	pushl %eax
+	jmp  _haltproc
+
+.p2align 2,0x90
+.globl _haltproc
+.type _haltproc,@function
+
+_haltproc:
+           mov $1,%eax
+           movzwl U_SYSTEM_EXITCODE,%ebx
+           pushl %ebx
+           call _actualsyscall
+           addl  $4,%esp
+           jmp   _haltproc
+
+_actualsyscall:
+         int $0x80
+         jb .LErrorcode
+         xor %ebx,%ebx
+         ret
+.LErrorcode:
+         mov %eax,%ebx
+         mov $-1,%eax
+         ret
+        .p2align 2,0x90
+
+# This section is needed for NetBSD to recognize a NetBSD binary as such.
+# otherwise it will be startup in Linux emulation mode.
+
+.section ".note.netbsd.ident","a"
+.p2align 2
+
+.long 7
+.long 4
+# ELF NOTE TYPE NETBSD TAG
+.long 1
+.ascii "NetBSD\0\0"
+.long 199905

+ 76 - 76
rtl/win32/wdllprt0.as

@@ -1,76 +1,76 @@
-// DLL Startup code for WIN32 port of Free Pascal
-// Written by P.Ozerski 16.10.1998
-     .text
-     .globl _mainCRTStartup
-_mainCRTStartup:
-     movb $1,U_SYSTEM_ISCONSOLE
-     jmp .LDLL_Entry
-     .globl _WinMainCRTStartup
-_WinMainCRTStartup:
-     movb $0,U_SYSTEM_ISCONSOLE
-.LDLL_Entry:
-     pushl    %ebp
-     movl     %esp,%ebp
-     pushl    %ebx
-     pushl    %esi
-     pushl    %edi
-     movl     8(%ebp),%edi
-     movl     %edi,SysInstance
-     movl     12(%ebp),%edi
-     movl     %edi,U_SYSTEM_DLLREASON
-     movl     16(%ebp),%edi
-     movl     %edi,U_SYSTEM_DLLPARAM
-     movl     %esp,__stkptr
-     call     _FPC_DLL_Entry
-     popl     %edi
-     popl     %esi
-     popl     %ebx
-     popl     %ebp
-     ret      $12
-
-     .globl asm_exit
-asm_exit:
-    pushl  %eax
-	call   exitprocess
-
-.text
-.globl	exitprocess
-exitprocess:
-	jmp	*.L10
-	.balign 4,144
-
-.text
-	.balign 4,144
-
-.section .idata$2
-	.rva	.L7
-	.long	0,0
-	.rva	.L6
-	.rva	.L8
-
-.section .idata$4
-.L7:
-	.rva	.L9
-	.long	0
-
-.section .idata$5
-.L8:
-
-
-.section .idata$5
-.L10:
-	.rva	.L9
-	.long	0
-
-.section .idata$6
-.L9:
-	.short	0
-	.ascii	"ExitProcess\000"
-	.balign 2,0
-
-.section .idata$7
-.L6:
-	.ascii	"kernel32.dll\000"
-
-.bss
-    .comm   __stkptr,4
+// DLL Startup code for WIN32 port of Free Pascal
+// Written by P.Ozerski 16.10.1998
+     .text
+     .globl _mainCRTStartup
+_mainCRTStartup:
+     movb $1,U_SYSTEM_ISCONSOLE
+     jmp .LDLL_Entry
+     .globl _WinMainCRTStartup
+_WinMainCRTStartup:
+     movb $0,U_SYSTEM_ISCONSOLE
+.LDLL_Entry:
+     pushl    %ebp
+     movl     %esp,%ebp
+     pushl    %ebx
+     pushl    %esi
+     pushl    %edi
+     movl     8(%ebp),%edi
+     movl     %edi,SysInstance
+     movl     12(%ebp),%edi
+     movl     %edi,U_SYSTEM_DLLREASON
+     movl     16(%ebp),%edi
+     movl     %edi,U_SYSTEM_DLLPARAM
+     movl     %esp,__stkptr
+     call     _FPC_DLL_Entry
+     popl     %edi
+     popl     %esi
+     popl     %ebx
+     popl     %ebp
+     ret      $12
+
+     .globl asm_exit
+asm_exit:
+    pushl  %eax
+	call   exitprocess
+
+.text
+.globl	exitprocess
+exitprocess:
+	jmp	*.L10
+	.balign 4,144
+
+.text
+	.balign 4,144
+
+.section .idata$2
+	.rva	.L7
+	.long	0,0
+	.rva	.L6
+	.rva	.L8
+
+.section .idata$4
+.L7:
+	.rva	.L9
+	.long	0
+
+.section .idata$5
+.L8:
+
+
+.section .idata$5
+.L10:
+	.rva	.L9
+	.long	0
+
+.section .idata$6
+.L9:
+	.short	0
+	.ascii	"ExitProcess\000"
+	.balign 2,0
+
+.section .idata$7
+.L6:
+	.ascii	"kernel32.dll\000"
+
+.bss
+    .comm   __stkptr,4

部分文件因为文件数量过多而无法显示