mirror of
https://github.com/cc65/cc65.git
synced 2025-01-10 19:29:45 +00:00
Added new .feature: pc_assignment
git-svn-id: svn://svn.cc65.org/cc65/trunk@310 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
5abb3954a6
commit
f55d0ccee1
@ -147,6 +147,7 @@ void ErrorMsg (const FilePos* Pos, unsigned ErrNum, va_list ap)
|
||||
"Identifier expected",
|
||||
"`.endmacro' expected",
|
||||
"Option key expected",
|
||||
"`=' expected",
|
||||
"Command is only valid in 65816 mode",
|
||||
"User error: %s",
|
||||
"String constant too long",
|
||||
|
@ -88,6 +88,7 @@ enum Errors {
|
||||
ERR_IDENT_EXPECTED,
|
||||
ERR_ENDMACRO_EXPECTED,
|
||||
ERR_OPTION_KEY_EXPECTED,
|
||||
ERR_EQ_EXPECTED,
|
||||
ERR_816_MODE_ONLY,
|
||||
ERR_USER,
|
||||
ERR_STRING_TOO_LONG,
|
||||
|
@ -68,7 +68,7 @@ unsigned char NoColonLabels = 0; /* Allow labels without a colon */
|
||||
unsigned char LooseStringTerm = 0; /* Allow ' as string terminator */
|
||||
unsigned char AtInIdents = 0; /* Allow '@' in identifiers */
|
||||
unsigned char DollarInIdents = 0; /* Allow '$' in identifiers */
|
||||
|
||||
unsigned char PCAssignment = 0; /* Allow "* = $XXX" or "$ = $XXX" */
|
||||
|
||||
|
||||
|
||||
|
@ -69,6 +69,7 @@ extern unsigned char NoColonLabels; /* Allow labels without a colon */
|
||||
extern unsigned char LooseStringTerm;/* Allow ' as string terminator */
|
||||
extern unsigned char AtInIdents; /* Allow '@' in identifiers */
|
||||
extern unsigned char DollarInIdents; /* Allow '$' in identifiers */
|
||||
extern unsigned char PCAssignment; /* Allow "* = $XXX" or "$ = $XXX" */
|
||||
|
||||
|
||||
|
||||
|
@ -314,6 +314,19 @@ static void OptVersion (const char* Opt, const char* Arg)
|
||||
|
||||
|
||||
|
||||
static void DoPCAssign (void)
|
||||
/* Start absolute code */
|
||||
{
|
||||
long PC = ConstExpression ();
|
||||
if (PC < 0 || PC > 0xFFFFFF) {
|
||||
Error (ERR_RANGE);
|
||||
} else {
|
||||
SetAbsPC (PC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void OneLine (void)
|
||||
/* Assemble one line */
|
||||
{
|
||||
@ -324,49 +337,49 @@ static void OneLine (void)
|
||||
* and not from internally pushed input.
|
||||
*/
|
||||
if (!HavePushedInput ()) {
|
||||
InitListingLine ();
|
||||
InitListingLine ();
|
||||
}
|
||||
|
||||
if (Tok == TOK_COLON) {
|
||||
/* An unnamed label */
|
||||
ULabDef ();
|
||||
NextTok ();
|
||||
/* An unnamed label */
|
||||
ULabDef ();
|
||||
NextTok ();
|
||||
}
|
||||
|
||||
/* Assemble the line */
|
||||
if (Tok == TOK_IDENT) {
|
||||
|
||||
/* Is it a macro? */
|
||||
if (IsMacro (SVal)) {
|
||||
/* Is it a macro? */
|
||||
if (IsMacro (SVal)) {
|
||||
|
||||
/* Yes, start a macro expansion */
|
||||
MacExpandStart ();
|
||||
Done = 1;
|
||||
/* Yes, start a macro expansion */
|
||||
MacExpandStart ();
|
||||
Done = 1;
|
||||
|
||||
} else {
|
||||
} else {
|
||||
|
||||
/* No, label. Remember the identifier, then skip it */
|
||||
int HadWS = WS; /* Did we have whitespace before the ident? */
|
||||
strcpy (Ident, SVal);
|
||||
NextTok ();
|
||||
/* No, label. Remember the identifier, then skip it */
|
||||
int HadWS = WS; /* Did we have whitespace before the ident? */
|
||||
strcpy (Ident, SVal);
|
||||
NextTok ();
|
||||
|
||||
/* If a colon follows, this is a label definition. If there
|
||||
* is no colon, it's an assignment.
|
||||
*/
|
||||
/* If a colon follows, this is a label definition. If there
|
||||
* is no colon, it's an assignment.
|
||||
*/
|
||||
if (Tok == TOK_EQ) {
|
||||
/* Skip the '=' */
|
||||
NextTok ();
|
||||
/* Define the symbol with the expression following the '=' */
|
||||
SymDef (Ident, Expression (), 0);
|
||||
/* Don't allow anything after a symbol definition */
|
||||
Done = 1;
|
||||
} else {
|
||||
/* Define a label */
|
||||
SymDef (Ident, CurrentPC (), IsZPSeg ());
|
||||
/* Skip the colon. If NoColonLabels is enabled, allow labels
|
||||
* without a colon if there is no whitespace before the
|
||||
* identifier.
|
||||
*/
|
||||
/* Skip the '=' */
|
||||
NextTok ();
|
||||
/* Define the symbol with the expression following the '=' */
|
||||
SymDef (Ident, Expression (), 0);
|
||||
/* Don't allow anything after a symbol definition */
|
||||
Done = 1;
|
||||
} else {
|
||||
/* Define a label */
|
||||
SymDef (Ident, CurrentPC (), IsZPSeg ());
|
||||
/* Skip the colon. If NoColonLabels is enabled, allow labels
|
||||
* without a colon if there is no whitespace before the
|
||||
* identifier.
|
||||
*/
|
||||
if (Tok != TOK_COLON) {
|
||||
if (HadWS || !NoColonLabels) {
|
||||
Error (ERR_COLON_EXPECTED);
|
||||
@ -394,7 +407,18 @@ static void OneLine (void)
|
||||
} else if (Tok == TOK_IDENT && IsMacro (SVal)) {
|
||||
/* A macro expansion */
|
||||
MacExpandStart ();
|
||||
}
|
||||
} else if (PCAssignment && (Tok == TOK_STAR || Tok == TOK_PC)) {
|
||||
NextTok ();
|
||||
if (Tok != TOK_EQ) {
|
||||
Error (ERR_EQ_EXPECTED);
|
||||
SkipUntilSep ();
|
||||
} else {
|
||||
/* Skip the equal sign */
|
||||
NextTok ();
|
||||
/* Enter absolute mode */
|
||||
DoPCAssign ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Line separator must come here */
|
||||
|
@ -519,6 +519,7 @@ static void DoFeature (void)
|
||||
"LOOSE_STRING_TERM",
|
||||
"AT_IN_IDENTIFIERS",
|
||||
"DOLLAR_IN_IDENTIFIERS",
|
||||
"PC_ASSIGNMENT",
|
||||
};
|
||||
|
||||
/* Allow a list of comma separated keywords */
|
||||
@ -548,6 +549,7 @@ static void DoFeature (void)
|
||||
case 2: LooseStringTerm = 1; break;
|
||||
case 3: AtInIdents = 1; break;
|
||||
case 4: DollarInIdents = 1; break;
|
||||
case 5: PCAssignment = 1; break;
|
||||
default: Internal ("Invalid feature: %d", Feature);
|
||||
}
|
||||
|
||||
@ -870,7 +872,7 @@ static void DoOrg (void)
|
||||
/* Start absolute code */
|
||||
{
|
||||
long PC = ConstExpression ();
|
||||
if (PC < 0 || PC > 0xFFFF) {
|
||||
if (PC < 0 || PC > 0xFFFFFF) {
|
||||
Error (ERR_RANGE);
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user