summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rw-r--r--misc/Doxyfile752
-rwxr-xr-xmisc/Nindent18
-rw-r--r--misc/README2
-rw-r--r--misc/altreg.inc72
-rw-r--r--misc/c16.mac82
-rw-r--r--misc/c32.mac52
-rwxr-xr-xmisc/cleanfile176
-rwxr-xr-xmisc/cleanpatch258
-rw-r--r--misc/crcgen.c44
-rw-r--r--misc/exebin.mac57
-rw-r--r--misc/exebin2.mac114
-rwxr-xr-xmisc/findleak.pl42
-rw-r--r--misc/findleak.txt59
-rwxr-xr-xmisc/fmtinsns.pl40
-rwxr-xr-xmisc/genfma.pl63
-rw-r--r--misc/hints.txt26
-rw-r--r--misc/magic6
-rwxr-xr-xmisc/makedist.sh71
-rw-r--r--misc/myC32.mac121
-rw-r--r--misc/nasm.sl320
-rw-r--r--misc/nasmstab296
-rw-r--r--misc/omfdump.c223
-rw-r--r--misc/pmw.bat9
-rw-r--r--misc/proc32.ash441
-rwxr-xr-xmisc/release96
-rw-r--r--misc/scitech.mac1223
-rwxr-xr-xmisc/tag-release13
-rw-r--r--misc/xcrcgen.c80
28 files changed, 4756 insertions, 0 deletions
diff --git a/misc/Doxyfile b/misc/Doxyfile
new file mode 100644
index 0000000..1bb1cc3
--- /dev/null
+++ b/misc/Doxyfile
@@ -0,0 +1,752 @@
+# Doxyfile 1.2.5
+
+# This file describes the settings to be used by doxygen for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# General configuration options
+#---------------------------------------------------------------------------
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME = "NASM - the Netwide Assembler"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER = 0.98
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = doxy
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Dutch, French, Italian, Czech, Swedish, German, Finnish, Japanese,
+# Korean, Hungarian, Norwegian, Spanish, Romanian, Russian, Croatian,
+# Polish, Portuguese and Slovene.
+
+OUTPUT_LANGUAGE = English
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = YES
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these class will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. It is allowed to use relative paths in the argument list.
+
+STRIP_FROM_PATH =
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a class diagram (in Html and LaTeX) for classes with base or
+# super classes. Setting the tag to NO turns the diagrams off.
+
+CLASS_DIAGRAMS = YES
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+
+SOURCE_BROWSER = YES
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower case letters. If set to YES upper case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# users are adviced to set this option to NO.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like the Qt-style comments (thus requiring an
+# explict @brief command for a brief description.
+
+JAVADOC_AUTOBRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# reimplements.
+
+INHERIT_DOCS = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 4
+
+# The ENABLE_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consist of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
+# only. Doxygen will then generate output that is more tailored for C.
+# For instance some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text.
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = .
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+FILE_PATTERNS = *.c *.h
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE =
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories.
+
+EXCLUDE_PATTERNS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS =
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+
+INPUT_FILTER =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse.
+
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet
+
+HTML_STYLESHEET =
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE = 4
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript and frames is required (for instance Netscape 4.0+
+# or Internet explorer 4.0+).
+
+GENERATE_TREEVIEW = YES
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = YES
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimised for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = YES
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using a WORD or other.
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assigments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = YES
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_PREDEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED =
+
+#---------------------------------------------------------------------------
+# Configuration::addtions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES tag can be used to specify one or more tagfiles.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = NO
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, INCLUDE_GRAPH, and HAVE_DOT tags are set to
+# YES then doxygen will generate a graph for each documented file showing
+# the direct and indirect include dependencies of the file with other
+# documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, INCLUDED_BY_GRAPH, and HAVE_DOT tags are set to
+# YES then doxygen will generate a graph for each documented header file showing
+# the documented files that directly or indirectly include this file
+
+INCLUDED_BY_GRAPH = YES
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found on the path.
+
+DOT_PATH =
+
+# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than
+# this value, doxygen will try to truncate the graph, so that it fits within
+# the specified constraint. Beware that most browsers cannot cope with very
+# large images.
+
+MAX_DOT_GRAPH_WIDTH = 1024
+
+# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than
+# this value, doxygen will try to truncate the graph, so that it fits within
+# the specified constraint. Beware that most browsers cannot cope with very
+# large images.
+
+MAX_DOT_GRAPH_HEIGHT = 1024
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+#---------------------------------------------------------------------------
+# Configuration::addtions related to the search engine
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE = NO
+
+# The CGI_NAME tag should be the name of the CGI script that
+# starts the search engine (doxysearch) with the correct parameters.
+# A script with this name will be generated by doxygen.
+
+CGI_NAME = search.cgi
+
+# The CGI_URL tag should be the absolute URL to the directory where the
+# cgi binaries are located. See the documentation of your http daemon for
+# details.
+
+CGI_URL =
+
+# The DOC_URL tag should be the absolute URL to the directory where the
+# documentation is located. If left blank the absolute path to the
+# documentation, with file:// prepended to it, will be used.
+
+DOC_URL =
+
+# The DOC_ABSPATH tag should be the absolute path to the directory where the
+# documentation is located. If left blank the directory on the local machine
+# will be used.
+
+DOC_ABSPATH =
+
+# The BIN_ABSPATH tag must point to the directory where the doxysearch binary
+# is installed.
+
+BIN_ABSPATH = /usr/local/bin/
+
+# The EXT_DOC_PATHS tag can be used to specify one or more paths to
+# documentation generated for other projects. This allows doxysearch to search
+# the documentation for these projects as well.
+
+EXT_DOC_PATHS =
diff --git a/misc/Nindent b/misc/Nindent
new file mode 100755
index 0000000..0d75ccc
--- /dev/null
+++ b/misc/Nindent
@@ -0,0 +1,18 @@
+#!/bin/sh
+PARAM="-npro -kr -i4 -ts8 -nut -sob -l80 -ss -ncs -cp1"
+RES=`indent --version`
+V1=`echo $RES | cut -d' ' -f3 | cut -d'.' -f1`
+V2=`echo $RES | cut -d' ' -f3 | cut -d'.' -f2`
+V3=`echo $RES | cut -d' ' -f3 | cut -d'.' -f3`
+if [ $V1 -gt 2 ]; then
+ PARAM="$PARAM -il0"
+elif [ $V1 -eq 2 ]; then
+ if [ $V2 -gt 2 ]; then
+ PARAM="$PARAM -il0";
+ elif [ $V2 -eq 2 ]; then
+ if [ $V3 -ge 10 ]; then
+ PARAM="$PARAM -il0"
+ fi
+ fi
+fi
+exec indent $PARAM "$@"
diff --git a/misc/README b/misc/README
new file mode 100644
index 0000000..f39ba4d
--- /dev/null
+++ b/misc/README
@@ -0,0 +1,2 @@
+There are various helpful bits and pieces for NASM,
+including but not limited to Simon photograph =)
diff --git a/misc/altreg.inc b/misc/altreg.inc
new file mode 100644
index 0000000..9892818
--- /dev/null
+++ b/misc/altreg.inc
@@ -0,0 +1,72 @@
+;;
+;; altreg.inc
+;;
+;; Alternate register names for 64-bit mode
+;;
+
+;;
+;; Intel documents R8L-R15L instead of R8B-R15B
+;; (Warning: this may confuse people with an AT&T-style assembly
+;; background, where "r8l" means R8D, etc.)
+;;
+%idefine r8l r8b
+%idefine r9l r9b
+%idefine r10l r10b
+%idefine r11l r11b
+%idefine r12l r12b
+%idefine r13l r13b
+%idefine r14l r14b
+%idefine r15l r15b
+
+;;
+;; Numeric register names for the lower 8 registers
+;;
+%idefine r0 rax
+%idefine r1 rcx
+%idefine r2 rdx
+%idefine r3 rbx
+%idefine r4 rsp
+%idefine r5 rbp
+%idefine r6 rsi
+%idefine r7 rdi
+
+%idefine r0d eax
+%idefine r1d ecx
+%idefine r2d edx
+%idefine r3d ebx
+%idefine r4d esp
+%idefine r5d ebp
+%idefine r6d esi
+%idefine r7d edi
+
+%idefine r0w ax
+%idefine r1w cx
+%idefine r2w dx
+%idefine r3w bx
+%idefine r4w sp
+%idefine r5w bp
+%idefine r6w si
+%idefine r7w di
+
+%idefine r0b al
+%idefine r1b cl
+%idefine r2b dl
+%idefine r3b bl
+%idefine r4b spl
+%idefine r5b bpl
+%idefine r6b sil
+%idefine r7b dil
+
+%idefine r0l al
+%idefine r1l cl
+%idefine r2l dl
+%idefine r3l bl
+%idefine r4l spl
+%idefine r5l bpl
+%idefine r6l sil
+%idefine r7l dil
+
+%idefine r0h ah
+%idefine r1h ch
+%idefine r2h dh
+%idefine r3h bh
diff --git a/misc/c16.mac b/misc/c16.mac
new file mode 100644
index 0000000..50b5d5e
--- /dev/null
+++ b/misc/c16.mac
@@ -0,0 +1,82 @@
+; NASM macro set to make interfacing to 16-bit programs easier -*- nasm -*-
+
+
+
+%imacro proc 1 ; begin a procedure definition
+
+%push proc
+
+ global %1
+
+%1: push bp
+
+ mov bp,sp
+
+%ifdef FARCODE PASCAL ; arguments may start at bp+4 or bp+6
+
+%assign %$arg 6
+
+%define %$firstarg 6
+
+%else
+
+%assign %$arg 4
+
+%define %$firstarg 4
+
+%endif
+
+%define %$procname %1
+
+%endmacro
+
+
+
+%imacro arg 0-1 2 ; used with the argument name as a label
+
+%00 equ %$arg
+
+ ; we could possibly be adding some
+
+ ; debug information at this point...?
+
+%assign %$arg %1+%$arg
+
+%endmacro
+
+
+
+%imacro endproc 0
+
+%ifnctx proc
+
+%error Mismatched `endproc'/`proc'
+
+%else
+
+ mov sp,bp
+
+ pop bp
+
+%ifdef PASCAL
+
+ retf %$arg - %$firstarg
+
+%elifdef FARCODE
+
+ retf
+
+%else
+
+ retn
+
+%endif
+
+__end_%$procname: ; useful for calculating function size
+
+%pop
+
+%endif
+
+%endmacro
+
diff --git a/misc/c32.mac b/misc/c32.mac
new file mode 100644
index 0000000..f0c116b
--- /dev/null
+++ b/misc/c32.mac
@@ -0,0 +1,52 @@
+; NASM macro set to make interfacing to 32-bit programs easier -*- nasm -*-
+
+
+
+%imacro proc 1 ; begin a procedure definition
+
+%push proc
+
+ global %1
+
+%1: push ebp
+
+ mov ebp,esp
+
+%assign %$arg 8
+
+%define %$procname %1
+
+%endmacro
+
+
+
+%imacro arg 0-1 4 ; used with the argument name as a label
+
+%00 equ %$arg
+
+%assign %$arg %1+%$arg
+
+%endmacro
+
+
+
+%imacro endproc 0
+
+%ifnctx proc
+
+%error Mismatched `endproc'/`proc'
+
+%else
+
+ leave
+
+ ret
+
+__end_%$procname: ; useful for calculating function size
+
+%pop
+
+%endif
+
+%endmacro
+
diff --git a/misc/cleanfile b/misc/cleanfile
new file mode 100755
index 0000000..cefd29e
--- /dev/null
+++ b/misc/cleanfile
@@ -0,0 +1,176 @@
+#!/usr/bin/perl -w
+#
+# Clean a text file -- or directory of text files -- of stealth whitespace.
+# WARNING: this can be a highly destructive operation. Use with caution.
+#
+
+use bytes;
+use File::Basename;
+
+# Default options
+$max_width = 79;
+
+# Clean up space-tab sequences, either by removing spaces or
+# replacing them with tabs.
+sub clean_space_tabs($)
+{
+ no bytes; # Tab alignment depends on characters
+
+ my($li) = @_;
+ my($lo) = '';
+ my $pos = 0;
+ my $nsp = 0;
+ my($i, $c);
+
+ for ($i = 0; $i < length($li); $i++) {
+ $c = substr($li, $i, 1);
+ if ($c eq "\t") {
+ my $npos = ($pos+$nsp+8) & ~7;
+ my $ntab = ($npos >> 3) - ($pos >> 3);
+ $lo .= "\t" x $ntab;
+ $pos = $npos;
+ $nsp = 0;
+ } elsif ($c eq "\n" || $c eq "\r") {
+ $lo .= " " x $nsp;
+ $pos += $nsp;
+ $nsp = 0;
+ $lo .= $c;
+ $pos = 0;
+ } elsif ($c eq " ") {
+ $nsp++;
+ } else {
+ $lo .= " " x $nsp;
+ $pos += $nsp;
+ $nsp = 0;
+ $lo .= $c;
+ $pos++;
+ }
+ }
+ $lo .= " " x $nsp;
+ return $lo;
+}
+
+# Compute the visual width of a string
+sub strwidth($) {
+ no bytes; # Tab alignment depends on characters
+
+ my($li) = @_;
+ my($c, $i);
+ my $pos = 0;
+ my $mlen = 0;
+
+ for ($i = 0; $i < length($li); $i++) {
+ $c = substr($li,$i,1);
+ if ($c eq "\t") {
+ $pos = ($pos+8) & ~7;
+ } elsif ($c eq "\n") {
+ $mlen = $pos if ($pos > $mlen);
+ $pos = 0;
+ } else {
+ $pos++;
+ }
+ }
+
+ $mlen = $pos if ($pos > $mlen);
+ return $mlen;
+}
+
+$name = basename($0);
+
+@files = ();
+
+while (defined($a = shift(@ARGV))) {
+ if ($a =~ /^-/) {
+ if ($a eq '-width' || $a eq '-w') {
+ $max_width = shift(@ARGV)+0;
+ } else {
+ print STDERR "Usage: $name [-width #] files...\n";
+ exit 1;
+ }
+ } else {
+ push(@files, $a);
+ }
+}
+
+foreach $f ( @files ) {
+ print STDERR "$name: $f\n";
+
+ if (! -f $f) {
+ print STDERR "$f: not a file\n";
+ next;
+ }
+
+ if (!open(FILE, '+<', $f)) {
+ print STDERR "$name: Cannot open file: $f: $!\n";
+ next;
+ }
+
+ binmode FILE;
+
+ # First, verify that it is not a binary file; consider any file
+ # with a zero byte to be a binary file. Is there any better, or
+ # additional, heuristic that should be applied?
+ $is_binary = 0;
+
+ while (read(FILE, $data, 65536) > 0) {
+ if ($data =~ /\0/) {
+ $is_binary = 1;
+ last;
+ }
+ }
+
+ if ($is_binary) {
+ print STDERR "$name: $f: binary file\n";
+ next;
+ }
+
+ seek(FILE, 0, 0);
+
+ $in_bytes = 0;
+ $out_bytes = 0;
+ $blank_bytes = 0;
+
+ @blanks = ();
+ @lines = ();
+ $lineno = 0;
+
+ while ( defined($line = <FILE>) ) {
+ $lineno++;
+ $in_bytes += length($line);
+ $line =~ s/[ \t\r]*$//; # Remove trailing spaces
+ $line = clean_space_tabs($line);
+
+ if ( $line eq "\n" ) {
+ push(@blanks, $line);
+ $blank_bytes += length($line);
+ } else {
+ push(@lines, @blanks);
+ $out_bytes += $blank_bytes;
+ push(@lines, $line);
+ $out_bytes += length($line);
+ @blanks = ();
+ $blank_bytes = 0;
+ }
+
+ $l_width = strwidth($line);
+ if ($max_width && $l_width > $max_width) {
+ print STDERR
+ "$f:$lineno: line exceeds $max_width characters ($l_width)\n";
+ }
+ }
+
+ # Any blanks at the end of the file are discarded
+
+ if ($in_bytes != $out_bytes) {
+ # Only write to the file if changed
+ seek(FILE, 0, 0);
+ print FILE @lines;
+
+ if ( !defined($where = tell(FILE)) ||
+ !truncate(FILE, $where) ) {
+ die "$name: Failed to truncate modified file: $f: $!\n";
+ }
+ }
+
+ close(FILE);
+}
diff --git a/misc/cleanpatch b/misc/cleanpatch
new file mode 100755
index 0000000..9680d03
--- /dev/null
+++ b/misc/cleanpatch
@@ -0,0 +1,258 @@
+#!/usr/bin/perl -w
+#
+# Clean a patch file -- or directory of patch files -- of stealth whitespace.
+# WARNING: this can be a highly destructive operation. Use with caution.
+#
+
+use bytes;
+use File::Basename;
+
+# Default options
+$max_width = 79;
+
+# Clean up space-tab sequences, either by removing spaces or
+# replacing them with tabs.
+sub clean_space_tabs($)
+{
+ no bytes; # Tab alignment depends on characters
+
+ my($li) = @_;
+ my($lo) = '';
+ my $pos = 0;
+ my $nsp = 0;
+ my($i, $c);
+
+ for ($i = 0; $i < length($li); $i++) {
+ $c = substr($li, $i, 1);
+ if ($c eq "\t") {
+ my $npos = ($pos+$nsp+8) & ~7;
+ my $ntab = ($npos >> 3) - ($pos >> 3);
+ $lo .= "\t" x $ntab;
+ $pos = $npos;
+ $nsp = 0;
+ } elsif ($c eq "\n" || $c eq "\r") {
+ $lo .= " " x $nsp;
+ $pos += $nsp;
+ $nsp = 0;
+ $lo .= $c;
+ $pos = 0;
+ } elsif ($c eq " ") {
+ $nsp++;
+ } else {
+ $lo .= " " x $nsp;
+ $pos += $nsp;
+ $nsp = 0;
+ $lo .= $c;
+ $pos++;
+ }
+ }
+ $lo .= " " x $nsp;
+ return $lo;
+}
+
+# Compute the visual width of a string
+sub strwidth($) {
+ no bytes; # Tab alignment depends on characters
+
+ my($li) = @_;
+ my($c, $i);
+ my $pos = 0;
+ my $mlen = 0;
+
+ for ($i = 0; $i < length($li); $i++) {
+ $c = substr($li,$i,1);
+ if ($c eq "\t") {
+ $pos = ($pos+8) & ~7;
+ } elsif ($c eq "\n") {
+ $mlen = $pos if ($pos > $mlen);
+ $pos = 0;
+ } else {
+ $pos++;
+ }
+ }
+
+ $mlen = $pos if ($pos > $mlen);
+ return $mlen;
+}
+
+$name = basename($0);
+
+@files = ();
+
+while (defined($a = shift(@ARGV))) {
+ if ($a =~ /^-/) {
+ if ($a eq '-width' || $a eq '-w') {
+ $max_width = shift(@ARGV)+0;
+ } else {
+ print STDERR "Usage: $name [-width #] files...\n";
+ exit 1;
+ }
+ } else {
+ push(@files, $a);
+ }
+}
+
+foreach $f ( @files ) {
+ print STDERR "$name: $f\n";
+
+ if (! -f $f) {
+ print STDERR "$f: not a file\n";
+ next;
+ }
+
+ if (!open(FILE, '+<', $f)) {
+ print STDERR "$name: Cannot open file: $f: $!\n";
+ next;
+ }
+
+ binmode FILE;
+
+ # First, verify that it is not a binary file; consider any file
+ # with a zero byte to be a binary file. Is there any better, or
+ # additional, heuristic that should be applied?
+ $is_binary = 0;
+
+ while (read(FILE, $data, 65536) > 0) {
+ if ($data =~ /\0/) {
+ $is_binary = 1;
+ last;
+ }
+ }
+
+ if ($is_binary) {
+ print STDERR "$name: $f: binary file\n";
+ next;
+ }
+
+ seek(FILE, 0, 0);
+
+ $in_bytes = 0;
+ $out_bytes = 0;
+ $lineno = 0;
+
+ @lines = ();
+
+ $in_hunk = 0;
+ $err = 0;
+
+ while ( defined($line = <FILE>) ) {
+ $lineno++;
+ $in_bytes += length($line);
+
+ if (!$in_hunk) {
+ if ($line =~
+ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) {
+ $minus_lines = $2;
+ $plus_lines = $4;
+ if ($minus_lines || $plus_lines) {
+ $in_hunk = 1;
+ @hunk_lines = ($line);
+ }
+ } else {
+ push(@lines, $line);
+ $out_bytes += length($line);
+ }
+ } else {
+ # We're in a hunk
+
+ if ($line =~ /^\+/) {
+ $plus_lines--;
+
+ $text = substr($line, 1);
+ $text =~ s/[ \t\r]*$//; # Remove trailing spaces
+ $text = clean_space_tabs($text);
+
+ $l_width = strwidth($text);
+ if ($max_width && $l_width > $max_width) {
+ print STDERR
+ "$f:$lineno: adds line exceeds $max_width ",
+ "characters ($l_width)\n";
+ }
+
+ push(@hunk_lines, '+'.$text);
+ } elsif ($line =~ /^\-/) {
+ $minus_lines--;
+ push(@hunk_lines, $line);
+ } elsif ($line =~ /^ /) {
+ $plus_lines--;
+ $minus_lines--;
+ push(@hunk_lines, $line);
+ } else {
+ print STDERR "$name: $f: malformed patch\n";
+ $err = 1;
+ last;
+ }
+
+ if ($plus_lines < 0 || $minus_lines < 0) {
+ print STDERR "$name: $f: malformed patch\n";
+ $err = 1;
+ last;
+ } elsif ($plus_lines == 0 && $minus_lines == 0) {
+ # End of a hunk. Process this hunk.
+ my $i;
+ my $l;
+ my @h = ();
+ my $adj = 0;
+ my $done = 0;
+
+ for ($i = scalar(@hunk_lines)-1; $i > 0; $i--) {
+ $l = $hunk_lines[$i];
+ if (!$done && $l eq "+\n") {
+ $adj++; # Skip this line
+ } elsif ($l =~ /^[ +]/) {
+ $done = 1;
+ unshift(@h, $l);
+ } else {
+ unshift(@h, $l);
+ }
+ }
+
+ $l = $hunk_lines[0]; # Hunk header
+ undef @hunk_lines; # Free memory
+
+ if ($adj) {
+ die unless
+ ($l =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@(.*)$/);
+ my $mstart = $1;
+ my $mlin = $2;
+ my $pstart = $3;
+ my $plin = $4;
+ my $tail = $5; # doesn't include the final newline
+
+ $l = sprintf("@@ -%d,%d +%d,%d @@%s\n",
+ $mstart, $mlin, $pstart, $plin-$adj,
+ $tail);
+ }
+ unshift(@h, $l);
+
+ # Transfer to the output array
+ foreach $l (@h) {
+ $out_bytes += length($l);
+ push(@lines, $l);
+ }
+
+ $in_hunk = 0;
+ }
+ }
+ }
+
+ if ($in_hunk) {
+ print STDERR "$name: $f: malformed patch\n";
+ $err = 1;
+ }
+
+ if (!$err) {
+ if ($in_bytes != $out_bytes) {
+ # Only write to the file if changed
+ seek(FILE, 0, 0);
+ print FILE @lines;
+
+ if ( !defined($where = tell(FILE)) ||
+ !truncate(FILE, $where) ) {
+ die "$name: Failed to truncate modified file: $f: $!\n";
+ }
+ }
+ }
+
+ close(FILE);
+}
diff --git a/misc/crcgen.c b/misc/crcgen.c
new file mode 100644
index 0000000..f11e252
--- /dev/null
+++ b/misc/crcgen.c
@@ -0,0 +1,44 @@
+#include <inttypes.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ /* Polynomial in bit-reversed notation */
+ uint64_t poly;
+ uint64_t crctab[256], v;
+ int i, j;
+
+ poly = strtoumax(argv[1], NULL, 0);
+
+ printf("/* C */\n");
+ printf("static const uint64_t crc64_tab[256] = {\n");
+ for (i = 0; i < 256; i++) {
+ v = i;
+ for (j = 0; j < 8; j++)
+ v = (v >> 1) ^ ((v & 1) ? poly : 0);
+ crctab[i] = v;
+ }
+
+ for (i = 0; i < 256; i += 2) {
+ printf(" /* %02x */ UINT64_C(0x%016"PRIx64"), "
+ "UINT64_C(0x%016"PRIx64")%s\n",
+ i, crctab[i], crctab[i+1], (i == 254) ? "" : ",");
+ }
+ printf("};\n\n");
+
+ printf("# perl\n");
+ printf("@crc64_tab = (\n");
+ for (i = 0; i < 256; i += 2) {
+ printf(" [0x%08"PRIx32", 0x%08"PRIx32"], "
+ "[0x%08"PRIx32", 0x%08"PRIx32"]%-1s # %02x\n",
+ (uint32_t)(crctab[i] >> 32),
+ (uint32_t)(crctab[i]),
+ (uint32_t)(crctab[i+1] >> 32),
+ (uint32_t)(crctab[i+1]),
+ (i == 254) ? "" : ",",
+ i);
+ }
+ printf(");\n");
+
+ return 0;
+}
diff --git a/misc/exebin.mac b/misc/exebin.mac
new file mode 100644
index 0000000..8d1eaf8
--- /dev/null
+++ b/misc/exebin.mac
@@ -0,0 +1,57 @@
+; -*- nasm -*-
+; NASM macro file to allow the `bin' output format to generate
+; simple .EXE files by constructing the EXE header by hand.
+; Adapted from a contribution by Yann Guidon <whygee_corp@hol.fr>
+
+%define EXE_stack_size EXE_realstacksize
+
+%macro EXE_begin 0
+ ORG 0E0h
+ section .text
+
+header_start:
+ db 4Dh,5Ah ; EXE file signature
+ dw EXE_allocsize % 512
+ dw (EXE_allocsize + 511) / 512
+ dw 0 ; relocation information: none
+ dw (header_end-header_start)/16 ; header size in paragraphs
+ dw (EXE_absssize + EXE_realstacksize) / 16 ; min extra mem
+ dw (EXE_absssize + EXE_realstacksize) / 16 ; max extra mem
+ dw -10h ; Initial SS (before fixup)
+ dw EXE_endbss + EXE_realstacksize ; Initial SP (1K DPMI+1K STACK)
+ dw 0 ; (no) Checksum
+ dw 100h ; Initial IP - start just after the header
+ dw -10h ; Initial CS (before fixup)
+ dw 0 ; file offset to relocation table: none
+ dw 0 ; (no overlay)
+ align 16,db 0
+header_end:
+
+EXE_startcode:
+ section .data
+EXE_startdata:
+ section .bss
+EXE_startbss:
+%endmacro
+
+%macro EXE_stack 1
+EXE_realstacksize equ %1
+%define EXE_stack_size EXE_bogusstacksize ; defeat EQU in EXE_end
+%endmacro
+
+%macro EXE_end 0
+ section .text
+EXE_endcode:
+ section .data
+EXE_enddata:
+ section .bss
+ alignb 4
+EXE_endbss:
+
+EXE_acodesize equ (EXE_endcode-EXE_startcode+3) & (~3)
+EXE_datasize equ EXE_enddata-EXE_startdata
+EXE_absssize equ (EXE_endbss-EXE_startbss+3) & (~3)
+EXE_allocsize equ EXE_acodesize + EXE_datasize
+
+EXE_stack_size equ 0x800 ; default if nothing else was used
+%endmacro
diff --git a/misc/exebin2.mac b/misc/exebin2.mac
new file mode 100644
index 0000000..89c6889
--- /dev/null
+++ b/misc/exebin2.mac
@@ -0,0 +1,114 @@
+; -*- nasm -*-
+
+; NASM macro file to allow the `bin' output format to generate
+
+; simple .EXE files by constructing the EXE header by hand.
+
+; Adapted from a contribution by Yann Guidon <whygee_corp@hol.fr>
+
+
+
+%define EXE_stack_size EXE_realstacksize
+
+
+
+%macro EXE_begin 0
+
+ ORG 0E0h
+
+ section .text
+
+
+
+header_start:
+
+ db 4Dh,5Ah ; EXE file signature
+
+ dw EXE_allocsize % 512
+
+ dw (EXE_allocsize + 511) / 512
+
+ dw 0 ; relocation information: none
+
+ dw (header_end-header_start)/16 ; header size in paragraphs
+
+ dw (EXE_absssize + EXE_realstacksize) / 16 ; min extra mem
+
+ dw (EXE_absssize + EXE_realstacksize) / 16 ; max extra mem
+
+ dw -10h ; Initial SS (before fixup)
+
+ dw EXE_endbss + EXE_realstacksize ; Initial SP (1K DPMI+1K STACK)
+
+ dw 0 ; (no) Checksum
+
+ dw 100h ; Initial IP - start just after the header
+
+ dw -10h ; Initial CS (before fixup)
+
+ dw 0 ; file offset to relocation table: none
+
+ dw 0 ; (no overlay)
+
+ align 16,db 0
+
+header_end:
+
+
+
+EXE_startcode:
+
+ section .data
+
+EXE_startdata:
+
+ section .bss
+
+EXE_startbss:
+
+%endmacro
+
+
+
+%macro EXE_stack 1
+
+EXE_realstacksize equ %1
+
+%define EXE_stack_size EXE_bogusstacksize ; defeat EQU in EXE_end
+
+%endmacro
+
+
+
+%macro EXE_end 0
+
+ section .text
+
+EXE_endcode:
+
+ section .data
+
+EXE_enddata:
+
+ section .bss
+
+ alignb 4
+
+EXE_endbss:
+
+
+
+EXE_acodesize equ (EXE_endcode-EXE_startcode+3) & (~3)
+
+EXE_datasize equ EXE_enddata-EXE_startdata
+
+EXE_absssize equ (EXE_endbss-EXE_startbss+3) & (~3)
+
+EXE_allocsize equ EXE_acodesize + EXE_datasize
+
+
+
+EXE_stack_size equ 0x800 ; default if nothing else was used
+
+%endmacro
+
diff --git a/misc/findleak.pl b/misc/findleak.pl
new file mode 100755
index 0000000..dbb3367
--- /dev/null
+++ b/misc/findleak.pl
@@ -0,0 +1,42 @@
+#!/usr/bin/perl
+# From: Ed Beroset <beroset@mindspring.com>
+
+my %mem = {};
+my %alloc = {};
+while(<>)
+{
+ if (/realloc\((0x[0-9a-f]+).*\).*returns \((0x[0-9a-f]+)/)
+ {
+ $mem{$1}--;
+ if ($mem{$1} != 0) {
+ print "free before alloc! $_";
+ }
+ if ($mem{$2} != 0) {
+ print "memory leak! $_";
+ }
+ $mem{$2}++;
+ $alloc{$2} = $_;
+ }
+ elsif (/free\((0x[0-9a-f]+)/)
+ {
+ $mem{$1}--;
+ if ($mem{$1} != 0) {
+ print "free before alloc! $_";
+ }
+ }
+ elsif (m/returns (0x[0-9a-f]+)/)
+ {
+ if ($mem{$1} != 0) {
+ print "memory leak! $_";
+ }
+ $mem{$1}++;
+ $alloc{$1} = $_;
+ }
+}
+foreach $goo (sort keys %mem)
+{
+ if ($mem{$goo})
+ {
+ print "$mem{$goo} $alloc{$goo}";
+ }
+}
diff --git a/misc/findleak.txt b/misc/findleak.txt
new file mode 100644
index 0000000..8a1cfdc
--- /dev/null
+++ b/misc/findleak.txt
@@ -0,0 +1,59 @@
+Subject: [nasm-devel] tool to help find memory leaks
+Date: Fri, 02 Nov 2001 22:08:01 -0500
+From: Ed Beroset <beroset@mindspring.com>
+Reply-To: nasm-devel@yahoogroups.com
+To: nasm-devel@yahoogroups.com
+
+Here's a little Perl script I wrote a while ago to help track down memory
+leaks in nasm. First, compile nasm with LOGALLOC defined (see
+nasmlib.c). That creates a log file of all allocs and frees. This Perl
+script reads that file and tells you which source code lines caused a leak
+(or a free of unallocated memory). There are many leaks, almost all of
+them in the preprocessor.
+
+-+--- findleak.pl begins
+#!/usr/bin/perl
+my %mem = {};
+my %alloc = {};
+while(<>)
+{
+ if (/realloc\((0x[0-9a-f]+).*\).*returns \((0x[0-9a-f]+)/)
+ {
+ $mem{$1}--;
+ if ($mem{$1} != 0) {
+ print "free before alloc! $_";
+ }
+ if ($mem{$2} != 0) {
+ print "memory leak! $_";
+ }
+ $mem{$2}++;
+ $alloc{$2} = $_;
+ }
+ elsif (/free\((0x[0-9a-f]+)/)
+ {
+ $mem{$1}--;
+ if ($mem{$1} != 0) {
+ print "free before alloc! $_";
+ }
+ }
+ elsif (m/returns (0x[0-9a-f]+)/)
+ {
+ if ($mem{$1} != 0) {
+ print "memory leak! $_";
+ }
+ $mem{$1}++;
+ $alloc{$1} = $_;
+ }
+}
+foreach $goo (sort keys %mem)
+{
+ if ($mem{$goo})
+ {
+ print "$mem{$goo} $alloc{$goo}";
+ }
+}
+-+--- findleak.pl ends
+
+
+
+Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
diff --git a/misc/fmtinsns.pl b/misc/fmtinsns.pl
new file mode 100755
index 0000000..848ee2d
--- /dev/null
+++ b/misc/fmtinsns.pl
@@ -0,0 +1,40 @@
+#!/usr/bin/perl
+#
+# Re-align the columns in insns.dat, and enforce case conventions
+#
+
+@cols = (0, 16, 48, 96);
+
+while ($line = <STDIN>) {
+ chomp $line;
+ if ($line !~ /^\s*(\;.*|)$/) {
+ ($ln = $line) =~ s/\s+$//;
+ if ($line =~ /^\s*(\S+)\s+(\S+)\s+(\S+|\[.*\])\s+(\S+)\s*$/) {
+ @fields = ($1, $2, $3, $4);
+ $fields[0] = "\U$fields[0]" unless ($fields[0] =~ /^[^a-z]+cc$/);
+ $fields[3] =~ s/\,+$//;
+ $fields[3] = "\U$fields[3]" unless ($fields[3] eq 'ignore');
+ $c = 0;
+ $line = '';
+ for ($i = 0; $i < scalar(@fields); $i++) {
+ if ($i > 0 && $c >= $cols[$i]) {
+ $line .= ' ';
+ $c++;
+ }
+ while ($c < $cols[$i]) {
+ $line .= "\t";
+ $c = ($c+8) & ~7;
+ }
+ $line .= $fields[$i];
+ for ($j = 0; $j < length($fields[$i]); $j++) {
+ if (substr($fields[$i], $j, 1) eq "\t") {
+ $c = ($c+8) & ~7;
+ } else {
+ $c++;
+ }
+ }
+ }
+ }
+ }
+ print $line, "\n";
+}
diff --git a/misc/genfma.pl b/misc/genfma.pl
new file mode 100755
index 0000000..2b6a65c
--- /dev/null
+++ b/misc/genfma.pl
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+%packed_insns = (
+ 'vfmadd' => 0x98,
+ 'vfmaddsub' => 0x96,
+ 'vfmsubadd' => 0x97,
+ 'vfmsub' => 0x9a,
+ 'vfnmadd' => 0x9c,
+ 'vfnmsub' => 0x9e
+ );
+
+%scalar_insns = (
+ 'vfmadd' => 0x99,
+ 'vfmsub' => 0x9b,
+ 'vfnmadd' => 0x9d,
+ 'vfnmsub' => 0x9f
+ );
+
+foreach $pi ( sort(keys(%packed_insns)) ) {
+ $op = $packed_insns{$pi};
+ foreach $order ('132', '213', '231') {
+ $xorder = substr($order,1,1).substr($order,0,1).substr($order,2,1);
+ foreach $o ($order, $xorder) {
+ for ($w = 0; $w < 2; $w++) {
+ $suf = $w ? 'pd' : 'ps';
+ for ($l = 128; $l <= 256; $l <<= 1) {
+ $sx = ($l == 256) ? 'SY' : 'SO';
+ $mm = ($l == 256) ? 'ymm' : 'xmm';
+ printf "%-15s %-31s %-8s%-39s %s\n",
+ "\U${pi}${o}${suf}",
+ "${mm}reg,${mm}reg,${mm}rm",
+ "[rvm:",
+ sprintf("vex.dds.%d.66.0f38.w%d %02x /r]",
+ $l, $w, $op),
+ "FMA,FUTURE,${sx}";
+ }
+ }
+ }
+ $op += 0x10;
+ }
+}
+
+foreach $si ( sort(keys(%scalar_insns)) ) {
+ $op = $scalar_insns{$si};
+ foreach $order ('132', '213', '231') {
+ $xorder = substr($order,1,1).substr($order,0,1).substr($order,2,1);
+ foreach $o ($order, $xorder) {
+ for ($w = 0; $w < 2; $w++) {
+ $suf = $w ? 'sd' : 'ss';
+ $sx = $w ? 'SQ' : 'SD';
+ $l = 128;
+ $mm = 'xmm';
+ printf "%-15s %-31s %-8s%-39s %s\n",
+ "\U${si}${o}${suf}",
+ "${mm}reg,${mm}reg,${mm}rm",
+ '[rvm:',
+ sprintf("vex.dds.%d.66.0f38.w%d %02x /r]",
+ $l, $w, $op),
+ "FMA,FUTURE,${sx}";
+ }
+ }
+ $op += 0x10;
+ }
+}
diff --git a/misc/hints.txt b/misc/hints.txt
new file mode 100644
index 0000000..576e1cf
--- /dev/null
+++ b/misc/hints.txt
@@ -0,0 +1,26 @@
+Subject: Re: [nasm-devel] P4 insns
+Date: Sat, 05 May 2001 11:39:36 -0500
+From: Kyle Markley <kmarkley@seffera.net>
+Reply-To: nasm-devel@yahoogroups.com
+To: nasm-devel@yahoogroups.com
+
+berkus wrote:
+>
+> Use The Source, NASM!
+>
+> Do we have the P4 'probable branch taken' (3e) and 'probable branch
+> not taken' (2e) prefixes opcodes?
+
+They're just segment override prefixes: 2e is CS, 3e is DS. You can just
+say
+"cs jnz foo" for a not-taken hint, "ds jnz foo" for a taken hint.
+
+Maybe it would be nice to have a more suggestive name, but you could just
+%define one.
+
+---
+Kyle Markley
+
+
+
+Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
diff --git a/misc/magic b/misc/magic
new file mode 100644
index 0000000..0172f4a
--- /dev/null
+++ b/misc/magic
@@ -0,0 +1,6 @@
+# Put the following lines in your /etc/magic file to get 'file' to recognise
+# RDOFF Object Files
+
+0 string RDOFF RDOFF Object File
+>5 byte >32 version %c (little endian)
+>5 byte <32 version %d (big endian)
diff --git a/misc/makedist.sh b/misc/makedist.sh
new file mode 100755
index 0000000..3027196
--- /dev/null
+++ b/misc/makedist.sh
@@ -0,0 +1,71 @@
+#!/bin/sh
+# * THIS SCRIPT IS OBSOLETE DO NOT USE *
+
+MAJORVER=`grep NASM_MAJOR_VER nasm.h | head -1 | cut -f3 -d' '`
+MINORVER=`grep NASM_MINOR_VER nasm.h | head -1 | cut -f3 -d' '`
+VERSION=`grep NASM_VER nasm.h | head -1 | cut -f3 -d' ' | sed s/\"//g`
+DOSVERSION="${MAJORVER}${MINORVER}"
+NASM_TAR_GZ=dist/nasm-${VERSION}.tar.gz
+NASM_ZIP=dist/nasm${DOSVERSION}s.zip
+NASM_DOS_ZIP=dist/nasm${DOSVERSION}.zip
+NASM_DOC_ZIP=dist/nasm${DOSVERSION}d.zip
+
+if [ -d dist ]; then rm -rf dist; fi
+if [ -d nasm-${VERSION} ]; then rm -rf nasm-${VERSION}; fi
+if [ ! -d dist ]; then mkdir dist; fi
+if [ -f dist/nasm.tar.gz ]; then rm dist/nasm.tar.gz; fi
+mkdir nasm-${VERSION}
+(cd nasm-${VERSION}; ln -s ../* .;
+ rm -f nasm-${VERSION} dist Checklist GNUmakefile)
+find nasm-${VERSION}/ -follow -name GNUmakefile > tar-exclude
+find nasm-${VERSION}/ -follow -name RCS >> tar-exclude
+find nasm-${VERSION}/ -follow -name '*.exe' >> tar-exclude
+find nasm-${VERSION}/ -follow -name '*.uu' >> tar-exclude
+find nasm-${VERSION}/ -follow -name '*,v' >> tar-exclude
+for i in nasm-${VERSION}/doc/{nasmdoc.hpj,nasmdoc.rtf,nasmdoc.texi,Readme};
+ do echo $i; done >> tar-exclude
+tar chvfX dist/nasm-${VERSION}.tar tar-exclude nasm-${VERSION}
+rm -f tar-exclude
+tar tf dist/nasm-${VERSION}.tar | (echo nasm.doc; sed \
+ -e 's:^nasm-[^/]*/::' \
+ -e 's:/$::' \
+ -e '/install-sh/d' \
+ -e '/makedist\.sh/d' \
+ -e '/exasm\.zip/d' \
+ -e '/config/d' \
+ -e '/doc\/.*\.html/d' \
+ -e '/doc\/Readme/d' \
+ -e '/doc\/nasmdoc\.ps/d' \
+ -e '/doc\/nasmdoc\.txt/d' \
+ -e '/doc\/nasmdoc\.rtf/d' \
+ -e '/doc\/nasmdoc\.hpj/d' \
+ -e '/doc\/nasmdoc\.texi/d' \
+ -e '/doc\/nasmdoc\.hlp/d' \
+ -e '/doc\/nasm\.info/d' \
+ ) | sort > zipfiles
+sed \
+ -e '/^[^\/]*\.\(c\|h\|pl\|bas\|dat\)$/d' \
+ -e '/^doc\(\/.*\)\?/d' \
+ -e '/standard\.mac/d' \
+ -e '/Makefile/d' \
+ -e '/rdoff/d' \
+ < zipfiles > zipfiles.dos
+gzip -9 dist/nasm-${VERSION}.tar
+rm -rf nasm-${VERSION}
+ln -s doc/nasmdoc.src nasm.doc
+zip -l -k ${NASM_ZIP} `cat zipfiles`
+zip -k ${NASM_ZIP} *.exe misc/exasm.zip
+zip -l -k ${NASM_DOS_ZIP} `cat zipfiles.dos`
+zip -k ${NASM_DOS_ZIP} *.exe misc/exasm.zip
+rm -f nasm.doc
+(cd doc; zip -l -k ../${NASM_DOC_ZIP} \
+ Readme \
+ nasmdoc.src rdsrc.pl inslist.pl \
+ nasmdoc.txt \
+ nasmdoc.ps \
+ *.html
+ zip -k ../${NASM_DOC_ZIP} \
+ nasmdoc.hlp \
+ nasm.info)
+rm -f zipfiles zipfiles.dos
+echo Distributions complete.
diff --git a/misc/myC32.mac b/misc/myC32.mac
new file mode 100644
index 0000000..e70fc82
--- /dev/null
+++ b/misc/myC32.mac
@@ -0,0 +1,121 @@
+; NASM macro set to make interfacing to 32-bit programs easier
+; Also cool little macros to make NASM emulate some MASM things.
+;
+; Originally included in NASM. Modifications by Peter Johnson, 1999.
+;
+
+%imacro proc 1 ; begin a procedure definition
+%push proc
+ global %1
+%1: push ebp
+ mov ebp, esp
+%assign %$arg 8
+;%assign %$argnum 0
+%define %$procname %1
+%endmacro
+
+%imacro arg 0-1 4 ; used with the argument name as a label
+%00 equ %$arg
+;%assign %$argnum %$argnum+1
+;.arg%$argnum equ %1
+%assign %$arg %1+%$arg
+%endmacro
+
+%imacro endproc 0
+%ifnctx proc
+%error Mismatched `endproc'/`proc'
+%else
+; mov esp, ebp
+; pop ebp
+%ifdef LEGACY_ENDPROC
+ ret
+%endif
+;__end_%$procname: ; useful for calculating function size
+; global %{$procname}_arglen
+;%{$procname}_arglen equ %$arg-8
+;%assign %$i 1
+;%rep %$argnum
+; global %{$procname}_arg%$i
+;%{$procname}_arg%$i equ %{$procname}.arg%$i
+;%assign %$i %$i+1
+;%endrep
+%pop
+%endif
+%endmacro
+
+; redefine ret instructions for in-proc cases
+%imacro ret 0-1
+%ifnctx proc
+ ret %1
+%else
+ mov esp, ebp
+ pop ebp
+ ret %1
+%endif
+%endmacro
+
+%imacro retf 0-1
+%ifnctx proc
+ retf %1
+%else
+ mov esp, ebp
+ pop ebp
+ retf %1
+%endif
+%endmacro
+
+%imacro retn 0-1
+%ifnctx proc
+ retn %1
+%else
+ mov esp, ebp
+ pop ebp
+ retn %1
+%endif
+%endmacro
+
+; invoke calls a C function
+; defaults to word (16 bit) size parameters
+%macro invoke 1-*
+%rotate -1
+;%define invoketype word
+%rep (%0-1)
+; %ifidni %1,dword
+; %define invoketype dword
+; %elifidni %1,word
+; %define invoketype word
+; %elifidni %1,byte
+; %define invoketype byte
+; %else
+ %ifidni %1, cs
+ o16 push %1
+ %elifidni %1, ds
+ o16 push %1
+ %elifidni %1, es
+ o16 push %1
+ %elifidni %1, fs
+ o16 push %1
+ %elifidni %1, gs
+ o16 push %1
+ %elifidni %1, word cs
+ o16 push %1
+ %elifidni %1, word ds
+ o16 push %1
+ %elifidni %1, word es
+ o16 push %1
+ %elifidni %1, word fs
+ o16 push %1
+ %elifidni %1, word gs
+ o16 push %1
+ %else
+ push %1
+ %endif
+; %endif
+ %rotate -1
+%endrep
+call %1
+%if (%0!=1)
+ add esp, byte %{1}_arglen
+%endif
+%endmacro
+
diff --git a/misc/nasm.sl b/misc/nasm.sl
new file mode 100644
index 0000000..2ddb5c1
--- /dev/null
+++ b/misc/nasm.sl
@@ -0,0 +1,320 @@
+% This file defines a NASM editor mode for the JED editor.
+% JED's home page is http://space.mit.edu/~davis/jed.html.
+%
+% To install, copy this file into your JED_LIBRARY directory
+% (/usr/local/jed/lib or C:\JED\LIB or whatever), then add the
+% following lines to your .jedrc or jed.rc file:
+% autoload("nasm_mode", "nasm");
+% add_mode_for_extension("nasm", "asm");
+% (you can of course replace "asm" with whatever file extension
+% you like to use for your NASM source files).
+
+variable Nasm_Instruction_Indent = 10;
+variable Nasm_Comment_Column = 33;
+variable Nasm_Comment_Space = 1;
+
+variable nasm_kw_2 = strcat("ahalaxbhblbpbtbxchclcscxdbdddhdidldqdsdtdwdxes",
+ "fsgsinjajbjcjejgjljojpjsjzorsispssto");
+variable nasm_kw_3 = strncat("a16a32aaaaadaamaasadcaddandbsfbsrbtcbtrbtscbw",
+ "cdqclccldclicmccmpcr0cr2cr3cr4cwddaadasdecdiv",
+ "dr0dr1dr2dr3dr6dr7eaxebpebxecxediedxequesiesp",
+ "farfldfsthltincintjaejbejgejlejmpjnajnbjncjne",
+ "jngjnljnojnpjnsjnzjpejpolarldslealeslfslgslsl",
+ "lssltrmm0mm1mm2mm3mm4mm5mm6mm7movmulnegnopnot",
+ "o16o32outpopporrclrcrrepretrolrorrsmsalsarsbb",
+ "segshlshrsmist0st1st2st3st4st5st6st7stcstdsti",
+ "strsubtr3tr4tr5tr6tr7wrtxor", 9);
+variable nasm_kw_4 = strncat("arplbytecallcltscwdeemmsfabsfaddfbldfchsfcom",
+ "fcosfdivfenifildfistfld1fldzfmulfnopfsinfstp",
+ "fsubftstfxamfxchibtsidivimulinsbinsdinswint1",
+ "int3intoinvdiretjcxzjnaejnbejngejnlelahflgdt",
+ "lidtlldtlmswlocklongloopmovdmovqnearpandpopa",
+ "popfpushpxorreperepzresbresdresqrestreswretf",
+ "retnsahfsalcsetasetbsetcsetesetgsetlsetosetp",
+ "setssetzsgdtshldshrdsidtsldtsmswtestumovverr",
+ "verwwaitwordxaddxbtsxchg", 9);
+variable nasm_kw_5 = strncat("boundbswapcmovacmovbcmovccmovecmovgcmovlcmovo",
+ "cmovpcmovscmovzcmpsbcmpsdcmpswcpuiddwordenter",
+ "f2xm1faddpfbstpfclexfcomifcompfdisifdivpfdivr",
+ "ffreefiaddficomfidivfimulfinitfistpfisubfldcw",
+ "fldpifmulpfpremfptanfsavefsqrtfstcwfstswfsubp",
+ "fsubrfucomfyl2xicebpint01iretdiretwjecxzleave",
+ "lodsblodsdlodswloopeloopzmovsbmovsdmovswmovsx",
+ "movzxoutsboutsdoutswpaddbpadddpaddwpandnpopad",
+ "popawpopfdpopfwpslldpsllqpsllwpsradpsrawpsrld",
+ "psrlqpsrlwpsubbpsubdpsubwpushapushfqwordrdmsr",
+ "rdpmcrdtscrepnerepnzscasbscasdscaswsetaesetbe",
+ "setgesetlesetnasetnbsetncsetnesetngsetnlsetno",
+ "setnpsetnssetnzsetpesetposhortstosbstosdstosw",
+ "timestwordwrmsrxlatb", 14);
+variable nasm_kw_6 = strncat("cmovaecmovbecmovgecmovlecmovnacmovnbcmovnc",
+ "cmovnecmovngcmovnlcmovnocmovnpcmovnscmovnz",
+ "cmovpecmovpofcmovbfcmovefcmovufcomipfcompp",
+ "fdivrpficompfidivrfisubrfldenvfldl2efldl2t",
+ "fldlg2fldln2fpatanfprem1frstorfscalefsetpm",
+ "fstenvfsubrpfucomifucompincbininvlpgloopne",
+ "loopnzpaddsbpaddswpmulhwpmullwpsubsbpsubsw",
+ "pushadpushawpushfdpushfwsetnaesetnbesetnge",
+ "setnlewbinvd", 9);
+variable nasm_kw_7 = strncat("cmovnaecmovnbecmovngecmovnlecmpxchgfcmovbe",
+ "fcmovnbfcmovnefcmovnufdecstpfincstpfrndint",
+ "fsincosfucomipfucomppfxtractfyl2xp1loadall",
+ "paddusbpadduswpcmpeqbpcmpeqdpcmpeqwpcmpgtb",
+ "pcmpgtdpcmpgtwpmaddwdpsubusbpsubusw", 5);
+variable nasm_kw_8 = "fcmovnbepackssdwpacksswbpackuswb";
+variable nasm_kw_9 = strcat("cmpxchg8bpunpckhbwpunpckhdqpunpckhwdpunpcklbw",
+ "punpckldqpunpcklwd");
+variable nasm_kw_10 = "cmpxchg486loadall286";
+
+define nasm_indent_line() {
+ variable word, len, e, c;
+
+ e = eolp();
+
+ push_spot();
+ EXIT_BLOCK {
+ pop_spot();
+ if (what_column() <= Nasm_Instruction_Indent)
+ skip_white();
+ }
+
+ bol_skip_white();
+ c = what_column();
+
+ if (orelse
+ {looking_at_char(';')}
+ {looking_at_char('#')}
+ {looking_at_char('[')}) {
+ bol_trim();
+ pop_spot();
+ EXIT_BLOCK {
+ }
+ return;
+ }
+
+ if (looking_at_char('%')) {
+ go_right_1();
+ !if (orelse
+ {looking_at_char('$')}
+ {looking_at_char('%')}
+ {looking_at_char('+')}
+ {looking_at_char('-')}
+ {looking_at_char('0')}
+ {looking_at_char('1')}
+ {looking_at_char('2')}
+ {looking_at_char('3')}
+ {looking_at_char('4')}
+ {looking_at_char('5')}
+ {looking_at_char('6')}
+ {looking_at_char('7')}
+ {looking_at_char('8')}
+ {looking_at_char('9')}) {
+ bol_trim();
+ pop_spot();
+ EXIT_BLOCK {
+ }
+ return;
+ }
+ go_left_1();
+ }
+
+ push_mark();
+ skip_chars("%$+-");
+ skip_chars("0-9a-zA-Z_.");
+ word = bufsubstr();
+
+ if (orelse
+ {c == 1}
+ {looking_at_char(':')}) {
+ push_spot();
+ bol_trim();
+ pop_spot();
+ len = strlen(word);
+ if (looking_at_char(':')) {
+ go_right_1();
+ len++;
+ }
+ trim();
+ if (e or not(eolp())) {
+ if (len >= Nasm_Instruction_Indent) {
+ pop();
+ whitespace(1);
+ } else
+ whitespace(Nasm_Instruction_Indent - len);
+ if (e) {
+ pop_spot();
+ eol();
+ push_spot();
+ }
+ }
+ } else {
+ bol_trim();
+ whitespace(Nasm_Instruction_Indent);
+ }
+}
+
+define nasm_newline_indent() {
+ push_spot();
+ bol_skip_white();
+ if (eolp())
+ trim();
+ pop_spot();
+ newline();
+ nasm_indent_line();
+}
+
+define nasm_bol_self_ins() {
+ push_spot();
+ bskip_white();
+ bolp();
+ pop_spot();
+
+ call("self_insert_cmd");
+
+ % Grotty: force immediate update of the syntax highlighting.
+ insert_char('.');
+ deln(left(1));
+
+ if (())
+ nasm_indent_line();
+}
+
+define nasm_self_ins_ind() {
+ call("self_insert_cmd");
+
+ % Grotty: force immediate update of the syntax highlighting.
+ insert_char('.');
+ deln(left(1));
+
+ nasm_indent_line();
+}
+
+define nasm_insert_comment() {
+ variable spc;
+
+ bol_skip_white();
+ if (looking_at_char(';')) {
+ bol_trim();
+ go_right(1);
+ skip_white();
+ return;
+ } else if (eolp()) {
+ bol_trim();
+ insert("; ");
+ return;
+ }
+
+ forever {
+ skip_chars("^;\n'\"");
+ if (looking_at_char('\'')) {
+ go_right_1();
+ skip_chars("^'\n");
+ !if (eolp())
+ go_right_1();
+ } else if (looking_at_char('\"')) {
+ go_right_1();
+ skip_chars("^\"\n");
+ !if (eolp())
+ go_right_1();
+ } else if (looking_at_char(';')) {
+ !if (bolp()) {
+ go_left_1();
+ trim();
+ !if (looking_at_char(';'))
+ go_right_1();
+ }
+ break;
+ } else {
+ break;
+ }
+ }
+ spc = Nasm_Comment_Column - what_column();
+ if (spc < Nasm_Comment_Space)
+ spc = Nasm_Comment_Space;
+ whitespace(spc);
+ if (eolp()) {
+ insert("; ");
+ } else {
+ go_right_1();
+ skip_white();
+ }
+}
+
+$1 = "NASM";
+create_syntax_table($1);
+
+define_syntax (";", "", '%', $1);
+define_syntax ("([", ")]", '(', $1);
+define_syntax ('"', '"', $1);
+define_syntax ('\'', '\'', $1);
+define_syntax ("0-9a-zA-Z_.@#", 'w', $1);
+define_syntax ("-+0-9a-fA-F.xXL", '0', $1);
+define_syntax (",:", ',', $1);
+define_syntax ('%', '#', $1);
+define_syntax ("|^&<>+-*/%~", '+', $1);
+
+set_syntax_flags($1,1);
+
+#ifdef HAS_DFA_SYNTAX
+
+dfa_enable_highlight_cache("nasm.dfa", $1);
+dfa_define_highlight_rule(";.*$", "comment", $1);
+dfa_define_highlight_rule("[A-Za-z_\\.\\?][A-Za-z0-9_\\.\\?\\$#@~]*",
+ "Knormal", $1);
+dfa_define_highlight_rule("$([A-Za-z_\\.\\?][A-Za-z0-9_\\.\\?\\$#@~]*)?",
+ "normal", $1);
+dfa_define_highlight_rule("[0-9]+(\\.[0-9]*)?([Ee][\\+\\-]?[0-9]*)?",
+ "number", $1);
+dfa_define_highlight_rule("[0-9]+[QqBb]", "number", $1);
+dfa_define_highlight_rule("(0x|\\$[0-9A-Fa-f])[0-9A-Fa-f]*", "number", $1);
+dfa_define_highlight_rule("[0-9A-Fa-f]+[Hh]", "number", $1);
+dfa_define_highlight_rule("\"[^\"]*\"", "string", $1);
+dfa_define_highlight_rule("\"[^\"]*$", "string", $1);
+dfa_define_highlight_rule("'[^']*'", "string", $1);
+dfa_define_highlight_rule("'[^']*$", "string", $1);
+dfa_define_highlight_rule("[\\(\\)\\[\\],:]*", "delimiter", $1);
+dfa_define_highlight_rule("^[ \t]*#", "PQpreprocess", $1);
+dfa_define_highlight_rule("^[ \t]*\\%{?[^%\\$\\+\\-0-9]", "PQpreprocess", $1);
+dfa_define_highlight_rule("^%$", "preprocess", $1);
+dfa_define_highlight_rule("[\\|\\^&<>\\+\\-\\*/%~]*", "operator", $1);
+dfa_define_highlight_rule("%([%\\$]?-?[0-9A-Za-z_\\.\\?\\$~@]+|{[^}]*}?)",
+ "preprocess", $1);
+dfa_define_highlight_rule("[ \t]*", "normal", $1);
+dfa_define_highlight_rule(".", "normal", $1);
+dfa_build_highlight_table($1);
+#endif
+
+define_keywords_n($1, nasm_kw_2, 2, 0);
+define_keywords_n($1, nasm_kw_3, 3, 0);
+define_keywords_n($1, nasm_kw_4, 4, 0);
+define_keywords_n($1, nasm_kw_5, 5, 0);
+define_keywords_n($1, nasm_kw_6, 6, 0);
+define_keywords_n($1, nasm_kw_7, 7, 0);
+define_keywords_n($1, nasm_kw_8, 8, 0);
+define_keywords_n($1, nasm_kw_9, 9, 0);
+define_keywords_n($1, nasm_kw_10, 10, 0);
+
+define_keywords_n($1, "org", 3, 1);
+define_keywords_n($1, "bitsiend", 4, 1);
+define_keywords_n($1, "aligngroupstruc", 5, 1);
+define_keywords_n($1, "alignbcommonexternglobalistruc", 6, 1);
+define_keywords_n($1, "sectionsegmentlibrary", 7, 1);
+define_keywords_n($1, "absoluteendstruc", 8, 1);
+define_keywords_n($1, "uppercase", 9, 1);
+
+!if (keymap_p ($1)) make_keymap ($1);
+definekey("nasm_bol_self_ins", ";", $1);
+definekey("nasm_bol_self_ins", "#", $1);
+definekey("nasm_bol_self_ins", "%", $1);
+definekey("nasm_bol_self_ins", "[", $1);
+definekey("nasm_self_ins_ind", ":", $1);
+definekey("nasm_insert_comment", "^[;", $1);
+
+define nasm_mode() {
+ set_mode("NASM", 4);
+ use_keymap ("NASM");
+ use_syntax_table ("NASM");
+ set_buffer_hook ("indent_hook", "nasm_indent_line");
+ set_buffer_hook ("newline_indent_hook", "nasm_newline_indent");
+ runhooks("nasm_mode_hook");
+}
diff --git a/misc/nasmstab b/misc/nasmstab
new file mode 100644
index 0000000..32ef67e
--- /dev/null
+++ b/misc/nasmstab
@@ -0,0 +1,296 @@
+#!/usr/bin/perl
+
+sub StabLine ($ $ $ $ $ $) {
+ local ($comment,$n_strx,$type,$other,$desc,$value) = @_;
+ print $comment;
+ print "","dd",$n_strx;
+ print "","db",$type;
+ print "","db",$other;
+ print "","dw",$desc;
+ print "","dd","0" . $value . "h";
+}
+
+sub RStabLine ($ $ $ $ $) {
+ local ($comment,$offset,$info,$type,$symbol) = @_;
+ print $comment;
+ print "","dd",$offset;
+ print "","db",$type;
+ print "","db",$symbol;
+ print "","dw",$info;
+}
+
+#this sub exists because i've no idea how to print non-ascii numbers in perl
+
+sub OutBin ( $ $ ) {
+ local ($offset, $shnum) = @_;
+ seek(FINAL,$offset,0);
+ if ( $shnum == 2 ) { printf FINAL "\x02" } ;
+ if ( $shnum == 3 ) { printf FINAL "\x03" } ;
+ if ( $shnum == 4 ) { printf FINAL "\x04" } ;
+ if ( $shnum == 5 ) { printf FINAL "\x05" } ;
+ if ( $shnum == 6 ) { printf FINAL "\x06" } ;
+ if ( $shnum == 7 ) { printf FINAL "\x07" } ;
+ if ( $shnum == 8 ) { printf FINAL "\x08" } ;
+ if ( $shnum == 9 ) { printf FINAL "\x09" } ;
+ if ( $shnum == 10 ) { printf FINAL "\x0a" } ;
+ if ( $shnum == 11 ) { printf FINAL "\x0b" } ;
+ if ( $shnum == 12 ) { printf FINAL "\x0c" } ;
+ if ( $shnum == 13 ) { printf FINAL "\x0d" } ;
+ if ( $shnum == 14 ) { printf FINAL "\x0e" } ;
+ if ( $shnum == 15 ) { printf FINAL "\x0f" } ;
+}
+
+sub DispHelp () {
+ $\="\n";
+ print "Usage:";
+ print "\t-f,--input-file";
+ print "\t\tThe input file name (only required option)";
+ print "\t-o,--output-file";
+ print "\t\tThe output file name (if not specified, *.asm becomes *.o";
+ print "\t\tand anything else becomes a.out)";
+ print "\t-l,--list-file";
+ print "\t\tThe listing file's name (default: trailing .asm is
+removed";
+ print "\t\tif there and .lst is appended)";
+ print "\t-s,--second-asm-file";
+ print "\t\tThe second asm file's name (default: trailing .asm is";
+ print "\t\tremoved if there and .nasm is appended)";
+ print "\n";
+ exit ;
+}
+
+if ( $ARGV[0] eq "" ) { $ARGV[0] = "-h" };
+
+$i = 0;
+$filename = "";
+$outname = "";
+
+while ( $ARGV[$i] ne "" ) {
+ $_ = $ARGV[$i];
+ if ( m/^-/ ) {
+ if ( m/^-f$/ ) { $filename = $ARGV[++$i] };
+ if ( m/^-o$/ ) { $outname = $ARGV[++$i] };
+ if ( m/^-l$/ ) { $listname = $ARGV[++$i] };
+ if ( m/^-s$/ ) { $asmname = $ARGV[++$i] };
+ if ( m/^-h$/ ) { DispHelp };
+ } elsif ( m/^--\w+/ ) {
+ if ( m/^--input-file$/ ) { $filename = $ARGV[++$i] };
+ if ( m/^--output-file$/ ) { $outname = $ARGV[++$i] };
+ if ( m/^--list-file$/ ) { $listname = $ARGV[++$i] };
+ if ( m/^--second-asm-file$/ ) { $asmname = $ARGV[++$i] };
+ if ( m/^--help/ ) { DispHelp };
+ } elsif ( m/^--$/ ) {
+ while ( $ARGV[++$i] ) {
+ $NasmOptions .= " ";
+ $NasmOptions .= $_;
+ };
+ } else {
+ DispHelp()
+ };
+ $i++;
+};
+
+if ( $filename eq "" ) { DispHelp() };
+
+if ( $outname eq "" ) {
+ $outname = $filename;
+ $outname =~ s/\.asm/.o/;
+ if ( $outname eq $filename ) { $outname = "a.out" };
+};
+
+if ( $listname eq "" ) {
+ $listname = $filename;
+ $listname =~ s/\.asm//;
+ $listname .= ".lst";
+};
+
+if ( $asmname eq "" ) {
+ $asmname = $filename;
+ $asmname =~ s/\.asm//;
+ $asmname .= ".nasm";
+};
+
+$err = `nasm -f elf ${filename} -l ${listname} -o ${outname} `;
+
+if ( $err ) { die "\n$err\n"};
+
+open(LISTFILE,"${listname}") or die "\n $0: Could not reopen list file!\n";
+open(ASMFILE,">${asmname}") or die "\n $0: Could not open asm file!\n";
+
+select ASMFILE;
+
+open(OLDASM,$filename) or die "\n$0: Cannot open file $filename\n";
+
+while ( $x = <OLDASM> ) {
+ print $x;
+}
+
+@stab = ("n_desc", "value");
+@rel_stab = ("offset");
+$i = 0;
+$current_section = "";
+$has_text = 'FALSE';
+$midst_of_macro = 'FALSE';
+$line_dec = 0 ;
+
+while ( $x = <LISTFILE> ) {
+ if ( $x =~ m/[^;]*%include/ ) {
+ $x = <LISTFILE>;
+ while ( $x =~ m/\s+\d+\s+\<\d+\>\s+/ ) {
+ $x = <LISTFILE>;
+ $line_dec++;
+ }
+ }
+ if ( $current_section eq ".text" ) {
+ if ( $x =~ m/^\s+(\S+)\s+(\S+)\s+(\S+)\s+[^<]+$/ ) {
+ $stab[$i++] = $1-$line_dec; #linenum
+ $stab[$i++] = $2; #offset
+ $count++;
+ if ( $3 =~ m/-/ ) {
+ $x = <LISTFILE>;
+ $line_dec++;
+ }
+ $midst_of_macro = 'FALSE';
+ } elsif ( $x =~ m/^\s+(\S+)\s+(\S+)\s+(\S+)\s+<\d+>/ ) {
+ if ( $midst_of_macro eq 'TRUE' ) {
+ $stab[$i] = $stab[$i-2]; #same linenum
+ $line_dec++;
+ } else {
+ $stab[$i] = $1 - ++$line_dec;
+ $midst_of_macro = 'TRUE';
+ }
+ $count++;
+ $i++;
+ $stab[$i++] = $2;
+ if ( $3 =~ m/-/ ) {
+ $x = <LISTFILE>;
+ $line_dec++;
+ }
+
+ }
+ $has_text = 'TRUE';
+ } elsif ( $x =~ m/\s+\S+\s+\S+\s+\S+\s+<\d+>/ ) { # is it a macro?
+ $line_dec++;
+ }
+ if ( $x =~ s/(section|segment)\s+([^\s]+)/$2/ ) {
+ $current_section = $2;
+ }
+};
+
+close LISTFILE;
+
+unless ( $has_text eq "TRUE" ) {
+ $err = `nasm -f elf ${asmname} -o ${outname}`;
+ print STDERR $err;
+ exit;
+}
+
+#Write Stab section
+$, = "\t"; #output field separator
+$\ = "\n"; #output record separator
+
+print "section .stab noalloc";
+StabLine(";header",1,0,0,$count+1,length($filename)*2+3);
+StabLine(";so",length($asmname)+2,"064h",0,0,0);
+
+$offset = 12;
+$i = 0;
+$j = 0;
+$rel_stab[$j++] = $offset + 8;
+
+while ( $stab[$i] ) {
+ StabLine(";N_SLINE" . " " . ( ($i+2) / 2 ), 0, "044h", 0,
+ $stab[$i++], $stab[$i++]);
+ $offset += 12;
+ $rel_stab[$j++] = $offset + 8;
+}
+
+#Write .rel.stab section
+print "\n\nsection .rel.stab noalloc";
+
+open (READELF,"readelf -s ${outname} |") or die "\n$0: Could not run readelf\n";
+
+while ( $x = <READELF> ) {
+ if ( $x =~ m/\s+(\d+):\s+00000000\s+\d+\s+SECTION\s+\w+\s+\w+\s+1\s+/){ $textsymnum = $1;
+ };
+};
+close READELF;
+
+$i = 0;
+
+while ( $rel_stab[$i] ne "" ) {
+ RStabLine(";relocation for N_SLINE " . ($i), $rel_stab[$i], 0, 1, $textsymnum);
+ $i++;
+} ;
+
+#Write .stabstr section
+
+print "\n\nsection .stabstr noalloc";
+
+print "","db","0";
+print "","db",'"' . $asmname . '"';
+print "","db","0";
+print "","db",'"' . $asmname . '"' ;
+print "","db","0";
+
+close ASMFILE;
+
+$err = `nasm -f elf ${asmname} -o ${outname}`;
+
+if ( $err ) { die "\n$err\n" } ;
+
+open (READELF,"readelf -h -S ${outname} |") or die "\n$0: Could not run readelf\n";
+
+
+while ( $x = <READELF> ) {
+ if ( $x =~ m/Start\s+of\s+section\s+headers:\s+(\d+)\s+/ ) {
+ $shoff = $1;
+ }
+ if ( $x =~ m/Size\s+of\s+section\s+headers:\s+(\d+)\s+/ ) {
+ $shentsize = $1;
+ }
+ if ( $x =~ m/\[\s*(\d+)\]\s+.rel.stab\s+/ ) {
+ $relnum = $1;
+ }
+ if ( $x =~ m/\[\s*(\d+)\]\s+.stab\s+/ ) {
+ $stabnum = $1;
+ }
+ if ( $x =~ m/\[\s*(\d+)\]\s+.stabstr\s+/ ) {
+ $stabstrnum = $1;
+ }
+ if ( $x =~ m/\[\s*(\d+)\]\s+.symtab\s+/ ) {
+ $symtabnum = $1;
+ }
+}
+close READELF;
+
+sysopen (FINAL,"${outname}",2,0) or die "\n$0: Could not open ${outname}";
+$, = ""; #output field separator
+$\ = ""; #output record separator
+
+#set .rel.stab->type to rel
+OutBin($shoff + ($shentsize * $relnum) + 4,9);
+
+#set .rel.stab->link to .symtab
+OutBin($shoff + ($shentsize * $relnum) + 24,$symtabnum);
+
+#set .rel.stab->info to .stab
+OutBin($shoff + ($shentsize * $relnum) + 28,$stabnum);
+
+#set .rel.stab->entsize to 8
+OutBin($shoff + ($shentsize * $relnum) + 36,8);
+
+#set .stab->link to .stabstr
+OutBin($shoff + ($shentsize * $stabnum) + 24,$stabstrnum);
+
+#set .stab->entsize to 12
+OutBin($shoff + ($shentsize * $stabnum) + 36,12);
+
+#set .stabstr->type to strtab
+OutBin($shoff + ($shentsize * $stabstrnum) + 4,3);
+
+close FINAL;
+
+#Date: 17 Mar 2002 15:51:20 -0800
+#From: kitsred@hotmail.com (kired)
+#Newsgroups: alt.lang.asm
diff --git a/misc/omfdump.c b/misc/omfdump.c
new file mode 100644
index 0000000..322971e
--- /dev/null
+++ b/misc/omfdump.c
@@ -0,0 +1,223 @@
+/*
+ * omfdump.c
+ *
+ * Very simple program to dump the contents of an OMF (OBJ) file
+ *
+ * This assumes a littleendian, unaligned-load-capable host and a
+ * C compiler which handles basic C99.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <ctype.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+
+const char *progname;
+
+static const char *record_types[256] =
+{
+ [0x80] = "THEADR",
+ [0x82] = "LHEADR",
+ [0x88] = "COMENT",
+ [0x8a] = "MODEND16",
+ [0x8b] = "MODEND32",
+ [0x8c] = "EXTDEF",
+ [0x90] = "PUBDEF16",
+ [0x91] = "PUBDEF32",
+ [0x94] = "LINNUM16",
+ [0x95] = "LINNUM32",
+ [0x96] = "LNAMES",
+ [0x98] = "SEGDEF16",
+ [0x99] = "SEGDEF32",
+ [0x9a] = "GRPDEF",
+ [0x9c] = "FIXUPP16",
+ [0x9d] = "FIXUPP32",
+ [0xa0] = "LEDATA16",
+ [0xa1] = "LEDATA32",
+ [0xa2] = "LIDATA16",
+ [0xa3] = "LIDATA32",
+ [0xb0] = "COMDEF",
+ [0xb2] = "BAKPAT16",
+ [0xb3] = "BAKPAT32",
+ [0xb4] = "LEXTDEF",
+ [0xb6] = "LPUBDEF16",
+ [0xb7] = "LPUBDEF32",
+ [0xb8] = "LCOMDEF",
+ [0xbc] = "CEXTDEF",
+ [0xc2] = "COMDAT16",
+ [0xc3] = "COMDAT32",
+ [0xc4] = "LINSYM16",
+ [0xc5] = "LINSYM32",
+ [0xc6] = "ALIAS",
+ [0xc8] = "NBKPAT16",
+ [0xc9] = "NBKPAT32",
+ [0xca] = "LLNAMES",
+ [0xcc] = "VERNUM",
+ [0xce] = "VENDEXT",
+ [0xf0] = "LIBHDR",
+ [0xf1] = "LIBEND",
+};
+
+typedef void (*dump_func)(uint8_t, const uint8_t *, size_t);
+
+static void hexdump_data(unsigned int offset, const uint8_t *data, size_t n)
+{
+ unsigned int i, j;
+
+ for (i = 0; i < n; i += 16) {
+ printf(" %04x: ", i+offset);
+ for (j = 0; j < 16; j++) {
+ if (i+j < n)
+ printf("%02x%c", data[i+j], (j == 7) ? '-' : ' ');
+ else
+ printf(" ");
+ }
+ printf(" : ");
+ for (j = 0; j < 16; j++) {
+ if (i+j < n)
+ putchar(isprint(data[i+j]) ? data[i+j] : '.');
+ }
+ putchar('\n');
+ }
+}
+
+static void dump_unknown(uint8_t type, const uint8_t *data, size_t n)
+{
+ (void)type;
+ hexdump_data(0, data, n);
+}
+
+static void dump_coment(uint8_t type, const uint8_t *data, size_t n)
+{
+ uint8_t class;
+ static const char *coment_class[256] = {
+ [0x00] = "Translator",
+ [0x01] = "Copyright",
+ [0x81] = "Library specifier",
+ [0x9c] = "MS-DOS version",
+ [0x9d] = "Memory model",
+ [0x9e] = "DOSSEG",
+ [0x9f] = "Library search",
+ [0xa0] = "OMF extensions",
+ [0xa1] = "New OMF extension",
+ [0xa2] = "Link pass separator",
+ [0xa3] = "LIBMOD",
+ [0xa4] = "EXESTR",
+ [0xa6] = "INCERR",
+ [0xa7] = "NOPAD",
+ [0xa8] = "WKEXT",
+ [0xa9] = "LZEXT",
+ [0xda] = "Comment",
+ [0xdb] = "Compiler",
+ [0xdc] = "Date",
+ [0xdd] = "Timestamp",
+ [0xdf] = "User",
+ [0xe9] = "Dependency file",
+ [0xff] = "Command line"
+ };
+
+ if (n < 2) {
+ dump_unknown(type, data, n);
+ return;
+ }
+
+ type = data[0];
+ class = data[1];
+
+ printf(" [NP=%d NL=%d UD=%02X] %02X %s\n",
+ (type >> 7) & 1,
+ (type >> 6) & 1,
+ type & 0x3f,
+ class,
+ coment_class[class] ? coment_class[class] : "???");
+
+ hexdump_data(2, data+2, n-2);
+}
+
+static const dump_func dump_type[256] =
+{
+ [0x88] = dump_coment,
+};
+
+int dump_omf(int fd)
+{
+ struct stat st;
+ size_t len, n;
+ uint8_t type;
+ const uint8_t *p, *data;
+
+ if (fstat(fd, &st))
+ return -1;
+
+ len = st.st_size;
+
+ data = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (data == MAP_FAILED)
+ return -1;
+
+ p = data;
+ while (len >= 3) {
+ uint8_t csum;
+ int i;
+
+ type = p[0];
+ n = *(uint16_t *)(p+1);
+
+ printf("%02x %-10s %4zd bytes",
+ type,
+ record_types[type] ? record_types[type] : "???",
+ n);
+
+ if (len < n+3) {
+ printf("\n (truncated, only %zd bytes left)\n", len-3);
+ break; /* Truncated */
+ }
+
+ p += 3; /* Header doesn't count in the length */
+ n--; /* Remove checksum byte */
+
+ csum = 0;
+ for (i = -3; i < (int)n; i++)
+ csum -= p[i];
+
+ printf(", checksum %02X", p[i]);
+ if (csum == p[i])
+ printf(" (valid)\n");
+ else
+ printf(" (actual = %02X)\n", csum);
+
+ if (dump_type[type])
+ dump_type[type](type, p, n);
+ else
+ dump_unknown(type, p, n);
+
+ p += n+1;
+ len -= (n+4);
+ }
+
+ munmap((void *)data, st.st_size);
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int fd;
+ int i;
+
+ progname = argv[0];
+
+ for (i = 1; i < argc; i++) {
+ fd = open(argv[i], O_RDONLY);
+ if (fd < 0 || dump_omf(fd)) {
+ perror(argv[i]);
+ return 1;
+ }
+ close(fd);
+ }
+
+ return 0;
+}
diff --git a/misc/pmw.bat b/misc/pmw.bat
new file mode 100644
index 0000000..88b67a5
--- /dev/null
+++ b/misc/pmw.bat
@@ -0,0 +1,9 @@
+@echo off
+rem some batch file to bind nasm and ndisasm with pmode/w
+rem a mega cool dos extender for watcom done by tran
+rem
+rem max 8 megs, dpmi stack 256*16=4096, no banner
+pmwlite.exe nasm.exe
+pmwsetup.exe /X8388608 /P256 /B0 nasm.exe
+pmwlite.exe ndisasm.exe
+pmwsetup.exe /X8388608 /P256 /B0 ndisasm.exe
diff --git a/misc/proc32.ash b/misc/proc32.ash
new file mode 100644
index 0000000..f513b73
--- /dev/null
+++ b/misc/proc32.ash
@@ -0,0 +1,441 @@
+;--------=========xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=========--------
+;
+; Copyright (C) 1999 by Andrew Zabolotny
+; Miscelaneous NASM macros that makes use of new preprocessor features
+;
+; This library is free software; you can redistribute it and/or
+; modify it under the terms of the GNU Library General Public
+; License as published by the Free Software Foundation; either
+; version 2 of the License, or (at your option) any later version.
+;
+; This library is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+; Library General Public License for more details.
+;
+; You should have received a copy of the GNU Library General Public
+; License along with this library; if not, write to the Free
+; Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+;
+;--------=========xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=========--------
+
+; The macros in this file provides support for writing 32-bit C-callable
+; NASM routines. For a short description of every macros see the
+; corresponding comment before every one. Simple usage example:
+;
+; proc sin,1
+; targ %$angle
+; fld %$angle
+; fsin
+; endproc sin
+
+%ifndef __PROC32_ASH__
+%define __PROC32_ASH__
+
+[WARNING -macro-selfref]
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; Mangle a name to be compatible with the C compiler
+; Arguments:
+; The name
+; Example:
+; cname (my_func)
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%ifdef EXTERNC_UNDERSCORE
+ %define cname(x) _ %+ x
+%else
+ %define cname(x) x
+%endif
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; Import an external C procedure definition
+; Arguments:
+; The name of external C procedure
+; Example:
+; cextern printf
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%macro cextern 1
+ %xdefine %1 cname(%1)
+ %ifidni __OUTPUT_FORMAT__,obj
+ extern %1:wrt FLAT
+ %else
+ extern %1
+ %endif
+%endmacro
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; Export an C procedure definition
+; Arguments:
+; The name of C procedure
+; Example:
+; cglobal my_printf
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%macro cglobal 1
+ %xdefine %1 cname(%1)
+ global %1
+%endmacro
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; Misc macros to deal with PIC shared libraries
+; Comment:
+; Note that we have a different syntax for working with and without
+; PIC shared libraries. In a PIC environment we should load first
+; the address of the variable into a register and then work through
+; that address, i.e: mov eax,myvar; mov [eax],1
+; In a non-PIC environment we should directly write: mov myvar,1
+; Example:
+; extvar myvar
+; GetGOT
+; %ifdef PIC
+; mov ebx,myvar ; get offset of myvar into ebx
+; %else
+; lea ebx,myvar
+; %endif
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%ifdef PIC
+ cextern _GLOBAL_OFFSET_TABLE_
+ %macro GetGOT 0
+ %ifdef .$proc.stkofs
+ %assign .$proc.stkofs .$proc.stkofs+4
+ %endif
+ call %$Get_GOT
+ %$Get_GOT:
+ pop ebx
+ add ebx,_GLOBAL_OFFSET_TABLE_ + $$ - %$Get_GOT wrt ..gotpc
+ %endmacro
+ %macro extvar 1
+ cextern %1
+ %xdefine %1 [ebx+%1 wrt ..got]
+ %endmacro
+%else
+ %define GetGOT
+ %macro extvar 1
+ cextern %1
+ %endmacro
+%endif
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; Begin a procedure definition
+; For performance reasons we don't use stack frame pointer EBP,
+; instead we're using the [esp+xx] addressing. Because of this
+; you should be careful when you work with stack pointer.
+; The push/pop instructions are macros that are defined to
+; deal correctly with these issues.
+; Arguments:
+; First argument - the procedure name
+; Second optional argument - the number of bytes for local variables
+; The following arguments could specify the registers that should be
+; pushed at beginning of procedure and popped before exiting
+; Example:
+; proc MyTestProc
+; proc MyTestProc,4,ebx,esi,edi
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%macro proc 1-3+ 0
+ cglobal %1
+ %push %1
+ align 16
+%1:
+ %xdefine %$proc.name %1
+ ; total size of local arguments
+ %assign %$proc.locsize (%2+3) & 0xFFFC
+ ; offset from esp to argument
+ %assign %$proc.argofs 4+%$proc.locsize
+ ; additional offset to args (tracks push/pops)
+ %assign .$proc.stkofs 0
+ ; offset from esp to local arguments
+ %assign %$proc.locofs 0
+ ; Now push the registers that we should save
+ %define %$proc.save %3
+ %if %$proc.locsize != 0
+ sub esp,%$proc.locsize
+ %endif
+ push %$proc.save
+%endmacro
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; Declare an argument passed on stack
+; This macro defines two additional macros:
+; first (with the name given by first argument) - [esp+xx]
+; second (with a underscore appended to first argument) - esp+xx
+; Arguments:
+; First argument defines the procedure argument name
+; Second optional parameter defines the size of the argument
+; Default value is 4 (a double word)
+; Example:
+; arg .my_float
+; arg .my_double,8
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%macro arg 1-2 4
+ %ifndef %$proc.argofs
+ %error "`arg' not in a proc context"
+ %else
+ ; Trick: temporary undefine .$proc.stkofs so that it won't be expanded
+ %assign %%. .$proc.stkofs
+ %undef .$proc.stkofs
+ %xdefine %{1}_ esp+%$proc.argofs+.$proc.stkofs
+ %xdefine %1 [esp+%$proc.argofs+.$proc.stkofs]
+ %assign .$proc.stkofs %%.
+ %assign %$proc.argofs %2+%$proc.argofs
+ %endif
+%endmacro
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; Declare an local variable
+; first (with the name given by first argument) - [esp+xx]
+; second (with a slash prefixing the first argument) - esp+xx
+; Arguments:
+; First argument defines the procedure argument name
+; Second optional parameter defines the size of the argument
+; Default value is 4 (a double word)
+; Example:
+; loc .int_value
+; loc .double_value,8
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%macro loc 1-2 4
+ %ifndef %$proc.locofs
+ %error "`loc' not in a proc context"
+ %elif %$proc.locofs + %2 > %$proc.locsize
+ %error "local stack space exceeded"
+ %else
+ %assign %%. .$proc.stkofs
+ %undef .$proc.stkofs
+ %xdefine %{1}_ esp+%$proc.locofs+.$proc.stkofs
+ %xdefine %1 [esp+%$proc.locofs+.$proc.stkofs]
+ %assign .$proc.stkofs %%.
+ %assign %$proc.locofs %$proc.locofs+%2
+ %endif
+%endmacro
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; Get the type of given size into context-local variable %$type
+; Arguments:
+; Size of type we want (1,2,4,8 or 10)
+; Example:
+; type 4 ; gives "dword"
+; type 10 ; gives "tword"
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%macro type 1
+ %if %1 = 1
+ %define %$type byte
+ %elif %1 = 2
+ %define %$type word
+ %elif %1 = 4
+ %define %$type dword
+ %elif %1 = 8
+ %define %$type qword
+ %elif %1 = 10
+ %define %$type tword
+ %else
+ %define %$. %1
+ %error "unknown type for argument size %$."
+ %endif
+%endmacro
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; Same as `arg' but prepends "word", "dword" etc (typed arg)
+; first (with the name given by first argument) - dword [esp+xx]
+; second (with a slash prefixing the first argument) - esp+xx
+; Arguments:
+; Same as for `arg'
+; Example:
+; targ .my_float ; .my_float is now "dword [esp+xxx]"
+; targ .my_double,8 ; .my_double is now "qword [esp+xxx]"
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%macro targ 1-2 4
+ %ifndef %$proc.argofs
+ %error "`targ' not in a proc context"
+ %else
+ arg %1,%2
+ type %2
+ %assign %%. .$proc.stkofs
+ %undef .$proc.stkofs
+ %xdefine %1 %$type %1
+ %assign .$proc.stkofs %%.
+ %endif
+%endmacro
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; Same as `loc' but prepends "word", "dword" etc (typed loc)
+; first (with the name given by first argument) - dword [esp+xx]
+; second (with a slash prefixing the first argument) - esp+xx
+; Arguments:
+; Same as for `loc'
+; Example:
+; tloc int_value
+; tloc double_value,8
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%macro tloc 1-2 4
+ %ifndef %$proc.locofs
+ %error "`tloc' not in a proc context"
+ %else
+ loc %1,%2
+ type %2
+ %assign %%. .$proc.stkofs
+ %undef .$proc.stkofs
+ %xdefine %1 %$type %1
+ %assign .$proc.stkofs %%.
+ %endif
+%endmacro
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; Finish a procedure
+; Gives an error if proc/endproc pairs mismatch
+; Defines an label called __end_(procedure name)
+; which is useful for calculating function size
+; Arguments:
+; (optional) The name of procedure
+; Example:
+; endproc MyTestProc
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%push tmp ; trick: define a dummy context to avoid error in next line
+%macro endproc 0-1 %$proc.name
+ %ifndef %$proc.argofs
+ %error "`endproc' not in a proc context"
+ %elifnidn %$proc.name,%1
+ %define %$. %1
+ %error "endproc names mismatch: expected `%$proc.name'"
+ %error "but got `%$.' instead"
+ %elif %$proc.locofs < %$proc.locsize
+ %error "unused local space declared (used %$proc.locofs, requested %$proc.locsize)"
+ %else
+%$exit:
+ ; Now pop the registers that we should restore on exit
+ pop %$proc.save
+ %if %$proc.locsize != 0
+ add esp,%$proc.locsize
+ %endif
+ ret
+__end_%1:
+ %pop
+ %endif
+%endmacro
+%pop
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; A replacement for "push" for use within procedures
+; Arguments:
+; any number of registers which will be push'ed successively
+; Example:
+; push eax,ebx,ecx,edx
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%macro push 0-*
+; dummy comment to avoid problems with "push" on the same line with a label
+ %rep %0
+ push %1
+ %rotate 1
+ %assign .$proc.stkofs .$proc.stkofs+4
+ %endrep
+%endmacro
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; A replacement for "pop" for use within procedures
+; Arguments:
+; any number of registers which will be pop'ed in reverse order
+; Example:
+; pop eax,ebx,ecx,edx
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%macro pop 0-*
+; dummy comment to avoid problems with "pop" on the same line with a label
+ %rep %0
+ %rotate -1
+ pop %1
+ %assign .$proc.stkofs .$proc.stkofs-4
+ %endrep
+%endmacro
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; Replacements for "pushfd" and "popfd" that takes care of esp
+; Example:
+; pushfd
+; popfd
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%macro pushfd 0
+ pushfd
+ %assign .$proc.stkofs .$proc.stkofs+4
+%endmacro
+%macro popfd 0
+ popfd
+ %assign .$proc.stkofs .$proc.stkofs-4
+%endmacro
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; Exit from current procedure (optionally on given condition)
+; Arguments:
+; Either none or a condition code
+; Example:
+; exit
+; exit nz
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%macro exit 0-1 mp
+ j%1 near %$exit
+%endmacro
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; start an conditional branch
+; Arguments:
+; A condition code
+; second (optional) argument - "short" (by default - "near")
+; Example:
+; if nz
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%macro if 1-2 near
+; dummy comment to avoid problems with "if" on the same line with a label
+ %push if
+ j%-1 %2 %$elseif
+%endmacro
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; define the "else" branch of a conditional statement
+; Arguments:
+; optionaly: "short" if jmp to endif is less than 128 bytes away
+; Example:
+; else
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%macro else 0-1
+ %ifnctx if
+ %error "`else' without matching `if'"
+ %else
+ jmp %1 %$endif
+%$elseif:
+ %define %$elseif_defined
+ %endif
+%endmacro
+
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+; Summary:
+; Finish am conditional statement
+; Arguments:
+; none
+; Example:
+; endif
+;-----======xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx======-----
+%macro endif 0
+ %ifnctx if
+ %error "`endif' without matching `if'"
+ %else
+ %ifndef %$elseif_defined
+%$elseif:
+ %endif
+%$endif:
+ %pop
+ %endif
+%endmacro
+
+%endif ; __PROC32_ASH__
diff --git a/misc/release b/misc/release
new file mode 100755
index 0000000..9b8cffa
--- /dev/null
+++ b/misc/release
@@ -0,0 +1,96 @@
+#!/bin/bash -xe
+#
+# Generate a NASM release
+#
+# Usage: release version [destination]
+#
+
+version="$1"
+if [ -z "$1" ]; then
+ echo "Usage: $0 version [destination]" 1>&2
+ exit 1
+fi
+
+WHERE="$2"
+if [ -z "$WHERE" ]; then
+ WHERE=/var/tmp
+fi
+
+if [ -n "$GIT_DIR" ]; then
+ HERE="$GIT_DIR"
+else
+ HERE=`pwd`
+fi
+
+if [ x`cat version` != x"${version}" ]; then
+ echo "${version}" > version
+ git update-index version
+ git commit -m "Version ${version}" -- version
+fi
+git tag -m "NASM version ${version}" -f "nasm-${version}"
+
+cd "$WHERE"
+rm -rf nasm-release.*
+work=nasm-release.$$
+mkdir $work
+cd $work
+unset GIT_DIR
+git clone -s -l "$HERE" nasm
+rm -rf nasm/.git nasm/.gitignore
+
+# Create files which are in the release but automatically generated
+cd nasm
+./autogen.sh
+./configure --prefix=/usr/local
+make perlreq spec
+make alldeps
+make distclean
+cd ..
+
+# Clean up any previous attempt
+rm -f ../nasm-"$version".tar.gz ../nasm-"$version"-xdoc.tar.gz
+rm -f ../nasm-"$version".tar.bz2 ../nasm-"$version"-xdoc.tar.bz2
+rm -f ../nasm-"$version".zip ../nasm-"$version"-xdoc.zip
+
+# Create tarfile (Unix convention: file includes prefix)
+mv nasm nasm-"$version"
+tar cvvf nasm-"$version".tar nasm-"$version"
+bzip2 -9k nasm-"$version".tar
+gzip -9 nasm-"$version".tar
+mv nasm-"$version".tar.gz nasm-"$version".tar.bz2 ..
+
+# Create zipfile (DOS convention: no prefix, convert file endings)
+cd nasm-"$version"
+zip -9Dlr ../../nasm-"$version".zip * -x \*.jpg -x \*.zip -x \*.ico # Text files
+zip -9Dgr ../../nasm-"$version".zip * -i \*.jpg -i \*.zip -i \*.ico # Binary files
+cd ..
+
+# Record what we have already generated
+find nasm-"$version" -not -type d -print > main
+
+# Create documentation
+cd nasm-"$version"
+./configure --prefix=/usr/local
+make doc
+# Remove intermediate files.
+make cleaner
+cd ..
+
+# Remove non-documentation
+cat main | xargs rm -f
+
+# Create doc tarfile
+tar cvvf nasm-"$version"-xdoc.tar nasm-"$version"/doc
+bzip2 -9k nasm-"$version"-xdoc.tar
+gzip -9 nasm-"$version"-xdoc.tar
+mv nasm-"$version"-xdoc.tar.gz nasm-"$version"-xdoc.tar.bz2 ..
+
+# Create doc zipfile (DOS convention: no prefix, convert file endings)
+# (Note: generating Win .hlp files requires additional tools)
+cd nasm-"$version"
+zip -9Dlr ../../nasm-"$version"-xdoc.zip doc -x \*.pdf -x \*.info\*
+zip -9Dgr ../../nasm-"$version"-xdoc.zip doc -i \*.pdf -i \*.info\*
+
+# Clean up
+cd ../..
+rm -rf "$work"
diff --git a/misc/scitech.mac b/misc/scitech.mac
new file mode 100644
index 0000000..26f85f4
--- /dev/null
+++ b/misc/scitech.mac
@@ -0,0 +1,1223 @@
+;****************************************************************************
+;*
+;* ========================================================================
+;*
+;* The contents of this file are subject to the SciTech MGL Public
+;* License Version 1.0 (the "License"); you may not use this file
+;* except in compliance with the License. You may obtain a copy of
+;* the License at http://www.scitechsoft.com/mgl-license.txt
+;*
+;* Software distributed under the License is distributed on an
+;* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+;* implied. See the License for the specific language governing
+;* rights and limitations under the License.
+;*
+;* The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
+;*
+;* The Initial Developer of the Original Code is SciTech Software, Inc.
+;* All Rights Reserved.
+;*
+;* ========================================================================
+;*
+;* Language: NetWide Assembler (NASM) or Turbo Assembler (TASM)
+;* Environment: Any Intel Environment
+;*
+;* Description: Macros to provide memory model independant assembly language
+;* module for C programming. Supports the large and flat memory
+;* models.
+;*
+;* The defines that you should use when assembling modules that
+;* use this macro package are:
+;*
+;* __LARGE__ Assemble for 16-bit large model
+;* __FLAT__ Assemble for 32-bit FLAT memory model
+;* __NOU__ No underscore for all external C labels
+;* __NOU_VAR__ No underscore for global variables only
+;*
+;* The default settings are for 16-bit large memory model with
+;* leading underscores for symbol names.
+;*
+;* The main intent of the macro file is to enable programmers
+;* to write _one_ set of source that can be assembled to run
+;* in either 16 bit real and protected modes or 32 bit
+;* protected mode without the need to riddle the code with
+;* 'if flatmodel' style conditional assembly (it is still there
+;* but nicely hidden by a macro layer that enhances the
+;* readability and understandability of the resulting code).
+;*
+;****************************************************************************
+
+; Include the appropriate version in here depending on the assembler. NASM
+; appears to always try and parse code, even if it is in a non-compiling
+; block of a ifdef expression, and hence crashes if we include the TASM
+; macro package in the same header file. Hence we split the macros up into
+; two separate header files.
+
+ifdef __NASM_MAJOR__
+
+;============================================================================
+; Macro package when compiling with NASM.
+;============================================================================
+
+; Turn off underscores for globals if disabled for all externals
+
+%ifdef __NOU__
+%define __NOU_VAR__
+%endif
+
+; Define the __WINDOWS__ symbol if we are compiling for any Windows
+; environment
+
+%ifdef __WINDOWS16__
+%define __WINDOWS__ 1
+%endif
+%ifdef __WINDOWS32__
+%define __WINDOWS__ 1
+%define __WINDOWS32_386__ 1
+%endif
+
+; Macros for accessing 'generic' registers
+
+%ifdef __FLAT__
+%idefine _ax eax
+%idefine _bx ebx
+%idefine _cx ecx
+%idefine _dx edx
+%idefine _si esi
+%idefine _di edi
+%idefine _bp ebp
+%idefine _sp esp
+%idefine _es
+%idefine UCHAR BYTE ; Size of a character
+%idefine USHORT WORD ; Size of a short
+%idefine UINT DWORD ; Size of an integer
+%idefine ULONG DWORD ; Size of a long
+%idefine BOOL DWORD ; Size of a boolean
+%idefine DPTR DWORD ; Size of a data pointer
+%idefine FDPTR FWORD ; Size of a far data pointer
+%idefine NDPTR DWORD ; Size of a near data pointer
+%idefine CPTR DWORD ; Size of a code pointer
+%idefine FCPTR FWORD ; Size of a far code pointer
+%idefine NCPTR DWORD ; Size of a near code pointer
+%idefine FPTR NEAR ; Distance for function pointers
+%idefine DUINT dd ; Declare a integer variable
+%idefine intsize 4
+%idefine flatmodel 1
+%else
+%idefine _ax ax
+%idefine _bx bx
+%idefine _cx cx
+%idefine _dx dx
+%idefine _si si
+%idefine _di di
+%idefine _bp bp
+%idefine _sp sp
+%idefine _es es:
+%idefine UCHAR BYTE ; Size of a character
+%idefine USHORT WORD ; Size of a short
+%idefine UINT WORD ; Size of an integer
+%idefine ULONG DWORD ; Size of a long
+%idefine BOOL WORD ; Size of a boolean
+%idefine DPTR DWORD ; Size of a data pointer
+%idefine FDPTR DWORD ; Size of a far data pointer
+%idefine NDPTR WORD ; Size of a near data pointer
+%idefine CPTR DWORD ; Size of a code pointer
+%idefine FCPTR DWORD ; Size of a far code pointer
+%idefine NCPTR WORD ; Size of a near code pointer
+%idefine FPTR FAR ; Distance for function pointers
+%idefine DUINT dw ; Declare a integer variable
+%idefine intsize 2
+%endif
+%idefine invert ~
+%idefine offset
+%idefine use_nasm
+
+; Convert all jumps to near jumps, since NASM does not so this automatically
+
+%idefine jo jo near
+%idefine jno jno near
+%idefine jz jz near
+%idefine jnz jnz near
+%idefine je je near
+%idefine jne jne near
+%idefine jb jb near
+%idefine jbe jbe near
+%idefine ja ja near
+%idefine jae jae near
+%idefine jl jl near
+%idefine jle jle near
+%idefine jg jg near
+%idefine jge jge near
+%idefine jc jc near
+%idefine jnc jnc near
+%idefine js js near
+%idefine jns jns near
+
+%ifdef DOUBLE
+%idefine REAL QWORD
+%idefine DREAL dq
+%else
+%idefine REAL DWORD
+%idefine DREAL dd
+%endif
+
+; Boolean truth values (same as those in debug.h)
+
+%idefine False 0
+%idefine True 1
+%idefine No 0
+%idefine Yes 1
+%idefine Yes 1
+
+; Macro to be invoked at the start of all modules to set up segments for
+; later use. Does nothing for NASM.
+
+%imacro header 1
+%endmacro
+
+; Macro to begin a data segment
+
+%imacro begdataseg 1
+%ifdef __GNUC__
+segment .data public class=DATA use32 flat
+%else
+%ifdef flatmodel
+segment _DATA public align=4 class=DATA use32 flat
+%else
+segment _DATA public align=4 class=DATA use16
+%endif
+%endif
+%endmacro
+
+; Macro to end a data segment
+
+%imacro enddataseg 1
+%endmacro
+
+; Macro to begin a code segment
+
+%imacro begcodeseg 1
+%ifdef __GNUC__
+segment .text public class=CODE use32 flat
+%else
+%ifdef flatmodel
+segment _TEXT public align=16 class=CODE use32 flat
+%else
+segment %1_TEXT public align=16 class=CODE use16
+%endif
+%endif
+%endmacro
+
+; Macro to begin a near code segment
+
+%imacro begcodeseg_near 0
+%ifdef __GNUC__
+segment .text public class=CODE use32 flat
+%else
+%ifdef flatmodel
+segment _TEXT public align=16 class=CODE use32 flat
+%else
+segment _TEXT public align=16 class=CODE use16
+%endif
+%endif
+%endmacro
+
+; Macro to end a code segment
+
+%imacro endcodeseg 1
+%endmacro
+
+; Macro to end a near code segment
+
+%imacro endcodeseg_near 0
+%endmacro
+
+; Macro for an extern C symbol. If the C compiler requires leading
+; underscores, then the underscores are added to the symbol names, otherwise
+; they are left off. The symbol name is referenced in the assembler code
+; using the non-underscored symbol name.
+
+%imacro cextern 2
+%ifdef __NOU_VAR__
+extern %1
+%else
+extern _%1
+%define %1 _%1
+%endif
+%endmacro
+
+%imacro cexternfunc 2
+%ifdef __NOU__
+extern %1
+%else
+extern _%1
+%define %1 _%1
+%endif
+%endmacro
+
+; Macro for a public C symbol. If the C compiler requires leading
+; underscores, then the underscores are added to the symbol names, otherwise
+; they are left off. The symbol name is referenced in the assembler code
+; using the non-underscored symbol name.
+
+%imacro cpublic 1
+%ifdef __NOU_VAR__
+global %1
+%1:
+%else
+global _%1
+_%1:
+%define %1 _%1
+%endif
+%endmacro
+
+; Macro for an global C symbol. If the C compiler requires leading
+; underscores, then the underscores are added to the symbol names, otherwise
+; they are left off. The symbol name is referenced in the assembler code
+; using the non-underscored symbol name.
+
+%imacro cglobal 1
+%ifdef __NOU_VAR__
+global %1
+%else
+global _%1
+%define %1 _%1
+%endif
+%endmacro
+
+; Macro for an global C function symbol. If the C compiler requires leading
+; underscores, then the underscores are added to the symbol names, otherwise
+; they are left off. The symbol name is referenced in the assembler code
+; using the non-underscored symbol name.
+
+%imacro cglobalfunc 1
+%ifdef __NOU__
+global %1
+%else
+global _%1
+%define %1 _%1
+%endif
+%endmacro
+
+; Macro to start a C callable function. This will be a far function for
+; 16-bit code, and a near function for 32-bit code.
+
+%imacro cprocstatic 1
+%push cproc
+%1:
+%ifdef flatmodel
+%stacksize flat
+%define ret retn
+%else
+%stacksize large
+%define ret retf
+%endif
+%assign %$localsize 0
+%endmacro
+
+%imacro cprocstart 1
+%push cproc
+ cglobalfunc %1
+%1:
+%ifdef flatmodel
+%stacksize flat
+%define ret retn
+%else
+%stacksize large
+%define ret retf
+%endif
+%assign %$localsize 0
+%endmacro
+
+; This macro sets up a procedure to be exported from a 16 bit DLL. Since the
+; calling conventions are always _far _pascal for 16 bit DLL's, we actually
+; rename this routine with an extra underscore with 'C' calling conventions
+; and a small DLL stub will be provided by the high level code to call the
+; assembler routine.
+
+%imacro cprocstartdll16 1
+%ifdef __WINDOWS16__
+cprocstart _%1
+%else
+cprocstart %1
+%endif
+%endmacro
+
+; Macro to start a C callable near function.
+
+%imacro cprocnear 1
+%push cproc
+ cglobalfunc %1
+%1:
+%define ret retn
+%ifdef flatmodel
+%stacksize flat
+%else
+%stacksize small
+%endif
+%assign %$localsize 0
+%endmacro
+
+; Macro to start a C callable far function.
+
+%imacro cprocfar 1
+%push cproc
+ cglobalfunc %1
+%1:
+%define ret retf
+%ifdef flatmodel
+%stacksize flat
+%else
+%stacksize large
+%endif
+%assign %$localsize 0
+%endmacro
+
+; Macro to end a C function
+
+%imacro cprocend 0
+%pop
+%endmacro
+
+; Macros for entering and exiting C callable functions. Note that we must
+; always save and restore the SI and DI registers for C functions, and for
+; 32 bit C functions we also need to save and restore EBX and clear the
+; direction flag.
+
+%imacro enter_c 0
+ push _bp
+ mov _bp,_sp
+%ifnidn %$localsize,0
+ sub _sp,%$localsize
+%endif
+%ifdef flatmodel
+ push ebx
+%endif
+ push _si
+ push _di
+%endmacro
+
+%imacro leave_c 0
+ pop _di
+ pop _si
+%ifdef flatmodel
+ pop ebx
+ cld
+%endif
+%ifnidn %$localsize,0
+ mov _sp,_bp
+%endif
+ pop _bp
+%endmacro
+
+%imacro use_ebx 0
+%ifdef flatmodel
+ push ebx
+%endif
+%endmacro
+
+%imacro unuse_ebx 0
+%ifdef flatmodel
+ pop ebx
+%endif
+%endmacro
+
+; Macros for saving and restoring the value of DS,ES,FS,GS when it is to
+; be used in assembly routines. This evaluates to nothing in the flat memory
+; model, but is saves and restores DS in the large memory model.
+
+%imacro use_ds 0
+%ifndef flatmodel
+ push ds
+%endif
+%endmacro
+
+%imacro unuse_ds 0
+%ifndef flatmodel
+ pop ds
+%endif
+%endmacro
+
+%imacro use_es 0
+%ifndef flatmodel
+ push es
+%endif
+%endmacro
+
+%imacro unuse_es 0
+%ifndef flatmodel
+ pop es
+%endif
+%endmacro
+
+; Macros for loading the address of a data pointer into a segment and
+; index register pair. The %imacro explicitly loads DS or ES in the 16 bit
+; memory model, or it simply loads the offset into the register in the flat
+; memory model since DS and ES always point to all addressable memory. You
+; must use the correct _REG (ie: _BX) %imacros for documentation purposes.
+
+%imacro _lds 2
+%ifdef flatmodel
+ mov %1,%2
+%else
+ lds %1,%2
+%endif
+%endmacro
+
+%imacro _les 2
+%ifdef flatmodel
+ mov %1,%2
+%else
+ les %1,%2
+%endif
+%endmacro
+
+; Macros for adding and subtracting a value from registers. Two value are
+; provided, one for 16 bit modes and another for 32 bit modes (the extended
+; register is used in 32 bit modes).
+
+%imacro _add 3
+%ifdef flatmodel
+ add e%1, %3
+%else
+ add %1, %2
+%endif
+%endmacro
+
+%imacro _sub 3
+%ifdef flatmodel
+ sub e%1, %3
+%else
+ sub %1, %2
+%endif
+%endmacro
+
+; Macro to clear the high order word for the 32 bit extended registers.
+; This is used to convert an unsigned 16 bit value to an unsigned 32 bit
+; value, and will evaluate to nothing in 16 bit modes.
+
+%imacro clrhi 1
+%ifdef flatmodel
+ movzx e%1,%1
+%endif
+%endmacro
+
+%imacro sgnhi 1
+%ifdef flatmodel
+ movsx e%1,%1
+%endif
+%endmacro
+
+; Macro to load an extended register with an integer value in either mode
+
+%imacro loadint 2
+%ifdef flatmodel
+ mov e%1,%2
+%else
+ xor e%1,e%1
+ mov %1,%2
+%endif
+%endmacro
+
+; Macros to load and store integer values with string instructions
+
+%imacro LODSINT 0
+%ifdef flatmodel
+ lodsd
+%else
+ lodsw
+%endif
+%endmacro
+
+%imacro STOSINT 0
+%ifdef flatmodel
+ stosd
+%else
+ stosw
+%endif
+%endmacro
+
+; Macros to provide resb, resw, resd compatibility with NASM
+
+%imacro dclb 1
+times %1 db 0
+%endmacro
+
+%imacro dclw 1
+times %1 dw 0
+%endmacro
+
+%imacro dcld 1
+times %1 dd 0
+%endmacro
+
+; macros to declare assembler function stubs for function structures
+
+%imacro BEGIN_STUBS_DEF 2
+begdataseg _STUBS
+%ifdef __NOU_VAR__
+extern %1
+%define STUBS_START %1
+%else
+extern _%1
+%define STUBS_START _%1
+%endif
+enddataseg _STUBS
+begcodeseg _STUBS
+%assign off %2
+%endmacro
+
+%imacro DECLARE_STUB 1
+%ifdef __NOU__
+ global %1
+%1:
+%else
+ global _%1
+_%1:
+%endif
+ jmp [DWORD STUBS_START+off]
+%assign off off+4
+%endmacro
+
+%imacro DECLARE_STDCALL 2
+%ifdef STDCALL_MANGLE
+ global _%1@%2
+_%1@%2:
+%else
+%ifdef __GNUC__
+ global _%1
+_%1:
+%else
+ global %1
+%1:
+%endif
+%endif
+ jmp [DWORD STUBS_START+off]
+%assign off off+4
+%endmacro
+
+%imacro END_STUBS_DEF 0
+endcodeseg _STUBS
+%endmacro
+
+; macros to declare assembler import stubs for binary loadable drivers
+
+%imacro BEGIN_IMPORTS_DEF 1
+BEGIN_STUBS_DEF %1,4
+%endmacro
+
+%imacro DECLARE_IMP 1
+DECLARE_STUB %1
+%endmacro
+
+%imacro END_IMPORTS_DEF 0
+END_STUBS_DEF
+%endmacro
+
+else ; __NASM_MAJOR__
+
+;============================================================================
+; Macro package when compiling with TASM.
+;============================================================================
+
+; Turn off underscores for globals if disabled for all externals
+
+ifdef __NOU__
+__NOU_VAR__ = 1
+endif
+
+; Define the __WINDOWS__ symbol if we are compiling for any Windows
+; environment
+
+ifdef __WINDOWS16__
+__WINDOWS__ = 1
+endif
+ifdef __WINDOWS32__
+__WINDOWS__ = 1
+__WINDOWS32_386__ = 1
+endif
+ifdef __WIN386__
+__WINDOWS__ = 1
+__WINDOWS32_386__ = 1
+endif
+ifdef __VXD__
+__WINDOWS__ = 1
+__WINDOWS32_386__ = 1
+ MASM
+ .386
+ NO_SEGMENTS = 1
+ include vmm.inc ; IGNORE DEPEND
+ include vsegment.inc ; IGNORE DEPEND
+ IDEAL
+endif
+
+; Macros for accessing 'generic' registers
+
+ifdef __FLAT__
+ _ax EQU eax ; EAX is used for accumulator
+ _bx EQU ebx ; EBX is used for accumulator
+ _cx EQU ecx ; ECX is used for looping
+ _dx EQU edx ; EDX is used for data register
+ _si EQU esi ; ESI is the source index register
+ _di EQU edi ; EDI is the destination index register
+ _bp EQU ebp ; EBP is used for base pointer register
+ _sp EQU esp ; ESP is used for stack pointer register
+ _es EQU ; ES and DS are the same in 32 bit PM
+ typedef UCHAR BYTE ; Size of a character
+ typedef USHORT WORD ; Size of a short
+ typedef UINT DWORD ; Size of an integer
+ typedef ULONG DWORD ; Size of a long
+ typedef BOOL DWORD ; Size of a boolean
+ typedef DPTR DWORD ; Size of a data pointer
+ typedef FDPTR FWORD ; Size of a far data pointer
+ typedef NDPTR DWORD ; Size of a near data pointer
+ typedef CPTR DWORD ; Size of a code pointer
+ typedef FCPTR FWORD ; Size of a far code pointer
+ typedef NCPTR DWORD ; Size of a near code pointer
+ typedef DUINT DWORD ; Declare a integer variable
+ FPTR EQU NEAR ; Distance for function pointers
+ intsize = 4 ; Size of an integer
+ flatmodel = 1 ; This is a flat memory model
+ P386 ; Turn on 386 code generation
+ MODEL FLAT ; Set up for 32 bit simplified FLAT model
+else
+ _ax EQU ax ; AX is used for accumulator
+ _bx EQU bx ; BX is used for accumulator
+ _cx EQU cx ; CX is used for looping
+ _dx EQU dx ; DX is used for data register
+ _si EQU si ; SI is the source index register
+ _di EQU di ; DI is the destination index register
+ _bp EQU bp ; BP is used for base pointer register
+ _sp EQU sp ; SP is used for stack pointer register
+ _es EQU es: ; ES is used for segment override
+ typedef UCHAR BYTE ; Size of a character
+ typedef USHORT WORD ; Size of a short
+ typedef UINT WORD ; Size of an integer
+ typedef ULONG DWORD ; Size of a long
+ typedef BOOL WORD ; Size of a boolean
+ typedef DPTR DWORD ; Size of a data pointer
+ typedef FDPTR DWORD ; Size of a far data pointer
+ typedef NDPTR WORD ; Size of a near data pointer
+ typedef CPTR DWORD ; Size of a code pointer
+ typedef FCPTR DWORD ; Size of a far code pointer
+ typedef NCPTR WORD ; Size of a near code pointer
+ typedef DUINT WORD ; Declare a integer variable
+ FPTR EQU FAR ; Distance for function pointers
+ intsize = 2 ; Size of an integer
+ P386 ; Turn on 386 code generation
+endif
+ invert EQU not
+
+; Provide a typedef for real floating point numbers
+
+ifdef DOUBLE
+typedef REAL QWORD
+typedef DREAL QWORD
+else
+typedef REAL DWORD
+typedef DREAL DWORD
+endif
+
+; Macros to access the floating point stack registers to convert them
+; from NASM style to TASM style
+
+st0 EQU st(0)
+st1 EQU st(1)
+st2 EQU st(2)
+st3 EQU st(3)
+st4 EQU st(4)
+st5 EQU st(5)
+st6 EQU st(6)
+st7 EQU st(7)
+st8 EQU st(8)
+
+; Boolean truth values (same as those in debug.h)
+
+ifndef __VXD__
+False = 0
+True = 1
+No = 0
+Yes = 1
+Yes = 1
+endif
+
+; Macros for the _DATA data segment. This segment contains initialised data.
+
+MACRO begdataseg name
+ifdef __VXD__
+ MASM
+VXD_LOCKED_DATA_SEG
+ IDEAL
+else
+ifdef flatmodel
+ DATASEG
+else
+SEGMENT _DATA DWORD PUBLIC USE16 'DATA'
+endif
+endif
+ENDM
+
+MACRO enddataseg name
+ifdef __VXD__
+ MASM
+VXD_LOCKED_DATA_ENDS
+ IDEAL
+else
+ifndef flatmodel
+ENDS _DATA
+endif
+endif
+ENDM
+
+; Macro for the main code segment.
+
+MACRO begcodeseg name
+ifdef __VXD__
+ MASM
+VXD_LOCKED_CODE_SEG
+ IDEAL
+else
+ifdef flatmodel
+ CODESEG
+ ASSUME CS:FLAT,DS:FLAT,SS:FLAT
+else
+SEGMENT &name&_TEXT PARA PUBLIC USE16 'CODE'
+ ASSUME CS:&name&_TEXT,DS:_DATA
+endif
+endif
+ENDM
+
+; Macro for a near code segment
+
+MACRO begcodeseg_near
+ifdef flatmodel
+ CODESEG
+ ASSUME CS:FLAT,DS:FLAT,SS:FLAT
+else
+SEGMENT _TEXT PARA PUBLIC USE16 'CODE'
+ ASSUME CS:_TEXT,DS:_DATA
+endif
+ENDM
+
+MACRO endcodeseg name
+ifdef __VXD__
+ MASM
+VXD_LOCKED_CODE_ENDS
+ IDEAL
+else
+ifndef flatmodel
+ENDS &name&_TEXT
+endif
+endif
+ENDM
+
+MACRO endcodeseg_near
+ifndef flatmodel
+ENDS _TEXT
+endif
+ENDM
+
+; Macro to be invoked at the start of all modules to set up segments for
+; later use.
+
+MACRO header name
+begdataseg name
+enddataseg name
+ENDM
+
+; Macro for an extern C symbol. If the C compiler requires leading
+; underscores, then the underscores are added to the symbol names, otherwise
+; they are left off. The symbol name is referenced in the assembler code
+; using the non-underscored symbol name.
+
+MACRO cextern name,size
+ifdef __NOU_VAR__
+ EXTRN name:size
+else
+ EXTRN _&name&:size
+name EQU _&name&
+endif
+ENDM
+
+MACRO cexternfunc name,size
+ifdef __NOU__
+ EXTRN name:size
+else
+ EXTRN _&name&:size
+name EQU _&name&
+endif
+ENDM
+
+MACRO stdexternfunc name,args,size
+ifdef STDCALL_MANGLE
+ EXTRN _&name&@&num_args&:size
+name EQU _&name&@&num_args
+else
+ EXTRN name:size
+endif
+ENDM
+
+; Macro for a public C symbol. If the C compiler requires leading
+; underscores, then the underscores are added to the symbol names, otherwise
+; they are left off. The symbol name is referenced in the assembler code
+; using the non-underscored symbol name.
+
+MACRO cpublic name
+ifdef __NOU_VAR__
+name:
+ PUBLIC name
+else
+_&name&:
+ PUBLIC _&name&
+name EQU _&name&
+endif
+ENDM
+
+; Macro for an global C symbol. If the C compiler requires leading
+; underscores, then the underscores are added to the symbol names, otherwise
+; they are left off. The symbol name is referenced in the assembler code
+; using the non-underscored symbol name.
+
+MACRO cglobal name
+ifdef __NOU_VAR__
+ PUBLIC name
+else
+ PUBLIC _&name&
+name EQU _&name&
+endif
+ENDM
+
+; Macro for an global C function symbol. If the C compiler requires leading
+; underscores, then the underscores are added to the symbol names, otherwise
+; they are left off. The symbol name is referenced in the assembler code
+; using the non-underscored symbol name.
+
+MACRO cglobalfunc name
+ifdef __NOU__
+ PUBLIC name
+else
+ PUBLIC _&name&
+name EQU _&name&
+endif
+ENDM
+
+; Macro to start a C callable function. This will be a far function for
+; 16-bit code, and a near function for 32-bit code.
+
+MACRO cprocstatic name ; Set up model independant private proc
+ifdef flatmodel
+PROC name NEAR
+else
+PROC name FAR
+endif
+LocalSize = 0
+ENDM
+
+MACRO cprocstart name ; Set up model independant proc
+ifdef flatmodel
+ifdef __NOU__
+PROC name NEAR
+else
+PROC _&name& NEAR
+endif
+else
+ifdef __NOU__
+PROC name FAR
+else
+PROC _&name& FAR
+endif
+endif
+LocalSize = 0
+ cglobalfunc name
+ENDM
+
+MACRO cprocnear name ; Set up near proc
+ifdef __NOU__
+PROC name NEAR
+else
+PROC _&name& NEAR
+endif
+LocalSize = 0
+ cglobalfunc name
+ENDM
+
+MACRO cprocfar name ; Set up far proc
+ifdef __NOU__
+PROC name FAR
+else
+PROC _&name& FAR
+endif
+LocalSize = 0
+ cglobalfunc name
+ENDM
+
+MACRO cprocend ; End procedure macro
+ENDP
+ENDM
+
+; This macro sets up a procedure to be exported from a 16 bit DLL. Since the
+; calling conventions are always _far _pascal for 16 bit DLL's, we actually
+; rename this routine with an extra underscore with 'C' calling conventions
+; and a small DLL stub will be provided by the high level code to call the
+; assembler routine.
+
+MACRO cprocstartdll16 name
+ifdef __WINDOWS16__
+cprocstart _&name&
+else
+cprocstart name
+endif
+ENDM
+
+; Macros for entering and exiting C callable functions. Note that we must
+; always save and restore the SI and DI registers for C functions, and for
+; 32 bit C functions we also need to save and restore EBX and clear the
+; direction flag.
+
+MACRO save_c_regs
+ifdef flatmodel
+ push ebx
+endif
+ push _si
+ push _di
+ENDM
+
+MACRO enter_c
+ push _bp
+ mov _bp,_sp
+ IFDIFI <LocalSize>,<0>
+ sub _sp,LocalSize
+ ENDIF
+ save_c_regs
+ENDM
+
+MACRO restore_c_regs
+ pop _di
+ pop _si
+ifdef flatmodel
+ pop ebx
+endif
+ENDM
+
+MACRO leave_c
+ restore_c_regs
+ cld
+ IFDIFI <LocalSize>,<0>
+ mov _sp,_bp
+ ENDIF
+ pop _bp
+ENDM
+
+MACRO use_ebx
+ifdef flatmodel
+ push ebx
+endif
+ENDM
+
+MACRO unuse_ebx
+ifdef flatmodel
+ pop ebx
+endif
+ENDM
+
+; Macros for saving and restoring the value of DS,ES,FS,GS when it is to
+; be used in assembly routines. This evaluates to nothing in the flat memory
+; model, but is saves and restores DS in the large memory model.
+
+MACRO use_ds
+ifndef flatmodel
+ push ds
+endif
+ENDM
+
+MACRO unuse_ds
+ifndef flatmodel
+ pop ds
+endif
+ENDM
+
+MACRO use_es
+ifndef flatmodel
+ push es
+endif
+ENDM
+
+MACRO unuse_es
+ifndef flatmodel
+ pop es
+endif
+ENDM
+
+; Macros for loading the address of a data pointer into a segment and
+; index register pair. The macro explicitly loads DS or ES in the 16 bit
+; memory model, or it simply loads the offset into the register in the flat
+; memory model since DS and ES always point to all addressable memory. You
+; must use the correct _REG (ie: _BX) macros for documentation purposes.
+
+MACRO _lds reg, addr
+ifdef flatmodel
+ mov reg,addr
+else
+ lds reg,addr
+endif
+ENDM
+
+MACRO _les reg, addr
+ifdef flatmodel
+ mov reg,addr
+else
+ les reg,addr
+endif
+ENDM
+
+; Macros for adding and subtracting a value from registers. Two value are
+; provided, one for 16 bit modes and another for 32 bit modes (the extended
+; register is used in 32 bit modes).
+
+MACRO _add reg, val16, val32
+ifdef flatmodel
+ add e&reg&, val32
+else
+ add reg, val16
+endif
+ENDM
+
+MACRO _sub reg, val16, val32
+ifdef flatmodel
+ sub e&reg&, val32
+else
+ sub reg, val16
+endif
+ENDM
+
+; Macro to clear the high order word for the 32 bit extended registers.
+; This is used to convert an unsigned 16 bit value to an unsigned 32 bit
+; value, and will evaluate to nothing in 16 bit modes.
+
+MACRO clrhi reg
+ifdef flatmodel
+ movzx e&reg&,reg
+endif
+ENDM
+
+MACRO sgnhi reg
+ifdef flatmodel
+ movsx e&reg&,reg
+endif
+ENDM
+
+; Macro to load an extended register with an integer value in either mode
+
+MACRO loadint reg,val
+ifdef flatmodel
+ mov e&reg&,val
+else
+ xor e&reg&,e&reg&
+ mov reg,val
+endif
+ENDM
+
+; Macros to load and store integer values with string instructions
+
+MACRO LODSINT
+ifdef flatmodel
+ lodsd
+else
+ lodsw
+endif
+ENDM
+
+MACRO STOSINT
+ifdef flatmodel
+ stosd
+else
+ stosw
+endif
+ENDM
+
+; Macros to provide resb, resw, resd compatibility with NASM
+
+MACRO dclb count
+db count dup (0)
+ENDM
+
+MACRO dclw count
+dw count dup (0)
+ENDM
+
+MACRO dcld count
+dd count dup (0)
+ENDM
+
+; Macros to provide resb, resw, resd compatibility with NASM
+
+MACRO resb count
+db count dup (?)
+ENDM
+
+MACRO resw count
+dw count dup (?)
+ENDM
+
+MACRO resd count
+dd count dup (?)
+ENDM
+
+; Macros to declare assembler stubs for function structures
+
+MACRO BEGIN_STUBS_DEF name, firstOffset
+begdataseg _STUBS
+ifdef __NOU_VAR__
+ EXTRN name:DWORD
+STUBS_START = name
+else
+ EXTRN _&name&:DWORD
+name EQU _&name&
+STUBS_START = _&name
+endif
+enddataseg _STUBS
+begcodeseg _STUBS
+off = firstOffset
+ENDM
+
+MACRO DECLARE_STUB name
+ifdef __NOU__
+name:
+ PUBLIC name
+else
+_&name:
+ PUBLIC _&name
+endif
+ jmp [DWORD STUBS_START+off]
+off = off + 4
+ENDM
+
+MACRO DECLARE_STDCALL name,num_args
+ifdef STDCALL_MANGLE
+_&name&@&num_args&:
+ PUBLIC _&name&@&num_args&
+else
+name:
+ PUBLIC name
+endif
+ jmp [DWORD STUBS_START+off]
+off = off + 4
+ENDM
+
+MACRO END_STUBS_DEF
+endcodeseg _STUBS
+ENDM
+
+MACRO BEGIN_IMPORTS_DEF name
+BEGIN_STUBS_DEF name,4
+ENDM
+
+MACRO DECLARE_IMP name
+DECLARE_STUB name
+ENDM
+
+MACRO END_IMPORTS_DEF
+END_STUBS_DEF
+ENDM
+
+endif
diff --git a/misc/tag-release b/misc/tag-release
new file mode 100755
index 0000000..efaa4c3
--- /dev/null
+++ b/misc/tag-release
@@ -0,0 +1,13 @@
+#!/bin/sh
+version="$1"
+if [ -z "$version" ]; then
+ echo "Usage: $0 version" 1>&2
+ exit 1
+fi
+
+echo "$version" > version
+git add version
+git commit -m "NASM $version"
+git tag -a -m "NASM $version" nasm-"$version"
+git push
+git push --tags
diff --git a/misc/xcrcgen.c b/misc/xcrcgen.c
new file mode 100644
index 0000000..acfd48e
--- /dev/null
+++ b/misc/xcrcgen.c
@@ -0,0 +1,80 @@
+/*
+ * Produce a "generalized CRC" table. Assumes a platform with
+ * /dev/urandom -- otherwise reimplement get_random_byte().
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static uint8_t get_random_byte(void)
+{
+ static int fd = -1;
+ uint8_t buf;
+ int rv;
+
+ if (fd < 0)
+ fd = open("/dev/urandom", O_RDONLY);
+
+ do {
+ errno = 0;
+ rv = read(fd, &buf, 1);
+ if (rv < 1 && errno != EAGAIN)
+ abort();
+ } while (rv < 1);
+
+ return buf;
+}
+
+static void random_permute(uint8_t *buf)
+{
+ int i, j, k;
+ int m;
+
+ for (i = 0; i < 256; i++)
+ buf[i] = i;
+
+ m = 255;
+ for (i = 255; i > 0; i--) {
+ if (i <= (m >> 1))
+ m >>= 1;
+ do {
+ j = get_random_byte() & m;
+ } while (j > i);
+ k = buf[i];
+ buf[i] = buf[j];
+ buf[j] = k;
+ }
+}
+
+static void xcrc_table(uint64_t *buf)
+{
+ uint8_t perm[256];
+ int i, j;
+
+ memset(buf, 0, 8*256); /* Make static checkers happy */
+
+ for (i = 0; i < 8; i++) {
+ random_permute(perm);
+ for (j = 0; j < 256; j++)
+ buf[j] = (buf[j] << 8) | perm[j];
+ }
+}
+
+int main(void)
+{
+ int i;
+ uint64_t buf[256];
+
+ xcrc_table(buf);
+
+ for (i = 0; i < 256; i++) {
+ printf("%016"PRIx64"\n", buf[i]);
+ }
+
+ return 0;
+}