]> git.sur5r.net Git - cc65/blob - src/cc65/opcodes.h
Working on the backend
[cc65] / src / cc65 / opcodes.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 opcodes.h                                 */
4 /*                                                                           */
5 /*                  Opcode and addressing mode definitions                   */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2001     Ullrich von Bassewitz                                        */
10 /*              Wacholderweg 14                                              */
11 /*              D-70597 Stuttgart                                            */
12 /* EMail:       uz@musoftware.de                                             */
13 /*                                                                           */
14 /*                                                                           */
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.                                    */
18 /*                                                                           */
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:                            */
22 /*                                                                           */
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              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef OPCODES_H
37 #define OPCODES_H
38
39
40
41 /*****************************************************************************/
42 /*                                   Data                                    */
43 /*****************************************************************************/
44
45
46
47 /* Definitions for the possible opcodes */
48 typedef enum {
49     OPC_ADC,
50     OPC_AND,
51     OPC_ASL,
52     OPC_BCC,
53     OPC_BCS,
54     OPC_BEQ,
55     OPC_BIT,
56     OPC_BMI,
57     OPC_BNE,
58     OPC_BPL,
59     OPC_BRA,
60     OPC_BRK,
61     OPC_BVC,
62     OPC_BVS,
63     OPC_CLC,
64     OPC_CLD,
65     OPC_CLI,
66     OPC_CLV,
67     OPC_CMP,
68     OPC_CPX,
69     OPC_CPY,
70     OPC_DEA,
71     OPC_DEC,
72     OPC_DEX,
73     OPC_DEY,
74     OPC_EOR,
75     OPC_INA,
76     OPC_INC,
77     OPC_INX,
78     OPC_INY,
79     OPC_JMP,
80     OPC_JSR,
81     OPC_LDA,
82     OPC_LDX,
83     OPC_LDY,
84     OPC_LSR,
85     OPC_NOP,
86     OPC_ORA,
87     OPC_PHA,
88     OPC_PHP,
89     OPC_PHX,
90     OPC_PHY,
91     OPC_PLA,
92     OPC_PLP,
93     OPC_PLX,
94     OPC_PLY,
95     OPC_ROL,
96     OPC_ROR,
97     OPC_RTI,
98     OPC_RTS,
99     OPC_SBC,
100     OPC_SEC,
101     OPC_SED,
102     OPC_SEI,
103     OPC_STA,
104     OPC_STX,
105     OPC_STY,
106     OPC_TAX,
107     OPC_TAY,
108     OPC_TRB,
109     OPC_TSB,
110     OPC_TSX,
111     OPC_TXA,
112     OPC_TXS,
113     OPC_TYA,
114     OPC_COUNT                   /* Number of opcodes available */
115 } opc_t;
116
117 /* Addressing modes (bitmapped). */
118 typedef enum {
119     AM_IMP      = 0x0001,       /* implicit + accumulator */
120     AM_IMM      = 0x0002,       /* immidiate */
121     AM_ZP       = 0x0004,       /* zeropage */
122     AM_ZPX      = 0x0008,       /* zeropage,X */
123     AM_ABS      = 0x0010,       /* absolute */
124     AM_ABSX     = 0x0020,       /* absolute,X */
125     AM_ABSY     = 0x0040,       /* absolute,Y */
126     AM_ZPX_IND  = 0x0080,       /* (zeropage,x) */
127     AM_ZP_INDY  = 0x0100,       /* (zeropage),y */
128     AM_ZP_IND   = 0x0200,       /* (zeropage) */
129     AM_BRA      = 0x0400        /* branch */
130 } am_t;
131
132 /* Opcode description */
133 typedef struct {
134     char        Mnemo[4];       /* Mnemonic */
135     opc_t       OPC;            /* Opcode */
136     unsigned    Usage;          /* Usage flags */
137 } OPCDesc;
138
139
140
141 /*****************************************************************************/
142 /*                                   Code                                    */
143 /*****************************************************************************/
144
145
146
147 const OPCDesc* FindOpcode (const char* OPC);
148 /* Find the given opcode and return the opcode description. If the opcode was
149  * not found, NULL is returned.
150  */
151
152 unsigned GetInsnSize (opc_t OPC, am_t AM);
153 /* Return the size of the given instruction */
154
155 const OPCDesc* GetOPCDesc (opc_t OPC);
156 /* Get an opcode description */
157
158
159
160 /* End of opcodes.h */
161 #endif
162
163
164