]> Shamusworld >> Repos - rmac/blob - rmac.h
Bumping the patch level for the last commit. :-P
[rmac] / rmac.h
1 //
2 // RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
3 // RMAC.H - Main Application Code
4 // Copyright (C) 199x Landon Dyer, 2011 Reboot & 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 __RMAC_H__
10 #define __RMAC_H__
11
12 //
13 // TARGET SPECIFIC BUILD SETTINGS
14 //
15 #if defined(WIN32) || defined (WIN64)
16         // Release platform - windows
17         #define PLATFORM        "Win32"
18         #define _OPEN_FLAGS     _O_TRUNC|_O_CREAT|_O_BINARY|_O_RDWR
19         #define _OPEN_INC       _O_RDONLY|_O_BINARY
20         #define _PERM_MODE      _S_IREAD|_S_IWRITE 
21         #ifdef _MSC_VER
22                 #if _MSC_VER > 1000
23                         #pragma warning(disable:4996)
24                 #endif
25
26         // Makes warnings double clickable on visual studio (ggn)
27         #define STRINGIZE_HELPER(x) #x
28         #define STRINGIZE(x) STRINGIZE_HELPER(x)
29         #define WARNING(desc) __pragma(message(__FILE__ "(" STRINGIZE(__LINE__) ") : Warning: " #desc))
30
31         // usage:
32         // WARNING(FIXME: Code removed because...)
33
34         #else
35         //If we're not compiling for Visual Studio let's assume that we're using
36         //some flavour of gcc instead. So let's use the gcc compliant macro instead.
37         //If some weirdo uses something else (I dunno, Intel compiler or something?)
38         //this is probably going to explode spectacularly. Let's wait for the fireworks!
39         #define DO_PRAGMA(x) _Pragma (#x)
40         #define WARNING(desc) DO_PRAGMA(message (#desc))
41
42         #endif
43         #include <io.h>
44         #include <fcntl.h>
45         #include <stdio.h>
46         #include <stdlib.h>
47         #include <string.h>
48         #include <ctype.h>
49         #include <sys/types.h>
50         #include <sys/stat.h>
51
52 #else 
53         #ifdef __GCCUNIX__
54         // Release platform - mac OS-X or linux
55         #define PLATFORM        "OSX/Linux"
56         #define _OPEN_FLAGS     O_TRUNC|O_CREAT|O_RDWR
57         #define _OPEN_INC       O_RDONLY
58         #define _PERM_MODE      S_IREAD|S_IWRITE 
59         // WARNING WARNING WARNING
60         #define DO_PRAGMA(x) _Pragma (#x)
61         #define WARNING(desc) DO_PRAGMA(message (#desc))
62         #include <sys/fcntl.h>
63         #include <stdio.h>
64         #include <stdlib.h>
65         #include <string.h>
66         #include <ctype.h>
67         #include <sys/types.h>
68         #include <sys/stat.h>
69         #include <unistd.h>
70 #else
71         // Release platform - not specified 
72         #define PLATFORM        "Unknown"
73         #define _OPEN_FLAGS     O_TRUNC|O_CREAT|O_RDWR
74         #define _OPEN_INC       O_RDONLY
75         #define _PERM_MODE      S_IREAD|S_IWRITE 
76         // Defined here, even though the platfrom may not support it...
77         #define DO_PRAGMA(x) _Pragma (#x)
78         #define WARNING(desc) DO_PRAGMA(message (#desc))
79         #include <sys/fcntl.h>
80         #include <stdio.h>
81         #include <stdlib.h>
82         #include <string.h>
83         #include <ctype.h>
84         #include <sys/types.h>
85         #include <sys/stat.h>
86         #endif
87 #endif
88
89 //
90 // Non-target specific stuff
91 //
92 #include <inttypes.h>
93 #include "symbol.h"
94
95 #define BYTE         uint8_t
96 #define WORD         uint16_t
97 #define LONG         uint32_t
98 #define VOID         void
99
100 #define ERROR        (-1)                       // Generic error return
101 #define EOS          '\0'                       // End of string
102 #define SPACE        ' '                        // ASCII space 
103 #define SLASHCHAR    '/'
104 #define SLASHSTRING  "/"
105 #define VALUE        LONG                       // Assembler value
106 #define TOKEN        LONG                       // Assembler token
107 #define FNSIZ        128                        // Maximum size of a filename
108 #define OK           0                          // OK return
109 #define DEBUG        if (debug)         // Debug conditional
110 #define MAXARGV      100                        // Maximum number of commandline args
111 #define STDOUT       1                          // Standard output
112 #define ERROUT       2                          // Error output
113 #define CREATMASK    0
114
115 // (Normally) non-printable tokens
116 #define COLON        ':'                        // : (grumble: GNUmacs hates ':')
117 #define CONST        'a'                        // CONST <value>
118 #define ACONST       'A'                        // ACONST <value> <attrib>
119 #define STRING       'b'                        // STRING <address>
120 #define SYMBOL       'c'                        // SYMBOL <address>
121 #define EOL          'e'                        // End of line
122 #define TKEOF        'f'                        // End of file (or macro)
123 #define DEQUALS      'g'                        // ==
124 #define SET          149                        // set
125 #define REG          'R'                        // reg
126 #define EQUREG       148                        // equreg
127 #define CCDEF        183                        // ccdef
128 #define DCOLON       'h'                        // ::
129 #define GE           'i'                        // >=
130 #define LE           'j'                        // <=
131 #define NE           'k'                        // <> or !=
132 #define SHR          'l'                        // >>
133 #define SHL          'm'                        // <<
134 #define UNMINUS      'n'                        // Unary '-'
135 #define DOTB         'B'                        // .b or .B or .s or .S
136 #define DOTW         'W'                        // .w or .W
137 #define DOTL         'L'                        // .l or .L
138 #define DOTI         'I'                        // .i or .I
139 #define ENDEXPR      'E'                        // End of expression
140
141 // Object code formats
142 #define ALCYON       0                          // Alcyon/DRI C object format
143 #define MWC          1                          // Mark Williams object format
144 #define BSD          2                          // BSD object format
145
146 // Pointer type that can point to (almost) anything
147 #define PTR union _ptr
148 PTR
149 {
150    char * cp;                                           // Char
151    WORD * wp;                                           // WORD
152    LONG * lp;                                           // LONG
153    LONG lw;                                                     // LONG
154    SYM ** sy;                                           // SYM
155    TOKEN * tk;                                          // TOKEN
156 };
157
158 // Symbol spaces
159 #define LABEL        0                          // User-defined symbol
160 #define MACRO        1                          // Macro definition
161 #define MACARG       2                          // Macro argument
162 #define SY_UNDEF     -1                         // Undefined (lookup never matches it)
163
164 // Symbol and expression attributes
165 #define DEFINED      0x8000                     // Symbol has been defined
166 #define GLOBAL       0x4000                     // Symbol has been .GLOBL'd
167 #define COMMON       0x2000                     // Symbol has been .COMM'd
168 #define REFERENCED   0x1000                     // Symbol has been referenced
169 #define EQUATED      0x0800                     // Symbol was equated
170 #define SDECLLIST    0x0400                     // Symbol is on 'sdecl'-order list
171
172 // Expression spaces, ORed with symbol and expression attributes above
173 #define ABS          0x0000                     // In absolute space
174 #define TEXT         0x0001                     // Relative to text
175 #define DATA         0x0002                     // Relative to data
176 #define BSS          0x0004                     // Relative to BSS
177 //#define M6502        0x0008           // 6502/microprocessor (absolute)
178 #define TDB          (TEXT|DATA|BSS)    // Mask for text+data+bss
179
180 // Sizes 
181 #define SIZB         0x0001                     // .b 
182 #define SIZW         0x0002                     // .w 
183 #define SIZL         0x0004                     // .l 
184 #define SIZN         0x0008                     // no .(size) specifier
185
186 // RISC register bank definitions (used in extended symbol attributes also)
187 #define BANK_N       0x0000                     // No register bank specified
188 #define BANK_0       0x0001                     // Register bank zero specified
189 #define BANK_1       0x0002                     // Register bank one specified
190 #define EQUATEDREG   0x0008                     // Equated register symbol
191 #define UNDEF_EQUR   0x0010
192 #define EQUATEDCC    0x0020
193 #define UNDEF_CC     0x0040
194
195 //#define RISCSYM      0x00010000
196
197 // Globals, externals, etc.
198 extern int verb_flag;
199 extern int debug;
200 extern int rgpu, rdsp;
201 extern int err_flag;
202 extern int err_fd;
203 extern int regbank;
204 extern char * firstfname;
205 extern int list_fd;
206 extern int as68_flag;
207 extern int list_flag;
208 extern int glob_flag;
209 extern int lsym_flag;
210 extern int sbra_flag;
211 extern int obj_format;
212 extern int legacy_flag;
213
214 // Exported functions
215 char * fext(char *, char *, int);
216 int nthpath(char *, int, char *);
217
218 #endif // __RMAC_H__
219