int opcode; /* the token, passed from "parser.c" */
int operands; /* number of operands */
long opd[3]; /* bit flags for operand types */
- char *code; /* the code it assembles to */
+ const char *code; /* the code it assembles to */
unsigned long flags; /* some flags */
};
+/*
+ * this define is used to signify the end of an itemplate
+ */
+#define ITEMPLATE_END {-1,-1,{-1,-1,-1},NULL,0}
+
/*
* Instruction template flags. These specify which processor
* targets the instruction is eligible for, whether it is
foreach $j (@$aname) {
print A " $j\n";
}
- print A " {-1}\n};\n\n";
+ print A " ITEMPLATE_END\n};\n\n";
}
print A "struct itemplate *nasm_instructions[] = {\n";
foreach $i (@opcodes, @opcodes_cc) {
foreach $j (@big) {
print D " $j\n";
}
- print D " {-1}\n};\n\n";
+ print D " ITEMPLATE_END\n};\n\n";
for ($c=0; $c<256; $c++) {
$h = sprintf "%02X", $c;
" - don't edit it */\n\n";
print N "/* This file in included by names.c */\n\n";
- print N "static char *insn_names[] = {";
+ print N "const static char *insn_names[] = {";
$first = 1;
foreach $i (@opcodes) {
print N "," if ( !$first );
}
print N "\n};\n\n";
print N "/* Conditional instructions */\n";
- print N "static char *icn[] = {";
+ print N "const static char *icn[] = {";
$first = 1;
foreach $i (@opcodes_cc) {
print N "," if ( !$first );
open OUTPUT,">macros.c" || die "unable to open macros.c\n";
print OUTPUT "/* This file auto-generated from standard.mac by macros.pl" .
-" - don't edit it */\n\n#include <stddef.h>\n\nstatic char *stdmac[] = {\n";
+" - don't edit it */\n\n#include <stddef.h>\n\nconst static char *stdmac[] = {\n";
foreach $fname ( @ARGV ) {
open INPUT,$fname || die "unable to open $fname\n";
* distributed in the NASM archive.
*/
-static char *reg_names[] = { /* register names, as strings */
+const static char *reg_names[] = { /* register names, as strings */
"ah", "al", "ax", "bh", "bl", "bp", "bx", "ch", "cl",
"cr0", "cr2", "cr3", "cr4", "cs", "cx", "dh", "di", "dl", "dr0",
"dr1", "dr2", "dr3", "dr6", "dr7", "ds", "dx", "eax", "ebp",
"xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"
};
-static char *conditions[] = { /* condition code names */
+const static char *conditions[] = { /* condition code names */
"a", "ae", "b", "be", "c", "e", "g", "ge", "l", "le", "na", "nae",
"nb", "nbe", "nc", "ne", "ng", "nge", "nl", "nle", "no", "np",
"ns", "nz", "o", "p", "pe", "po", "s", "z"
static int get_bits (char *value);
static unsigned long get_cpu (char *cpu_str);
-static void report_error (int, char *, ...);
static void parse_cmdline (int, char **);
static void assemble_file (char *);
static int getkw (char *buf, char **value);
static void register_output_formats(void);
+static void report_error (int severity, const char *fmt, ...);
static void usage(void);
static int using_debug_info;
* The option names for the suppressible warnings. As before, entry
* zero does nothing.
*/
-static char *suppressed_names[1+ERR_WARN_MAX] = {
+const static char *suppressed_names[1+ERR_WARN_MAX] = {
NULL, "macro-params", "macro-selfref", "orphan-labels", "number-overflow",
"gnu-elf-extensions"
};
* The explanations for the suppressible warnings. As before, entry
* zero does nothing.
*/
-static char *suppressed_what[1+ERR_WARN_MAX] = {
+const static char *suppressed_what[1+ERR_WARN_MAX] = {
NULL,
"macro calls with wrong no. of params",
"cyclic macro self-references",
static int terminate_after_phase;
int user_nolist = 0; /* fbk 9/2/00 */
-static void nasm_fputs(char *line, FILE *ofile)
+static void nasm_fputs(const char *line, FILE *outfile)
{
- if (ofile) {
- fputs(line, ofile);
- fputc('\n', ofile);
+ if (outfile) {
+ fputs(line, outfile);
+ fputc('\n', outfile);
} else
puts(line);
}
struct textargs
{
- char *label;
+ const char *label;
int value;
};
return -1;
}
-static void report_error (int severity, char *fmt, ...)
+static void report_error (int severity, const char *fmt, ...)
{
va_list ap;
/*
* An error reporting function should look like this.
*/
-typedef void (*efunc) (int severity, char *fmt, ...);
+typedef void (*efunc) (int severity, const char *fmt, ...);
/*
* These are the error severity codes which get passed as the first
* This is a short (one-liner) description of the type of
* output generated by the driver.
*/
- char *fullname;
+ const char *fullname;
/*
* This is a single keyword used to select the driver.
*/
- char *shortname;
+ const char *shortname;
/*
* this is reserved for out module specific help.
* It is set to NULL in all the out modules but is not implemented
* in the main program
*/
- char *helpstring;
+ const char *helpstring;
/*
* this is a pointer to the first element of the debug information
* This is a short (one-liner) description of the type of
* output generated by the driver.
*/
- char *fullname;
+ const char *fullname;
/*
* This is a single keyword used to select the driver.
*/
- char *shortname;
+ const char *shortname;
/*
* by the scanner.
*/
#include "names.c"
-static char *special_names[] = {
+const static char *special_names[] = {
"byte", "dword", "far", "long", "near", "nosplit", "qword",
"short", "to", "tword", "word"
};
-static char *prefix_names[] = {
+const static char *prefix_names[] = {
"a16", "a32", "lock", "o16", "o32", "rep", "repe", "repne",
"repnz", "repz", "times"
};
return rslt;
}
-void null_debug_routine()
+void null_debug_routine(void)
{
}
+
struct dfmt null_debug_form = {
"Null debug format",
"null",
char *nasm_strcat(char *one, char *two);
void nasmlib_cleanup(void);
-void null_debug_routine();
+void null_debug_routine(void);
extern struct dfmt null_debug_form;
extern struct dfmt *null_debug_arr[2];
#endif
standard_extension (inname, outname, ".o", error);
}
-static char *aout_stdmac[] = {
+const static char *aout_stdmac[] = {
"%define __SECT__ [section .text]",
"%macro __NASM_CDecl__ 1",
"%endmacro",
r->target = s;
}
-static struct Section *find_section_by_name(char *name)
+static struct Section *find_section_by_name(const char *name)
{
struct Section *s;
standard_extension (inname, outname, "", error);
}
-static char *bin_stdmac[] = {
+const static char *bin_stdmac[] = {
"%define __SECT__ [section .text]",
"%imacro org 1+.nolist",
"[org %1]",
standard_extension (inname, outname, ".obj", error);
}
-static char *coff_stdmac[] = {
+const static char *coff_stdmac[] = {
"%define __SECT__ [section .text]",
"%macro __NASM_CDecl__ 1",
"%endmacro",
standard_extension (inname, outname, ".o", error);
}
-static char *elf_stdmac[] = {
+const static char *elf_stdmac[] = {
"%define __SECT__ [section .text]",
"%macro __NASM_CDecl__ 1",
"%define $_%1 $%1",
attrs = 0;
while (*name == '.')
name++; /* hack, but a documented one */
- p = name;
+ p = name;
while (*p && !isspace(*p))
p++;
if (*p) {
return segment; /* no special treatment */
}
-static void obj_filename (char *inname, char *outname, efunc error)
+static void obj_filename (char *inname, char *outname, efunc lerror)
{
strcpy(obj_infile, inname);
- standard_extension (inname, outname, ".obj", error);
+ standard_extension (inname, outname, ".obj", lerror);
}
static void obj_write_file (int debuginfo)
fputc ( (-cksum) & 0xFF, ofp);
}
-static char *obj_stdmac[] = {
+static const char *obj_stdmac[] = {
"%define __SECT__ [section .text]",
"%imacro group 1+.nolist",
"[group %1]",
}
else /* it's a register */
{
- int i;
-
if (value->type>=EXPR_SIMPLE || value->value!=1) {
error (ERR_NONFATAL, "invalid operand type");
result->opcode = -1;
* we treat CXZ and ECXZ as condition codes, albeit non-invertible
* ones, so we need a different enum...
*/
-static char *conditions[] = {
+const static char *conditions[] = {
"a", "ae", "b", "be", "c", "cxz", "e", "ecxz", "g", "ge", "l", "le",
"na", "nae", "nb", "nbe", "nc", "ne", "ng", "nge", "nl", "nle", "no",
"np", "ns", "nz", "o", "p", "pe", "po", "s", "z"
/*
* Directive names.
*/
-static char *directives[] = {
+const static char *directives[] = {
"%arg",
"%assign", "%clear", "%define", "%elif", "%elifctx", "%elifdef",
"%elifid", "%elifidn", "%elifidni", "%elifmacro", "%elifnctx", "%elifndef",
TM_IFNDEF, TM_INCLUDE, TM_LOCAL
};
-static char *tasm_directives[] = {
+const static char *tasm_directives[] = {
"arg", "elif", "else", "endif", "if", "ifdef", "ifdifi",
"ifndef", "include", "local"
};