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";
18 foreach $arg ( @ARGV ) {
19 if ( $arg =~ /^\-/ ) {
20 if ( $arg =~ /^\-([adins])$/ ) {
23 die "$0: Unknown option: ${arg}\n";
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";
38 next if (/^\s*$/); # blank lines
39 if ( /^\s*;/ ) # comments
41 if ( /^\s*;\#\s*(.+)/ ) # section subheader
43 print S
"\n\\S{} $1\n\n";
48 unless (/^\s*(\S+)\s+(\S+)\s+(\S+|\[.*\])\s+(\S+)\s*$/) {
49 warn "line $line does not contain four fields\n";
52 my @entry = ($1, $2, $3, $4);
54 $entry[1] =~ s/ignore//;
55 $entry[1] =~ s/void//;
56 $entry[3] =~ s/ignore//;
59 $entry[3] =~ s/,SM2//;
61 $entry[3] =~ s/,AR2//;
62 printf S
"\\c %-16s %-24s %s\n",$entry[0],$entry[1],$entry[3];
68 printf STDERR
"Done: %d instructions\n", $insns;