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_flag)
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
71 if (v + 0x8000 >= 0x18000)
72 return error(range_error);
78 // Arrange for fixup later on
79 AddFixup(FU_WORD|FU_SEXT, sloc, aNexpr);
88 if ((aNexattr & TDB) == cursect)
90 else if ((aNexattr & TDB) != ABS)
93 if (v + 0x8000 >= 0x10000)
94 return error(range_error);
100 // Arrange for fixup later on
101 AddFixup(FU_WORD|FU_SEXT|FU_PCREL, sloc, aNexpr);
107 // Compute ixreg and size+scale
108 w = (WORD)((aNixreg << 12) | aNixsiz);
110 if (aNexattr & DEFINED)
115 return error(abs_error);
117 if (v + 0x80 >= 0x180)
118 return error(range_error);
125 // Fixup the byte later
126 AddFixup(FU_BYTE|FU_SEXT, sloc+1, aNexpr);
132 // Compute ixreg and size+scale
133 w = (WORD)((aNixreg << 12) | aNixsiz);
135 if (aNexattr & DEFINED)
138 if ((aNexattr & TDB) == cursect)
140 else if ((aNexattr & TDB) != ABS)
143 if (v + 0x80 >= 0x100)
144 return error(range_error);
151 // Fixup the byte later
152 AddFixup(FU_WBYTE|FU_SEXT|FU_PCREL, sloc, aNexpr);
164 return error("illegal byte-sized relative reference");
166 if (v + 0x100 >= 0x200)
167 return error(range_error);
173 AddFixup(FU_BYTE|FU_SEXT, sloc+1, aNexpr);
183 rmark(cursect, sloc, tdb, MWORD, NULL);
185 if (v + 0x10000 >= 0x20000)
186 return error(range_error);
192 AddFixup(FU_WORD|FU_SEXT, sloc, aNexpr);
201 rmark(cursect, sloc, tdb, MLONG, NULL);
207 AddFixup(FU_LONG, sloc, aNexpr);
213 // IMMED size problem
222 rmark(cursect, sloc, tdb, MWORD, NULL);
224 if (v + 0x8000 >= 0x10000)
225 return error(range_error);
231 AddFixup(FU_WORD|FU_SEXT, sloc, aNexpr);
240 rmark(cursect, sloc, tdb, MLONG, NULL);
246 AddFixup(FU_LONG, sloc, aNexpr);
257 return error("unsupported 68020 addressing mode");
259 // Bad addressing mode in ea gen
266 // Undefine dirty macros