2 // RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
3 // EAGEN0.C - Effective Address Code Generation
4 // Generated Code for eaN (Included twice by "eagen.c")
5 // Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
6 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
7 // Source utilised with the kind permission of Landon Dyer
17 w = (WORD)(aNexattr & DEFINED);
18 tdb = (WORD)(aNexattr & TDB);
22 // "Do nothing" - they're in the opword
32 // This is a performance hit, though
40 rmark(cursect, sloc, tdb, MWORD, NULL);
42 if ((v == 0) && optim_flags[OPT_INDIRECT_DISP])
44 // If expr is 0, size optimise the opcode.
45 // Generally the lower 6 bits of the opcode
46 // for expr(ax) are 101rrr where rrr=the
47 // number of the register, then followed by
48 // a word containing 'expr'. We need to change
50 if ((siz & 0x8000) == 0)
52 chptr_opcode[0] &= ((0xFFC7 >> 8) & 255); // mask off bits
53 chptr_opcode[1] &= 0xFFC7 & 255; // mask off bits
54 chptr_opcode[0] |= ((0x0010 >> 8) & 255); // slap in 010 bits
55 chptr_opcode[1] |= 0x0010 & 255; // slap in 010 bits
59 // Special case for move ea,ea:
60 // there are two ea fields there and
61 // we get a signal if it's the second ea field
62 // from m_ea - siz's 16th bit is set
63 chptr_opcode[0] &= ((0xFE3F >> 8) & 255); // mask off bits
64 chptr_opcode[1] &= 0xFE3F & 255; // mask off bits
65 chptr_opcode[0] |= ((0x0080 >> 8) & 255); // slap in 010 bits
66 chptr_opcode[1] |= 0x0080 & 255; // slap in 010 bits
70 warn("0(An) converted to (An)");
75 if ((v + 0x8000) >= 0x18000)
76 return error(range_error);
82 // Arrange for fixup later on
83 AddFixup(FU_WORD|FU_SEXT, sloc, aNexpr);
92 if ((aNexattr & TDB) == cursect)
94 else if ((aNexattr & TDB) != ABS)
97 if (v + 0x8000 >= 0x10000)
98 return error(range_error);
104 // Arrange for fixup later on
105 AddFixup(FU_WORD|FU_SEXT|FU_PCREL, sloc, aNexpr);
111 // Compute ixreg and size+scale
112 w = (WORD)((aNixreg << 12) | aNixsiz);
114 if (aNexattr & DEFINED)
119 return error(abs_error);
121 if (v + 0x80 >= 0x180)
122 return error(range_error);
129 // Fixup the byte later
130 AddFixup(FU_BYTE|FU_SEXT, sloc+1, aNexpr);
136 // Compute ixreg and size+scale
137 w = (WORD)((aNixreg << 12) | aNixsiz);
139 if (aNexattr & DEFINED)
142 if ((aNexattr & TDB) == cursect)
144 else if ((aNexattr & TDB) != ABS)
147 if (v + 0x80 >= 0x100)
148 return error(range_error);
155 // Fixup the byte later
156 AddFixup(FU_WBYTE|FU_SEXT|FU_PCREL, sloc, aNexpr);
168 return error("illegal byte-sized relative reference");
170 if (v + 0x100 >= 0x200)
171 return error(range_error);
177 AddFixup(FU_BYTE|FU_SEXT, sloc+1, aNexpr);
187 rmark(cursect, sloc, tdb, MWORD, NULL);
189 if (v + 0x10000 >= 0x20000)
190 return error(range_error);
196 AddFixup(FU_WORD|FU_SEXT, sloc, aNexpr);
205 rmark(cursect, sloc, tdb, MLONG, NULL);
211 AddFixup(FU_LONG, sloc, aNexpr);
217 // IMMED size problem
226 rmark(cursect, sloc, tdb, MWORD, NULL);
228 if (v + 0x8000 >= 0x10000)
229 return error(range_error);
235 AddFixup(FU_WORD|FU_SEXT, sloc, aNexpr);
244 rmark(cursect, sloc, tdb, MLONG, NULL);
250 AddFixup(FU_LONG, sloc, aNexpr);
261 return error("unsupported 68020 addressing mode");
263 // Bad addressing mode in ea gen
270 // Undefine dirty macros