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