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