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