2 // RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
3 // PARMODE.C - Addressing Modes Parser Include
4 // Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
5 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
6 // Source utilised with the kind permission of Landon Dyer
9 // This file is included (twice) to parse two addressing modes, into slightly
10 // different var names
15 if ((*tok >= KW_D0) && (*tok <= KW_D7))
20 else if ((*tok >= KW_A0) && (*tok <= KW_A7))
29 if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK)
35 // Small problem with this is that the opening parentheses might be an
36 // expression that's part of a displacement; this code will falsely flag
41 // (An,Xn[.siz][*scale])
42 // (PC,Xn[.siz][*scale])
44 // (d8,An,Xn[.siz][*scale])
46 // (d8,PC,Xn[.siz][*scale])
55 if ((*tok >= KW_A0) && (*tok <= KW_A7))
75 goto AMn_IX0; // Handle ",Xn[.siz][*scale])"
77 else if (*tok == KW_PC)
78 { // (PC,Xn[.siz][*scale])
82 // Common index handler; enter here with `tok' pointing at the comma.
84 AMn_IX0: // Handle indexed with missing expr
87 AnEXATTR = ABS | DEFINED;
89 AMn_IXN: // Handle any indexed (tok -> a comma)
94 if (*tok < KW_D0 || *tok > KW_A7)
97 AnIXREG = *tok++ & 15;
100 { // Index reg size: <empty> | .W | .L
110 case DOTB: // .B not allowed here...
115 { // scale: *1, *2, *4, *8
118 if (*tok++ != CONST || *tok > 8)
139 if (*tok++ != ')') // final ")"
144 else if (*tok == '[')
150 if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK)
153 // It could be that this is really just an expression prefixing a
154 // register as a displacement...
161 // Otherwise, check for PC & etc displacements...
165 if ((*tok >= KW_A0) && (*tok <= KW_A7))
175 else if (*tok == ')')
184 else if (*tok == KW_PC)
191 else if (*tok == ')')
193 AMn = PCDISP; // expr(PC)
204 else if (*tok=='-' && tok[1]=='(' && ((tok[2]>=KW_A0) && (tok[2]<=KW_A7)) && tok[3]==')')
210 else if (*tok == KW_CCR)
216 else if (*tok == KW_SR)
222 else if (*tok == KW_USP)
237 if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK)
248 else if (*tok != '(')
253 // Defined, absolute values from $FFFF8000..$00007FFF get optimized
255 if ((AnEXATTR & (TDB|DEFINED)) == DEFINED && (AnEXVAL + 0x8000) < 0x10000)
258 // Is .L forced here?
270 if ((*tok >= KW_A0) && (*tok <= KW_A7))
284 else if (*tok == KW_PC)
299 // Addressing mode OK
305 // Clean up dirty little macros