1 /*****************************************************************************/
5 /* Object file options for the ca65 macroassembler */
9 /* (C) 1998 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@musoftware.de */
15 /* This software is provided 'as-is', without any expressed or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
32 /*****************************************************************************/
36 #include "../common/optdefs.h"
37 #include "../common/xmalloc.h"
45 /*****************************************************************************/
47 /*****************************************************************************/
52 static Option* OptRoot = 0;
53 static Option* OptLast = 0;
54 static unsigned OptCount = 0;
58 /*****************************************************************************/
60 /*****************************************************************************/
64 static Option* NewOption (unsigned char Type)
65 /* Create a new option, insert it into the list and return it */
70 Opt = xmalloc (sizeof (*Opt));
72 /* Initialize fields */
77 /* Insert it into the list */
85 /* One more option now */
88 /* Return the new struct */
94 void OptStr (unsigned char Type, const char* Text)
95 /* Add a string option */
99 /* String must have less than 255 bytes */
100 if (strlen (Text) > 255) {
101 Fatal (FAT_STRING_TOO_LONG);
103 O = NewOption (Type);
104 O->V.Str = xstrdup (Text);
109 void OptComment (const char* Comment)
112 OptStr (OPT_COMMENT, Comment);
117 void OptAuthor (const char* Author)
118 /* Add an author statement */
120 OptStr (OPT_AUTHOR, Author);
125 void OptTranslator (const char* Translator)
126 /* Add a translator option */
128 OptStr (OPT_TRANSLATOR, Translator);
133 void OptCompiler (const char* Compiler)
134 /* Add a compiler option */
136 OptStr (OPT_COMPILER, Compiler);
141 void OptOS (const char* OS)
142 /* Add an operating system option */
149 void OptDateTime (unsigned long DateTime)
150 /* Add a date/time option */
152 Option* O = NewOption (OPT_DATETIME);
158 void WriteOptions (void)
159 /* Write the options to the object file */
163 /* Tell the object file module that we're about to start the options */
166 /* Write the option count */
167 ObjWrite16 (OptCount);
169 /* Walk through the list and write the options */
173 /* Write the type of the option */
176 /* Write the argument */
177 switch (O->Type & OPT_ARGMASK) {
180 ObjWriteStr (O->V.Str);
184 ObjWrite32 (O->V.Val);
188 Internal ("Invalid option type: $%02X", O->Type & 0xFF);
197 /* Done writing options */