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
13 // TARGET SPECIFIC BUILD SETTINGS
16 #define PLATFORM "Win32" // Release platform - windows
17 #define _OPEN_FLAGS _O_TRUNC|_O_CREAT|_O_BINARY|_O_RDWR
18 #define _OPEN_INC _O_RDONLY|_O_BINARY
19 #define _PERM_MODE _S_IREAD|_S_IWRITE
22 #pragma warning(disable:4996)
31 #include <sys/types.h>
35 #define PLATFORM "OSX/Linux" // Release platform - mac OS-X or linux
36 #define _OPEN_FLAGS O_TRUNC|O_CREAT|O_RDWR
37 #define _OPEN_INC O_RDONLY
38 #define _PERM_MODE S_IREAD|S_IWRITE
39 #include <sys/fcntl.h>
44 #include <sys/types.h>
48 #define PLATFORM "Unknown" // Release platform - not specified
49 #define _OPEN_FLAGS O_TRUNC|O_CREAT|O_RDWR
50 #define _OPEN_INC O_RDONLY
51 #define _PERM_MODE S_IREAD|S_IWRITE
52 #include <sys/fcntl.h>
57 #include <sys/types.h>
63 // Non-target specific stuff
73 #define ERROR (-1) // Generic error return
74 #define EOS '\0' // End of string
75 #define SPACE ' ' // Ascii space
77 #define SLASHSTRING "/"
78 #define VALUE LONG // Assembler value
79 #define TOKEN LONG // Assembler token
80 #define FNSIZ 128 // Maximum size of a filename
81 #define OK 0 // OK return
82 #define DEBUG if (debug) // Debug conditional
83 #define MAXARGV 100 // Maximum number of commandline args
84 #define STDOUT 1 // Standard output
85 #define ERROUT 2 // Error output
88 // (Normally) non-printable tokens
89 #define COLON ':' // : (grumble: GNUmacs hates ':')
90 #define CONST 'a' // CONST <value>
91 #define ACONST 'A' // ACONST <value> <attrib>
92 #define STRING 'b' // STRING <address>
93 #define SYMBOL 'c' // SYMBOL <address>
94 #define EOL 'e' // End of line
95 #define TKEOF 'f' // End of file (or macro)
96 #define DEQUALS 'g' // ==
97 #define SET 149 // set
98 #define REG 'R' // reg
99 #define EQUREG 148 // equreg
100 #define CCDEF 183 // ccdef
101 #define DCOLON 'h' // ::
104 #define NE 'k' // <> or !=
105 #define SHR 'l' // >>
106 #define SHL 'm' // <<
107 #define UNMINUS 'n' // Unary '-'
108 #define DOTB 'B' // .b or .B or .s or .S
109 #define DOTW 'W' // .w or .W
110 #define DOTL 'L' // .l or .L
111 #define DOTI 'I' // .i or .I
112 #define ENDEXPR 'E' // End of expression
114 // Object code formats
115 #define ALCYON 0 // Alcyon/DRI C object format
116 #define MWC 1 // Mark Williams object format
117 #define BSD 2 // BSD object format
119 // Pointer type that can point to (almost) anything
120 #define PTR union _ptr
132 #define LABEL 0 // User-defined symbol
133 #define MACRO 1 // Macro definition
134 #define MACARG 2 // Macro argument
135 #define SY_UNDEF -1 // Undefined (lookup never matches it)
137 // Symbol and expression attributes
138 #define DEFINED 0x8000 // Symbol has been defined
139 #define GLOBAL 0x4000 // Symbol has been .GLOBL'd
140 #define COMMON 0x2000 // Symbol has been .COMM'd
141 #define REFERENCED 0x1000 // Symbol has been referenced
142 #define EQUATED 0x0800 // Symbol was equated
143 #define SDECLLIST 0x0400 // Symbol is on 'sdecl'-order list
145 // Expression spaces, ORed with symbol and expression attributes above
146 #define ABS 0x0000 // In absolute space
147 #define TEXT 0x0001 // Relative to text
148 #define DATA 0x0002 // Relative to data
149 #define BSS 0x0004 // Relative to BSS
150 //#define M6502 0x0008 // 6502/microprocessor (absolute)
151 #define TDB (TEXT|DATA|BSS) // Mask for text+data+bss
154 #define SIZB 0x0001 // .b
155 #define SIZW 0x0002 // .w
156 #define SIZL 0x0004 // .l
157 #define SIZN 0x0008 // no .(size) specifier
159 // RISC register bank definitions (used in extended symbol attributes also)
160 #define BANK_N 0x0000 // No register bank specified
161 #define BANK_0 0x0001 // Register bank zero specified
162 #define BANK_1 0x0002 // Register bank one specified
163 #define EQUATEDREG 0x0008 // Equated register symbol
164 #define UNDEF_EQUR 0x0010
165 #define EQUATEDCC 0x0020
166 #define UNDEF_CC 0x0040
168 #define RISCSYM 0x00010000
170 // Globals, externals etc
171 extern int verb_flag;
173 extern int rgpu, rdsp;
177 extern char * firstfname;
179 extern int as68_flag;
180 extern int list_flag;
181 extern int glob_flag;
182 extern int lsym_flag;
183 extern int sbra_flag;
184 extern int obj_format;
190 SYM * newsym(char *, int, int);
191 char * fext(char *, char *, int);
192 void cantcreat(char *);
193 int kmatch(char *, int *, int *, int *, int *);
195 int nthpath(char *, int, char *);
196 void clear(char *, LONG);
197 char * copy(char *, char *, LONG);
198 int rmac_qsort(char *, int, int, int (*)());