mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 04:30:10 +00:00
New feature: startaddress
git-svn-id: svn://svn.cc65.org/cc65/trunk@1713 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
6156a8b472
commit
df5132d31c
@ -1152,11 +1152,84 @@ static void ParseConDes (void)
|
||||
|
||||
|
||||
|
||||
static void ParseStartAddress (void)
|
||||
/* Parse the STARTADDRESS feature */
|
||||
{
|
||||
static const IdentTok Attributes [] = {
|
||||
{ "DEFAULT", CFGTOK_DEFAULT },
|
||||
};
|
||||
|
||||
|
||||
/* Attribute values. */
|
||||
unsigned long DefStartAddr = 0;
|
||||
|
||||
/* Bitmask to remember the attributes we got already */
|
||||
enum {
|
||||
atNone = 0x0000,
|
||||
atDefault = 0x0001
|
||||
};
|
||||
unsigned AttrFlags = atNone;
|
||||
|
||||
/* Parse the attributes */
|
||||
while (1) {
|
||||
|
||||
/* Map the identifier to a token */
|
||||
cfgtok_t AttrTok;
|
||||
CfgSpecialToken (Attributes, ENTRY_COUNT (Attributes), "Attribute");
|
||||
AttrTok = CfgTok;
|
||||
|
||||
/* An optional assignment follows */
|
||||
CfgNextTok ();
|
||||
CfgOptionalAssign ();
|
||||
|
||||
/* Check which attribute was given */
|
||||
switch (AttrTok) {
|
||||
|
||||
case CFGTOK_DEFAULT:
|
||||
/* Don't allow this twice */
|
||||
FlagAttr (&AttrFlags, atDefault, "DEFAULT");
|
||||
/* We expect a number */
|
||||
CfgAssureInt ();
|
||||
CfgRangeCheck (0, 0xFFFFFF);
|
||||
/* Remember the value for later */
|
||||
DefStartAddr = CfgIVal;
|
||||
break;
|
||||
|
||||
default:
|
||||
FAIL ("Unexpected attribute token");
|
||||
|
||||
}
|
||||
|
||||
/* Skip the attribute value */
|
||||
CfgNextTok ();
|
||||
|
||||
/* Semicolon ends the ConDes decl, otherwise accept an optional comma */
|
||||
if (CfgTok == CFGTOK_SEMI) {
|
||||
break;
|
||||
} else if (CfgTok == CFGTOK_COMMA) {
|
||||
CfgNextTok ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if we have all mandatory attributes */
|
||||
AttrCheck (AttrFlags, atDefault, "DEFAULT");
|
||||
|
||||
/* If no start address was given on the command line, use the one given
|
||||
* here
|
||||
*/
|
||||
if (!HaveStartAddr) {
|
||||
StartAddr = DefStartAddr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void ParseFeatures (void)
|
||||
/* Parse a features section */
|
||||
{
|
||||
static const IdentTok Features [] = {
|
||||
{ "CONDES", CFGTOK_CONDES },
|
||||
{ "STARTADDRESS", CFGTOK_STARTADDRESS },
|
||||
};
|
||||
|
||||
while (CfgTok == CFGTOK_IDENT) {
|
||||
@ -1177,6 +1250,11 @@ static void ParseFeatures (void)
|
||||
ParseConDes ();
|
||||
break;
|
||||
|
||||
case CFGTOK_STARTADDRESS:
|
||||
ParseStartAddress ();
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
Error ("Unexpected feature token");
|
||||
}
|
||||
|
@ -46,6 +46,9 @@
|
||||
const char* OutputName = "a.out"; /* Name of output file */
|
||||
|
||||
unsigned ModuleId = 0; /* Id for o65 module */
|
||||
|
||||
/* Start address */
|
||||
unsigned char HaveStartAddr = 0; /* Start address not given */
|
||||
unsigned long StartAddr = 0x200; /* Start address */
|
||||
|
||||
unsigned char VerboseMap = 0; /* Verbose map file */
|
||||
|
@ -47,6 +47,8 @@
|
||||
extern const char* OutputName; /* Name of output file */
|
||||
|
||||
extern unsigned ModuleId; /* Id for o65 module */
|
||||
|
||||
extern unsigned char HaveStartAddr; /* True if start address was given */
|
||||
extern unsigned long StartAddr; /* Start address */
|
||||
|
||||
extern unsigned char VerboseMap; /* Verbose map file */
|
||||
|
@ -270,6 +270,7 @@ static void OptStartAddr (const char* Opt, const char* Arg)
|
||||
/* Set the default start address */
|
||||
{
|
||||
StartAddr = CvtNumber (Opt, Arg);
|
||||
HaveStartAddr = 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -106,6 +106,8 @@ typedef enum {
|
||||
CFGTOK_CC65,
|
||||
|
||||
CFGTOK_CONDES,
|
||||
CFGTOK_STARTADDRESS,
|
||||
|
||||
CFGTOK_SEGMENT,
|
||||
CFGTOK_LABEL,
|
||||
CFGTOK_COUNT,
|
||||
@ -115,7 +117,9 @@ typedef enum {
|
||||
CFGTOK_DESTRUCTOR,
|
||||
|
||||
CFGTOK_DECREASING,
|
||||
CFGTOK_INCREASING
|
||||
CFGTOK_INCREASING,
|
||||
|
||||
CFGTOK_DEFAULT
|
||||
|
||||
} cfgtok_t;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user