1 /*
2 ** cpu.h 650x/651x cpu-description header-file
3 ** (c) in 2002,2008,2009,2014 by Frank Wille
4 */
5 
6 #define BIGENDIAN 0
7 #define LITTLEENDIAN 1
8 #define VASM_CPU_650X 1
9 
10 /* maximum number of operands for one mnemonic */
11 #define MAX_OPERANDS 2
12 
13 /* maximum number of mnemonic-qualifiers per mnemonic */
14 #define MAX_QUALIFIERS 0
15 
16 /* data type to represent a target-address */
17 typedef int16_t taddr;
18 typedef uint16_t utaddr;
19 
20 /* minimum instruction alignment */
21 #define INST_ALIGN 1
22 
23 /* default alignment for n-bit data */
24 #define DATA_ALIGN(n) 1
25 
26 /* operand class for n-bit data definitions */
27 #define DATA_OPERAND(n) DATAOP
28 
29 /* returns true when instruction is valid for selected cpu */
30 #define MNEMONIC_VALID(i) cpu_available(i)
31 
32 /* we define two additional unary operations, '<' and '>' */
33 int ext_unary_eval(int,taddr,taddr *,int);
34 int ext_find_base(symbol **,expr *,section *,taddr);
35 #define LOBYTE (LAST_EXP_TYPE+1)
36 #define HIBYTE (LAST_EXP_TYPE+2)
37 #define EXT_UNARY_NAME(s) (*s=='<'||*s=='>')
38 #define EXT_UNARY_TYPE(s) (*s=='<'?LOBYTE:HIBYTE)
39 #define EXT_UNARY_EVAL(t,v,r,c) ext_unary_eval(t,v,r,c)
40 #define EXT_FIND_BASE(b,e,s,p) ext_find_base(b,e,s,p)
41 
42 /* type to store each operand */
43 typedef struct {
44   int type;
45   expr *value;
46 } operand;
47 
48 
49 /* additional mnemonic data */
50 typedef struct {
51   unsigned char opcode;
52   unsigned char zp_opcode;  /* !=0 means optimization to zero page allowed */
53   uint16_t available;
54 } mnemonic_extension;
55 
56 /* available */
57 #define M6502    1       /* standard 6502 instruction set */
58 #define ILL      2       /* illegal 6502 instructions */
59 #define DTV      4       /* C64 DTV instruction set extension */
60 #define M65C02   8       /* 65C02 instruction set */
61 
62 
63 /* adressing modes */
64 #define IMPLIED  0
65 #define ABS      1       /* $1234 */
66 #define ABSX     2       /* $1234,X */
67 #define ABSY     3       /* $1234,Y */
68 #define INDIR    4       /* ($1234) - JMP only */
69 #define INDX     5       /* ($12,X) */
70 #define INDY     6       /* ($12),Y */
71 #define DPINDIR  7       /* ($12) */
72 #define INDIRX   8       /* ($1234,X) */
73 #define ZPAGE    9       /* add ZPAGE-ABS to optimize ABS/ABSX/ABSY */
74 #define ZPAGEX   10
75 #define ZPAGEY   11
76 #define RELJMP   12      /* B!cc/JMP construction */
77 #define REL      13      /* $1234 - relative branch */
78 #define IMMED    14      /* #$12 */
79 #define DATAOP   15      /* data operand */
80 #define ACCU     16      /* A */
81 #define DUMX     17      /* dummy X as 'second' operand */
82 #define DUMY     18      /* dummy Y as 'second' operand */
83 
84 
85 /* exported by cpu.c */
86 int cpu_available(int);
87