Makefile: clean up the lib directory on make clean
[nasm/sigaren-mirror.git] / doc / inslist.pl
blob509de000f5ec6b692dc629ac22ea65c2dad6d870
1 #!/usr/bin/perl
2 ## --------------------------------------------------------------------------
3 ##
4 ## Copyright 1996-2009 The NASM Authors - All Rights Reserved
5 ## See the file AUTHORS included with the NASM distribution for
6 ## the specific copyright holders.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted provided that the following
10 ## conditions are met:
12 ## * Redistributions of source code must retain the above copyright
13 ## notice, this list of conditions and the following disclaimer.
14 ## * Redistributions in binary form must reproduce the above
15 ## copyright notice, this list of conditions and the following
16 ## disclaimer in the documentation and/or other materials provided
17 ## with the distribution.
18 ##
19 ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
20 ## CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
21 ## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 ## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 ## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 ## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 ## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 ## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31 ## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ## --------------------------------------------------------------------------
36 # inslist.pl produce inslist.src
39 # Opcode prefixes which need their own opcode tables
40 # LONGER PREFIXES FIRST!
41 @disasm_prefixes = qw(0F24 0F25 0F38 0F3A 0F7A 0FA6 0FA7 0F);
43 print STDERR "Reading insns.dat...\n";
45 @args = ();
46 undef $output;
47 foreach $arg ( @ARGV ) {
48 if ( $arg =~ /^\-/ ) {
49 if ( $arg =~ /^\-([adins])$/ ) {
50 $output = $1;
51 } else {
52 die "$0: Unknown option: ${arg}\n";
54 } else {
55 push (@args, $arg);
59 $fname = "../insns.dat" unless $fname = $args[0];
60 open (F, $fname) || die "unable to open $fname";
61 print STDERR "Writing inslist.src...\n";
62 open S, ">inslist.src";
63 $line = 0;
64 $insns = 0;
65 while (<F>) {
66 $line++;
67 next if (/^\s*$/); # blank lines
68 if ( /^\s*;/ ) # comments
70 if ( /^\s*;\#\s*(.+)/ ) # section subheader
72 print S "\n\\S{} $1\n\n";
74 next;
76 chomp;
77 unless (/^\s*(\S+)\s+(\S+)\s+(\S+|\[.*\])\s+(\S+)\s*$/) {
78 warn "line $line does not contain four fields\n";
79 next;
81 my @entry = ($1, $2, $3, $4);
83 $entry[1] =~ s/ignore//;
84 $entry[1] =~ s/void//;
85 $entry[3] =~ s/ignore//;
86 $entry[3] =~ s/,SB//;
87 $entry[3] =~ s/,SM//;
88 $entry[3] =~ s/,SM2//;
89 $entry[3] =~ s/,SQ//;
90 $entry[3] =~ s/,AR2//;
91 printf S "\\c %-16s %-24s %s\n",$entry[0],$entry[1],$entry[3];
92 $insns++;
94 print S "\n";
95 close S;
96 close F;
97 printf STDERR "Done: %d instructions\n", $insns;