]> Shamusworld >> Repos - rmac/blob - amode.h
Initial commit for 68020/30/40/60/68881/68882/68851 support.
[rmac] / amode.h
1 //
2 // RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
3 // AMODE.H - Addressing Modes
4 // Copyright (C) 199x Landon Dyer, 2017 Reboot and Friends
5 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
6 // Source utilised with the kind permission of Landon Dyer
7 //
8
9 #ifndef __AMODE_H__
10 #define __AMODE_H__
11
12 #include "rmac.h"
13
14 // 68000 and 68020 addressing modes
15 #define DREG         000                                // Dn
16 #define AREG         010                                // An
17 #define AIND         020                                // (An)
18 #define APOSTINC     030                                // (An)+
19 #define APREDEC      040                                // -(An)
20 #define ADISP        050                                // (d16,An) d16(An)
21 #define AINDEXED     060                                // (d8,An,Xn) d8(An,Xn)
22 #define ABSW         070                                // xxx.W
23 #define ABSL         071                                // xxx or xxx.L
24 #define PCDISP       072                                // (d16,PC) d16(PC)
25 #define PCINDEXED    073                                // (d16,PC,Xn) d16(PC,Xn)
26 #define IMMED        074                                // #data
27 #define ABASE        0100                               // (bd,An,Xn)
28 #define MEMPOST      0101                               // ([bd,An],Xn,od)
29 #define MEMPRE       0102                               // ([bc,An,Xn],od)
30 #define PCBASE       0103                               // (bd,PC,Xn)
31 #define PCMPOST      0104                               // ([bd,PC],Xn,od)
32 #define PCMPRE       0105                               // ([bc,PC,Xn],od)
33 #define AM_USP       0106
34 #define AM_SR        0107
35 #define AM_CCR       0110
36 #define AM_NONE      0111                               // Nothing
37 #define CACHES       0120               // Instruction/Data/Both Caches (IC/DC/BC)
38 #define CREG         0121                               // Control registers (see CREGlut in mach.h)
39 #define FREG         0122               // FPU registers (fp0-fp7)
40 #define FPSCR        0123               // FPU system control registers (fpiar, fpsr, fpcr)
41
42 // Addressing-mode masks
43 #define M_DREG       0x00000001L                // Dn
44 #define M_AREG       0x00000002L                // An
45 #define M_AIND       0x00000004L                // (An)
46 #define M_APOSTINC   0x00000008L                // (An)+
47 #define M_APREDEC    0x00000010L                // -(An)
48 #define M_ADISP      0x00000020L                // (d16,An) d16(An)
49 #define M_AINDEXED   0x00000040L                // (d8,An,Xn) d8(An,Xn)
50 #define M_ABSW       0x00000080L                // xxx.W
51 #define M_ABSL       0x00000100L                // xxx or xxx.L
52 #define M_PCDISP     0x00000200L                // (d16,PC) d16(PC)
53 #define M_PCINDEXED  0x00000400L                // (d16,PC,Xn) d16(PC,Xn)
54 #define M_IMMED      0x00000800L                // #data
55 #define M_ABASE      0x00001000L                // (bd,An,Xn)
56 #define M_MEMPOST    0x00002000L                // ([bd,An],Xn,od)
57 #define M_MEMPRE     0x00004000L                // ([bd,An,Xn],od)
58 #define M_PCBASE     0x00008000L                // (bd,PC,Xn)
59 #define M_PCMPOST    0x00010000L                // ([bd,PC],Xn,od)
60 #define M_PCMPRE     0x00020000L                // ([bc,PC,Xn],od)
61 #define M_AM_USP     0x00040000L                // USP
62 #define M_AM_SR      0x00080000L                // SR
63 #define M_AM_CCR     0x00100000L                // CCR
64 #define M_AM_NONE    0x00200000L                // (nothing)
65 #define M_BITFLD     0x00400000L                // 68020 bitfield
66 #define M_CREG       0x00800000L                // Control registers
67 #define M_FREG       0x01000000L                // FPn
68 #define M_FPSCR      0x02000000L                // fpiar, fpsr, fpcr
69
70 // Addr mode categories
71 #define C_ALL        0x00000FFFL
72 #define C_DATA       0x00000FFDL
73 #define C_MEM        0x00000FFCL
74 #define C_CTRL       0x000007E4L
75 #define C_ALT        0x000001FFL
76 #define C_ALL030     0x0003FFFFL
77 #define C_CTRL030    0x0003F7E4L
78 #define C_DATA030    0x0003FFFDL
79 #define C_MOVES      (M_AIND|M_APOSTINC|M_APREDEC|M_ADISP|M_AINDEXED|M_ABSW|M_ABSL|M_ABASE|M_MEMPRE|M_MEMPOST)
80
81 #define C_ALTDATA    (C_DATA&C_ALT)
82 #define C_ALTMEM     (C_MEM&C_ALT)
83 #define C_ALTCTRL    (C_CTRL&C_ALT)
84 #define C_LABEL      (M_ABSW|M_ABSL)
85 #define C_NONE       M_AM_NONE
86
87 #define C_CREG       (M_AM_USP|M_CREG)
88
89 // Scales
90 #define TIMES1       00000                              // (empty or *1)
91 #define TIMES2       01000                              // *2
92 #define TIMES4       02000                              // *4
93 #define TIMES8       03000                              // *8
94
95 #define M_FC            (M_IMMED|M_DREG|M_CREG)
96 #define M_MRN           (M_DREG|M_AREG|M_CREG)
97
98 //EA extension word
99 #define EXT_D            0x0000                 // Dn
100 #define EXT_A            0x8000                 // An
101 #define EXT_W            0x0000                 // Index Size Sign-Extended Word
102 #define EXT_L            0x0800                 // Index Size Long Word
103 #define EXT_TIMES1   0x0000         // Scale factor 1
104 #define EXT_TIMES2   0x0200         // Scale factor 2
105 #define EXT_TIMES4   0x0400         // Scale factor 4
106 #define EXT_TIMES8   0x0600         // Scale factor 8
107 #define EXT_FULLWORD 0x0100                     // Use full extension word format
108 #define EXT_BS           0x0080                 // Base Register Suppressed
109 #define EXT_IS           0x0040                 // Index Operand Suppressed
110 #define EXT_BDSIZE0  0x0010                     // Base Displacement Size Null (Suppressed)
111 #define EXT_BDSIZEW  0x0020                     // Base Displacement Size Word
112 #define EXT_BDSIZEL  0x0030                     // Base Displacement Size Long
113 #define EXT_IISPRE0  0x0000                     // Indirect and Indexing Operand - No Memory Indirect Action
114 #define EXT_IISPREN  0x0001                     // Indirect and Indexing Operand - Indirect Preindexed with Null Outer Displacement
115 #define EXT_IISPREW  0x0002                     // Indirect and Indexing Operand - Indirect Preindexed with Word Outer Displacement
116 #define EXT_IISPREL  0x0003                     // Indirect and Indexing Operand - Indirect Preindexed with Long Outer Displacement
117 #define EXT_IISPOSN  0x0005                     // Indirect and Indexing Operand - Indirect Postindexed with Null Outer Displacement
118 #define EXT_IISPOSW  0x0006                     // Indirect and Indexing Operand - Indirect Postindexed with Word Outer Displacement
119 #define EXT_IISPOSL  0x0007                     // Indirect and Indexing Operand - Indirect Postindexed with Long Outer Displacement
120 #define EXT_IISNOI0  0x0000                     // Indirect and Indexing Operand - No Memory Indirect Action
121 #define EXT_IISNOIN  0x0001                     // Indirect and Indexing Operand - Memory Indirect with Null Outer Displacement
122 #define EXT_IISNOIW  0x0002                     // Indirect and Indexing Operand - Memory Indirect with Word Outer Displacement
123 #define EXT_IISNOIL  0x0003                     // Indirect and Indexing Operand - Memory Indirect with Long Outer Displacement
124
125 #define EXPRSIZE     128                                // Maximum #tokens in an expression
126
127 // Addressing mode variables, output of amode()
128 extern int nmodes;
129 extern int am0, am1;
130 extern int a0reg, a1reg, a2reg;
131 extern TOKEN a0expr[], a1expr[];
132 extern VALUE a0exval, a1exval;
133 extern WORD a0exattr, a1exattr;
134 extern int a0ixreg, a1ixreg;
135 extern int a0ixsiz, a1ixsiz;
136 extern TOKEN a0oexpr[], a1oexpr[];
137 extern VALUE a0oexval, a1oexval;
138 extern WORD a0oexattr, a1oexattr;
139 extern SYM * a0esym, * a1esym;
140 extern VALUE a0bexval, a1bexval;
141 extern WORD a0bexattr, a1bexattr;
142 extern WORD a0bsize, a1bsize;
143 extern TOKEN a0bexpr[], a1bexpr[];
144 extern WORD a0extension, a1extension;
145
146 // Mnemonic table structure
147 #define MNTAB  struct _mntab
148 MNTAB {
149    WORD mnattr;                                                 // Attributes (CGSPECIAL, SIZN, ...)
150    LONG mn0, mn1;                                               // Addressing modes
151    WORD mninst;                                                 // Instruction mask
152    WORD mncont;                                                 // Continuation (or -1)
153    int (*mnfunc)(WORD, WORD);                   // Mnemonic builder
154 };
155
156 // mnattr:
157 #define CGSPECIAL    0x8000                             // Special (don't parse addr modes)
158
159 // Exported functions
160 int amode(int);
161 int reglist(WORD *);
162 int fpu_reglist_left(WORD *);
163 int fpu_reglist_right(WORD *);
164 #endif // __AMODE_H__
165