From: cuz Date: Tue, 31 Oct 2000 18:08:25 +0000 (+0000) Subject: Moved the target configurations into separate files X-Git-Tag: V2.12.0~3110 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1226f095e120269d3c6e799acc7f8e2aad96f7d0;p=cc65 Moved the target configurations into separate files git-svn-id: svn://svn.cc65.org/cc65/trunk@416 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/ld65/.cvsignore b/src/ld65/.cvsignore index 93a652341..f0c6de94c 100644 --- a/src/ld65/.cvsignore +++ b/src/ld65/.cvsignore @@ -2,4 +2,12 @@ ld65 *.map *.s - +apple2.inc +atari.inc +c128.inc +c64.inc +cbm610.inc +geos.inc +none.inc +pet.inc +plus4.inc diff --git a/src/ld65/cfg/apple2.cfg b/src/ld65/cfg/apple2.cfg new file mode 100644 index 000000000..2f99839c7 --- /dev/null +++ b/src/ld65/cfg/apple2.cfg @@ -0,0 +1,11 @@ +MEMORY { + ZP: start = $00, size = $1A, type = rw; + RAM: start = $800, size = $8E00, file = %O; +} +SEGMENTS { + CODE: load = RAM, type = ro; + RODATA: load = RAM, type = ro; + DATA: load = RAM, type = rw; + BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp; +} diff --git a/src/ld65/cfg/atari.cfg b/src/ld65/cfg/atari.cfg new file mode 100644 index 000000000..bbe4a7d48 --- /dev/null +++ b/src/ld65/cfg/atari.cfg @@ -0,0 +1,14 @@ +MEMORY { + ZP: start = $82, size = $7E, type = rw; + HEADER: start = $0000, size = $6, file = %O; + RAM: start = $1F00, size = $9D1F, file = %O; # $9D1F: matches upper bound $BC1F +} +SEGMENTS { + EXEHDR: load = HEADER, type = wprot; + CODE: load = RAM, type = wprot, define = yes; + RODATA: load = RAM, type = wprot; + DATA: load = RAM, type = rw; + BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp; + AUTOSTRT: load = RAM, type = wprot; +} diff --git a/src/ld65/cfg/c128.cfg b/src/ld65/cfg/c128.cfg new file mode 100644 index 000000000..d64208a24 --- /dev/null +++ b/src/ld65/cfg/c128.cfg @@ -0,0 +1,11 @@ +MEMORY { + ZP: start = $02, size = $1A, type = rw; + RAM: start = $1bff, size = $a401, file = %O; +} +SEGMENTS { + CODE: load = RAM, type = wprot; + RODATA: load = RAM, type = wprot; + DATA: load = RAM, type = rw; + BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp; +} diff --git a/src/ld65/cfg/c64.cfg b/src/ld65/cfg/c64.cfg new file mode 100644 index 000000000..1a5afef6e --- /dev/null +++ b/src/ld65/cfg/c64.cfg @@ -0,0 +1,11 @@ +MEMORY { + ZP: start = $02, size = $1A, type = rw; + RAM: start = $7FF, size = $c801, file = %O; +} +SEGMENTS { + CODE: load = RAM, type = wprot; + RODATA: load = RAM, type = wprot; + DATA: load = RAM, type = rw; + BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp; +} diff --git a/src/ld65/cfg/cbm610.cfg b/src/ld65/cfg/cbm610.cfg new file mode 100644 index 000000000..c6ffb786f --- /dev/null +++ b/src/ld65/cfg/cbm610.cfg @@ -0,0 +1,11 @@ +MEMORY { + ZP: start = $02, size = $1A, type = rw; + RAM: start = $0001, size = $FFF0, file = %O; +} +SEGMENTS { + CODE: load = RAM, type = wprot; + RODATA: load = RAM, type = wprot; + DATA: load = RAM, type = rw; + BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp; +} diff --git a/src/ld65/cfg/cvt-cfg.pl b/src/ld65/cfg/cvt-cfg.pl new file mode 100755 index 000000000..c03dd4633 --- /dev/null +++ b/src/ld65/cfg/cvt-cfg.pl @@ -0,0 +1,67 @@ +#!/usr/bin/perl + +# Check number of params +die "Usage: cvt-cfg.pl input output varname\n" unless ($#ARGV == 2); + +# Get the parameters +$InputName = shift (@ARGV); +$OutputName = shift (@ARGV); +$VarName = shift (@ARGV); + +# Open both files +open (IN, "<$InputName") or die "Cannot open $InputName\n"; +open (OUT, ">$OutputName") or die "Cannot open $OutputName\n"; + +# Print the header to the output file +print OUT "static const char $VarName [] = \n"; + +# Read from input, print to output +while ($Line = ) { + + # Remove the newline + chomp $Line; + + # Separate an existing comment. No need to be overly clever, just ignore + # hash marks in strings. + if ($Line =~ /(.*?)(\s*)(\#\s*)(.*?)\s*$/) { + $Line = $1; + $CommentSpace = $2; + $Comment = $4; + } else { + $CommentSpace = ""; + $Comment = ""; + } + + # Remove leading and trailing spaces + $Line =~ s/^\s*|\s*$//g; + + # Replace control chars + $Line =~ s/\\/\\\\/g; + $Line =~ s/\"/\\\"/g; + $Line =~ s/\'/\\\'/g; + + # Print to output + print OUT "\"$Line\""; + + # Add a comment if we have one + if ($Comment ne "") { + print OUT "$CommentSpace/* $Comment */"; + } + + # Terminate the line + print OUT "\n"; +} + +# Terminate the variable declaration +print OUT ";\n"; + +# Close the files +close IN; +close OUT; + +# Done +exit 0; + + + + diff --git a/src/ld65/cfg/geos.cfg b/src/ld65/cfg/geos.cfg new file mode 100644 index 000000000..a6391ca71 --- /dev/null +++ b/src/ld65/cfg/geos.cfg @@ -0,0 +1,11 @@ +MEMORY { + HEADER: start = $204, size = 508, file = %O; + RAM: start = $400, size = $7C00, file = %O; +} +SEGMENTS { + HEADER: load = HEADER, type = ro; + CODE: load = RAM, type = ro; + RODATA: load = RAM, type = ro; + DATA: load = RAM, type = rw; + BSS: load = RAM, type = bss, define = yes; +} diff --git a/src/ld65/cfg/lunix.cfg b/src/ld65/cfg/lunix.cfg new file mode 100644 index 000000000..824638549 --- /dev/null +++ b/src/ld65/cfg/lunix.cfg @@ -0,0 +1,17 @@ +MEMORY { + COMBINED: start = $0000, size = $FFFF, file = %O; + ZEROPAGE: start = $0000, size = $0100, file = %O; +} +SEGMENTS { + CODE: load = COMBINED, type = wprot; + RODATA: load = COMBINED, type = wprot; + DATA: load = COMBINED, type = rw, define = yes; + BSS: load = COMBINED, type = bss, define = yes; + ZEROPAGE: load = ZEROPAGE, type = zp; +} +FILES { + %O: format = o65; +} +FORMATS { + o65: os = lunix, type = small, extsym = "LUNIXKERNAL", extsym = "LIB6502"; +} diff --git a/src/ld65/cfg/nes.cfg b/src/ld65/cfg/nes.cfg new file mode 100644 index 000000000..b0e903433 --- /dev/null +++ b/src/ld65/cfg/nes.cfg @@ -0,0 +1,11 @@ +MEMORY { + ZP: start = $02, size = $1A, type = rw; + RAM: start = $03FF, size = $7BFF, file = %O; +} +SEGMENTS { + CODE: load = RAM, type = wprot; + RODATA: load = RAM, type = wprot; + DATA: load = RAM, type = rw; + BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp; +} diff --git a/src/ld65/cfg/none.cfg b/src/ld65/cfg/none.cfg new file mode 100644 index 000000000..bb708dec0 --- /dev/null +++ b/src/ld65/cfg/none.cfg @@ -0,0 +1,9 @@ +MEMORY { + RAM: start = %S, size = $10000, file = %O; +} +SEGMENTS { + CODE: load = RAM, type = rw; + RODATA: load = RAM, type = rw; + DATA: load = RAM, type = rw; + BSS: load = RAM, type = bss, define = yes; +} diff --git a/src/ld65/cfg/osa65.cfg b/src/ld65/cfg/osa65.cfg new file mode 100644 index 000000000..750e580cf --- /dev/null +++ b/src/ld65/cfg/osa65.cfg @@ -0,0 +1,17 @@ +MEMORY { + COMBINED: start = $0000, size = $FFFF, file = %O; + ZEROPAGE: start = $0000, size = $0100, file = %O; +} +SEGMENTS { + CODE: load = COMBINED, type = wprot; + RODATA: load = COMBINED, type = wprot; + DATA: load = COMBINED, type = rw, define = yes; + BSS: load = COMBINED, type = bss, define = yes; + ZEROPAGE: load = ZEROPAGE, type = zp; +} +FILES { + %O: format = o65; +} +FORMATS { + o65: os = osa65, type = small, extsym = "OSA2KERNAL", extsym = "LIB6502"; +} diff --git a/src/ld65/cfg/pet.cfg b/src/ld65/cfg/pet.cfg new file mode 100644 index 000000000..6c6b6d798 --- /dev/null +++ b/src/ld65/cfg/pet.cfg @@ -0,0 +1,12 @@ +MEMORY { + ZP: start = $02, size = $1A, type = rw; + RAM: start = $03FF, size = $7BFF, file = %O; +} +SEGMENTS { + CODE: load = RAM, type = wprot; + RODATA: load = RAM, type = wprot; + DATA: load = RAM, type = rw; + BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp; +} + diff --git a/src/ld65/cfg/plus4.cfg b/src/ld65/cfg/plus4.cfg new file mode 100644 index 000000000..e0ef42a09 --- /dev/null +++ b/src/ld65/cfg/plus4.cfg @@ -0,0 +1,11 @@ +MEMORY { + ZP: start = $02, size = $1A, type = rw; + RAM: start = $0fff, size = $7001, file = %O; +} +SEGMENTS { + CODE: load = RAM, type = wprot; + RODATA: load = RAM, type = wprot; + DATA: load = RAM, type = rw; + BSS: load = RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp; +} diff --git a/src/ld65/make/gcc.mak b/src/ld65/make/gcc.mak index 9fb16a6b7..30a6be1a7 100644 --- a/src/ld65/make/gcc.mak +++ b/src/ld65/make/gcc.mak @@ -11,6 +11,12 @@ CFLAGS = -g -O2 -Wall -I$(COMMON) $(CDEFS) CC=gcc LDFLAGS= +# Perl script for config file conversion +CVT=cfg/cvt-cfg.pl + +# ----------------------------------------------------------------------------- +# List of all object files + OBJS = bin.o \ binfmt.o \ config.o \ @@ -29,7 +35,23 @@ OBJS = bin.o \ objfile.o \ scanner.o \ segments.o \ - tgtcfg.o + tgtcfg.o + +# ----------------------------------------------------------------------------- +# List of all config includes + +INCS = apple2.inc \ + atari.inc \ + c64.inc \ + c128.inc \ + cbm610.inc \ + geos.inc \ + none.inc \ + pet.inc \ + plus4.inc + +# ----------------------------------------------------------------------------- +# LIBS = $(COMMON)/common.a @@ -47,14 +69,14 @@ endif -ld65: $(OBJS) $(LIBS) +ld65: $(INCS) $(OBJS) $(LIBS) $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) clean: rm -f *~ core *.map -zap: clean - rm -f *.o $(EXECS) .depend +zap: clean + rm -f *.o $(INCS) $(EXECS) .depend # ------------------------------------------------------------------------------ @@ -63,6 +85,36 @@ zap: clean .PHONY: depend dep depend dep: $(OBJS:.o=.c) @echo "Creating dependency information" - $(CC) -I$(COMMON) -MM $^ > .depend + $(CC) -I$(COMMON) -MM -MG $^ > .depend + +# ----------------------------------------------------------------------------- +# Rules to make config includes + +apple2.inc: cfg/apple2.cfg + @$(CVT) $< $@ CfgApple2 + +atari.inc: cfg/atari.cfg + @$(CVT) $< $@ CfgAtari + +c64.inc: cfg/c64.cfg + @$(CVT) $< $@ CfgC64 + +c128.inc: cfg/c128.cfg + @$(CVT) $< $@ CfgC128 + +cbm610.inc: cfg/cbm610.cfg + @$(CVT) $< $@ CfgCBM610 + +geos.inc: cfg/geos.cfg + @$(CVT) $< $@ CfgGeos + +none.inc: cfg/none.cfg + @$(CVT) $< $@ CfgNone + +pet.inc: cfg/pet.cfg + @$(CVT) $< $@ CfgPET + +plus4.inc: cfg/plus4.cfg + @$(CVT) $< $@ CfgPlus4 diff --git a/src/ld65/tgtcfg.c b/src/ld65/tgtcfg.c index 839f5fc40..7844c4b24 100644 --- a/src/ld65/tgtcfg.c +++ b/src/ld65/tgtcfg.c @@ -43,180 +43,20 @@ /*****************************************************************************/ - -static const char CfgNone [] = - "MEMORY {" - "RAM: start = %S, size = $10000, file = %O;" - "}" - "SEGMENTS {" - "CODE: load = RAM, type = rw;" - "RODATA: load = RAM, type = rw;" - "DATA: load = RAM, type = rw;" - "BSS: load = RAM, type = bss, define = yes;" - "}"; - -static const char CfgAtari [] = - "MEMORY {" - "ZP: start = $82, size = $7E, type = rw;" - "HEADER: start = $0000, size = $6, file = %O;" - "RAM: start = $1F00, size = $9D1F, file = %O;" /* 9D1F: matches upper bound BC1F */ - "}" - "SEGMENTS {" - "EXEHDR: load = HEADER, type = wprot;" - "CODE: load = RAM, type = wprot, define = yes;" - "RODATA: load = RAM, type = wprot;" - "DATA: load = RAM, type = rw;" - "BSS: load = RAM, type = bss, define = yes;" - "ZEROPAGE: load = ZP, type = zp;" - "AUTOSTRT: load = RAM, type = wprot;" - "}"; - -static const char CfgC64 [] = - "MEMORY {" - "ZP: start = $02, size = $1A, type = rw;" - "RAM: start = $7FF, size = $c801, file = %O;" - "}" - "SEGMENTS {" - "CODE: load = RAM, type = wprot;" - "RODATA: load = RAM, type = wprot;" - "DATA: load = RAM, type = rw;" - "BSS: load = RAM, type = bss, define = yes;" - "ZEROPAGE: load = ZP, type = zp;" - "}"; - -static const char CfgC128 [] = - "MEMORY {" - "ZP: start = $02, size = $1A, type = rw;" - "RAM: start = $1bff, size = $a401, file = %O;" - "}" - "SEGMENTS {" - "CODE: load = RAM, type = wprot;" - "RODATA: load = RAM, type = wprot;" - "DATA: load = RAM, type = rw;" - "BSS: load = RAM, type = bss, define = yes;" - "ZEROPAGE: load = ZP, type = zp;" - "}"; - -static const char CfgAce [] = - ""; - -static const char CfgPlus4 [] = - "MEMORY {" - "ZP: start = $02, size = $1A, type = rw;" - "RAM: start = $0fff, size = $7001, file = %O;" - "}" - "SEGMENTS {" - "CODE: load = RAM, type = wprot;" - "RODATA: load = RAM, type = wprot;" - "DATA: load = RAM, type = rw;" - "BSS: load = RAM, type = bss, define = yes;" - "ZEROPAGE: load = ZP, type = zp;" - "}"; - -static const char CfgCBM610 [] = - "MEMORY {" - "ZP: start = $02, size = $1A, type = rw;" - "RAM: start = $0001, size = $FFF0, file = %O;" - "}" - "SEGMENTS {" - "CODE: load = RAM, type = wprot;" - "RODATA: load = RAM, type = wprot;" - "DATA: load = RAM, type = rw;" - "BSS: load = RAM, type = bss, define = yes;" - "ZEROPAGE: load = ZP, type = zp;" - "}"; - -static const char CfgPET [] = - "MEMORY {" - "ZP: start = $02, size = $1A, type = rw;" - "RAM: start = $03FF, size = $7BFF, file = %O;" - "}" - "SEGMENTS {" - "CODE: load = RAM, type = wprot;" - "RODATA: load = RAM, type = wprot;" - "DATA: load = RAM, type = rw;" - "BSS: load = RAM, type = bss, define = yes;" - "ZEROPAGE: load = ZP, type = zp;" - "}"; - -static const char CfgNES [] = - "MEMORY {" - "RAM: start = $0200, size = $0600, file = \"\";" - "ROM: start = $8000, size = $8000, file = %O;" - "}" - "SEGMENTS {" - "CODE: load = ROM, type = ro;" - "RODATA: load = ROM, type = ro;" - "DATA: load = ROM, run = RAM, type = rw, define = yes;" - "BSS: load = RAM, type = bss, define = yes;" - "VECTORS: load = ROM, type = ro, start = $FFFA;" - "}"; - -static const char CfgLunix [] = - "MEMORY {" - "COMBINED: start = $0000, size = $FFFF, file = %O;" - "ZEROPAGE: start = $0000, size = $0100, file = %O;" - "}" - "SEGMENTS {" - "CODE: load = COMBINED, type = wprot;" - "RODATA: load = COMBINED, type = wprot;" - "DATA: load = COMBINED, type = rw, define = yes;" - "BSS: load = COMBINED, type = bss, define = yes;" - "ZEROPAGE: load = ZEROPAGE, type = zp;" - "}" - "FILES {" - "%O: format = o65;" - "}" - "FORMATS {" - "o65: os = lunix, type = small," - "extsym = \"LUNIXKERNAL\", extsym = \"LIB6502\";" - "}"; - -static const char CfgOSA65 [] = - "MEMORY {" - "COMBINED: start = $0000, size = $FFFF, file = %O;" - "ZEROPAGE: start = $0000, size = $0100, file = %O;" - "}" - "SEGMENTS {" - "CODE: load = COMBINED, type = wprot;" - "RODATA: load = COMBINED, type = wprot;" - "DATA: load = COMBINED, type = rw, define = yes;" - "BSS: load = COMBINED, type = bss, define = yes;" - "ZEROPAGE: load = ZEROPAGE, type = zp;" - "}" - "FILES {" - "%O: format = o65;" - "}" - "FORMATS {" - "o65: os = osa65, type = small," - "extsym = \"OSA2KERNAL\", extsym = \"LIB6502\";" - "}"; - -static const char CfgApple2 [] = - "MEMORY {" - "ZP: start = $00, size = $1A, type = rw;" - "RAM: start = $800, size = $8E00, file = %O;" - "}" - "SEGMENTS { " - "CODE: load = RAM, type = ro;" - "RODATA: load = RAM, type = ro;" - "DATA: load = RAM, type = rw;" - "BSS: load = RAM, type = bss, define = yes;" - "ZEROPAGE: load = ZP, type = zp;" - "}"; - -static const char CfgGeos [] = - "MEMORY {" - "HEADER: start = $204, size = 508, file = %O;" - "RAM: start = $400, size = $7C00, file = %O;" - "}" - "SEGMENTS { " - "HEADER: load = HEADER, type = ro;" - "CODE: load = RAM, type = ro;" - "RODATA: load = RAM, type = ro;" - "DATA: load = RAM, type = rw;" - "BSS: load = RAM, type = bss, define = yes;" - "}"; + +/* An empty config */ +static const char CfgEmpty[] = ""; + +/* Actual target configurations, converted into C strings by a perl script */ +#include "apple2.inc" +#include "atari.inc" +#include "c128.inc" +#include "c64.inc" +#include "cbm610.inc" +#include "geos.inc" +#include "none.inc" +#include "pet.inc" +#include "plus4.inc" @@ -232,18 +72,15 @@ const TargetDesc Targets [TGT_COUNT] = { { BINFMT_BINARY, CfgAtari }, { BINFMT_BINARY, CfgC64 }, { BINFMT_BINARY, CfgC128 }, - { BINFMT_BINARY, CfgAce }, + { BINFMT_BINARY, CfgEmpty }, /* Ace */ { BINFMT_BINARY, CfgPlus4 }, { BINFMT_BINARY, CfgCBM610 }, { BINFMT_BINARY, CfgPET }, - { BINFMT_BINARY, CfgNES }, -#if 0 - { BINFMT_O65, CfgLunix }, - { BINFMT_O65, CfgOSA65 }, -#endif + { BINFMT_BINARY, CfgEmpty }, /* NES */ { BINFMT_BINARY, CfgApple2 }, { BINFMT_BINARY, CfgGeos }, }; +