Add optional feature to use brackets instead of parens for 6502 indirect addressing.
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#include "expr.h"
|
||||
#include "instr.h"
|
||||
#include "nexttok.h"
|
||||
#include "global.h"
|
||||
|
||||
|
||||
|
||||
@@ -53,6 +54,20 @@ void GetEA (EffAddr* A)
|
||||
/* Parse an effective address, return the result in A */
|
||||
{
|
||||
unsigned long Restrictions;
|
||||
token_t IndirectEnter;
|
||||
token_t IndirectLeave;
|
||||
const char* IndirectExpect;
|
||||
|
||||
/* Choose syntax for indirection */
|
||||
if (BracketAsIndirect) {
|
||||
IndirectEnter = TOK_LBRACK;
|
||||
IndirectLeave = TOK_RBRACK;
|
||||
IndirectExpect = "']' expected";
|
||||
} else {
|
||||
IndirectEnter = TOK_LPAREN;
|
||||
IndirectLeave = TOK_RPAREN;
|
||||
IndirectExpect = "')' expected";
|
||||
}
|
||||
|
||||
/* Clear the output struct */
|
||||
A->AddrModeSet = 0;
|
||||
@@ -97,23 +112,7 @@ void GetEA (EffAddr* A)
|
||||
NextTok ();
|
||||
A->AddrModeSet = AM65_ACCU;
|
||||
|
||||
} else if (CurTok.Tok == TOK_LBRACK) {
|
||||
|
||||
/* [dir] or [dir],y */
|
||||
NextTok ();
|
||||
A->Expr = Expression ();
|
||||
Consume (TOK_RBRACK, "']' expected");
|
||||
if (CurTok.Tok == TOK_COMMA) {
|
||||
/* [dir],y */
|
||||
NextTok ();
|
||||
Consume (TOK_Y, "`Y' expected");
|
||||
A->AddrModeSet = AM65_DIR_IND_LONG_Y;
|
||||
} else {
|
||||
/* [dir] */
|
||||
A->AddrModeSet = AM65_DIR_IND_LONG | AM65_ABS_IND_LONG;
|
||||
}
|
||||
|
||||
} else if (CurTok.Tok == TOK_LPAREN) {
|
||||
} else if (CurTok.Tok == IndirectEnter) {
|
||||
|
||||
/* One of the indirect modes */
|
||||
NextTok ();
|
||||
@@ -127,12 +126,12 @@ void GetEA (EffAddr* A)
|
||||
/* (adr,x) */
|
||||
NextTok ();
|
||||
A->AddrModeSet = AM65_ABS_X_IND | AM65_DIR_X_IND;
|
||||
ConsumeRParen ();
|
||||
Consume (IndirectLeave, IndirectExpect);
|
||||
} else if (CurTok.Tok == TOK_S) {
|
||||
/* (rel,s),y */
|
||||
NextTok ();
|
||||
A->AddrModeSet = AM65_STACK_REL_IND_Y;
|
||||
ConsumeRParen ();
|
||||
Consume (IndirectLeave, IndirectExpect);
|
||||
ConsumeComma ();
|
||||
Consume (TOK_Y, "`Y' expected");
|
||||
} else {
|
||||
@@ -142,7 +141,7 @@ void GetEA (EffAddr* A)
|
||||
} else {
|
||||
|
||||
/* (adr) or (adr),y */
|
||||
ConsumeRParen ();
|
||||
Consume (IndirectLeave, IndirectExpect);
|
||||
if (CurTok.Tok == TOK_COMMA) {
|
||||
/* (adr),y */
|
||||
NextTok ();
|
||||
@@ -154,6 +153,23 @@ void GetEA (EffAddr* A)
|
||||
}
|
||||
}
|
||||
|
||||
} else if (CurTok.Tok == TOK_LBRACK) {
|
||||
|
||||
/* Never executed if BracketAsIndirect feature is enabled. */
|
||||
/* [dir] or [dir],y */
|
||||
NextTok ();
|
||||
A->Expr = Expression ();
|
||||
Consume (TOK_RBRACK, "']' expected");
|
||||
if (CurTok.Tok == TOK_COMMA) {
|
||||
/* [dir],y */
|
||||
NextTok ();
|
||||
Consume (TOK_Y, "`Y' expected");
|
||||
A->AddrModeSet = AM65_DIR_IND_LONG_Y;
|
||||
} else {
|
||||
/* [dir] */
|
||||
A->AddrModeSet = AM65_DIR_IND_LONG | AM65_ABS_IND_LONG;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/* Remaining stuff:
|
||||
|
||||
Reference in New Issue
Block a user