diff options
author | Charles Crayne <chuck@thor.crayne.org> | 2008-01-20 16:27:03 -0800 |
---|---|---|
committer | Charles Crayne <chuck@thor.crayne.org> | 2008-01-20 16:27:03 -0800 |
commit | c17a0eb31b109af863bc7fb5b9e80172d11d4c75 (patch) | |
tree | 15637d263dad4643a11cdcbb92e68c78258ce40a /doc | |
parent | e6c01e659e21f10ad38ad18c304f3b3bbab2a9ff (diff) | |
download | nasm-c17a0eb31b109af863bc7fb5b9e80172d11d4c75.tar.gz nasm-c17a0eb31b109af863bc7fb5b9e80172d11d4c75.tar.bz2 nasm-c17a0eb31b109af863bc7fb5b9e80172d11d4c75.zip |
Add autogenerated instruction list to NASM documentation
1. Allow included files in rdsrc.pl
2. New program inslist.pl to generate instruction list from insns.dat
3. Mark certain comments in insns.dat as documentation subheaders
4. Add Instruction List appendix to nasmdoc.src
5. Update build process to invoke inslist.pl
Diffstat (limited to 'doc')
-rw-r--r-- | doc/Makefile.in | 3 | ||||
-rw-r--r-- | doc/inslist.pl | 66 | ||||
-rw-r--r-- | doc/makedocs.bat | 1 | ||||
-rw-r--r-- | doc/nasmdoc.src | 11 | ||||
-rw-r--r-- | doc/rdsrc.pl | 43 |
5 files changed, 114 insertions, 10 deletions
diff --git a/doc/Makefile.in b/doc/Makefile.in index 5c2f905..e0e245e 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -33,8 +33,9 @@ all: $(OUT) os2: nasm.inf # Consider html, txt and ps output a side effect -nasmdoc.dip: nasmdoc.src rdsrc.pl +nasmdoc.dip: nasmdoc.src rdsrc.pl inslist.pl ../insns.dat mkdir -p html + $(PERL) $(srcdir)/inslist.pl $(PERL) $(srcdir)/rdsrc.pl < $< mv -f *.html html diff --git a/doc/inslist.pl b/doc/inslist.pl new file mode 100644 index 0000000..8cab04b --- /dev/null +++ b/doc/inslist.pl @@ -0,0 +1,66 @@ +#!/usr/bin/perl +# +# inslist.pl produce inslist.src +# +# The Netwide Assembler is copyright (C) 1996 Simon Tatham and +# Julian Hall. All rights reserved. The software is +# redistributable under the licence given in the file "Licence" +# distributed in the NASM archive. + +# Opcode prefixes which need their own opcode tables +# LONGER PREFIXES FIRST! +@disasm_prefixes = qw(0F24 0F25 0F38 0F3A 0F7A 0FA6 0FA7 0F); + +print STDERR "Reading insns.dat...\n"; + +@args = (); +undef $output; +foreach $arg ( @ARGV ) { + if ( $arg =~ /^\-/ ) { + if ( $arg =~ /^\-([adins])$/ ) { + $output = $1; + } else { + die "$0: Unknown option: ${arg}\n"; + } + } else { + push (@args, $arg); + } +} + +$fname = "../insns.dat" unless $fname = $args[0]; +open (F, $fname) || die "unable to open $fname"; +print STDERR "Writing inslist.src...\n"; +open S, ">inslist.src"; +$line = 0; +$insns = 0; +while (<F>) { + $line++; + if ( /^\s*;/ ) # comments + { + if ( /^\s*;\#\s*(.+)/ ) # section subheader + { + print S "\n\\S{} $1\n\n"; + } + next; + } + chomp; + my @entry = split; + next if $#entry == -1; # blank lines + (warn "line $line does not contain four fields\n"), next if $#entry != 3; + + @entry[1] =~ s/ignore//; + @entry[1] =~ s/void//; + @entry[3] =~ s/ignore//; + @entry[3] =~ s/,SB//; + @entry[3] =~ s/,SM//; + @entry[3] =~ s/,SM2//; + @entry[3] =~ s/,SQ//; + @entry[3] =~ s/,AR2//; + printf S "\\c %-16s %-24s %s\n",@entry[0],@entry[1],@entry[3]; + $insns++; +} +print S "\n"; +close S; +close F; +printf STDERR "Done: %d instructions\n", $insns; + diff --git a/doc/makedocs.bat b/doc/makedocs.bat index 70db811..5372394 100644 --- a/doc/makedocs.bat +++ b/doc/makedocs.bat @@ -39,6 +39,7 @@ echo This takes a while. Stretch! echo. echo. +perl inslist.pl perl rdsrc.pl<nasmdoc.src echo. echo. diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src index ad79744..a86ca8d 100644 --- a/doc/nasmdoc.src +++ b/doc/nasmdoc.src @@ -6880,3 +6880,14 @@ developer's site at and we'll try to fix them. Feel free to send contributions and new features as well. +\A{inslist} \i{Instruction List} + +\H{inslistintro} Introduction + +The following sections show the instructions which NASM currently supports. For each +instruction, there is a separate entry for each supported addressing mode. The third +column shows the processor type in which the instruction was introduced and, + when appropriate, one or more usage flags. + +\& inslist.src + diff --git a/doc/rdsrc.pl b/doc/rdsrc.pl index 4965172..a6a7008 100644 --- a/doc/rdsrc.pl +++ b/doc/rdsrc.pl @@ -79,6 +79,12 @@ # defines document metadata, such as authorship, title and copyright; # different output formats use this differently. # +# Include subfile +# \&{filename} +# Includes filename. Recursion is allowed. +# + +use IO::File; $diag = 1, shift @ARGV if $ARGV[0] eq "-d"; @@ -96,15 +102,7 @@ $pname = "para000000"; @pnames = @pflags = (); $para = undef; while (<>) { - chomp; - if (!/\S/ || /^\\(IA|IR|M)/) { # special case: \IA \IR \M imply new-paragraph - &got_para($para); - $para = undef; - } - if (/\S/) { - s/\\#.*$//; # strip comments - $para .= " " . $_; - } + &check_include($_); } &got_para($para); print "done.\n"; @@ -143,6 +141,33 @@ print "Producing Documentation Intermediate Paragraphs: "; &write_dip; print "done.\n"; +sub check_include { + local $_ = shift; + if (/\\& (\S+)/) { + &include($1); + } else { + &get_para($_); + } +} +sub get_para($_) { + chomp; + if (!/\S/ || /^\\(IA|IR|M)/) { # special case: \IA \IR \M imply new-paragraph + &got_para($para); + $para = undef; + } + if (/\S/) { + s/\\#.*$//; # strip comments + $para .= " " . $_; + } +} +sub include { + my $name = shift; + my $F = IO::File->new($name) + or die "Cannot open $name: $!"; + while (<$F>) { + &check_include($_); + } +} sub got_para { local ($_) = @_; my $pflags = "", $i, $w, $l, $t; |