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
16 #include <sys/types.h>
20 // TARGET SPECIFIC BUILD SETTINGS
22 #if defined(WIN32) || defined (WIN64)
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
32 #pragma warning(disable:4996)
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))
41 // WARNING(FIXME: Code removed because...)
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
46 // instead. If some weirdo uses something else (I dunno, Intel compiler or
47 // something?) this is probably going to explode spectacularly. Let's wait
49 #define DO_PRAGMA(x) _Pragma (#x)
50 #define WARNING(desc) DO_PRAGMA(message (#desc))
51 #define inline __inline
57 #include <sys/fcntl.h>
59 // Release platform - mac OS-X or linux
60 #define PLATFORM "OSX/Linux"
61 #define _OPEN_FLAGS O_TRUNC|O_CREAT|O_RDWR
62 #define _OPEN_INC O_RDONLY
63 #define _PERM_MODE S_IRUSR|S_IWUSR
64 // WARNING WARNING WARNING
65 #define DO_PRAGMA(x) _Pragma (#x)
66 #define WARNING(desc) DO_PRAGMA(message (#desc))
68 // Release platform - not specified
69 #include <sys/fcntl.h>
70 #define PLATFORM "Unknown"
71 #define _OPEN_FLAGS O_TRUNC|O_CREAT|O_RDWR
72 #define _OPEN_INC O_RDONLY
73 #define _PERM_MODE S_IREAD|S_IWRITE
74 // Defined here, even though the platform may not support it...
75 #define DO_PRAGMA(x) _Pragma (#x)
76 #define WARNING(desc) DO_PRAGMA(message (#desc))
81 // Non-target specific stuff
91 #define ERROR (-1) // Generic error return
92 #define EOS '\0' // End of string
93 #define SPACE ' ' // ASCII space
95 #define SLASHSTRING "/"
96 #define VALUE LONG // Assembler value
97 #define TOKEN LONG // Assembler token
98 #define FNSIZ 128 // Maximum size of a filename
99 #define OK 0 // OK return
100 #define DEBUG if (debug) // Debug conditional
101 #define MAXARGV 100 // Maximum number of commandline args
102 #define STDOUT 1 // Standard output
103 #define ERROUT 2 // Error output
106 // (Normally) non-printable tokens
107 #define COLON ':' // : (grumble: GNUmacs hates ':')
108 #define CONST 'a' // CONST <value>
109 #define ACONST 'A' // ACONST <value> <attrib>
110 #define STRING 'b' // STRING <address>
111 #define SYMBOL 'c' // SYMBOL <address>
112 #define EOL 'e' // End of line
113 #define TKEOF 'f' // End of file (or macro)
114 #define DEQUALS 'g' // ==
115 #define SET 149 // set
116 #define REG 'R' // reg
117 #define EQUREG 148 // equreg
118 #define CCDEF 183 // ccdef
119 #define DCOLON 'h' // ::
122 #define NE 'k' // <> or !=
123 #define SHR 'l' // >>
124 #define SHL 'm' // <<
125 #define UNMINUS 'n' // Unary '-'
126 #define DOTB 'B' // .b or .B or .s or .S
127 #define DOTW 'W' // .w or .W
128 #define DOTL 'L' // .l or .L
129 #define DOTI 'I' // .i or .I
130 #define ENDEXPR 'E' // End of expression
132 // Object code formats
133 #define ALCYON 0 // Alcyon/DRI C object format
134 #define MWC 1 // Mark Williams object format
135 #define BSD 2 // BSD object format
137 // Pointer type that can point to (almost) anything
138 #define PTR union _ptr
150 #define LABEL 0 // User-defined symbol
151 #define MACRO 1 // Macro definition
152 #define MACARG 2 // Macro argument
153 #define SY_UNDEF -1 // Undefined (lookup never matches it)
155 // Symbol and expression attributes
156 #define DEFINED 0x8000 // Symbol has been defined
157 #define GLOBAL 0x4000 // Symbol has been .GLOBL'd
158 #define COMMON 0x2000 // Symbol has been .COMM'd
159 #define REFERENCED 0x1000 // Symbol has been referenced
160 #define EQUATED 0x0800 // Symbol was equated
161 #define SDECLLIST 0x0400 // Symbol is on 'sdecl'-order list
163 // Expression spaces, ORed with symbol and expression attributes above
164 #define ABS 0x0000 // In absolute space
165 #define TEXT 0x0001 // Relative to text
166 #define DATA 0x0002 // Relative to data
167 #define BSS 0x0004 // Relative to BSS
168 //#define M6502 0x0008 // 6502/microprocessor (absolute)
169 #define TDB (TEXT|DATA|BSS) // Mask for text+data+bss
172 #define SIZB 0x0001 // .b
173 #define SIZW 0x0002 // .w
174 #define SIZL 0x0004 // .l
175 #define SIZN 0x0008 // no .(size) specifier
177 // RISC register bank definitions (used in extended symbol attributes also)
178 #define BANK_N 0x0000 // No register bank specified
179 #define BANK_0 0x0001 // Register bank zero specified
180 #define BANK_1 0x0002 // Register bank one specified
181 #define EQUATEDREG 0x0008 // Equated register symbol
182 #define UNDEF_EQUR 0x0010
183 #define EQUATEDCC 0x0020
184 #define UNDEF_CC 0x0040
186 //#define RISCSYM 0x00010000
188 // Optimisation defines
194 OPT_INDIRECT_DISP = 3,
195 OPT_COUNT // Dummy, used to count number of optimisation switches
198 // Globals, externals, etc.
199 extern int verb_flag;
201 extern int rgpu, rdsp;
205 extern char * firstfname;
207 extern int as68_flag;
208 extern int list_flag;
209 extern int glob_flag;
210 extern int lsym_flag;
211 extern int sbra_flag;
212 extern int obj_format;
213 extern int legacy_flag;
214 extern LONG PRGFLAGS;
215 extern int optim_flags[OPT_COUNT];
217 // Exported functions
218 char * fext(char *, char *, int);
219 int nthpath(char *, int, char *);
220 int ParseOptimization(char * optstring);