1 /*****************************************************************************/
5 /* Opcode and addressing mode definitions */
9 /* (C) 2001-2004 Ullrich von Bassewitz */
10 /* Roemerstrasse 52 */
11 /* D-70794 Filderstadt */
12 /* EMail: uz@cc65.org */
15 /* This software is provided 'as-is', without any expressed or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
32 /*****************************************************************************/
46 /*****************************************************************************/
48 /*****************************************************************************/
129 /* Number of opcodes available */
133 /* 65XX addressing modes */
135 AM65_IMP, /* implicit */
136 AM65_ACC, /* accumulator */
137 AM65_IMM, /* immidiate */
138 AM65_ZP, /* zeropage */
139 AM65_ZPX, /* zeropage,X */
140 AM65_ZPY, /* zeropage,Y */
141 AM65_ABS, /* absolute */
142 AM65_ABSX, /* absolute,X */
143 AM65_ABSY, /* absolute,Y */
144 AM65_ZPX_IND, /* (zeropage,x) */
145 AM65_ZP_INDY, /* (zeropage),y */
146 AM65_ZP_IND, /* (zeropage) */
147 AM65_BRA /* branch */
150 /* Branch conditions */
163 #define OF_NONE 0x0000U /* No additional information */
164 #define OF_UBRA 0x0001U /* Unconditional branch */
165 #define OF_CBRA 0x0002U /* Conditional branch */
166 #define OF_ZBRA 0x0004U /* Branch on zero flag condition */
167 #define OF_FBRA 0x0008U /* Branch on cond set by a load */
168 #define OF_LBRA 0x0010U /* Jump/branch is long */
169 #define OF_RET 0x0020U /* Return from function */
170 #define OF_LOAD 0x0040U /* Register load */
171 #define OF_STORE 0x0080U /* Register store */
172 #define OF_XFR 0x0100U /* Transfer instruction */
173 #define OF_CALL 0x0200U /* A subroutine call */
174 #define OF_REG_INCDEC 0x0400U /* A register increment or decrement */
175 #define OF_SETF 0x0800U /* Insn will set all load flags (not carry) */
176 #define OF_CMP 0x1000U /* A compare A/X/Y instruction */
177 #define OF_NOIMP 0x2000U /* Implicit addressing mode is actually A */
180 #define OF_BRA (OF_UBRA | OF_CBRA) /* Operation is a jump/branch */
181 #define OF_DEAD (OF_UBRA | OF_RET) /* Dead end - no exec behind this point */
183 /* Opcode description */
185 opc_t OPC; /* Opcode */
186 char Mnemo[9]; /* Mnemonic */
187 unsigned char Size; /* Size, 0 = check addressing mode */
188 unsigned short Use; /* Registers used by this insn */
189 unsigned short Chg; /* Registers changed by this insn */
190 unsigned short Info; /* Additional information */
193 /* Opcode description table */
194 extern const OPCDesc OPCTable[OP65_COUNT];
198 /*****************************************************************************/
200 /*****************************************************************************/
204 const OPCDesc* FindOP65 (const char* OPC);
205 /* Find the given opcode and return the opcode description. If the opcode was
206 ** not found, NULL is returned.
209 unsigned GetInsnSize (opc_t OPC, am_t AM);
210 /* Return the size of the given instruction */
212 #if defined(HAVE_INLINE)
213 INLINE const OPCDesc* GetOPCDesc (opc_t OPC)
214 /* Get an opcode description */
216 /* Return the description */
217 return &OPCTable [OPC];
220 # define GetOPCDesc(OPC) (&OPCTable [(OPC)])
223 #if defined(HAVE_INLINE)
224 INLINE unsigned GetOPCInfo (opc_t OPC)
225 /* Get opcode information */
227 /* Return the info */
228 return OPCTable[OPC].Info;
231 # define GetOPCInfo(OPC) (OPCTable[(OPC)].Info)
234 unsigned char GetAMUseInfo (am_t AM);
235 /* Get usage info for the given addressing mode (addressing modes that use
236 ** index registers return REG_r info for these registers).
239 opc_t GetInverseBranch (opc_t OPC);
240 /* Return a branch that reverse the condition of the branch given in OPC */
242 opc_t MakeShortBranch (opc_t OPC);
243 /* Return the short version of the given branch. If the branch is already
244 ** a short branch, return the opcode unchanged.
247 opc_t MakeLongBranch (opc_t OPC);
248 /* Return the long version of the given branch. If the branch is already
249 ** a long branch, return the opcode unchanged.
252 bc_t GetBranchCond (opc_t OPC);
253 /* Get the condition for the conditional branch in OPC */
255 bc_t GetInverseCond (bc_t BC);
256 /* Return the inverse condition of the given one */
260 /* End of opcodes.h */