NASM 2.03rc6
[nasm/avx512.git] / doc / inslist.pl
blob7b5603874a41f4bf1a2b18a2e4e3367259bc9764
1 #!/usr/bin/perl
3 # inslist.pl produce inslist.src
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 # Opcode prefixes which need their own opcode tables
11 # LONGER PREFIXES FIRST!
12 @disasm_prefixes = qw(0F24 0F25 0F38 0F3A 0F7A 0FA6 0FA7 0F);
14 print STDERR "Reading insns.dat...\n";
16 @args = ();
17 undef $output;
18 foreach $arg ( @ARGV ) {
19 if ( $arg =~ /^\-/ ) {
20 if ( $arg =~ /^\-([adins])$/ ) {
21 $output = $1;
22 } else {
23 die "$0: Unknown option: ${arg}\n";
25 } else {
26 push (@args, $arg);
30 $fname = "../insns.dat" unless $fname = $args[0];
31 open (F, $fname) || die "unable to open $fname";
32 print STDERR "Writing inslist.src...\n";
33 open S, ">inslist.src";
34 $line = 0;
35 $insns = 0;
36 while (<F>) {
37 $line++;
38 next if (/^\s*$/); # blank lines
39 if ( /^\s*;/ ) # comments
41 if ( /^\s*;\#\s*(.+)/ ) # section subheader
43 print S "\n\\S{} $1\n\n";
45 next;
47 chomp;
48 unless (/^\s*(\S+)\s+(\S+)\s+(\S+|\[.*\])\s+(\S+)\s*$/) {
49 warn "line $line does not contain four fields\n";
50 next;
52 my @entry = ($1, $2, $3, $4);
54 $entry[1] =~ s/ignore//;
55 $entry[1] =~ s/void//;
56 $entry[3] =~ s/ignore//;
57 $entry[3] =~ s/,SB//;
58 $entry[3] =~ s/,SM//;
59 $entry[3] =~ s/,SM2//;
60 $entry[3] =~ s/,SQ//;
61 $entry[3] =~ s/,AR2//;
62 printf S "\\c %-16s %-24s %s\n",$entry[0],$entry[1],$entry[3];
63 $insns++;
65 print S "\n";
66 close S;
67 close F;
68 printf STDERR "Done: %d instructions\n", $insns;