From 26ae91efffb98da281cf928bb5a7d6cf0d104622 Mon Sep 17 00:00:00 2001 From: cuz Date: Mon, 14 Feb 2005 10:36:23 +0000 Subject: [PATCH] Allow numeric OS types in the config file git-svn-id: svn://svn.cc65.org/cc65/trunk@3386 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ld65/config.c | 37 ++++++++++++++++++++++--------------- src/ld65/o65.h | 4 +++- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/ld65/config.c b/src/ld65/config.c index 670f4dedb..9f9fba2c6 100644 --- a/src/ld65/config.c +++ b/src/ld65/config.c @@ -912,7 +912,7 @@ static void ParseO65 (void) CfgError ("Exported symbol `%s' cannot be an import", CfgSVal); } /* Check if we have this symbol defined already. The entry - * routine will check this also, but we get a more verbose + * routine will check this also, but we get a more verbose * error message when checking it here. */ if (O65GetExport (O65FmtDesc, CfgSValId) != 0) { @@ -962,20 +962,27 @@ static void ParseO65 (void) default: CfgError ("Unexpected type token"); } - break; + break; case CFGTOK_OS: - /* Cannot use this attribute twice */ - FlagAttr (&AttrFlags, atOS, "OS"); - /* Get the operating system */ - CfgSpecialToken (OperatingSystems, ENTRY_COUNT (OperatingSystems), "OS type"); - switch (CfgTok) { - case CFGTOK_LUNIX: OS = O65OS_LUNIX; break; - case CFGTOK_OSA65: OS = O65OS_OSA65; break; - case CFGTOK_CC65: OS = O65OS_CC65; break; - default: CfgError ("Unexpected OS token"); - } - break; + /* Cannot use this attribute twice */ + FlagAttr (&AttrFlags, atOS, "OS"); + /* Get the operating system. It may be specified as name or + * as a number in the range 1..255. + */ + if (CfgTok == CFGTOK_INTCON) { + CfgRangeCheck (O65OS_MIN, O65OS_MAX); + OS = (unsigned) CfgIVal; + } else { + CfgSpecialToken (OperatingSystems, ENTRY_COUNT (OperatingSystems), "OS type"); + switch (CfgTok) { + case CFGTOK_LUNIX: OS = O65OS_LUNIX; break; + case CFGTOK_OSA65: OS = O65OS_OSA65; break; + case CFGTOK_CC65: OS = O65OS_CC65; break; + default: CfgError ("Unexpected OS token"); + } + } + break; case CFGTOK_ID: /* Cannot have this attribute twice */ @@ -1010,8 +1017,8 @@ static void ParseO65 (void) /* Check for attributes that may not be combined */ if (OS == O65OS_CC65) { - if ((AttrFlags & (atImport | atExport)) != 0) { - CfgError ("OS type CC65 may not have imports or exports"); + if ((AttrFlags & (atImport | atExport)) != 0 && ModuleId < 0x8000) { + CfgError ("OS type CC65 may not have imports or exports for ids < $8000"); } } else { if (AttrFlags & atID) { diff --git a/src/ld65/o65.h b/src/ld65/o65.h index 5115eabc6..d9e8832f8 100644 --- a/src/ld65/o65.h +++ b/src/ld65/o65.h @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1999-2003 Ullrich von Bassewitz */ +/* (C) 1999-2005 Ullrich von Bassewitz */ /* Römerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -62,9 +62,11 @@ typedef struct O65Desc O65Desc; #define O65OPT_TIMESTAMP 4 /* Operating system codes for O65OPT_OS */ +#define O65OS_MIN 1 #define O65OS_OSA65 1 #define O65OS_LUNIX 2 #define O65OS_CC65 3 +#define O65OS_MAX 255