summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaroly <karoly@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-04-28 23:13:29 +0000
committerkaroly <karoly@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-04-28 23:13:29 +0000
commitd667e37e132236c27ba3b4f966d2f21fc1d250e8 (patch)
tree937170732fdc70692a220bcd182fc1fae39bb02b
parentba6f7301e53a30cd892a7d723d1b762c3ab2d035 (diff)
downloadfpc-d667e37e132236c27ba3b4f966d2f21fc1d250e8.tar.gz
zxspectrum: pascal startup code. this allows the RTL to be built with any assembler
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@45165 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--rtl/zxspectrum/Makefile200
-rw-r--r--rtl/zxspectrum/Makefile.fpc9
-rw-r--r--rtl/zxspectrum/si_prc.pp37
3 files changed, 144 insertions, 102 deletions
diff --git a/rtl/zxspectrum/Makefile b/rtl/zxspectrum/Makefile
index f79940ee48..d401015b79 100644
--- a/rtl/zxspectrum/Makefile
+++ b/rtl/zxspectrum/Makefile
@@ -365,301 +365,301 @@ ifdef NO_EXCEPTIONS_IN_SYSTEM
override FPCOPT+=-dNO_EXCEPTIONS_IN_SYSTEM
endif
ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-haiku)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-solaris)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-darwin)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-embedded)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-symbian)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-nativent)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-iphonesim)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-android)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-aros)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),m68k-macos)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),m68k-embedded)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),powerpc-amiga)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),powerpc-embedded)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),powerpc-wii)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),powerpc-aix)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),sparc-embedded)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),x86_64-haiku)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),x86_64-netbsd)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),x86_64-solaris)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),x86_64-openbsd)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),x86_64-darwin)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),x86_64-embedded)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),x86_64-iphonesim)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),x86_64-android)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),x86_64-aros)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),x86_64-dragonfly)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),arm-netbsd)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),arm-palmos)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),arm-darwin)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),arm-gba)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),arm-nds)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),arm-embedded)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),arm-symbian)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),arm-android)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),arm-aros)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),arm-freertos)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),powerpc64-darwin)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),powerpc64-embedded)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),powerpc64-aix)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),avr-embedded)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),armeb-linux)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),armeb-embedded)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),mips-linux)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),mipsel-linux)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),mipsel-embedded)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),mipsel-android)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),jvm-java)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),jvm-android)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i8086-embedded)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i8086-msdos)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i8086-win16)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),aarch64-linux)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),aarch64-darwin)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),aarch64-win64)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),aarch64-android)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),wasm-wasm)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),sparc64-linux)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),riscv32-linux)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),riscv32-embedded)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),riscv64-linux)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),riscv64-embedded)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),xtensa-linux)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),xtensa-embedded)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),xtensa-freertos)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),z80-embedded)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),z80-zxspectrum)
-override TARGET_UNITS+=system
+override TARGET_UNITS+=system si_prc
endif
ifeq ($(FULL_TARGET),i386-linux)
override TARGET_LOADERS+=prt0
@@ -2845,3 +2845,5 @@ prt0$(OEXT) : prt0.asm
system$(PPUEXT) : system.pp $(SYSDEPS)
$(COMPILER) $(FPC_SYSTEM_OPT) -Us -Sg system.pp
$(EXECPPAS)
+si_prc$(PPUEXT) : system$(PPUEXT)
+ $(COMPILER) si_prc.pp
diff --git a/rtl/zxspectrum/Makefile.fpc b/rtl/zxspectrum/Makefile.fpc
index b0f615b339..f1fdabc1e3 100644
--- a/rtl/zxspectrum/Makefile.fpc
+++ b/rtl/zxspectrum/Makefile.fpc
@@ -5,7 +5,7 @@
main=rtl
[target]
loaders=prt0
-units=system
+units=system si_prc
[require]
nortl=y
@@ -54,11 +54,14 @@ SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)
#
prt0$(OEXT) : prt0.asm
- $(MAKE) $(COMPILER_UNITTARGETDIR)
+ $(MAKE) $(COMPILER_UNITTARGETDIR)
sdcc-sdasz80 -o $(UNITTARGETDIRPREFIX)prt0$(OEXT) prt0.asm
#
# System Units (System, Objpas, Strings)
#
system$(PPUEXT) : system.pp $(SYSDEPS)
$(COMPILER) $(FPC_SYSTEM_OPT) -Us -Sg system.pp
- $(EXECPPAS)
+ $(EXECPPAS)
+
+si_prc$(PPUEXT) : system$(PPUEXT)
+ $(COMPILER) si_prc.pp
diff --git a/rtl/zxspectrum/si_prc.pp b/rtl/zxspectrum/si_prc.pp
new file mode 100644
index 0000000000..3a49731809
--- /dev/null
+++ b/rtl/zxspectrum/si_prc.pp
@@ -0,0 +1,37 @@
+{
+ This file is part of the Free Pascal run time library.
+ Copyright (c) 2020 by Free Pascal development team
+
+ This file contains startup code for the ZX Spectrum
+
+ 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.
+
+ **********************************************************************}
+
+unit si_prc;
+
+interface
+
+implementation
+
+var
+ FPC_SAVE_IY: word; external name 'FPC_SAVE_IY';
+ fpc_stackarea_start: word; external name '__fpc_stackarea_start';
+ fpc_stackarea_end: word; external name '__fpc_stackarea_end';
+
+procedure PascalMain; external name 'PASCALMAIN';
+
+{ this *must* always remain the first procedure with code in this unit }
+procedure _start; assembler; nostackframe; public name '_start';
+asm
+ ld sp, fpc_stackarea_end
+ ld (FPC_SAVE_IY), iy
+ jp PASCALMAIN
+end;
+
+end.