1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-28 03:29:39 +00:00

Added new address size override commands z:, a: and f:.

git-svn-id: svn://svn.cc65.org/cc65/trunk@2222 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2003-06-17 20:22:14 +00:00
parent 7016496564
commit 3cbd6ca29b
3 changed files with 62 additions and 8 deletions

View File

@ -40,7 +40,7 @@
#include "nexttok.h" #include "nexttok.h"
#include "ea.h" #include "ea.h"
/*****************************************************************************/ /*****************************************************************************/
/* Code */ /* Code */
@ -51,12 +51,36 @@
void GetEA (EffAddr* A) void GetEA (EffAddr* A)
/* Parse an effective address, return the result in A */ /* Parse an effective address, return the result in A */
{ {
unsigned long Restrictions;
/* Clear the output struct */ /* Clear the output struct */
A->AddrModeSet = 0; A->AddrModeSet = 0;
A->Bank = 0; A->Bank = 0;
A->Expr = 0; A->Expr = 0;
/* Handle an addressing size override */
switch (Tok) {
case TOK_OVERRIDE_ZP:
Restrictions = AM_DIR | AM_DIR_X | AM_DIR_Y;
NextTok ();
break;
case TOK_OVERRIDE_ABS:
Restrictions = AM_ABS | AM_ABS_X | AM_ABS_Y;
NextTok ();
break;
case TOK_OVERRIDE_FAR:
Restrictions = AM_ABS_LONG | AM_ABS_LONG_X;
NextTok ();
break;
default:
Restrictions = ~0UL; /* None */
break;
}
/* Parse the effective address */
if (TokIsSep (Tok)) { if (TokIsSep (Tok)) {
A->AddrModeSet = AM_IMPLICIT; A->AddrModeSet = AM_IMPLICIT;
@ -167,7 +191,7 @@ void GetEA (EffAddr* A)
switch (Tok) { switch (Tok) {
case TOK_X: case TOK_X:
A->AddrModeSet = AM_ABS_X | AM_DIR_X; A->AddrModeSet = AM_ABS_LONG_X | AM_ABS_X | AM_DIR_X;
NextTok (); NextTok ();
break; break;
@ -188,11 +212,14 @@ void GetEA (EffAddr* A)
} else { } else {
A->AddrModeSet = AM_ABS | AM_DIR; A->AddrModeSet = AM_ABS_LONG | AM_ABS | AM_DIR;
} }
} }
} }
/* Apply addressing mode overrides */
A->AddrModeSet &= Restrictions;
} }

View File

@ -767,13 +767,31 @@ Again:
ReadIdent (0); ReadIdent (0);
/* Check for special names */ /* Check for special names */
if (SVal [1] == '\0') { if (SVal[1] == '\0') {
switch (toupper (SVal [0])) { switch (toupper (SVal [0])) {
case 'A': case 'A':
Tok = TOK_A; if (C == ':') {
NextChar ();
Tok = TOK_OVERRIDE_ABS;
} else {
Tok = TOK_A;
}
return; return;
case 'F':
if (C == ':') {
NextChar ();
Tok = TOK_OVERRIDE_FAR;
} else {
Tok = TOK_IDENT;
}
return;
case 'S':
Tok = TOK_S;
return;
case 'X': case 'X':
Tok = TOK_X; Tok = TOK_X;
return; return;
@ -782,9 +800,14 @@ Again:
Tok = TOK_Y; Tok = TOK_Y;
return; return;
case 'S': case 'Z':
Tok = TOK_S; if (C == ':') {
return; NextChar ();
Tok = TOK_OVERRIDE_ZP;
} else {
Tok = TOK_IDENT;
}
return;
default: default:
Tok = TOK_IDENT; Tok = TOK_IDENT;

View File

@ -105,6 +105,10 @@ enum Token {
TOK_LBRACK, /* [ */ TOK_LBRACK, /* [ */
TOK_RBRACK, /* ] */ TOK_RBRACK, /* ] */
TOK_OVERRIDE_ZP, /* z: */
TOK_OVERRIDE_ABS, /* a: */
TOK_OVERRIDE_FAR, /* f: */
TOK_MACPARAM, /* Macro parameter, not generated by scanner */ TOK_MACPARAM, /* Macro parameter, not generated by scanner */
TOK_REPCOUNTER, /* Repeat counter, not generated by scanner */ TOK_REPCOUNTER, /* Repeat counter, not generated by scanner */