Fixed distinction between [LOCAL]SYMBOL/IMMEDIATE for RIP-relative addressing.
[nasm.git] / macros.pl
blob0934d1741c85bb2b9ddf60c46b4c5cdebb99d188
1 #!/usr/bin/perl -w
2 #
3 # macros.pl produce macros.c from standard.mac
5 # The Netwide Assembler is copyright (C) 1996 Simon Tatham and
6 # Julian Hall. All rights reserved. The software is
7 # redistributable under the licence given in the file "Licence"
8 # distributed in the NASM archive.
10 use strict;
12 my $fname;
13 my $line = 0;
14 my $index = 0;
15 my $tasm_count;
17 undef $tasm_count;
19 open(OUTPUT,">macros.c") or die "unable to open macros.c\n";
21 print OUTPUT "/* This file auto-generated from standard.mac by macros.pl" .
22 " - don't edit it */\n\n#include <stddef.h>\n\nstatic const char *stdmac[] = {\n";
24 foreach $fname ( @ARGV ) {
25 open(INPUT,$fname) or die "unable to open $fname\n";
26 while (<INPUT>) {
27 $line++;
28 chomp;
29 if (m/^\s*\*END\*TASM\*MACROS\*\s*$/) {
30 $tasm_count = $index;
31 } elsif (m/^\s*((\s*([^\"\';\s]+|\"[^\"]*\"|\'[^\']*\'))*)\s*(;.*)?$/) {
32 $_ = $1;
33 s/\\/\\\\/g;
34 s/"/\\"/g;
35 if (length > 0) {
36 print OUTPUT " \"$_\",\n";
37 $index++;
39 } else {
40 die "$fname:$line: error unterminated quote";
43 close(INPUT);
45 print OUTPUT " NULL\n};\n";
46 $tasm_count = $index unless ( defined($tasm_count) );
47 print OUTPUT "#define TASM_MACRO_COUNT $tasm_count\n";
48 close(OUTPUT);