at character is not allowed to start an identifier, even with this
feature enabled.
+ <tag><tt>bracket_as_indirect</tt><label id="bracket_as_indirect"></tag>
+
+ Use <tt>[]</tt> intead of <tt>()</tt> for the indirect addressing mode.
+ Example:
+
+ <tscreen><verb>
+ lda [$82]
+ lda [$82,x]
+ lda [$82],y
+ </verb></tscreen>
+ <em/Note:/ This should not be used in 65186 mode because it conflicts with
+ the 65816 instruction syntax for far addressing. See the section covering
+ <tt/<ref id="address-sizes" name="address sizes">/ for more information.
+
<tag><tt>c_comments</tt><label id="c_comments"></tag>
Allow C like comments using <tt>/*</tt> and <tt>*/</tt> as left and right
#include "expr.h"
#include "instr.h"
#include "nexttok.h"
+#include "global.h"
/* 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;
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 ();
/* (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 {
} else {
/* (adr) or (adr),y */
- ConsumeRParen ();
+ Consume (IndirectLeave, IndirectExpect);
if (CurTok.Tok == TOK_COMMA) {
/* (adr),y */
NextTok ();
}
}
+ } 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: