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, 2017 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
13 WORD w = (WORD)(aNexattr & DEFINED);
14 WORD tdb = (WORD)(aNexattr & TDB);
18 // "Do nothing" - they're in the opword
28 // This is a performance hit, though
36 MarkRelocatable(cursect, sloc, tdb, MWORD, NULL);
38 if ((v == 0) && optim_flags[OPT_INDIRECT_DISP] && !movep)
40 // If expr is 0, size optimise the opcode. Generally the lower
41 // 6 bits of the opcode for expr(ax) are 101rrr where rrr=the
42 // number of the register, then followed by a word containing
43 // 'expr'. We need to change that to 010rrr.
44 if ((siz & 0x8000) == 0)
46 chptr_opcode[0] &= ((0xFFC7 >> 8) & 255); // mask off bits
47 chptr_opcode[1] &= 0xFFC7 & 255; // mask off bits
48 chptr_opcode[0] |= ((0x0010 >> 8) & 255); // slap in 010 bits
49 chptr_opcode[1] |= 0x0010 & 255; // slap in 010 bits
53 // Special case for move ea,ea: there are two ea fields
54 // there and we get a signal if it's the second ea field
55 // from m_ea - siz's 16th bit is set
56 chptr_opcode[0] &= ((0xFE3F >> 8) & 255); // mask off bits
57 chptr_opcode[1] &= 0xFE3F & 255; // mask off bits
58 chptr_opcode[0] |= ((0x0080 >> 8) & 255); // slap in 010 bits
59 chptr_opcode[1] |= 0x0080 & 255; // slap in 010 bits
63 warn("0(An) converted to (An)");
68 if ((v + 0x8000) >= 0x18000)
69 return error(range_error);
75 // Arrange for fixup later on
76 AddFixup(FU_WORD | FU_SEXT, sloc, aNexpr);
85 if ((aNexattr & TDB) == cursect)
87 else if ((aNexattr & TDB) != ABS)
90 if (v + 0x8000 >= 0x10000)
91 return error(range_error);
97 // Arrange for fixup later on
98 AddFixup(FU_WORD | FU_SEXT | FU_PCREL, sloc, aNexpr);
104 // Compute ixreg and size+scale
105 w = (WORD)((aNixreg << 12) | aNixsiz);
107 if (aNexattr & DEFINED)
112 return error(abs_error);
114 if (v + 0x80 >= 0x180)
115 return error(range_error);
122 // Fixup the byte later
123 AddFixup(FU_BYTE | FU_SEXT, sloc + 1, aNexpr);
129 // Compute ixreg and size+scale
130 w = (WORD)((aNixreg << 12) | aNixsiz);
132 if (aNexattr & DEFINED)
135 if ((aNexattr & TDB) == cursect)
137 else if ((aNexattr & TDB) != ABS)
140 if (v + 0x80 >= 0x100)
141 return error(range_error);
148 // Fixup the byte later
149 AddFixup(FU_WBYTE | FU_SEXT | FU_PCREL, sloc, aNexpr);
161 return error("illegal byte-sized relative reference");
163 if (v + 0x100 >= 0x200)
164 return error(range_error);
170 AddFixup(FU_BYTE | FU_SEXT, sloc + 1, aNexpr);
179 if (v + 0x10000 >= 0x20000)
180 return error(range_error);
183 MarkRelocatable(cursect, sloc, tdb, MWORD, NULL);
189 AddFixup(FU_WORD | FU_SEXT, sloc, aNexpr);
198 MarkRelocatable(cursect, sloc, tdb, MLONG, NULL);
204 AddFixup(FU_LONG, sloc, aNexpr);
210 // IMMED size problem
219 MarkRelocatable(cursect, sloc, tdb, MWORD, NULL);
221 if (v + 0x8000 >= 0x10000)
222 return error(range_error);
228 AddFixup(FU_WORD | FU_SEXT, sloc, aNexpr);
237 MarkRelocatable(cursect, sloc, tdb, MLONG, NULL);
243 AddFixup(FU_LONG, sloc, aNexpr);
254 return error("unsupported 68020 addressing mode");
256 // Bad addressing mode in ea gen
263 // Undefine dirty macros