diff options
Diffstat (limited to 'doc')
57 files changed, 17295 insertions, 0 deletions
diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..ae31229 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,102 @@ +# +# UNIX Makefile for NASM documentation +# + +srcdir = . + +prefix = /usr/local +exec_prefix = ${prefix} +bindir = ${exec_prefix}/bin +mandir = ${datarootdir}/man +docdir = $(prefix)/doc/nasm +infodir = ${datarootdir}/info +datarootdir = ${prefix}/share + +INSTALL = /usr/bin/install -c +INSTALL_PROGRAM = ${INSTALL} +INSTALL_DATA = ${INSTALL} -m 644 + +PERL = perl +MAKEINFO = makeinfo +TEXI2DVI = texi2dvi +TEXI2IPF = texi2ipf +IPFC = ipfc + +ACRODIST = false # Acrobat Distiller +PSTOPDF = false # BSD/MacOS X utility +PS2PDF = ps2pdf # Part of GhostScript + +SRCS = nasmdoc.src inslist.src changes.src +OUT = info html nasmdoc.txt nasmdoc.ps nasmdoc.pdf + +# exports +export srcdir +export PERL + +all: $(OUT) + +os2: nasm.inf + +inslist.src: inslist.pl ../insns.dat + $(PERL) $(srcdir)/inslist.pl + +.PHONY: html +html: html/nasmdoc0.html + +html/nasmdoc0.html: $(SRCS) rdsrc.pl + mkdir -p html + $(PERL) $(srcdir)/rdsrc.pl html < $< + mv -f *.html html + +nasmdoc.dip: $(SRCS) rdsrc.pl + $(PERL) $(srcdir)/rdsrc.pl dip < $< + +nasmdoc.texi: $(SRCS) rdsrc.pl + $(PERL) $(srcdir)/rdsrc.pl texi < $< + +nasmdoc.txt: $(SRCS) rdsrc.pl + $(PERL) $(srcdir)/rdsrc.pl txt < $< + +nasmdoc.ps: nasmdoc.dip nasmlogo.eps $(srcdir)/../version genpsdriver.pl \ + genps.pl psfonts.ph pswidth.ph head.ps + $(PERL) $(srcdir)/genpsdriver.pl > nasmdoc.ps + +nasmdoc.pdf: nasmdoc.ps + $(ACRODIST) -n -q --nosecurity -o $@ $< || \ + $(PS2PDF) $< $@ || \ + $(PSTOPDF) $< -o $@ + +.PHONY: info +info: info/nasm.info + +info/nasm.info: nasmdoc.texi + mkdir -p info + $(MAKEINFO) $< + mv -f *.info *.info-* info + +# DVI output from texinfo (optional) +nasmdoc.dvi: nasmdoc.texi + $(TEXI2DVI) nasmdoc.texi + +# Rules for building an OS/2 book +nasmdoc.ipf: nasmdoc.texi + $(TEXI2IPF) $< >$@ + +nasm.inf: nasmdoc.ipf + $(IPFC) -i -s $< $@ + +clean: + -rm -f *.rtf *.hpj *.texi *.gid *.ipf *.dip + -rm -f *.aux *.cp *.fn *.ky *.pg *.log *.toc *.tp *.vr + +spotless: clean + -rm -rf html info + -rm -f *.hlp nasmdoc.txt *.inf *.pdf *.dvi + -rm -f nasmdoc*.ps inslist.src + +install: all + mkdir -p $(INSTALLROOT)$(infodir) + $(INSTALL_DATA) info/* $(INSTALLROOT)$(infodir) + mkdir -p $(INSTALLROOT)$(docdir)/html + $(INSTALL_DATA) html/* $(INSTALLROOT)$(docdir)/html + $(INSTALL_DATA) nasmdoc.ps nasmdoc.pdf nasmdoc.txt $(INSTALLROOT)$(docdir) diff --git a/doc/Makefile.in b/doc/Makefile.in new file mode 100644 index 0000000..a2ef4e3 --- /dev/null +++ b/doc/Makefile.in @@ -0,0 +1,102 @@ +# +# UNIX Makefile for NASM documentation +# + +srcdir = @srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +mandir = @mandir@ +docdir = $(prefix)/doc/nasm +infodir = @infodir@ +datarootdir = @datarootdir@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +PERL = perl +MAKEINFO = makeinfo +TEXI2DVI = texi2dvi +TEXI2IPF = texi2ipf +IPFC = ipfc + +ACRODIST = @ACRODIST@ # Acrobat Distiller +PSTOPDF = @PSTOPDF@ # BSD/MacOS X utility +PS2PDF = @PS2PDF@ # Part of GhostScript + +SRCS = nasmdoc.src inslist.src changes.src +OUT = info html nasmdoc.txt nasmdoc.ps nasmdoc.pdf + +# exports +export srcdir +export PERL + +all: $(OUT) + +os2: nasm.inf + +inslist.src: inslist.pl ../insns.dat + $(PERL) $(srcdir)/inslist.pl + +.PHONY: html +html: html/nasmdoc0.html + +html/nasmdoc0.html: $(SRCS) rdsrc.pl + mkdir -p html + $(PERL) $(srcdir)/rdsrc.pl html < $< + mv -f *.html html + +nasmdoc.dip: $(SRCS) rdsrc.pl + $(PERL) $(srcdir)/rdsrc.pl dip < $< + +nasmdoc.texi: $(SRCS) rdsrc.pl + $(PERL) $(srcdir)/rdsrc.pl texi < $< + +nasmdoc.txt: $(SRCS) rdsrc.pl + $(PERL) $(srcdir)/rdsrc.pl txt < $< + +nasmdoc.ps: nasmdoc.dip nasmlogo.eps $(srcdir)/../version genpsdriver.pl \ + genps.pl psfonts.ph pswidth.ph head.ps + $(PERL) $(srcdir)/genpsdriver.pl > nasmdoc.ps + +nasmdoc.pdf: nasmdoc.ps + $(ACRODIST) -n -q --nosecurity -o $@ $< || \ + $(PS2PDF) $< $@ || \ + $(PSTOPDF) $< -o $@ + +.PHONY: info +info: info/nasm.info + +info/nasm.info: nasmdoc.texi + mkdir -p info + $(MAKEINFO) $< + mv -f *.info *.info-* info + +# DVI output from texinfo (optional) +nasmdoc.dvi: nasmdoc.texi + $(TEXI2DVI) nasmdoc.texi + +# Rules for building an OS/2 book +nasmdoc.ipf: nasmdoc.texi + $(TEXI2IPF) $< >$@ + +nasm.inf: nasmdoc.ipf + $(IPFC) -i -s $< $@ + +clean: + -rm -f *.rtf *.hpj *.texi *.gid *.ipf *.dip + -rm -f *.aux *.cp *.fn *.ky *.pg *.log *.toc *.tp *.vr + +spotless: clean + -rm -rf html info + -rm -f *.hlp nasmdoc.txt *.inf *.pdf *.dvi + -rm -f nasmdoc*.ps inslist.src + +install: all + mkdir -p $(INSTALLROOT)$(infodir) + $(INSTALL_DATA) info/* $(INSTALLROOT)$(infodir) + mkdir -p $(INSTALLROOT)$(docdir)/html + $(INSTALL_DATA) html/* $(INSTALLROOT)$(docdir)/html + $(INSTALL_DATA) nasmdoc.ps nasmdoc.pdf nasmdoc.txt $(INSTALLROOT)$(docdir) diff --git a/doc/afmmetrics.pl b/doc/afmmetrics.pl new file mode 100755 index 0000000..6d7bfc2 --- /dev/null +++ b/doc/afmmetrics.pl @@ -0,0 +1,130 @@ +#!/usr/bin/perl +## -------------------------------------------------------------------------- +## +## Copyright 1996-2009 The NASM Authors - All Rights Reserved +## See the file AUTHORS included with the NASM distribution for +## the specific copyright holders. +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following +## conditions are met: +## +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above +## copyright notice, this list of conditions and the following +## disclaimer in the documentation and/or other materials provided +## with the distribution. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +## CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## -------------------------------------------------------------------------- + +# +# Parse AFM metric files +# + +@widths = ((undef)x256); + +while ( $line = <STDIN> ) { + if ( $line =~ /^\s*FontName\s+(.*)\s*$/ ) { + $fontname = $1; + } elsif ( $line =~ /^\s*StartCharMetrics\b/ ) { + $charmetrics = 1; + } elsif ( $line =~ /^\s*EndCharMetrics\b/ ) { + $charmetrics = 0; + } elsif ( $line =~ /^\s*StartKernPairs\b/ ) { + $kerndata = 1; + } elsif ( $line =~ /^\s*EndKernPairs\b/ ) { + $kerndata = 0; + } elsif ( $charmetrics ) { + @data = split(/\s*;\s*/, $line); + undef $charcode, $width, $name; + foreach $d ( @data ) { + @dd = split(/\s+/, $d); + if ( $dd[0] eq 'C' ) { + $charcode = $dd[1]; + } elsif ( $dd[0] eq 'WX' ) { + $width = $dd[1]; + } elsif ( $dd[0] eq 'W' ) { + $width = $dd[2]; + } elsif ( $dd[0] eq 'N' ) { + $name = $dd[1]; + } + } + if ( defined($name) && defined($width) ) { + $charwidth{$name} = $width; + } + } elsif ( $kerndata ) { + @data = split(/\s+/, $line); + if ( $data[0] eq 'KPX' ) { + if ( defined($charcodes{$data[1]}) && + defined($charcodes{$data[2]}) && + $data[3] != 0 ) { + $kernpairs{chr($charcodes{$data[1]}). + chr($charcodes{$data[2]})} = $data[3]; + } + } + } +} + +sub qstr($) { + my($s) = @_; + my($o,$c,$i); + $o = '"'; + for ( $i = 0 ; $i < length($s) ; $i++ ) { + $c = substr($s,$i,1); + if ( $c lt ' ' || $c gt '~' ) { + $o .= sprintf("\\%03o", ord($c)); + } elsif ( $c eq "\'" || $c eq "\"" || $c eq "\\" ) { + $o .= "\\".$c; + } else { + $o .= $c; + } + } + return $o.'"'; +} + +$psfont = $fontname; +$psfont =~ s/[^A-Za-z0-9]/_/g; + +print "%PS_${psfont} = (\n"; +print " name => \'$fontname\',\n"; +print " widths => {"; +$lw = 100000; +foreach $cc ( keys(%charwidth) ) { + $ss = sprintf('%s => %d, ', qstr($cc), $charwidth{$cc}); + $lw += length($ss); + if ( $lw > 72 ) { + print "\n "; + $lw = 4 + length($ss); + } + print $ss; +} +print "\n }\n"; +#print " kern => {"; +#$lw = 100000; +#foreach $kp ( keys(%kernpairs) ) { +# $ss = sprintf('%s => %d, ', qstr($kp), $kernpairs{$kp}); +# $lw += length($ss); +# if ( $lw > 72 ) { +# print "\n "; +# $lw = 4 + length($ss); +# } +# print $ss; +#} +#print " }\n"; +print ");\n"; +print "1;\n"; diff --git a/doc/changes.src b/doc/changes.src new file mode 100644 index 0000000..0592f22 --- /dev/null +++ b/doc/changes.src @@ -0,0 +1,1938 @@ +\# +\# NASM revision history in nasmdoc format +\# + +\H{cl-2.xx} NASM 2 Series + +The NASM 2 series support x86-64, and is the production version of NASM +since 2007. + + +\S{cl-2.08} Version 2.08 + +\b A number of enhancements/fixes in macros area. + +\b Support for arbitrarily terminating macro expansions \c{%exitmacro}. + See \k{exitmacro}. + +\b Support for recursive macro expansion \c{%rmacro/irmacro}. + See \k{mlrmacro}. + +\b Support for converting strings to tokens. See \k{deftok}. + +\b Fuzzy operand size logic introduced. + +\b Fix COFF stack overrun on too long export identifiers. + +\b Fix Macho-O alignment bug. + +\b Fix crashes with -fwin32 on file with many exports. + +\b Fix stack overrun for too long [DEBUG id]. + +\b Fix incorrect sbyte usage in IMUL (hit only if optimization + flag passed). + +\b Append ending token for \c{.stabs} records in the ELF output format. + +\b New NSIS script which uses ModernUI and MultiUser approach. + +\b Visual Studio 2008 NASM integration (rules file). + +\b Warn a user if a constant is too long (and as result will be stripped). + +\b The obsoleted pre-XOP AMD SSE5 instruction set which was never actualized + was removed. + +\b Fix stack overrun on too long error file name passed from the command line. + +\b Bind symbols to the .text section by default (ie in case if SECTION + directive was omitted) in the ELF output format. + +\b Fix sync points array index wrapping. + +\b A few fixes for FMA4 and XOP instruction templates. + +\b Add AMD Lightweight Profiling (LWP) instructions. + +\S{cl-2.07} Version 2.07 + +\b NASM is now under the 2-clause BSD license. See \k{legal}. + +\b Fix the section type for the \c{.strtab} section in the \c{elf64} + output format. + +\b Fix the handling of \c{COMMON} directives in the \c{obj} output format. + +\b New \c{ith} and \c{srec} output formats; these are variants of the + \c{bin} output format which output Intel hex and Motorola S-records, + respectively. See \k{ithfmt} and \k{srecfmt}. + +\b \c{rdf2ihx} replaced with an enhanced \c{rdf2bin}, which can output + binary, COM, Intel hex or Motorola S-records. + +\b The Windows installer now puts the NASM directory first in the + \c{PATH} of the "NASM Shell". + +\b Revert the early expansion behavior of \c{%+} to pre-2.06 behavior: + \c{%+} is only expanded late. + +\b Yet another Mach-O alignment fix. + +\b Don't delete the list file on errors. Also, include error and + warning information in the list file. + +\b Support for 64-bit Mach-O output, see \k{machofmt}. + +\b Fix assert failure on certain operations that involve strings with + high-bit bytes. + + +\S{cl-2.06} Version 2.06 + +\b This release is dedicated to the memory of Charles A. Crayne, long + time NASM developer as well as moderator of \c{comp.lang.asm.x86} and + author of the book \e{Serious Assembler}. We miss you, Chuck. + +\b Support for indirect macro expansion (\c{%[...]}). See \k{indmacro}. + +\b \c{%pop} can now take an argument, see \k{pushpop}. + +\b The argument to \c{%use} is no longer macro-expanded. Use + \c{%[...]} if macro expansion is desired. + +\b Support for thread-local storage in ELF32 and ELF64. See \k{elftls}. + +\b Fix crash on \c{%ifmacro} without an argument. + +\b Correct the arguments to the \c{POPCNT} instruction. + +\b Fix section alignment in the Mach-O format. + +\b Update AVX support to version 5 of the Intel specification. + +\b Fix the handling of accesses to context-local macros from higher + levels in the context stack. + +\b Treat \c{WAIT} as a prefix rather than as an instruction, thereby + allowing constructs like \c{O16 FSAVE} to work correctly. + +\b Support for structures with a non-zero base offset. See \k{struc}. + +\b Correctly handle preprocessor token concatenation (see \k{concat}) + involving floating-point numbers. + +\b The \c{PINSR} series of instructions have been corrected and + rationalized. + +\b Removed AMD SSE5, replaced with the new XOP/FMA4/CVT16 (rev 3.03) + spec. + +\b The ELF backends no longer automatically generate a \c{.comment} section. + +\b Add additional "well-known" ELF sections with default attributes. See + \k{elfsect}. + + +\S{cl-2.05.01} Version 2.05.01 + +\b Fix the \c{-w}/\c{-W} option parsing, which was broken in NASM 2.05. + + +\S{cl-2.05} Version 2.05 + +\b Fix redundant REX.W prefix on \c{JMP reg64}. + +\b Make the behaviour of \c{-O0} match NASM 0.98 legacy behavior. + See \k{opt-O}. + +\b \c{-w-user} can be used to suppress the output of \c{%warning} directives. + See \k{opt-w}. + +\b Fix bug where \c{ALIGN} would issue a full alignment datum instead of + zero bytes. + +\b Fix offsets in list files. + +\b Fix \c{%include} inside multi-line macros or loops. + +\b Fix error where NASM would generate a spurious warning on valid + optimizations of immediate values. + +\b Fix arguments to a number of the \c{CVT} SSE instructions. + +\b Fix RIP-relative offsets when the instruction carries an immediate. + +\b Massive overhaul of the ELF64 backend for spec compliance. + +\b Fix the Geode \c{PFRCPV} and \c{PFRSQRTV} instruction. + +\b Fix the SSE 4.2 \c{CRC32} instruction. + + +\S{cl-2.04} Version 2.04 + +\b Sanitize macro handing in the \c{%error} directive. + +\b New \c{%warning} directive to issue user-controlled warnings. + +\b \c{%error} directives are now deferred to the final assembly phase. + +\b New \c{%fatal} directive to immediately terminate assembly. + +\b New \c{%strcat} directive to join quoted strings together. + +\b New \c{%use} macro directive to support standard macro directives. See + \k{use}. + +\b Excess default parameters to \c{%macro} now issues a warning by default. + See \k{mlmacro}. + +\b Fix \c{%ifn} and \c{%elifn}. + +\b Fix nested \c{%else} clauses. + +\b Correct the handling of nested \c{%rep}s. + +\b New \c{%unmacro} directive to undeclare a multi-line macro. + See \k{unmacro}. + +\b Builtin macro \c{__PASS__} which expands to the current assembly pass. + See \k{pass_macro}. + +\b \c{__utf16__} and \c{__utf32__} operators to generate UTF-16 and UTF-32 + strings. See \k{unicode}. + +\b Fix bug in case-insensitive matching when compiled on platforms that + don't use the \c{configure} script. Of the official release binaries, + that only affected the OS/2 binary. + +\b Support for x87 packed BCD constants. See \k{bcdconst}. + +\b Correct the \c{LTR} and \c{SLDT} instructions in 64-bit mode. + +\b Fix unnecessary REX.W prefix on indirect jumps in 64-bit mode. + +\b Add AVX versions of the AES instructions (\c{VAES}...). + +\b Fix the 256-bit FMA instructions. + +\b Add 256-bit AVX stores per the latest AVX spec. + +\b VIA XCRYPT instructions can now be written either with or without + \c{REP}, apparently different versions of the VIA spec wrote them + differently. + +\b Add missing 64-bit \c{MOVNTI} instruction. + +\b Fix the operand size of \c{VMREAD} and \c{VMWRITE}. + +\b Numerous bug fixes, especially to the AES, AVX and VTX instructions. + +\b The optimizer now always runs until it converges. It also runs even + when disabled, but doesn't optimize. This allows most forward references + to be resolved properly. + +\b \c{%push} no longer needs a context identifier; omitting the context + identifier results in an anonymous context. + + +\S{cl-2.03.01} Version 2.03.01 + +\b Fix buffer overflow in the listing module. + +\b Fix the handling of hexadecimal escape codes in `...` strings. + +\b The Postscript/PDF documentation has been reformatted. + +\b The \c{-F} option now implies \c{-g}. + + +\S{cl-2.03} Version 2.03 + +\b Add support for Intel AVX, CLMUL and FMA instructions, +including YMM registers. + +\b \c{dy}, \c{resy} and \c{yword} for 32-byte operands. + +\b Fix some SSE5 instructions. + +\b Intel \c{INVEPT}, \c{INVVPID} and \c{MOVBE} instructions. + +\b Fix checking for critical expressions when the optimizer is enabled. + +\b Support the DWARF debugging format for ELF targets. + +\b Fix optimizations of signed bytes. + +\b Fix operation on bigendian machines. + +\b Fix buffer overflow in the preprocessor. + +\b \c{SAFESEH} support for Win32, \c{IMAGEREL} for Win64 (SEH). + +\b \c{%?} and \c{%??} to refer to the name of a macro itself. In particular, +\c{%idefine keyword $%?} can be used to make a keyword "disappear". + +\b New options for dependency generation: \c{-MD}, \c{-MF}, +\c{-MP}, \c{-MT}, \c{-MQ}. + +\b New preprocessor directives \c{%pathsearch} and \c{%depend}; INCBIN +reimplemented as a macro. + +\b \c{%include} now resolves macros in a sane manner. + +\b \c{%substr} can now be used to get other than one-character substrings. + +\b New type of character/string constants, using backquotes (\c{`...`}), +which support C-style escape sequences. + +\b \c{%defstr} and \c{%idefstr} to stringize macro definitions before +creation. + +\b Fix forward references used in \c{EQU} statements. + + +\S{cl-2.02} Version 2.02 + +\b Additional fixes for MMX operands with explicit \c{qword}, as well as + (hopefully) SSE operands with \c{oword}. + +\b Fix handling of truncated strings with \c{DO}. + +\b Fix segfaults due to memory overwrites when floating-point constants + were used. + +\b Fix segfaults due to missing include files. + +\b Fix OpenWatcom Makefiles for DOS and OS/2. + +\b Add autogenerated instruction list back into the documentation. + +\b ELF: Fix segfault when generating stabs, and no symbols have been + defined. + +\b ELF: Experimental support for DWARF debugging information. + +\b New compile date and time standard macros. + +\b \c{%ifnum} now returns true for negative numbers. + +\b New \c{%iftoken} test for a single token. + +\b New \c{%ifempty} test for empty expansion. + +\b Add support for the \c{XSAVE} instruction group. + +\b Makefile for Netware/gcc. + +\b Fix issue with some warnings getting emitted way too many times. + +\b Autogenerated instruction list added to the documentation. + + +\S{cl-2.01} Version 2.01 + +\b Fix the handling of MMX registers with explicit \c{qword} tags on + memory (broken in 2.00 due to 64-bit changes.) + +\b Fix the PREFETCH instructions. + +\b Fix the documentation. + +\b Fix debugging info when using \c{-f elf} +(backwards compatibility alias for \c{-f elf32}). + +\b Man pages for rdoff tools (from the Debian project.) + +\b ELF: handle large numbers of sections. + +\b Fix corrupt output when the optimizer runs out of passes. + + +\S{cl-2.00} Version 2.00 + +\b Added c99 data-type compliance. + +\b Added general x86-64 support. + +\b Added win64 (x86-64 COFF) output format. + +\b Added \c{__BITS__} standard macro. + +\b Renamed the \c{elf} output format to \c{elf32} for clarity. + +\b Added \c{elf64} and \c{macho} (MacOS X) output formats. + +\b Added Numeric constants in \c{dq} directive. + +\b Added \c{oword}, \c{do} and \c{reso} pseudo operands. + +\b Allow underscores in numbers. + +\b Added 8-, 16- and 128-bit floating-point formats. + +\b Added binary, octal and hexadecimal floating-point. + +\b Correct the generation of floating-point constants. + +\b Added floating-point option control. + +\b Added Infinity and NaN floating point support. + +\b Added ELF Symbol Visibility support. + +\b Added setting OSABI value in ELF header directive. + +\b Added Generate Makefile Dependencies option. + +\b Added Unlimited Optimization Passes option. + +\b Added \c{%IFN} and \c{%ELIFN} support. + +\b Added Logical Negation Operator. + +\b Enhanced Stack Relative Preprocessor Directives. + +\b Enhanced ELF Debug Formats. + +\b Enhanced Send Errors to a File option. + +\b Added SSSE3, SSE4.1, SSE4.2, SSE5 support. + +\b Added a large number of additional instructions. + +\b Significant performance improvements. + +\b \c{-w+warning} and \c{-w-warning} can now be written as -Wwarning and + -Wno-warning, respectively. See \k{opt-w}. + +\b Add \c{-w+error} to treat warnings as errors. See \k{opt-w}. + +\b Add \c{-w+all} and \c{-w-all} to enable or disable all suppressible + warnings. See \k{opt-w}. + + +\H{cl-0.98.xx} NASM 0.98 Series + +The 0.98 series was the production versions of NASM from 1999 to 2007. + + +\S{cl-0.98.39} Version 0.98.39 + +\b fix buffer overflow + +\b fix outas86's \c{.bss} handling + +\b "make spotless" no longer deletes config.h.in. + +\b \c{%(el)if(n)idn} insensitivity to string quotes difference (#809300). + +\b (nasm.c)\c{__OUTPUT_FORMAT__} changed to string value instead of symbol. + +\S{cl-0.98.38} Version 0.98.38 + + +\b Add Makefile for 16-bit DOS binaries under OpenWatcom, and modify + \c{mkdep.pl} to be able to generate completely pathless dependencies, as + required by OpenWatcom wmake (it supports path searches, but not + explicit paths.) + +\b Fix the \c{STR} instruction. + +\b Fix the ELF output format, which was broken under certain + circumstances due to the addition of stabs support. + +\b Quick-fix Borland format debug-info for \c{-f obj} + +\b Fix for \c{%rep} with no arguments (#560568) + +\b Fix concatenation of preprocessor function call (#794686) + +\b Fix long label causes coredump (#677841) + +\b Use autoheader as well as autoconf to keep configure from generating + ridiculously long command lines. + +\b Make sure that all of the formats which support debugging output + actually will suppress debugging output when \c{-g} not specified. + +\S{cl-0.98.37} Version 0.98.37 + + +\b Paths given in \c{-I} switch searched for \c{incbin}-ed as + well as \c{%include}-ed files. + +\b Added stabs debugging for the ELF output format, patch from + Martin Wawro. + +\b Fix \c{output/outbin.c} to allow origin > 80000000h. + +\b Make \c{-U} switch work. + +\b Fix the use of relative offsets with explicit prefixes, e.g. +\c{a32 loop foo}. + +\b Remove \c{backslash()}. + +\b Fix the \c{SMSW} and \c{SLDT} instructions. + +\b \c{-O2} and \c{-O3} are no longer aliases for \c{-O10} and \c{-O15}. +If you mean the latter, please say so! :) + +\S{cl-0.98.36} Version 0.98.36 + + +\b Update rdoff - librarian/archiver - common rec - docs! + +\b Fix signed/unsigned problems. + +\b Fix \c{JMP FAR label} and \c{CALL FAR label}. + +\b Add new multisection support - map files - fix align bug + +\b Fix sysexit, movhps/movlps reg,reg bugs in insns.dat + +\b \c{Q} or \c{O} suffixes indicate octal + +\b Support Prescott new instructions (PNI). + +\b Cyrix \c{XSTORE} instruction. + + +\S{cl-0.98.35} Version 0.98.35 + +\b Fix build failure on 16-bit DOS (Makefile.bc3 workaround for compiler bug.) + +\b Fix dependencies and compiler warnings. + +\b Add "const" in a number of places. + +\b Add -X option to specify error reporting format (use -Xvc to + integrate with Microsoft Visual Studio.) + +\b Minor changes for code legibility. + +\b Drop use of tmpnam() in rdoff (security fix.) + + +\S{cl-0.98.34} Version 0.98.34 + +\b Correct additional address-size vs. operand-size confusions. + +\b Generate dependencies for all Makefiles automatically. + +\b Add support for unimplemented (but theoretically available) + registers such as tr0 and cr5. Segment registers 6 and 7 are called + segr6 and segr7 for the operations which they can be represented. + +\b Correct some disassembler bugs related to redundant address-size prefixes. + Some work still remains in this area. + +\b Correctly generate an error for things like "SEG eax". + +\b Add the JMPE instruction, enabled by "CPU IA64". + +\b Correct compilation on newer gcc/glibc platforms. + +\b Issue an error on things like "jmp far eax". + + +\S{cl-0.98.33} Version 0.98.33 + +\b New __NASM_PATCHLEVEL__ and __NASM_VERSION_ID__ standard macros to + round out the version-query macros. version.pl now understands + X.YYplWW or X.YY.ZZplWW as a version number, equivalent to + X.YY.ZZ.WW (or X.YY.0.WW, as appropriate). + +\b New keyword "strict" to disable the optimization of specific + operands. + +\b Fix the handing of size overrides with JMP instructions + (instructions such as "jmp dword foo".) + +\b Fix the handling of "ABSOLUTE label", where "label" points into a + relocatable segment. + +\b Fix OBJ output format with lots of externs. + +\b More documentation updates. + +\b Add -Ov option to get verbose information about optimizations. + +\b Undo a braindead change which broke \c{%elif} directives. + +\b Makefile updates. + + +\S{cl-0.98.32} Version 0.98.32 + +\b Fix NASM crashing when \c{%macro} directives were left unterminated. + +\b Lots of documentation updates. + +\b Complete rewrite of the PostScript/PDF documentation generator. + +\b The MS Visual C++ Makefile was updated and corrected. + +\b Recognize .rodata as a standard section name in ELF. + +\b Fix some obsolete Perl4-isms in Perl scripts. + +\b Fix configure.in to work with autoconf 2.5x. + +\b Fix a couple of "make cleaner" misses. + +\b Make the normal "./configure && make" work with Cygwin. + + +\S{cl-0.98.31} Version 0.98.31 + +\b Correctly build in a separate object directory again. + +\b Derive all references to the version number from the version file. + +\b New standard macros __NASM_SUBMINOR__ and __NASM_VER__ macros. + +\b Lots of Makefile updates and bug fixes. + +\b New \c{%ifmacro} directive to test for multiline macros. + +\b Documentation updates. + +\b Fixes for 16-bit OBJ format output. + +\b Changed the NASM environment variable to NASMENV. + + +\S{cl-0.98.30} Version 0.98.30 + +\b Changed doc files a lot: completely removed old READMExx and + Wishlist files, incorporating all information in CHANGES and TODO. + +\b I waited a long time to rename zoutieee.c to (original) outieee.c + +\b moved all output modules to output/ subdirectory. + +\b Added 'make strip' target to strip debug info from nasm & ndisasm. + +\b Added INSTALL file with installation instructions. + +\b Added -v option description to nasm man. + +\b Added dist makefile target to produce source distributions. + +\b 16-bit support for ELF output format (GNU extension, but useful.) + + +\S{cl-0.98.28} Version 0.98.28 + +\b Fastcooked this for Debian's Woody release: +Frank applied the INCBIN bug patch to 0.98.25alt and called +it 0.98.28 to not confuse poor little apt-get. + + +\S{cl-0.98.26} Version 0.98.26 + +\b Reorganised files even better from 0.98.25alt + + +\S{cl-0.98.25alt} Version 0.98.25alt + +\b Prettified the source tree. Moved files to more reasonable places. + +\b Added findleak.pl script to misc/ directory. + +\b Attempted to fix doc. + + +\S{cl-0.98.25} Version 0.98.25 + +\b Line continuation character \c{\\}. + +\b Docs inadvertantly reverted - "dos packaging". + + +\S{cl-0.98.24p1} Version 0.98.24p1 + +\b FIXME: Someone, document this please. + + +\S{cl-0.98.24} Version 0.98.24 + +\b Documentation - Ndisasm doc added to Nasm.doc. + + +\S{cl-0.98.23} Version 0.98.23 + +\b Attempted to remove rdoff version1 + +\b Lino Mastrodomenico's patches to preproc.c (%$$ bug?). + + +\S{cl-0.98.22} Version 0.98.22 + +\b Update rdoff2 - attempt to remove v1. + + +\S{cl-0.98.21} Version 0.98.21 + +\b Optimization fixes. + + +\S{cl-0.98.20} Version 0.98.20 + +\b Optimization fixes. + + +\S{cl-0.98.19} Version 0.98.19 + +\b H. J. Lu's patch back out. + + +\S{cl-0.98.18} Version 0.98.18 + +\b Added ".rdata" to "-f win32". + + +\S{cl-0.98.17} Version 0.98.17 + +\b H. J. Lu's "bogus elf" patch. (Red Hat problem?) + + +\S{cl-0.98.16} Version 0.98.16 + +\b Fix whitespace before "[section ..." bug. + + +\S{cl-0.98.15} Version 0.98.15 + +\b Rdoff changes (?). + +\b Fix fixes to memory leaks. + + +\S{cl-0.98.14} Version 0.98.14 + +\b Fix memory leaks. + + +\S{cl-0.98.13} Version 0.98.13 + +\b There was no 0.98.13 + + +\S{cl-0.98.12} Version 0.98.12 + +\b Update optimization (new function of "-O1") + +\b Changes to test/bintest.asm (?). + + +\S{cl-0.98.11} Version 0.98.11 + +\b Optimization changes. + +\b Ndisasm fixed. + + +\S{cl-0.98.10} Version 0.98.10 + +\b There was no 0.98.10 + + +\S{cl-0.98.09} Version 0.98.09 + +\b Add multiple sections support to "-f bin". + +\b Changed GLOBAL_TEMP_BASE in outelf.c from 6 to 15. + +\b Add "-v" as an alias to the "-r" switch. + +\b Remove "#ifdef" from Tasm compatibility options. + +\b Remove redundant size-overrides on "mov ds, ex", etc. + +\b Fixes to SSE2, other insns.dat (?). + +\b Enable uppercase "I" and "P" switches. + +\b Case insinsitive "seg" and "wrt". + +\b Update install.sh (?). + +\b Allocate tokens in blocks. + +\b Improve "invalid effective address" messages. + + +\S{cl-0.98.08} Version 0.98.08 + +\b Add "\c{%strlen}" and "\c{%substr}" macro operators + +\b Fixed broken c16.mac. + +\b Unterminated string error reported. + +\b Fixed bugs as per 0.98bf + + +\S{cl-0.98.09b with John Coffman patches released 28-Oct-2001} Version 0.98.09b with John Coffman patches released 28-Oct-2001 + +Changes from 0.98.07 release to 98.09b as of 28-Oct-2001 + +\b More closely compatible with 0.98 when -O0 is implied +or specified. Not strictly identical, since backward +branches in range of short offsets are recognized, and signed +byte values with no explicit size specification will be +assembled as a single byte. + +\b More forgiving with the PUSH instruction. 0.98 requires +a size to be specified always. 0.98.09b will imply the size +from the current BITS setting (16 or 32). + +\b Changed definition of the optimization flag: + + -O0 strict two-pass assembly, JMP and Jcc are + handled more like 0.98, except that back- + ward JMPs are short, if possible. + + -O1 strict two-pass assembly, but forward + branches are assembled with code guaranteed + to reach; may produce larger code than + -O0, but will produce successful assembly + more often if branch offset sizes are not + specified. + + -O2 multi-pass optimization, minimize branch + offsets; also will minimize signed immed- + iate bytes, overriding size specification. + + -O3 like -O2, but more passes taken, if needed + + +\S{cl-0.98.07 released 01/28/01} Version 0.98.07 released 01/28/01 + +\b Added Stepane Denis' SSE2 instructions to a *working* + version of the code - some earlier versions were based on + broken code - sorry 'bout that. version "0.98.07" + + +01/28/01 + + +\b Cosmetic modifications to nasm.c, nasm.h, + AUTHORS, MODIFIED + + +\S{cl-0.98.06f released 01/18/01} Version 0.98.06f released 01/18/01 + + +\b - Add "metalbrain"s jecxz bug fix in insns.dat + - alter nasmdoc.src to match - version "0.98.06f" + + +\S{cl-0.98.06e released 01/09/01} Version 0.98.06e released 01/09/01 + + +\b Removed the "outforms.h" file - it appears to be + someone's old backup of "outform.h". version "0.98.06e" + +01/09/01 + +\b fbk - finally added the fix for the "multiple %includes bug", + known since 7/27/99 - reported originally (?) and sent to + us by Austin Lunnen - he reports that John Fine had a fix + within the day. Here it is... + +\b Nelson Rush resigns from the group. Big thanks to Nelson for + his leadership and enthusiasm in getting these changes + incorporated into Nasm! + +\b fbk - [list +], [list -] directives - ineptly implemented, should + be re-written or removed, perhaps. + +\b Brian Raiter / fbk - "elfso bug" fix - applied to aoutb format + as well - testing might be desirable... + +08/07/00 + +\b James Seter - -postfix, -prefix command line switches. + +\b Yuri Zaporogets - rdoff utility changes. + + +\S{cl-0.98p1} Version 0.98p1 + +\b GAS-like palign (Panos Minos) + +\b FIXME: Someone, fill this in with details + + +\S{cl-0.98bf (bug-fixed)} Version 0.98bf (bug-fixed) + +\b Fixed - elf and aoutb bug - shared libraries + - multiple "%include" bug in "-f obj" + - jcxz, jecxz bug + - unrecognized option bug in ndisasm + +\S{cl-0.98.03 with John Coffman's changes released 27-Jul-2000} Version 0.98.03 with John Coffman's changes released 27-Jul-2000 + +\b Added signed byte optimizations for the 0x81/0x83 class +of instructions: ADC, ADD, AND, CMP, OR, SBB, SUB, XOR: +when used as 'ADD reg16,imm' or 'ADD reg32,imm.' Also +optimization of signed byte form of 'PUSH imm' and 'IMUL +reg,imm'/'IMUL reg,reg,imm.' No size specification is needed. + +\b Added multi-pass JMP and Jcc offset optimization. Offsets +on forward references will preferentially use the short form, +without the need to code a specific size (short or near) for +the branch. Added instructions for 'Jcc label' to use the +form 'Jnotcc $+3/JMP label', in cases where a short offset +is out of bounds. If compiling for a 386 or higher CPU, then +the 386 form of Jcc will be used instead. + +This feature is controlled by a new command-line switch: "O", +(upper case letter O). "-O0" reverts the assembler to no +extra optimization passes, "-O1" allows up to 5 extra passes, +and "-O2"(default), allows up to 10 extra optimization passes. + +\b Added a new directive: 'cpu XXX', where XXX is any of: +8086, 186, 286, 386, 486, 586, pentium, 686, PPro, P2, P3 or +Katmai. All are case insensitive. All instructions will +be selected only if they apply to the selected cpu or lower. +Corrected a couple of bugs in cpu-dependence in 'insns.dat'. + +\b Added to 'standard.mac', the "use16" and "use32" forms of +the "bits 16/32" directive. This is nothing new, just conforms +to a lot of other assemblers. (minor) + +\b Changed label allocation from 320/32 (10000 labels @ 200K+) +to 32/37 (1000 labels); makes running under DOS much easier. +Since additional label space is allocated dynamically, this +should have no effect on large programs with lots of labels. +The 37 is a prime, believed to be better for hashing. (minor) + + +\S{cl-0.98.03} Version 0.98.03 + +"Integrated patchfile 0.98-0.98.01. I call this version 0.98.03 for +historical reasons: 0.98.02 was trashed." --John Coffman +<johninsd@san.rr.com>, 27-Jul-2000 + +\b Kendall Bennett's SciTech MGL changes + +\b Note that you must define "TASM_COMPAT" at compile-time +to get the Tasm Ideal Mode compatibility. + +\b All changes can be compiled in and out using the TASM_COMPAT macros, +and when compiled without TASM_COMPAT defined we get the exact same +binary as the unmodified 0.98 sources. + +\b standard.mac, macros.c: Added macros to ignore TASM directives before +first include + +\b nasm.h: Added extern declaration for tasm_compatible_mode + +\b nasm.c: Added global variable tasm_compatible_mode + +\b Added command line switch for TASM compatible mode (-t) + +\b Changed version command line to reflect when compiled with TASM additions + +\b Added response file processing to allow all arguments on a single +line (response file is @resp rather than -@resp for NASM format). + +\b labels.c: Changes islocal() macro to support TASM style @@local labels. + +\b Added islocalchar() macro to support TASM style @@local labels. + +\b parser.c: Added support for TASM style memory references (ie: mov +[DWORD eax],10 rather than the NASM style mov DWORD [eax],10). + +\b preproc.c: Added new directives, \c{%arg}, \c{%local}, \c{%stacksize} to directives +table + +\b Added support for TASM style directives without a leading % symbol. + +\b Integrated a block of changes from Andrew Zabolotny <bit@eltech.ru>: + +\b A new keyword \c{%xdefine} and its case-insensitive counterpart \c{%ixdefine}. +They work almost the same way as \c{%define} and \c{%idefine} but expand +the definition immediately, not on the invocation. Something like a cross +between \c{%define} and \c{%assign}. The "x" suffix stands for "eXpand", so +"xdefine" can be deciphered as "expand-and-define". Thus you can do +things like this: + +\c %assign ofs 0 +\c +\c %macro arg 1 +\c %xdefine %1 dword [esp+ofs] +\c %assign ofs ofs+4 +\c %endmacro + +\b Changed the place where the expansion of %$name macros are expanded. +Now they are converted into ..@ctxnum.name form when detokenizing, so +there are no quirks as before when using %$name arguments to macros, +in macros etc. For example: + +\c %macro abc 1 +\c %define %1 hello +\c %endm +\c +\c abc %$here +\c %$here + + Now last line will be expanded into "hello" as expected. This also allows + for lots of goodies, a good example are extended "proc" macros included + in this archive. + +\b Added a check for "cstk" in smacro_defined() before calling get_ctx() - + this allows for things like: + +\c %ifdef %$abc +\c %endif + + to work without warnings even in no context. + +\b Added a check for "cstk" in %if*ctx and %elif*ctx directives - + this allows to use \c{%ifctx} without excessive warnings. If there is + no active context, \c{%ifctx} goes through "false" branch. + +\b Removed "user error: " prefix with \c{%error} directive: it just clobbers the + output and has absolutely no functionality. Besides, this allows to write + macros that does not differ from built-in functions in any way. + +\b Added expansion of string that is output by \c{%error} directive. Now you + can do things like: + +\c %define hello(x) Hello, x! +\c +\c %define %$name andy +\c %error "hello(%$name)" + + Same happened with \c{%include} directive. + +\b Now all directives that expect an identifier will try to expand and + concatenate everything without whitespaces in between before usage. + For example, with "unfixed" nasm the commands + +\c %define %$abc hello +\c %define __%$abc goodbye +\c __%$abc + + would produce "incorrect" output: last line will expand to + +\c hello goodbyehello + + Not quite what you expected, eh? :-) The answer is that preprocessor + treats the \c{%define} construct as if it would be + +\c %define __ %$abc goodbye + + (note the white space between __ and %$abc). After my "fix" it + will "correctly" expand into + +\c goodbye + + as expected. Note that I use quotes around words "correct", "incorrect" + etc because this is rather a feature not a bug; however current behaviour + is more logical (and allows more advanced macro usage :-). + + Same change was applied to: + \c{%push},\c{%macro},\c{%imacro},\c{%define},\c{%idefine},\c{%xdefine},\c{%ixdefine}, + \c{%assign},\c{%iassign},\c{%undef} + +\b A new directive [WARNING {+|-}warning-id] have been added. It works only + if the assembly phase is enabled (i.e. it doesn't work with nasm -e). + +\b A new warning type: macro-selfref. By default this warning is disabled; + when enabled NASM warns when a macro self-references itself; for example + the following source: + +\c [WARNING macro-selfref] +\c +\c %macro push 1-* +\c %rep %0 +\c push %1 +\c %rotate 1 +\c %endrep +\c %endmacro +\c +\c push eax,ebx,ecx + + will produce a warning, but if we remove the first line we won't see it + anymore (which is The Right Thing To Do {tm} IMHO since C preprocessor + eats such constructs without warnings at all). + +\b Added a "error" routine to preprocessor which always will set ERR_PASS1 + bit in severity_code. This removes annoying repeated errors on first + and second passes from preprocessor. + +\b Added the %+ operator in single-line macros for concatenating two + identifiers. Usage example: + +\c %define _myfunc _otherfunc +\c %define cextern(x) _ %+ x +\c cextern (myfunc) + + After first expansion, third line will become "_myfunc". After this + expansion is performed again so it becomes "_otherunc". + +\b Now if preprocessor is in a non-emitting state, no warning or error + will be emitted. Example: + +\c %if 1 +\c mov eax,ebx +\c %else +\c put anything you want between these two brackets, +\c even macro-parameter references %1 or local +\c labels %$zz or macro-local labels %%zz - no +\c warning will be emitted. +\c %endif + +\b Context-local variables on expansion as a last resort are looked up + in outer contexts. For example, the following piece: + +\c %push outer +\c %define %$a [esp] +\c +\c %push inner +\c %$a +\c %pop +\c %pop + + will expand correctly the fourth line to [esp]; if we'll define another + %$a inside the "inner" context, it will take precedence over outer + definition. However, this modification has been applied only to + expand_smacro and not to smacro_define: as a consequence expansion + looks in outer contexts, but \c{%ifdef} won't look in outer contexts. + + This behaviour is needed because we don't want nested contexts to + act on already defined local macros. Example: + +\c %define %$arg1 [esp+4] +\c test eax,eax +\c if nz +\c mov eax,%$arg1 +\c endif + + In this example the "if" mmacro enters into the "if" context, so %$arg1 + is not valid anymore inside "if". Of course it could be worked around + by using explicitely %$$arg1 but this is ugly IMHO. + +\b Fixed memory leak in \c{%undef}. The origline wasn't freed before + exiting on success. + +\b Fixed trap in preprocessor when line expanded to empty set of tokens. + This happens, for example, in the following case: + +\c #define SOMETHING +\c SOMETHING + + +\S{cl-0.98} Version 0.98 + +All changes since NASM 0.98p3 have been produced by H. Peter Anvin <hpa@zytor.com>. + +\b The documentation comment delimiter is \# not #. + +\b Allow EQU definitions to refer to external labels; reported by + Pedro Gimeno. + +\b Re-enable support for RDOFF v1; reported by Pedro Gimeno. + +\b Updated License file per OK from Simon and Julian. + + +\S{cl-0.98p9} Version 0.98p9 + +\b Update documentation (although the instruction set reference will + have to wait; I don't want to hold up the 0.98 release for it.) + +\b Verified that the NASM implementation of the PEXTRW and PMOVMSKB + instructions is correct. The encoding differs from what the Intel + manuals document, but the Pentium III behaviour matches NASM, not + the Intel manuals. + +\b Fix handling of implicit sizes in PSHUFW and PINSRW, reported by + Stefan Hoffmeister. + +\b Resurrect the -s option, which was removed when changing the + diagnostic output to stdout. + + +\S{cl-0.98p8} Version 0.98p8 + +\b Fix for "DB" when NASM is running on a bigendian machine. + +\b Invoke insns.pl once for each output script, making Makefile.in + legal for "make -j". + +\b Improve the Unix configure-based makefiles to make package + creation easier. + +\b Included an RPM .spec file for building RPM (RedHat Package Manager) + packages on Linux or Unix systems. + +\b Fix Makefile dependency problems. + +\b Change src/rdsrc.pl to include sectioning information in info + output; required for install-info to work. + +\b Updated the RDOFF distribution to version 2 from Jules; minor + massaging to make it compile in my environment. + +\b Split doc files that can be built by anyone with a Perl interpreter off + into a separate archive. + +\b "Dress rehearsal" release! + + +\S{cl-0.98p7} Version 0.98p7 + +\b Fixed opcodes with a third byte-sized immediate argument to not + complain if given "byte" on the immediate. + +\b Allow \c{%undef} to remove single-line macros with arguments. This + matches the behaviour of #undef in the C preprocessor. + +\b Allow -d, -u, -i and -p to be specified as -D, -U, -I and -P for + compatibility with most C compilers and preprocessors. This allows + Makefile options to be shared between cc and nasm, for example. + +\b Minor cleanups. + +\b Went through the list of Katmai instructions and hopefully fixed the + (rather few) mistakes in it. + +\b (Hopefully) fixed a number of disassembler bugs related to ambiguous + instructions (disambiguated by -p) and SSE instructions with REP. + +\b Fix for bug reported by Mark Junger: "call dword 0x12345678" should + work and may add an OSP (affected CALL, JMP, Jcc). + +\b Fix for environments when "stderr" isn't a compile-time constant. + + +\S{cl-0.98p6} Version 0.98p6 + + +\b Took officially over coordination of the 0.98 release; so drop + the p3.x notation. Skipped p4 and p5 to avoid confusion with John + Fine's J4 and J5 releases. + +\b Update the documentation; however, it still doesn't include + documentation for the various new instructions. I somehow wonder if + it makes sense to have an instruction set reference in the assembler + manual when Intel et al have PDF versions of their manuals online. + +\b Recognize "idt" or "centaur" for the -p option to ndisasm. + +\b Changed error messages back to stderr where they belong, but add an + -E option to redirect them elsewhere (the DOS shell cannot redirect + stderr.) + +\b -M option to generate Makefile dependencies (based on code from Alex + Verstak.) + +\b \c{%undef} preprocessor directive, and -u option, that undefines a + single-line macro. + +\b OS/2 Makefile (Mkfiles/Makefile.os2) for Borland under OS/2; from + Chuck Crayne. + +\b Various minor bugfixes (reported by): + - Dangling \c{%s} in preproc.c (Martin Junker) + +\b THERE ARE KNOWN BUGS IN SSE AND THE OTHER KATMAI INSTRUCTIONS. I am + on a trip and didn't bring the Katmai instruction reference, so I + can't work on them right now. + +\b Updated the License file per agreement with Simon and Jules to + include a GPL distribution clause. + + +\S{cl-0.98p3.7} Version 0.98p3.7 + +\b (Hopefully) fixed the canned Makefiles to include the outrdf2 and + zoutieee modules. + +\b Renamed changes.asm to changed.asm. + + +\S{cl-0.98p3.6} Version 0.98p3.6 + +\b Fixed a bunch of instructions that were added in 0.98p3.5 which had + memory operands, and the address-size prefix was missing from the + instruction pattern. + + +\S{cl-0.98p3.5} Version 0.98p3.5 + +\b Merged in changes from John S. Fine's 0.98-J5 release. John's based + 0.98-J5 on my 0.98p3.3 release; this merges the changes. + +\b Expanded the instructions flag field to a long so we can fit more + flags; mark SSE (KNI) and AMD or Katmai-specific instructions as + such. + +\b Fix the "PRIV" flag on a bunch of instructions, and create new + "PROT" flag for protected-mode-only instructions (orthogonal to if + the instruction is privileged!) and new "SMM" flag for SMM-only + instructions. + +\b Added AMD-only SYSCALL and SYSRET instructions. + +\b Make SSE actually work, and add new Katmai MMX instructions. + +\b Added a -p (preferred vendor) option to ndisasm so that it can + distinguish e.g. Cyrix opcodes also used in SSE. For example: + +\c ndisasm -p cyrix aliased.bin +\c 00000000 670F514310 paddsiw mm0,[ebx+0x10] +\c 00000005 670F514320 paddsiw mm0,[ebx+0x20] +\c ndisasm -p intel aliased.bin +\c 00000000 670F514310 sqrtps xmm0,[ebx+0x10] +\c 00000005 670F514320 sqrtps xmm0,[ebx+0x20] + +\b Added a bunch of Cyrix-specific instructions. + + +\S{cl-0.98p3.4} Version 0.98p3.4 + +\b Made at least an attempt to modify all the additional Makefiles (in + the Mkfiles directory). I can't test it, but this was the best I + could do. + +\b DOS DJGPP+"Opus Make" Makefile from John S. Fine. + +\b changes.asm changes from John S. Fine. + + +\S{cl-0.98p3.3} Version 0.98p3.3 + +\b Patch from Conan Brink to allow nesting of \c{%rep} directives. + +\b If we're going to allow INT01 as an alias for INT1/ICEBP (one of + Jules 0.98p3 changes), then we should allow INT03 as an alias for INT3 + as well. + +\b Updated changes.asm to include the latest changes. + +\b Tried to clean up the <CR>s that had snuck in from a DOS/Windows + environment into my Unix environment, and try to make sure than + DOS/Windows users get them back. + +\b We would silently generate broken tools if insns.dat wasn't sorted + properly. Change insns.pl so that the order doesn't matter. + +\b Fix bug in insns.pl (introduced by me) which would cause conditional + instructions to have an extra "cc" in disassembly, e.g. "jnz" + disassembled as "jccnz". + + +\S{cl-0.98p3.2} Version 0.98p3.2 + +\b Merged in John S. Fine's changes from his 0.98-J4 prerelease; see + http://www.csoft.net/cz/johnfine/ + +\b Changed previous "spotless" Makefile target (appropriate for distribution) + to "distclean", and added "cleaner" target which is same as "clean" + except deletes files generated by Perl scripts; "spotless" is union. + +\b Removed BASIC programs from distribution. Get a Perl interpreter + instead (see below.) + +\b Calling this "pre-release 3.2" rather than "p3-hpa2" because of + John's contributions. + +\b Actually link in the IEEE output format (zoutieee.c); fix a bunch of + compiler warnings in that file. Note I don't know what IEEE output + is supposed to look like, so these changes were made "blind". + + +\S{cl-0.98p3-hpa} Version 0.98p3-hpa + +\b Merged nasm098p3.zip with nasm-0.97.tar.gz to create a fully + buildable version for Unix systems (Makefile.in updates, etc.) + +\b Changed insns.pl to create the instruction tables in nasm.h and + names.c, so that a new instruction can be added by adding it *only* + to insns.dat. + +\b Added the following new instructions: SYSENTER, SYSEXIT, FXSAVE, + FXRSTOR, UD1, UD2 (the latter two are two opcodes that Intel + guarantee will never be used; one of them is documented as UD2 in + Intel documentation, the other one just as "Undefined Opcode" -- + calling it UD1 seemed to make sense.) + +\b MAX_SYMBOL was defined to be 9, but LOADALL286 and LOADALL386 are 10 + characters long. Now MAX_SYMBOL is derived from insns.dat. + +\b A note on the BASIC programs included: forget them. insns.bas is + already out of date. Get yourself a Perl interpreter for your + platform of choice at + \W{http://www.cpan.org/ports/index.html}{http://www.cpan.org/ports/index.html}. + + +\S{cl-0.98p3} Version 0.98 pre-release 3 + +\b added response file support, improved command line handling, new layout +help screen + +\b fixed limit checking bug, 'OUT byte nn, reg' bug, and a couple of rdoff +related bugs, updated Wishlist; 0.98 Prerelease 3. + + +\S{cl-0.98p2} Version 0.98 pre-release 2 + +\b fixed bug in outcoff.c to do with truncating section names longer +than 8 characters, referencing beyond end of string; 0.98 pre-release 2 + + +\S{cl-0.98p1} Version 0.98 pre-release 1 + +\b Fixed a bug whereby STRUC didn't work at all in RDF. + +\b Fixed a problem with group specification in PUBDEFs in OBJ. + +\b Improved ease of adding new output formats. Contribution due to +Fox Cutter. + +\b Fixed a bug in relocations in the `bin' format: was showing up when +a relocatable reference crossed an 8192-byte boundary in any output +section. + +\b Fixed a bug in local labels: local-label lookups were inconsistent +between passes one and two if an EQU occurred between the definition +of a global label and the subsequent use of a local label local to +that global. + +\b Fixed a seg-fault in the preprocessor (again) which happened when +you use a blank line as the first line of a multi-line macro +definition and then defined a label on the same line as a call to +that macro. + +\b Fixed a stale-pointer bug in the handling of the NASM environment +variable. Thanks to Thomas McWilliams. + +\b ELF had a hard limit on the number of sections which caused +segfaults when transgressed. Fixed. + +\b Added ability for ndisasm to read from stdin by using `-' as the +filename. + +\b ndisasm wasn't outputting the TO keyword. Fixed. + +\b Fixed error cascade on bogus expression in \c{%if} - an error in +evaluation was causing the entire \c{%if} to be discarded, thus creating +trouble later when the \c{%else} or \c{%endif} was encountered. + +\b Forward reference tracking was instruction-granular not operand- +granular, which was causing 286-specific code to be generated +needlessly on code of the form `shr word [forwardref],1'. Thanks to +Jim Hague for sending a patch. + +\b All messages now appear on stdout, as sending them to stderr serves +no useful purpose other than to make redirection difficult. + +\b Fixed the problem with EQUs pointing to an external symbol - this +now generates an error message. + +\b Allowed multiple size prefixes to an operand, of which only the first +is taken into account. + +\b Incorporated John Fine's changes, including fixes of a large number +of preprocessor bugs, some small problems in OBJ, and a reworking of +label handling to define labels before their line is assembled, rather +than after. + +\b Reformatted a lot of the source code to be more readable. Included +'coding.txt' as a guideline for how to format code for contributors. + +\b Stopped nested \c{%reps} causing a panic - they now cause a slightly more +friendly error message instead. + +\b Fixed floating point constant problems (patch by Pedro Gimeno) + +\b Fixed the return value of insn_size() not being checked for -1, indicating +an error. + +\b Incorporated 3Dnow! instructions. + +\b Fixed the 'mov eax, eax + ebx' bug. + +\b Fixed the GLOBAL EQU bug in ELF. Released developers release 3. + +\b Incorporated John Fine's command line parsing changes + +\b Incorporated David Lindauer's OMF debug support + +\b Made changes for LCC 4.0 support (\c{__NASM_CDecl__}, removed register size +specification warning when sizes agree). + + +\H{cl-0.9x} NASM 0.9 Series + +Revisions before 0.98. + + +\S{cl-0.97} Version 0.97 released December 1997 + +\b This was entirely a bug-fix release to 0.96, which seems to have got +cursed. Silly me. + +\b Fixed stupid mistake in OBJ which caused `MOV EAX,<constant>' to +fail. Caused by an error in the `MOV EAX,<segment>' support. + +\b ndisasm hung at EOF when compiled with lcc on Linux because lcc on +Linux somehow breaks feof(). ndisasm now does not rely on feof(). + +\b A heading in the documentation was missing due to a markup error in +the indexing. Fixed. + +\b Fixed failure to update all pointers on realloc() within extended- +operand code in parser.c. Was causing wrong behaviour and seg faults +on lines such as `dd 0.0,0.0,0.0,0.0,...' + +\b Fixed a subtle preprocessor bug whereby invoking one multi-line +macro on the first line of the expansion of another, when the second +had been invoked with a label defined before it, didn't expand the +inner macro. + +\b Added internal.doc back in to the distribution archives - it was +missing in 0.96 *blush* + +\b Fixed bug causing 0.96 to be unable to assemble its own test files, +specifically objtest.asm. *blush again* + +\b Fixed seg-faults and bogus error messages caused by mismatching +\c{%rep} and \c{%endrep} within multi-line macro definitions. + +\b Fixed a problem with buffer overrun in OBJ, which was causing +corruption at ends of long PUBDEF records. + +\b Separated DOS archives into main-program and documentation to reduce +download size. + + +\S{cl-0.96} Version 0.96 released November 1997 + +\b Fixed a bug whereby, if `nasm sourcefile' would cause a filename +collision warning and put output into `nasm.out', then `nasm +sourcefile -o outputfile' still gave the warning even though the +`-o' was honoured. +Fixed name pollution under Digital UNIX: one of its header files +defined R_SP, which broke the enum in nasm.h. + +\b Fixed minor instruction table problems: FUCOM and FUCOMP didn't have +two-operand forms; NDISASM didn't recognise the longer register +forms of PUSH and POP (eg FF F3 for PUSH BX); TEST mem,imm32 was +flagged as undocumented; the 32-bit forms of CMOV had 16-bit operand +size prefixes; `AAD imm' and `AAM imm' are no longer flagged as +undocumented because the Intel Architecture reference documents +them. + +\b Fixed a problem with the local-label mechanism, whereby strange +types of symbol (EQUs, auto-defined OBJ segment base symbols) +interfered with the `previous global label' value and screwed up +local labels. + +\b Fixed a bug whereby the stub preprocessor didn't communicate with +the listing file generator, so that the -a and -l options in +conjunction would produce a useless listing file. + +\b Merged `os2' object file format back into `obj', after discovering +that `obj' _also_ shouldn't have a link pass separator in a module +containing a non-trivial MODEND. Flat segments are now declared +using the FLAT attribute. `os2' is no longer a valid object format +name: use `obj'. + +\b Removed the fixed-size temporary storage in the evaluator. Very very +long expressions (like `mov ax,1+1+1+1+...' for two hundred 1s or +so) should now no longer crash NASM. + +\b Fixed a bug involving segfaults on disassembly of MMX instructions, +by changing the meaning of one of the operand-type flags in nasm.h. +This may cause other apparently unrelated MMX problems; it needs to +be tested thoroughly. + +\b Fixed some buffer overrun problems with large OBJ output files. +Thanks to DJ Delorie for the bug report and fix. + +\b Made preprocess-only mode actually listen to the \c{%line} markers as it +prints them, so that it can report errors more sanely. + +\b Re-designed the evaluator to keep more sensible track of expressions +involving forward references: can now cope with previously-nightmare +situations such as: + +\c mov ax,foo | bar +\c foo equ 1 +\c bar equ 2 + +\b Added the ALIGN and ALIGNB standard macros. + +\b Added PIC support in ELF: use of WRT to obtain the four extra +relocation types needed. + +\b Added the ability for output file formats to define their own +extensions to the GLOBAL, COMMON and EXTERN directives. + +\b Implemented common-variable alignment, and global-symbol type and +size declarations, in ELF. + +\b Implemented NEAR and FAR keywords for common variables, plus +far-common element size specification, in OBJ. + +\b Added a feature whereby EXTERNs and COMMONs in OBJ can be given a +default WRT specification (either a segment or a group). + +\b Transformed the Unix NASM archive into an auto-configuring package. + +\b Added a sanity-check for people applying SEG to things which are +already segment bases: this previously went unnoticed by the SEG +processing and caused OBJ-driver panics later. + +\b Added the ability, in OBJ format, to deal with `MOV EAX,<segment>' +type references: OBJ doesn't directly support dword-size segment +base fixups, but as long as the low two bytes of the constant term +are zero, a word-size fixup can be generated instead and it will +work. + +\b Added the ability to specify sections' alignment requirements in +Win32 object files and pure binary files. + +\b Added preprocess-time expression evaluation: the \c{%assign} (and +\c{%iassign}) directive and the bare \c{%if} (and \c{%elif}) conditional. Added +relational operators to the evaluator, for use only in \c{%if} +constructs: the standard relationals = < > <= >= <> (and C-like +synonyms == and !=) plus low-precedence logical operators &&, ^^ and +||. + +\b Added a preprocessor repeat construct: \c{%rep} / \c{%exitrep} / \c{%endrep}. + +\b Added the __FILE__ and __LINE__ standard macros. + +\b Added a sanity check for number constants being greater than +0xFFFFFFFF. The warning can be disabled. + +\b Added the %0 token whereby a variadic multi-line macro can tell how +many parameters it's been given in a specific invocation. + +\b Added \c{%rotate}, allowing multi-line macro parameters to be cycled. + +\b Added the `*' option for the maximum parameter count on multi-line +macros, allowing them to take arbitrarily many parameters. + +\b Added the ability for the user-level forms of EXTERN, GLOBAL and +COMMON to take more than one argument. + +\b Added the IMPORT and EXPORT directives in OBJ format, to deal with +Windows DLLs. + +\b Added some more preprocessor \c{%if} constructs: \c{%ifidn} / \c{%ifidni} (exact +textual identity), and \c{%ifid} / \c{%ifnum} / \c{%ifstr} (token type testing). + +\b Added the ability to distinguish SHL AX,1 (the 8086 version) from +SHL AX,BYTE 1 (the 286-and-upwards version whose constant happens to +be 1). + +\b Added NetBSD/FreeBSD/OpenBSD's variant of a.out format, complete +with PIC shared library features. + +\b Changed NASM's idiosyncratic handling of FCLEX, FDISI, FENI, FINIT, +FSAVE, FSTCW, FSTENV, and FSTSW to bring it into line with the +otherwise accepted standard. The previous behaviour, though it was a +deliberate feature, was a deliberate feature based on a +misunderstanding. Apologies for the inconvenience. + +\b Improved the flexibility of ABSOLUTE: you can now give it an +expression rather than being restricted to a constant, and it can +take relocatable arguments as well. + +\b Added the ability for a variable to be declared as EXTERN multiple +times, and the subsequent definitions are just ignored. + +\b We now allow instruction prefixes (CS, DS, LOCK, REPZ etc) to be +alone on a line (without a following instruction). + +\b Improved sanity checks on whether the arguments to EXTERN, GLOBAL +and COMMON are valid identifiers. + +\b Added misc/exebin.mac to allow direct generation of .EXE files by +hacking up an EXE header using DB and DW; also added test/binexe.asm +to demonstrate the use of this. Thanks to Yann Guidon for +contributing the EXE header code. + +\b ndisasm forgot to check whether the input file had been successfully +opened. Now it does. Doh! + +\b Added the Cyrix extensions to the MMX instruction set. + +\b Added a hinting mechanism to allow [EAX+EBX] and [EBX+EAX] to be +assembled differently. This is important since [ESI+EBP] and +[EBP+ESI] have different default base segment registers. + +\b Added support for the PharLap OMF extension for 4096-byte segment +alignment. + + +\S{cl-0.95 released July 1997} Version 0.95 released July 1997 + +\b Fixed yet another ELF bug. This one manifested if the user relied on +the default segment, and attempted to define global symbols without +first explicitly declaring the target segment. + +\b Added makefiles (for NASM and the RDF tools) to build Win32 console +apps under Symantec C++. Donated by Mark Junker. + +\b Added `macros.bas' and `insns.bas', QBasic versions of the Perl +scripts that convert `standard.mac' to `macros.c' and convert +`insns.dat' to `insnsa.c' and `insnsd.c'. Also thanks to Mark +Junker. + +\b Changed the diassembled forms of the conditional instructions so +that JB is now emitted as JC, and other similar changes. Suggested +list by Ulrich Doewich. + +\b Added `@' to the list of valid characters to begin an identifier +with. + +\b Documentary changes, notably the addition of the `Common Problems' +section in nasm.doc. + +\b Fixed a bug relating to 32-bit PC-relative fixups in OBJ. + +\b Fixed a bug in perm_copy() in labels.c which was causing exceptions +in cleanup_labels() on some systems. + +\b Positivity sanity check in TIMES argument changed from a warning to +an error following a further complaint. + +\b Changed the acceptable limits on byte and word operands to allow +things like `~10111001b' to work. + +\b Fixed a major problem in the preprocessor which caused seg-faults if +macro definitions contained blank lines or comment-only lines. + +\b Fixed inadequate error checking on the commas separating the +arguments to `db', `dw' etc. + +\b Fixed a crippling bug in the handling of macros with operand counts +defined with a `+' modifier. + +\b Fixed a bug whereby object file formats which stored the input file +name in the output file (such as OBJ and COFF) weren't doing so +correctly when the output file name was specified on the command +line. + +\b Removed [INC] and [INCLUDE] support for good, since they were +obsolete anyway. + +\b Fixed a bug in OBJ which caused all fixups to be output in 16-bit +(old-format) FIXUPP records, rather than putting the 32-bit ones in +FIXUPP32 (new-format) records. + +\b Added, tentatively, OS/2 object file support (as a minor variant on +OBJ). + +\b Updates to Fox Cutter's Borland C makefile, Makefile.bc2. + +\b Removed a spurious second fclose() on the output file. + +\b Added the `-s' command line option to redirect all messages which +would go to stderr (errors, help text) to stdout instead. + +\b Added the `-w' command line option to selectively suppress some +classes of assembly warning messages. + +\b Added the `-p' pre-include and `-d' pre-define command-line options. + +\b Added an include file search path: the `-i' command line option. + +\b Fixed a silly little preprocessor bug whereby starting a line with a +`%!' environment-variable reference caused an `unknown directive' +error. + +\b Added the long-awaited listing file support: the `-l' command line +option. + +\b Fixed a problem with OBJ format whereby, in the absence of any +explicit segment definition, non-global symbols declared in the +implicit default segment generated spurious EXTDEF records in the +output. + +\b Added the NASM environment variable. + +\b From this version forward, Win32 console-mode binaries will be +included in the DOS distribution in addition to the 16-bit binaries. +Added Makefile.vc for this purpose. + +\b Added `return 0;' to test/objlink.c to prevent compiler warnings. + +\b Added the __NASM_MAJOR__ and __NASM_MINOR__ standard defines. + +\b Added an alternative memory-reference syntax in which prefixing an +operand with `&' is equivalent to enclosing it in square brackets, +at the request of Fox Cutter. + +\b Errors in pass two now cause the program to return a non-zero error +code, which they didn't before. + +\b Fixed the single-line macro cycle detection, which didn't work at +all on macros with no parameters (caused an infinite loop). Also +changed the behaviour of single-line macro cycle detection to work +like cpp, so that macros like `extrn' as given in the documentation +can be implemented. + +\b Fixed the implementation of WRT, which was too restrictive in that +you couldn't do `mov ax,[di+abc wrt dgroup]' because (di+abc) wasn't +a relocatable reference. + + +\S{cl-0.94 released April 1997} Version 0.94 released April 1997 + + +\b Major item: added the macro processor. + +\b Added undocumented instructions SMI, IBTS, XBTS and LOADALL286. Also +reorganised CMPXCHG instruction into early-486 and Pentium forms. +Thanks to Thobias Jones for the information. + +\b Fixed two more stupid bugs in ELF, which were causing `ld' to +continue to seg-fault in a lot of non-trivial cases. + +\b Fixed a seg-fault in the label manager. + +\b Stopped FBLD and FBSTP from _requiring_ the TWORD keyword, which is +the only option for BCD loads/stores in any case. + +\b Ensured FLDCW, FSTCW and FSTSW can cope with the WORD keyword, if +anyone bothers to provide it. Previously they complained unless no +keyword at all was present. + +\b Some forms of FDIV/FDIVR and FSUB/FSUBR were still inverted: a +vestige of a bug that I thought had been fixed in 0.92. This was +fixed, hopefully for good this time... + +\b Another minor phase error (insofar as a phase error can _ever_ be +minor) fixed, this one occurring in code of the form + +\c rol ax,forward_reference +\c forward_reference equ 1 + +\b The number supplied to TIMES is now sanity-checked for positivity, +and also may be greater than 64K (which previously didn't work on +16-bit systems). + +\b Added Watcom C makefiles, and misc/pmw.bat, donated by Dominik Behr. + +\b Added the INCBIN pseudo-opcode. + +\b Due to the advent of the preprocessor, the [INCLUDE] and [INC] +directives have become obsolete. They are still supported in this +version, with a warning, but won't be in the next. + +\b Fixed a bug in OBJ format, which caused incorrect object records to +be output when absolute labels were made global. + +\b Updates to RDOFF subdirectory, and changes to outrdf.c. + + +\S{cl-0.93 released January 1997} Version 0.93 released January 1997 + +This release went out in a great hurry after semi-crippling bugs +were found in 0.92. + +\b Really \e{did} fix the stack overflows this time. *blush* + +\b Had problems with EA instruction sizes changing between passes, when +an offset contained a forward reference and so 4 bytes were +allocated for the offset in pass one; by pass two the symbol had +been defined and happened to be a small absolute value, so only 1 +byte got allocated, causing instruction size mismatch between passes +and hence incorrect address calculations. Fixed. + +\b Stupid bug in the revised ELF section generation fixed (associated +string-table section for .symtab was hard-coded as 7, even when this +didn't fit with the real section table). Was causing `ld' to +seg-fault under Linux. + +\b Included a new Borland C makefile, Makefile.bc2, donated by Fox +Cutter <lmb@comtch.iea.com>. + + +\S{cl-0.92 released January 1997} Version 0.92 released January 1997 + +\b The FDIVP/FDIVRP and FSUBP/FSUBRP pairs had been inverted: this was +fixed. This also affected the LCC driver. + +\b Fixed a bug regarding 32-bit effective addresses of the form +\c{[other_register+ESP]}. + +\b Documentary changes, notably documentation of the fact that Borland +Win32 compilers use `obj' rather than `win32' object format. + +\b Fixed the COMENT record in OBJ files, which was formatted +incorrectly. + +\b Fixed a bug causing segfaults in large RDF files. + +\b OBJ format now strips initial periods from segment and group +definitions, in order to avoid complications with the local label +syntax. + +\b Fixed a bug in disassembling far calls and jumps in NDISASM. + +\b Added support for user-defined sections in COFF and ELF files. + +\b Compiled the DOS binaries with a sensible amount of stack, to +prevent stack overflows on any arithmetic expression containing +parentheses. + +\b Fixed a bug in handling of files that do not terminate in a newline. + + +\S{cl-0.91 released November 1996} Version 0.91 released November 1996 + +\b Loads of bug fixes. + +\b Support for RDF added. + +\b Support for DBG debugging format added. + +\b Support for 32-bit extensions to Microsoft OBJ format added. + +\b Revised for Borland C: some variable names changed, makefile added. + +\b LCC support revised to actually work. + +\b JMP/CALL NEAR/FAR notation added. + +\b `a16', `o16', `a32' and `o32' prefixes added. + +\b Range checking on short jumps implemented. + +\b MMX instruction support added. + +\b Negative floating point constant support added. + +\b Memory handling improved to bypass 64K barrier under DOS. + +\b \c{$} prefix to force treatment of reserved words as identifiers added. + +\b Default-size mechanism for object formats added. + +\b Compile-time configurability added. + +\b \c{#}, \c{@}, \c{~} and c\{?} are now valid characters in labels. + +\b \c{-e} and \c{-k} options in NDISASM added. + + +\S{cl-0.90 released October 1996} Version 0.90 released October 1996 + +First release version. First support for object file output. Other +changes from previous version (0.3x) too numerous to document. diff --git a/doc/genps.pl b/doc/genps.pl new file mode 100755 index 0000000..c7c23cf --- /dev/null +++ b/doc/genps.pl @@ -0,0 +1,1231 @@ +#!/usr/bin/perl +## -------------------------------------------------------------------------- +## +## Copyright 1996-2009 The NASM Authors - All Rights Reserved +## See the file AUTHORS included with the NASM distribution for +## the specific copyright holders. +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following +## conditions are met: +## +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above +## copyright notice, this list of conditions and the following +## disclaimer in the documentation and/or other materials provided +## with the distribution. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +## CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## -------------------------------------------------------------------------- + +# +# Format the documentation as PostScript +# + +use Env; +use lib $srcdir; + +require 'psfonts.ph'; # The fonts we want to use +require 'pswidth.ph'; # PostScript string width + +use Fcntl; + +# +# PostScript configurables; these values are also available to the +# PostScript code itself +# +%psconf = ( + pagewidth => 595, # Page width in PostScript points + pageheight => 792, # Page height in PostScript points + lmarg => 100, # Left margin in PostScript points + rmarg => 50, # Right margin in PostScript points + topmarg => 100, # Top margin in PostScript points + botmarg => 100, # Bottom margin in PostScript points + plmarg => 50, # Page number position relative to left margin + prmarg => 0, # Page number position relative to right margin + pymarg => 50, # Page number position relative to bot margin + startcopyright => 75, # How much above the bottom margin is the + # copyright notice stuff + bulladj => 12, # How much to indent a bullet paragraph + tocind => 12, # TOC indentation per level + tocpnz => 24, # Width of TOC page number only zone + tocdots => 8, # Spacing between TOC dots + idxspace => 24, # Minimum space between index title and pg# + idxindent => 24, # How much to indent a subindex entry + idxgutter => 24, # Space between index columns + idxcolumns => 2, # Number of index columns + ); + +%psbool = ( + colorlinks => 0, # Set links in blue rather than black + ); + +# Known paper sizes +%papersizes = ( + 'a5' => [421, 595], # ISO half paper size + 'b5' => [501, 709], # ISO small paper size + 'a4' => [595, 842], # ISO standard paper size + 'letter' => [612, 792], # US common paper size + 'pa4' => [595, 792], # Compromise ("portable a4") + 'b4' => [709,1002], # ISO intermediate paper size + 'legal' => [612,1008], # US intermediate paper size + 'a3' => [842,1190], # ISO double paper size + '11x17' => [792,1224], # US double paper size + ); + +# +# Parse the command line +# +undef $input; +while ( $arg = shift(@ARGV) ) { + if ( $arg =~ /^\-(|no\-)(.*)$/ ) { + $parm = $2; + $true = ($1 eq '') ? 1 : 0; + if ( $true && defined($papersizes{$parm}) ) { + $psconf{pagewidth} = $papersizes{$parm}->[0]; + $psconf{pageheight} = $papersizes{$parm}->[1]; + } elsif ( defined($psbool{$parm}) ) { + $psbool{$parm} = $true; + } elsif ( $true && defined($psconf{$parm}) ) { + $psconf{$parm} = shift(@ARGV); + } elsif ( $parm =~ /^(title|subtitle|year|author|license)$/ ) { + $metadata{$parm} = shift(@ARGV); + } else { + die "$0: Unknown option: $arg\n"; + } + } else { + $input = $arg; + } +} + +# +# Document formatting parameters +# +$paraskip = 6; # Space between paragraphs +$chapstart = 30; # Space before a chapter heading +$chapskip = 24; # Space after a chapter heading +$tocskip = 6; # Space between TOC entries + +# Configure post-paragraph skips for each kind of paragraph +%skiparray = ('chap' => $chapskip, 'appn' => $chapstart, + 'head' => $paraskip, 'subh' => $paraskip, + 'norm' => $paraskip, 'bull' => $paraskip, + 'code' => $paraskip, 'toc0' => $tocskip, + 'toc1' => $tocskip, 'toc2' => $tocskip); + +# Custom encoding vector. This is basically the same as +# ISOLatin1Encoding (a level 2 feature, so we dont want to use it), +# but with the "naked" accents at \200-\237 moved to the \000-\037 +# range (ASCII control characters), and a few extra characters thrown +# in. It is basically a modified Windows 1252 codepage, minus, for +# now, the euro sign (\200 is reserved for euro.) + +@NASMEncoding = +( + undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, + undef, undef, undef, undef, undef, undef, 'dotlessi', 'grave', + 'acute', 'circumflex', 'tilde', 'macron', 'breve', 'dotaccent', + 'dieresis', undef, 'ring', 'cedilla', undef, 'hungarumlaut', + 'ogonek', 'caron', 'space', 'exclam', 'quotedbl', 'numbersign', + 'dollar', 'percent', 'ampersand', 'quoteright', 'parenleft', + 'parenright', 'asterisk', 'plus', 'comma', 'minus', 'period', + 'slash', 'zero', 'one', 'two', 'three', 'four', 'five', 'six', + 'seven', 'eight', 'nine', 'colon', 'semicolon', 'less', 'equal', + 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', + 'W', 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright', + 'asciicircum', 'underscore', 'quoteleft', 'a', 'b', 'c', 'd', 'e', + 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', + 't', 'u', 'v', 'w', 'x', 'y', 'z', 'braceleft', 'bar', 'braceright', + 'asciitilde', undef, undef, undef, 'quotesinglbase', 'florin', + 'quotedblbase', 'ellipsis', 'dagger', 'dbldagger', 'circumflex', + 'perthousand', 'Scaron', 'guilsinglleft', 'OE', undef, 'Zcaron', + undef, undef, 'grave', 'quotesingle', 'quotedblleft', + 'quotedblright', 'bullet', 'endash', 'emdash', 'tilde', 'trademark', + 'scaron', 'guilsignlright', 'oe', undef, 'zcaron', 'Ydieresis', + 'space', 'exclamdown', 'cent', 'sterling', 'currency', 'yen', + 'brokenbar', 'section', 'dieresis', 'copyright', 'ordfeminine', + 'guillemotleft', 'logicalnot', 'hyphen', 'registered', 'macron', + 'degree', 'plusminus', 'twosuperior', 'threesuperior', 'acute', 'mu', + 'paragraph', 'periodcentered', 'cedilla', 'onesuperior', + 'ordmasculine', 'guillemotright', 'onequarter', 'onehalf', + 'threequarters', 'questiondown', 'Agrave', 'Aacute', 'Acircumflex', + 'Atilde', 'Adieresis', 'Aring', 'AE', 'Ccedilla', 'Egrave', 'Eacute', + 'Ecircumflex', 'Edieresis', 'Igrave', 'Iacute', 'Icircumflex', + 'Idieresis', 'Eth', 'Ntilde', 'Ograve', 'Oacute', 'Ocircumflex', + 'Otilde', 'Odieresis', 'multiply', 'Oslash', 'Ugrave', 'Uacute', + 'Ucircumflex', 'Udieresis', 'Yacute', 'Thorn', 'germandbls', + 'agrave', 'aacute', 'acircumflex', 'atilde', 'adieresis', 'aring', + 'ae', 'ccedilla', 'egrave', 'eacute', 'ecircumflex', 'edieresis', + 'igrave', 'iacute', 'icircumflex', 'idieresis', 'eth', 'ntilde', + 'ograve', 'oacute', 'ocircumflex', 'otilde', 'odieresis', 'divide', + 'oslash', 'ugrave', 'uacute', 'ucircumflex', 'udieresis', 'yacute', + 'thorn', 'ydieresis' +); + +# Name-to-byte lookup hash +%charcode = (); +for ( $i = 0 ; $i < 256 ; $i++ ) { + $charcode{$NASMEncoding[$i]} = chr($i); +} + +# +# First, format the stuff coming from the front end into +# a cleaner representation +# +if ( defined($input) ) { + sysopen(PARAS, $input, O_RDONLY) or + die "$0: cannot open $input: $!\n"; +} else { + open(PARAS, "<&STDIN") or die "$0: $!\n"; +} +while ( defined($line = <PARAS>) ) { + chomp $line; + $data = <PARAS>; + chomp $data; + if ( $line =~ /^meta :(.*)$/ ) { + $metakey = $1; + $metadata{$metakey} = $data; + } elsif ( $line =~ /^indx :(.*)$/ ) { + $ixentry = $1; + push(@ixentries, $ixentry); + $ixterms{$ixentry} = [split(/\037/, $data)]; + # Look for commas. This is easier done on the string + # representation, so do it now. + if ( $data =~ /^(.*)\,\037sp\037/ ) { + $ixprefix = $1; + $ixprefix =~ s/\037n $//; # Discard possible font change at end + $ixhasprefix{$ixentry} = $ixprefix; + if ( !$ixprefixes{$ixprefix} ) { + $ixcommafirst{$ixentry}++; + } + $ixprefixes{$ixprefix}++; + } else { + # A complete term can also be used as a prefix + $ixprefixes{$data}++; + } + } else { + push(@ptypes, $line); + push(@paras, [split(/\037/, $data)]); + } +} +close(PARAS); + +# +# Convert an integer to a chosen base +# +sub int2base($$) { + my($i,$b) = @_; + my($s) = ''; + my($n) = ''; + my($z) = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + return '0' if ($i == 0); + if ( $i < 0 ) { $n = '-'; $i = -$i; } + while ( $i ) { + $s = substr($z,$i%$b,1) . $s; + $i = int($i/$b); + } + return $n.$s; +} + +# +# Convert a string to a rendering array +# +sub string2array($) +{ + my($s) = @_; + my(@a) = (); + + $s =~ s/\B\-\-\B/$charcode{'emdash'}/g; + $s =~ s/\B\-\B/ $charcode{'endash'} /g; + + while ( $s =~ /^(\s+|\S+)(.*)$/ ) { + push(@a, [0,$1]); + $s = $2; + } + + return @a; +} + +# +# Take a crossreference name and generate the PostScript name for it. +# +# This hack produces a somewhat smaller PDF... +#%ps_xref_list = (); +#$ps_xref_next = 0; +#sub ps_xref($) { +# my($s) = @_; +# my $q = $ps_xref_list{$s}; +# return $q if ( defined($ps_xref_list{$s}) ); +# $q = 'X'.int2base($ps_xref_next++, 52); +# $ps_xref_list{$s} = $q; +# return $q; +#} + +# Somewhat bigger PDF, but one which obeys # URLs +sub ps_xref($) { + return @_[0]; +} + +# +# Flow lines according to a particular font set and width +# +# A "font set" is represented as an array containing +# arrays of pairs: [<size>, <metricref>] +# +# Each line is represented as: +# [ [type,first|last,aux,fontset,page,ypos,optional col], +# [rendering array] ] +# +# A space character may be "squeezed" by up to this much +# (as a fraction of the normal width of a space.) +# +$ps_space_squeeze = 0.00; # Min space width 100% +sub ps_flow_lines($$$@) { + my($wid, $fontset, $type, @data) = @_; + my($fonts) = $$fontset{fonts}; + my($e); + my($w) = 0; # Width of current line + my($sw) = 0; # Width of current line due to spaces + my(@l) = (); # Current line + my(@ls) = (); # Accumulated output lines + my(@xd) = (); # Metadata that goes with subsequent text + my $hasmarker = 0; # Line has -6 marker + my $pastmarker = 0; # -6 marker found + + # If there is a -6 marker anywhere in the paragraph, + # *each line* output needs to have a -6 marker + foreach $e ( @data ) { + $hasmarker = 1 if ( $$e[0] == -6 ); + } + + $w = 0; + foreach $e ( @data ) { + if ( $$e[0] < 0 ) { + # Type is metadata. Zero width. + if ( $$e[0] == -6 ) { + $pastmarker = 1; + } + if ( $$e[0] == -1 || $$e[0] == -6 ) { + # -1 (end anchor) or -6 (marker) goes with the preceeding + # text, otherwise with the subsequent text + push(@l, $e); + } else { + push(@xd, $e); + } + } else { + my $ew = ps_width($$e[1], $fontset->{fonts}->[$$e[0]][1], + \@NASMEncoding) * + ($fontset->{fonts}->[$$e[0]][0]/1000); + my $sp = $$e[1]; + $sp =~ tr/[^ ]//d; # Delete nonspaces + my $esw = ps_width($sp, $fontset->{fonts}->[$$e[0]][1], + \@NASMEncoding) * + ($fontset->{fonts}->[$$e[0]][0]/1000); + + if ( ($w+$ew) - $ps_space_squeeze*($sw+$esw) > $wid ) { + # Begin new line + # Search backwards for previous space chunk + my $lx = scalar(@l)-1; + my @rm = (); + while ( $lx >= 0 ) { + while ( $lx >= 0 && $l[$lx]->[0] < 0 ) { + # Skip metadata + $pastmarker = 0 if ( $l[$lx]->[0] == -6 ); + $lx--; + }; + if ( $lx >= 0 ) { + if ( $l[$lx]->[1] eq ' ' ) { + splice(@l, $lx, 1); + @rm = splice(@l, $lx); + last; # Found place to break + } else { + $lx--; + } + } + } + + # Now @l contains the stuff to remain on the old line + # If we broke the line inside a link, then split the link + # into two. + my $lkref = undef; + foreach my $lc ( @l ) { + if ( $$lc[0] == -2 || $$lc[0] == -3 || $lc[0] == -7 ) { + $lkref = $lc; + } elsif ( $$lc[0] == -1 ) { + undef $lkref; + } + } + + if ( defined($lkref) ) { + push(@l, [-1,undef]); # Terminate old reference + unshift(@rm, $lkref); # Duplicate reference on new line + } + + if ( $hasmarker ) { + if ( $pastmarker ) { + unshift(@rm,[-6,undef]); # New line starts with marker + } else { + push(@l,[-6,undef]); # Old line ends with marker + } + } + + push(@ls, [[$type,0,undef,$fontset,0,0],[@l]]); + @l = @rm; + + $w = $sw = 0; + # Compute the width of the remainder array + for my $le ( @l ) { + if ( $$le[0] >= 0 ) { + my $xew = ps_width($$le[1], + $fontset->{fonts}->[$$le[0]][1], + \@NASMEncoding) * + ($fontset->{fonts}->[$$le[0]][0]/1000); + my $xsp = $$le[1]; + $xsp =~ tr/[^ ]//d; # Delete nonspaces + my $xsw = ps_width($xsp, + $fontset->{fonts}->[$$le[0]][1], + \@NASMEncoding) * + ($fontset->{fonts}->[$$le[0]][0]/1000); + $w += $xew; $sw += $xsw; + } + } + } + push(@l, @xd); # Accumulated metadata + @xd = (); + if ( $$e[1] ne '' ) { + push(@l, $e); + $w += $ew; $sw += $esw; + } + } + } + push(@l,@xd); + if ( scalar(@l) ) { + push(@ls, [[$type,0,undef,$fontset,0,0],[@l]]); # Final line + } + + # Mark the first line as first and the last line as last + if ( scalar(@ls) ) { + $ls[0]->[0]->[1] |= 1; # First in para + $ls[-1]->[0]->[1] |= 2; # Last in para + } + return @ls; +} + +# +# Once we have broken things into lines, having multiple chunks +# with the same font index is no longer meaningful. Merge +# adjacent chunks to keep down the size of the whole file. +# +sub ps_merge_chunks(@) { + my(@ci) = @_; + my($c, $lc); + my(@co, $eco); + + undef $lc; + @co = (); + $eco = -1; # Index of the last entry in @co + foreach $c ( @ci ) { + if ( defined($lc) && $$c[0] == $lc && $$c[0] >= 0 ) { + $co[$eco]->[1] .= $$c[1]; + } else { + push(@co, $c); $eco++; + $lc = $$c[0]; + } + } + return @co; +} + +# +# Convert paragraphs to rendering arrays. Each +# element in the array contains (font, string), +# where font can be one of: +# -1 end link +# -2 begin crossref +# -3 begin weblink +# -4 index item anchor +# -5 crossref anchor +# -6 left/right marker (used in the index) +# -7 page link (used in the index) +# 0 normal +# 1 empatic (italic) +# 2 code (fixed spacing) +# + +sub mkparaarray($@) { + my($ptype, @chunks) = @_; + + my @para = (); + my $in_e = 0; + my $chunk; + + if ( $ptype =~ /^code/ ) { + foreach $chunk ( @chunks ) { + push(@para, [2, $chunk]); + } + } else { + foreach $chunk ( @chunks ) { + my $type = substr($chunk,0,2); + my $text = substr($chunk,2); + + if ( $type eq 'sp' ) { + push(@para, [$in_e?1:0, ' ']); + } elsif ( $type eq 'da' ) { + push(@para, [$in_e?1:0, $charcode{'endash'}]); + } elsif ( $type eq 'n ' ) { + push(@para, [0, $text]); + $in_e = 0; + } elsif ( $type =~ '^e' ) { + push(@para, [1, $text]); + $in_e = ($type eq 'es' || $type eq 'e '); + } elsif ( $type eq 'c ' ) { + push(@para, [2, $text]); + $in_e = 0; + } elsif ( $type eq 'x ' ) { + push(@para, [-2, ps_xref($text)]); + } elsif ( $type eq 'xe' ) { + push(@para, [-1, undef]); + } elsif ( $type eq 'wc' || $type eq 'w ' ) { + $text =~ /\<(.*)\>(.*)$/; + my $link = $1; $text = $2; + push(@para, [-3, $link]); + push(@para, [($type eq 'wc') ? 2:0, $text]); + push(@para, [-1, undef]); + $in_e = 0; + } elsif ( $type eq 'i ' ) { + push(@para, [-4, $text]); + } else { + die "Unexpected paragraph chunk: $chunk"; + } + } + } + return @para; +} + +$npara = scalar(@paras); +for ( $i = 0 ; $i < $npara ; $i++ ) { + $paras[$i] = [mkparaarray($ptypes[$i], @{$paras[$i]})]; +} + +# +# This converts a rendering array to a simple string +# +sub ps_arraytostr(@) { + my $s = ''; + my $c; + foreach $c ( @_ ) { + $s .= $$c[1] if ( $$c[0] >= 0 ); + } + return $s; +} + +# +# This generates a duplicate of a paragraph +# +sub ps_dup_para(@) { + my(@i) = @_; + my(@o) = (); + my($c); + + foreach $c ( @i ) { + my @cc = @{$c}; + push(@o, [@cc]); + } + return @o; +} + +# +# This generates a duplicate of a paragraph, stripping anchor +# tags (-4 and -5) +# +sub ps_dup_para_noanchor(@) { + my(@i) = @_; + my(@o) = (); + my($c); + + foreach $c ( @i ) { + my @cc = @{$c}; + push(@o, [@cc]) unless ( $cc[0] == -4 || $cc[0] == -5 ); + } + return @o; +} + +# +# Scan for header paragraphs and fix up their contents; +# also generate table of contents and PDF bookmarks. +# +@tocparas = ([[-5, 'contents'], [0,'Contents']]); +@tocptypes = ('chap'); +@bookmarks = (['title', 0, 'Title'], ['contents', 0, 'Contents']); +%bookref = (); +for ( $i = 0 ; $i < $npara ; $i++ ) { + my $xtype = $ptypes[$i]; + my $ptype = substr($xtype,0,4); + my $str; + my $book; + + if ( $ptype eq 'chap' || $ptype eq 'appn' ) { + unless ( $xtype =~ /^\S+ (\S+) :(.*)$/ ) { + die "Bad para"; + } + my $secn = $1; + my $sech = $2; + my $xref = ps_xref($sech); + my $chap = ($ptype eq 'chap')?'Chapter':'Appendix'; + + $book = [$xref, 0, ps_arraytostr(@{$paras[$i]})]; + push(@bookmarks, $book); + $bookref{$secn} = $book; + + push(@tocparas, [ps_dup_para_noanchor(@{$paras[$i]})]); + push(@tocptypes, 'toc0'.' :'.$sech.':'.$chap.' '.$secn.':'); + + unshift(@{$paras[$i]}, + [-5, $xref], [0,$chap.' '.$secn.':'], [0, ' ']); + } elsif ( $ptype eq 'head' || $ptype eq 'subh' ) { + unless ( $xtype =~ /^\S+ (\S+) :(.*)$/ ) { + die "Bad para"; + } + my $secn = $1; + my $sech = $2; + my $xref = ps_xref($sech); + my $pref; + $pref = $secn; $pref =~ s/\.[^\.]+$//; # Find parent node + + $book = [$xref, 0, ps_arraytostr(@{$paras[$i]})]; + push(@bookmarks, $book); + $bookref{$secn} = $book; + $bookref{$pref}->[1]--; # Adjust count for parent node + + push(@tocparas, [ps_dup_para_noanchor(@{$paras[$i]})]); + push(@tocptypes, + (($ptype eq 'subh') ? 'toc2':'toc1').' :'.$sech.':'.$secn); + + unshift(@{$paras[$i]}, [-5, $xref]); + } +} + +# +# Add TOC to beginning of paragraph list +# +unshift(@paras, @tocparas); undef @tocparas; +unshift(@ptypes, @tocptypes); undef @tocptypes; + +# +# Add copyright notice to the beginning +# +@copyright_page = +([[0, $charcode{'copyright'}], + [0, ' '], [0, $metadata{'year'}], + [0, ' '], string2array($metadata{'author'}), + [0, ' '], string2array($metadata{'copyright_tail'})], + [string2array($metadata{'license'})], + [string2array($metadata{'auxinfo'})]); + +unshift(@paras, @copyright_page); +unshift(@ptypes, ('norm') x scalar(@copyright_page)); + +$npara = scalar(@paras); + +# +# No lines generated, yet. +# +@pslines = (); + +# +# Line Auxilliary Information Types +# +$AuxStr = 1; # String +$AuxPage = 2; # Page number (from xref) +$AuxPageStr = 3; # Page number as a PostScript string +$AuxXRef = 4; # Cross reference as a name +$AuxNum = 5; # Number + +# +# Break or convert paragraphs into lines, and push them +# onto the @pslines array. +# +sub ps_break_lines($$) { + my ($paras,$ptypes) = @_; + + my $linewidth = $psconf{pagewidth}-$psconf{lmarg}-$psconf{rmarg}; + my $bullwidth = $linewidth-$psconf{bulladj}; + my $indxwidth = ($linewidth-$psconf{idxgutter})/$psconf{idxcolumns} + -$psconf{idxspace}; + + my $npara = scalar(@{$paras}); + my $i; + + for ( $i = 0 ; $i < $npara ; $i++ ) { + my $xtype = $ptypes->[$i]; + my $ptype = substr($xtype,0,4); + my @data = @{$paras->[$i]}; + my @ls = (); + if ( $ptype eq 'code' ) { + my $p; + # Code paragraph; each chunk is a line + foreach $p ( @data ) { + push(@ls, [[$ptype,0,undef,\%BodyFont,0,0],[$p]]); + } + $ls[0]->[0]->[1] |= 1; # First in para + $ls[-1]->[0]->[1] |= 2; # Last in para + } elsif ( $ptype eq 'chap' || $ptype eq 'appn' ) { + # Chapters are flowed normally, but in an unusual font + @ls = ps_flow_lines($linewidth, \%ChapFont, $ptype, @data); + } elsif ( $ptype eq 'head' || $ptype eq 'subh' ) { + unless ( $xtype =~ /^\S+ (\S+) :(.*)$/ ) { + die "Bad para"; + } + my $secn = $1; + my $sech = $2; + my $font = ($ptype eq 'head') ? \%HeadFont : \%SubhFont; + @ls = ps_flow_lines($linewidth, $font, $ptype, @data); + # We need the heading number as auxillary data + $ls[0]->[0]->[2] = [[$AuxStr,$secn]]; + } elsif ( $ptype eq 'norm' ) { + @ls = ps_flow_lines($linewidth, \%BodyFont, $ptype, @data); + } elsif ( $ptype eq 'bull' ) { + @ls = ps_flow_lines($bullwidth, \%BodyFont, $ptype, @data); + } elsif ( $ptype =~ /^toc/ ) { + unless ( $xtype =~/^\S+ :([^:]*):(.*)$/ ) { + die "Bad para"; + } + my $xref = $1; + my $refname = $2.' '; + my $ntoc = substr($ptype,3,1)+0; + my $refwidth = ps_width($refname, $BodyFont{fonts}->[0][1], + \@NASMEncoding) * + ($BodyFont{fonts}->[0][0]/1000); + + @ls = ps_flow_lines($linewidth-$ntoc*$psconf{tocind}- + $psconf{tocpnz}-$refwidth, + \%BodyFont, $ptype, @data); + + # Auxilliary data: for the first line, the cross reference symbol + # and the reference name; for all lines but the first, the + # reference width; and for the last line, the page number + # as a string. + my $nl = scalar(@ls); + $ls[0]->[0]->[2] = [[$AuxStr,$refname], [$AuxXRef,$xref]]; + for ( $j = 1 ; $j < $nl ; $j++ ) { + $ls[$j]->[0]->[2] = [[$AuxNum,$refwidth]]; + } + push(@{$ls[$nl-1]->[0]->[2]}, [$AuxPageStr,$xref]); + } elsif ( $ptype =~ /^idx/ ) { + my $lvl = substr($ptype,3,1)+0; + + @ls = ps_flow_lines($indxwidth-$lvl*$psconf{idxindent}, + \%BodyFont, $ptype, @data); + } else { + die "Unknown para type: $ptype"; + } + # Merge adjacent identical chunks + foreach $l ( @ls ) { + @{$$l[1]} = ps_merge_chunks(@{$$l[1]}); + } + push(@pslines,@ls); + } +} + +# Break the main body text into lines. +ps_break_lines(\@paras, \@ptypes); + +# +# Break lines in to pages +# + +# Where to start on page 2, the copyright page +$curpage = 2; # Start on page 2 +$curypos = $psconf{pageheight}-$psconf{topmarg}-$psconf{botmarg}- + $psconf{startcopyright}; +undef $columnstart; # Not outputting columnar text +undef $curcolumn; # Current column +$nlines = scalar(@pslines); + +# +# This formats lines inside the global @pslines array into pages, +# updating the page and y-coordinate entries. Start at the +# $startline position in @pslines and go to but not including +# $endline. The global variables $curpage, $curypos, $columnstart +# and $curcolumn are updated appropriately. +# +sub ps_break_pages($$) { + my($startline, $endline) = @_; + + # Paragraph types which should never be broken + my $nobreakregexp = "^(chap|appn|head|subh|toc.|idx.)\$"; + # Paragraph types which are heading (meaning they should not be broken + # immediately after) + my $nobreakafter = "^(chap|appn|head|subh)\$"; + # Paragraph types which should never be broken *before* + my $nobreakbefore = "^idx[1-9]\$"; + # Paragraph types which are set in columnar format + my $columnregexp = "^idx.\$"; + + my $upageheight = $psconf{pageheight}-$psconf{topmarg}-$psconf{botmarg}; + + my $i; + + for ( $i = $startline ; $i < $endline ; $i++ ) { + my $linfo = $pslines[$i]->[0]; + if ( ($$linfo[0] eq 'chap' || $$linfo[0] eq 'appn' ) + && ($$linfo[1] & 1) ) { + # First line of a new chapter heading. Start a new page. + undef $columnstart; + $curpage++ if ( $curypos > 0 || defined($columnstart) ); + $curypos = $chapstart; + } elsif ( defined($columnstart) && $$linfo[0] !~ /$columnregexp/o ) { + undef $columnstart; + $curpage++; + $curypos = 0; + } + + if ( $$linfo[0] =~ /$columnregexp/o && !defined($columnstart) ) { + $columnstart = $curypos; + $curcolumn = 0; + } + + # Adjust position by the appropriate leading + $curypos += $$linfo[3]->{leading}; + + # Record the page and y-position + $$linfo[4] = $curpage; + $$linfo[5] = $curypos; + $$linfo[6] = $curcolumn if ( defined($columnstart) ); + + if ( $curypos > $upageheight ) { + # We need to break the page before this line. + my $broken = 0; # No place found yet + while ( !$broken && $pslines[$i]->[0]->[4] == $curpage ) { + my $linfo = $pslines[$i]->[0]; + my $pinfo = $pslines[$i-1]->[0]; + + if ( $$linfo[1] == 2 ) { + # This would be an orphan, don't break. + } elsif ( $$linfo[1] & 1 ) { + # Sole line or start of paragraph. Break unless + # the previous line was part of a heading. + $broken = 1 if ( $$pinfo[0] !~ /$nobreakafter/o && + $$linfo[0] !~ /$nobreakbefore/o ); + } else { + # Middle of paragraph. Break unless we're in a + # no-break paragraph, or the previous line would + # end up being a widow. + $broken = 1 if ( $$linfo[0] !~ /$nobreakregexp/o && + $$pinfo[1] != 1 ); + } + $i--; + } + die "Nowhere to break page $curpage\n" if ( !$broken ); + # Now $i should point to line immediately before the break, i.e. + # the next paragraph should be the first on the new page + if ( defined($columnstart) && + ++$curcolumn < $psconf{idxcolumns} ) { + # We're actually breaking text into columns, not pages + $curypos = $columnstart; + } else { + undef $columnstart; + $curpage++; + $curypos = 0; + } + next; + } + + # Add end of paragraph skip + if ( $$linfo[1] & 2 ) { + $curypos += $skiparray{$$linfo[0]}; + } + } +} + +ps_break_pages(0,$nlines); # Break the main text body into pages + +# +# Find the page number of all the indices +# +%ps_xref_page = (); # Crossref anchor pages +%ps_index_pages = (); # Index item pages +$nlines = scalar(@pslines); +for ( $i = 0 ; $i < $nlines ; $i++ ) { + my $linfo = $pslines[$i]->[0]; + foreach my $c ( @{$pslines[$i]->[1]} ) { + if ( $$c[0] == -4 ) { + if ( !defined($ps_index_pages{$$c[1]}) ) { + $ps_index_pages{$$c[1]} = []; + } elsif ( $ps_index_pages{$$c[1]}->[-1] eq $$linfo[4] ) { + # Pages are emitted in order; if this is a duplicated + # entry it will be the last one + next; # Duplicate + } + push(@{$ps_index_pages{$$c[1]}}, $$linfo[4]); + } elsif ( $$c[0] == -5 ) { + $ps_xref_page{$$c[1]} = $$linfo[4]; + } + } +} + +# +# Emit index paragraphs +# +$startofindex = scalar(@pslines); +@ixparas = ([[-5,'index'],[0,'Index']]); +@ixptypes = ('chap'); + +foreach $k ( @ixentries ) { + my $n,$i; + my $ixptype = 'idx0'; + my $prefix = $ixhasprefix{$k}; + my @ixpara = mkparaarray($ixptype,@{$ixterms{$k}}); + my $commapos = undef; + + if ( defined($prefix) && $ixprefixes{$prefix} > 1 ) { + # This entry has a "hanging comma" + for ( $i = 0 ; $i < scalar(@ixpara)-1 ; $i++ ) { + if ( substr($ixpara[$i]->[1],-1,1) eq ',' && + $ixpara[$i+1]->[1] eq ' ' ) { + $commapos = $i; + last; + } + } + } + if ( defined($commapos) ) { + if ( $ixcommafirst{$k} ) { + # This is the first entry; generate the + # "hanging comma" entry + my @precomma = splice(@ixpara,0,$commapos); + if ( $ixpara[0]->[1] eq ',' ) { + shift(@ixpara); # Discard lone comma + } else { + # Discard attached comma + $ixpara[0]->[1] =~ s/\,$//; + push(@precomma,shift(@ixpara)); + } + push(@precomma, [-6,undef]); + push(@ixparas, [@precomma]); + push(@ixptypes, $ixptype); + shift(@ixpara); # Remove space + } else { + splice(@ixpara,0,$commapos+2); + } + $ixptype = 'idx1'; + } + + push(@ixpara, [-6,undef]); # Left/right marker + $i = 1; $n = scalar(@{$ps_index_pages{$k}}); + foreach $p ( @{$ps_index_pages{$k}} ) { + if ( $i++ == $n ) { + push(@ixpara,[-7,$p],[0,"$p"],[-1,undef]); + } else { + push(@ixpara,[-7,$p],[0,"$p,"],[-1,undef],[0,' ']); + } + } + + push(@ixparas, [@ixpara]); + push(@ixptypes, $ixptype); +} + +# +# Flow index paragraphs into lines +# +ps_break_lines(\@ixparas, \@ixptypes); + +# +# Format index into pages +# +$nlines = scalar(@pslines); +ps_break_pages($startofindex, $nlines); + +# +# Push index onto bookmark list +# +push(@bookmarks, ['index', 0, 'Index']); + +# Get the list of fonts used +%ps_all_fonts = (); +foreach $fset ( @AllFonts ) { + foreach $font ( @{$fset->{fonts}} ) { + $ps_all_fonts{$font->[1]->{name}}++; + } +} + +# Emit the PostScript DSC header +print "%!PS-Adobe-3.0\n"; +print "%%Pages: $curpage\n"; +print "%%BoundingBox: 0 0 ", $psconf{pagewidth}, ' ', $psconf{pageheight}, "\n"; +print "%%Creator: (NASM psflow.pl)\n"; +print "%%DocumentData: Clean7Bit\n"; +print "%%DocumentFonts: ", join(' ', keys(%ps_all_fonts)), "\n"; +print "%%DocumentNeededFonts: ", join(' ', keys(%ps_all_fonts)), "\n"; +print "%%Orientation: Portrait\n"; +print "%%PageOrder: Ascend\n"; +print "%%EndComments\n"; +print "%%BeginProlog\n"; + +# Emit the configurables as PostScript tokens +foreach $c ( keys(%psconf) ) { + print "/$c ", $psconf{$c}, " def\n"; +} +foreach $c ( keys(%psbool) ) { + print "/$c ", ($psbool{$c}?'true':'false'), " def\n"; +} + +# Emit custom encoding vector +$zstr = '/NASMEncoding [ '; +foreach $c ( @NASMEncoding ) { + my $z = '/'.(defined($c)?$c:'.notdef ').' '; + if ( length($zstr)+length($z) > 72 ) { + print $zstr,"\n"; + $zstr = ' '; + } + $zstr .= $z; +} +print $zstr, "] def\n"; + +# Font recoding routine +# newname fontname -- +print "/nasmenc {\n"; +print " findfont dup length dict begin\n"; +print " { 1 index /FID ne {def}{pop pop} ifelse } forall\n"; +print " /Encoding NASMEncoding def\n"; +print " currentdict\n"; +print " end\n"; +print " definefont pop\n"; +print "} def\n"; + +# Emit fontset definitions +foreach $font ( keys(%ps_all_fonts) ) { + print '/',$font,'-NASM /',$font," nasmenc\n"; +} + +foreach $fset ( @AllFonts ) { + my $i = 0; + my @zfonts = (); + foreach $font ( @{$fset->{fonts}} ) { + print '/', $fset->{name}, $i, ' ', + '/', $font->[1]->{name}, '-NASM findfont ', + $font->[0], " scalefont def\n"; + push(@zfonts, $fset->{name}.$i); + $i++; + } + print '/', $fset->{name}, ' [', join(' ',@zfonts), "] def\n"; +} + +# This is used by the bullet-paragraph PostScript methods +print "/bullet [",ps_string($charcode{'bullet'}),"] def\n"; + +# Emit the canned PostScript prologue +open(PSHEAD, "< head.ps"); +while ( defined($line = <PSHEAD>) ) { + print $line; +} +close(PSHEAD); +print "%%EndProlog\n"; + +# Generate a PostScript string +sub ps_string($) { + my ($s) = @_; + my ($i,$c); + my ($o) = '('; + my ($l) = length($s); + for ( $i = 0 ; $i < $l ; $i++ ) { + $c = substr($s,$i,1); + if ( ord($c) < 32 || ord($c) > 126 ) { + $o .= sprintf("\\%03o", ord($c)); + } elsif ( $c eq '(' || $c eq ')' || $c eq "\\" ) { + $o .= "\\".$c; + } else { + $o .= $c; + } + } + return $o.')'; +} + +# Generate PDF bookmarks +print "%%BeginSetup\n"; +foreach $b ( @bookmarks ) { + print '[/Title ', ps_string($b->[2]), "\n"; + print '/Count ', $b->[1], ' ' if ( $b->[1] ); + print '/Dest /',$b->[0]," /OUT pdfmark\n"; +} + +# Ask the PostScript interpreter for the proper size media +print "setpagesize\n"; +print "%%EndSetup\n"; + +# Start a PostScript page +sub ps_start_page() { + $ps_page++; + print "%%Page: $ps_page $ps_page\n"; + print "%%BeginPageSetup\n"; + print "save\n"; + print "%%EndPageSetup\n"; + print '/', $ps_page, " pa\n"; +} + +# End a PostScript page +sub ps_end_page($) { + my($pn) = @_; + if ( $pn ) { + print "($ps_page)", (($ps_page & 1) ? 'pageodd' : 'pageeven'), "\n"; + } + print "restore showpage\n"; +} + +$ps_page = 0; + +# Title page +ps_start_page(); +$title = $metadata{'title'} || ''; +$title =~ s/ \- / $charcode{'emdash'} /; + +$subtitle = $metadata{'subtitle'} || ''; +$subtitle =~ s/ \- / $charcode{'emdash'} /; + +# Print title +print "/ti ", ps_string($title), " def\n"; +print "/sti ", ps_string($subtitle), " def\n"; +print "lmarg pageheight 2 mul 3 div moveto\n"; +print "tfont0 setfont\n"; +print "/title linkdest ti show\n"; +print "lmarg pageheight 2 mul 3 div 10 sub moveto\n"; +print "0 setlinecap 3 setlinewidth\n"; +print "pagewidth lmarg sub rmarg sub 0 rlineto currentpoint stroke moveto\n"; +print "hfont1 setfont sti stringwidth pop neg ", + -$HeadFont{leading}, " rmoveto\n"; +print "sti show\n"; + +# Print logo, if there is one +# FIX: To be 100% correct, this should look for DocumentNeeded* +# and DocumentFonts in the header of the EPSF and add those to the +# global header. +if ( defined($metadata{epslogo}) && + sysopen(EPS, $metadata{epslogo}, O_RDONLY) ) { + my @eps = (); + my ($bbllx,$bblly,$bburx,$bbury) = (undef,undef,undef,undef); + my $line; + my $scale = 1; + my $maxwidth = $psconf{pagewidth}-$psconf{lmarg}-$psconf{rmarg}; + my $maxheight = $psconf{pageheight}/3-40; + my $width, $height; + my $x, $y; + + while ( defined($line = <EPS>) ) { + last if ( $line =~ /^%%EOF/ ); + if ( !defined($bbllx) && + $line =~ /^\%\%BoundingBox\:\s*([0-9\.]+)\s+([0-9\.]+)\s+([0-9\.]+)\s+([0-9\.]+)/i ) { + $bbllx = $1+0; $bblly = $2+0; + $bburx = $3+0; $bbury = $4+0; + } + push(@eps,$line); + } + close(EPS); + + if ( defined($bbllx) ) { + $width = $bburx-$bbllx; + $height = $bbury-$bblly; + + if ( $width > $maxwidth ) { + $scale = $maxwidth/$width; + } + if ( $height*$scale > $maxheight ) { + $scale = $maxheight/$height; + } + + $x = ($psconf{pagewidth}-$width*$scale)/2; + $y = ($psconf{pageheight}-$height*$scale)/2; + + print "BeginEPSF\n"; + print $x, ' ', $y, " translate\n"; + print $scale, " dup scale\n" unless ( $scale == 1 ); + print -$bbllx, ' ', -$bblly, " translate\n"; + print "$bbllx $bblly moveto\n"; + print "$bburx $bblly lineto\n"; + print "$bburx $bbury lineto\n"; + print "$bbllx $bbury lineto\n"; + print "$bbllx $bblly lineto clip newpath\n"; + print "%%BeginDocument: ",ps_string($metadata{epslogo}),"\n"; + print @eps; + print "%%EndDocument\n"; + print "EndEPSF\n"; + } +} +ps_end_page(0); + +# Emit the rest of the document (page 2 and on) +$curpage = 2; +ps_start_page(); +foreach $line ( @pslines ) { + my $linfo = $line->[0]; + + if ( $$linfo[4] != $curpage ) { + ps_end_page($curpage > 2); + ps_start_page(); + $curpage = $$linfo[4]; + } + + print '['; + my $curfont = 0; + foreach my $c ( @{$line->[1]} ) { + if ( $$c[0] >= 0 ) { + if ( $curfont != $$c[0] ) { + print ($curfont = $$c[0]); + } + print ps_string($$c[1]); + } elsif ( $$c[0] == -1 ) { + print '{el}'; # End link + } elsif ( $$c[0] == -2 ) { + print '{/',$$c[1],' xl}'; # xref link + } elsif ( $$c[0] == -3 ) { + print '{',ps_string($$c[1]),'wl}'; # web link + } elsif ( $$c[0] == -4 ) { + # Index anchor -- ignore + } elsif ( $$c[0] == -5 ) { + print '{/',$$c[1],' xa}'; #xref anchor + } elsif ( $$c[0] == -6 ) { + print ']['; # Start a new array + $curfont = 0; + } elsif ( $$c[0] == -7 ) { + print '{/',$$c[1],' pl}'; # page link + } else { + die "Unknown annotation"; + } + } + print ']'; + if ( defined($$linfo[2]) ) { + foreach my $x ( @{$$linfo[2]} ) { + if ( $$x[0] == $AuxStr ) { + print ps_string($$x[1]); + } elsif ( $$x[0] == $AuxPage ) { + print $ps_xref_page{$$x[1]},' '; + } elsif ( $$x[0] == $AuxPageStr ) { + print ps_string($ps_xref_page{$$x[1]}); + } elsif ( $$x[0] == $AuxXRef ) { + print '/',ps_xref($$x[1]),' '; + } elsif ( $$x[0] == $AuxNum ) { + print $$x[1],' '; + } else { + die "Unknown auxilliary data type"; + } + } + } + print ($psconf{pageheight}-$psconf{topmarg}-$$linfo[5]); + print ' ', $$linfo[6] if ( defined($$linfo[6]) ); + print ' ', $$linfo[0].$$linfo[1], "\n"; +} + +ps_end_page(1); +print "%%EOF\n"; diff --git a/doc/genpsdriver.pl b/doc/genpsdriver.pl new file mode 100644 index 0000000..58e1f9a --- /dev/null +++ b/doc/genpsdriver.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl +## -------------------------------------------------------------------------- +## +## Copyright 1996-2009 The NASM Authors - All Rights Reserved +## See the file AUTHORS included with the NASM distribution for +## the specific copyright holders. +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following +## conditions are met: +## +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above +## copyright notice, this list of conditions and the following +## disclaimer in the documentation and/or other materials provided +## with the distribution. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +## CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## -------------------------------------------------------------------------- + +# +# Runs the equivalent of the following command line: +# +# $(PERL) $(srcdir)/genps.pl -subtitle "version `cat ../version`" \ +# nasmdoc.dip +# +# This is implemented as a Perl script since `cat ...` doesn't +# necessarily work on non-Unix systems. +# + +use File::Spec; +use Fcntl; +use Env; + +$perl = $ENV{PERL} || 'perl'; +$srcdir = $ENV{srcdir} || File::Spec->curdir(); + +$versionfile = File::Spec->catfile($srcdir, File::Spec->updir(), 'version'); +$genps = File::Spec->catfile($srcdir, 'genps.pl'); + +sysopen(VERSION, $versionfile, O_RDONLY) + or die "$0: cannot open $versionfile\n"; +$version = <VERSION>; +chomp $version; +close(VERSION); + +# \240 = no-break space, see @NASMEncoding in genps.pl. +# If we use a normal space, it breaks on 'doze platforms... +system($perl, $genps, '-subtitle', "version\240".$version, + @ARGV, 'nasmdoc.dip'); diff --git a/doc/head.ps b/doc/head.ps new file mode 100644 index 0000000..48b7af2 --- /dev/null +++ b/doc/head.ps @@ -0,0 +1,391 @@ +% +% PostScript header for NASM documentation +% + +% Avoid barfing on old PS implementations +/pdfmark where +{pop} {userdict /pdfmark /cleartomark load put} ifelse +/setpagedevice where +{pop} {userdict /setpagedevice /pop load put} ifelse + +% Useful definition +/space 32 def + +% +% This asks the PostScript interpreter for the proper size paper +% +/setpagesize { + 1 dict dup /PageSize [pagewidth pageheight] put setpagedevice +} def + +% +% Code to handle links +% +/min { 2 copy gt { exch } if pop } def +/max { 2 copy lt { exch } if pop } def + +/lkbegun 0 def +/lktype null def +/lkury 0 def +/lkurx 0 def +/lklly 0 def +/lkllx 0 def +/lkxmarg 1 def % Extra space for link in x dir +/lkymarg 1 def % Extra space for link in y dir +/lktarget () def + +% target type -- +/linkbegin { + userdict begin + /lkbegun 1 def + /lktype exch def + /lktarget exch def + colorlinks { 0 0 0.4 setrgbcolor } if + end +} def + +% target -- +/linkbegindest { + /Dest linkbegin +} def + +% uristring -- +/linkbeginuri { + /URI linkbegin +} def + +% pageno -- +/linkbeginpage { + /Page linkbegin +} def + +% string spacepadding -- +/linkshow { + userdict begin + /lspad exch def /lss exch def + lkbegun 0 ne { + gsave lss true charpath flattenpath pathbbox grestore + lkbegun 1 eq { + /lkury exch def + lss spacecount lspad mul add /lkurx exch def + /lklly exch def + /lkllx exch def + /lkbegun 2 def + } { + lkury max /lkury exch def + lss spacecount lspad mul add lkurx max /lkurx exch def + lklly min /lklly exch def + lkllx min /lkllx exch def + } ifelse + } if + lspad 0 space lss widthshow + end +} def + +% -- +/linkend { + userdict begin + [ lktype /URI eq { + /Action 2 dict dup /Subtype /URI put dup /URI lktarget put + } { + /Dest lktarget + } ifelse + /Border [0 0 0] + /Rect [ lkllx lkxmarg sub + lklly lkymarg sub + lkurx lkxmarg add + lkury lkymarg add ] + /Subtype /Link + /ANN pdfmark + /lkbegun 0 def + colorlinks { 0 setgray } if + end +} def + +% targetname -- +/linkdest { + [ /Dest 3 -1 roll + /View [ /XYZ currentpoint null ] + /DEST pdfmark +} def + +% A "fontset" is an array of fonts; a "stream" is an array of strings +% and numbers or procedures: +% [ 0 (Foo) ( ) (mani) ( ) 1 (padme) 0 ( ) (hum.) ] +% A number choses a font from the current fontset. +% A procedure is invoked as-is when printing the stream. +% +% When printing justified, an equal amount of space is added in +% between each string. + +% string -- spacecount +% Count space characters in a string +/spacecount { + 0 exch { + space eq { 1 add } if + } forall +} def + +% stream fontset -- spacecount width +% Get the width of a stream in the given fontset, and the +% number of space characters in the stream +/streamwidth { + gsave + 6 dict begin + /f exch def + /w 0 def + /s 0 def + f 0 get setfont + /integertype { + f exch get setfont + } def + /stringtype { + dup stringwidth pop w add /w exch def + spacecount s add /s exch def + } def + /arraytype { pop } def + % The input stream is on the top of the stack now + { + dup type exec + } forall + s w + end + grestore +} def + +% stream fontset spacer -- +% Show the stream in the given fontset, but add a certain amount +% of space to each space character +/showstreamspc { + 5 dict begin + /spc exch def + /f exch def + f 0 get setfont + /integertype { + f exch get setfont + } def + /stringtype { + spc linkshow + } def + /arraytype { + exec + } def + % Now stream is on the top of the stack + { + dup type exec + } forall + end +} def + +% stream fontset -- +% Show the stream in the given fontset, with no extra spacing +/showstream { + 0 showstreamspc +} def + +% stream fontset totalspace -- +% Show the stream justified to fit into a certain number of pixels +/showstreamjust { + userdict begin + /ts exch def /fs exch def /st exch def + st fs + st fs streamwidth ts exch sub exch + dup 0 gt { div } { pop } ifelse + showstreamspc + end +} def + +/bullmarg lmarg bulladj add def +/lwidth pagewidth lmarg sub rmarg sub def +/bwidth lwidth bulladj sub def + +% +% The various paragraph types +% The number at the end indicates start (1) of para, end (2) of para +% +/chapline { + currentpoint exch pop 10 sub lmarg exch moveto + 0 setlinecap 3 setlinewidth + lwidth 0 rlineto stroke +} def + +/chap0 { lmarg exch moveto cfont lwidth showstreamjust } def +/chap1 { lmarg exch moveto cfont lwidth showstreamjust } def +/chap2 { lmarg exch moveto cfont showstream chapline } def +/chap3 { lmarg exch moveto cfont showstream chapline } def + +/appn0 {chap0} def +/appn1 {chap1} def +/appn2 {chap2} def +/appn3 {chap3} def + +% lbl ypos fontset -- ypos +/headlbl { + 3 -1 roll [exch ( )] exch % ypos strm fontset + 2 copy % ypos strm fontset strm fontset + streamwidth % ypos strm fontset spccount width + lmarg exch sub % ypos strm fontset spccount xpos + 4 index % ypos strm fontset spccount xpos ypos + moveto % ypos strm fontset spccount + pop % ypos strm fontset spccount + showstream % ypos +} def + +/head0 { lmarg exch moveto hfont lwidth showstreamjust } def +/head1 { hfont headlbl lmarg exch moveto hfont lwidth showstreamjust } def +/head2 { lmarg exch moveto hfont showstream } def +/head3 { hfont headlbl lmarg exch moveto hfont showstream } def + +/subh0 { lmarg exch moveto sfont lwidth showstreamjust } def +/subh1 { sfont headlbl lmarg exch moveto sfont lwidth showstreamjust } def +/subh2 { lmarg exch moveto sfont showstream } def +/subh3 { sfont headlbl lmarg exch moveto sfont showstream } def + +/norm0 { lmarg exch moveto bfont lwidth showstreamjust } def +/norm1 { lmarg exch moveto bfont lwidth showstreamjust } def +/norm2 { lmarg exch moveto bfont showstream } def +/norm3 { lmarg exch moveto bfont showstream } def + +/code0 { lmarg exch moveto bfont showstream } def +/code1 { lmarg exch moveto bfont showstream } def +/code2 { lmarg exch moveto bfont showstream } def +/code3 { lmarg exch moveto bfont showstream } def + +/bull0 { bullmarg exch moveto bfont bwidth showstreamjust } def +/bull1 { dup lmarg exch moveto bullet bfont showstream + bullmarg exch moveto bfont bwidth showstreamjust } def +/bull2 { bullmarg exch moveto bfont showstream } def +/bull3 { dup lmarg exch moveto bullet bfont showstream + bullmarg exch moveto bfont showstream } def + +/tocw0 lwidth tocpnz sub def +/tocw1 tocw0 tocind sub def +/tocw2 tocw1 tocind sub def + +/tocx0 lmarg def +/tocx1 tocx0 tocind add def +/tocx2 tocx1 tocind add def + +/tocpn { + bfont0 setfont + 3 dict begin + /s exch def + /x s stringwidth pop pagewidth rmarg sub exch sub def + currentpoint /y exch def + lmarg sub tocdots div ceiling tocdots mul lmarg add + tocdots x { + y moveto (.) 0 linkshow + } for + x y moveto s 0 linkshow + end + linkend +} def + +/toc00 { tocx0 exch moveto 0 rmoveto bfont showstream } def +/toc01 { tocx0 exch moveto + linkbegindest bfont0 setfont 0 linkshow bfont showstream } def +/toc02 { tocx0 exch moveto 3 1 roll + 0 rmoveto bfont showstream tocpn } def +/toc03 { tocx0 exch moveto 4 1 roll + linkbegindest bfont0 setfont 0 linkshow bfont showstream tocpn } def + +/toc10 { tocx1 exch moveto 0 rmoveto bfont showstream } def +/toc11 { tocx1 exch moveto + linkbegindest bfont0 setfont 0 linkshow bfont showstream } def +/toc12 { tocx1 exch moveto 3 1 roll + 0 rmoveto bfont showstream tocpn } def +/toc13 { tocx1 exch moveto 4 1 roll + linkbegindest bfont0 setfont 0 linkshow bfont showstream tocpn } def + +/toc20 { tocx2 exch moveto 0 rmoveto bfont showstream } def +/toc21 { tocx2 exch moveto + linkbegindest bfont0 setfont 0 linkshow bfont showstream } def +/toc22 { tocx2 exch moveto 3 1 roll + 0 rmoveto bfont showstream tocpn } def +/toc23 { tocx2 exch moveto 4 1 roll + linkbegindest bfont0 setfont 0 linkshow bfont showstream tocpn } def + +% Spacing between index columns +/indexcolumn pagewidth lmarg sub rmarg sub idxgutter add idxcolumns div def +% Width of an individual index column +/indexcolwid indexcolumn idxgutter sub def + +/idx03 { + 2 dict begin + indexcolumn mul lmarg add + /x exch def /y exch def x y moveto + exch bfont showstream + dup bfont streamwidth + x indexcolwid add exch sub exch pop y moveto + bfont showstream + end +} def +/idx00 {idx03} def +/idx01 {idx03} def +/idx02 {idx03} def + +/idx13 { + 2 dict begin + indexcolumn mul lmarg add idxindent add + /x exch def /y exch def x y moveto + exch bfont showstream + dup bfont streamwidth + x indexcolwid idxindent sub add exch sub exch pop y moveto + bfont showstream + end +} def +/idx10 {idx13} def +/idx11 {idx13} def +/idx12 {idx13} def + +% +% Page numbers +% +/pagey botmarg pymarg sub def +/pagel lmarg plmarg sub def +/pager pagewidth rmarg sub prmarg add def + +/pageeven { pagel pagey moveto bfont1 setfont show } def +/pageodd { bfont1 setfont dup stringwidth pop pager exch sub + pagey moveto show } def + +% +% Functions invoked during parsing +% +/xa { linkdest } def +/pa { 0 pageheight moveto linkdest } def +/xl { linkbegindest } def +/wl { linkbeginuri } def +/pl { linkbeginpage } def +/el { linkend } def + +% +% PDF viewer options +% +[/PageMode /UseOutlines /DOCVIEW pdfmark % Display bookmarks + +% +% Functions to include EPS +% +/BeginEPSF { + /Before_EPSF_State save def + /dict_count countdictstack def + /op_count count 1 sub def + userdict begin + /showpage {} def + 0 setgray 0 setlinecap + 1 setlinewidth 0 setlinejoin + 10 setmiterlimit [ ] 0 setdash newpath + /languagelevel where + { + pop languagelevel + 1 ne { + false setstrokeadjust false setoverprint + } if + } if +} bind def +/EndEPSF { + count op_count sub {pop} repeat + countdictstack dict_count sub {end} repeat + Before_EPSF_State restore +} bind def diff --git a/doc/inslist.pl b/doc/inslist.pl new file mode 100644 index 0000000..509de00 --- /dev/null +++ b/doc/inslist.pl @@ -0,0 +1,98 @@ +#!/usr/bin/perl +## -------------------------------------------------------------------------- +## +## Copyright 1996-2009 The NASM Authors - All Rights Reserved +## See the file AUTHORS included with the NASM distribution for +## the specific copyright holders. +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following +## conditions are met: +## +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above +## copyright notice, this list of conditions and the following +## disclaimer in the documentation and/or other materials provided +## with the distribution. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +## CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## -------------------------------------------------------------------------- + +# +# inslist.pl produce inslist.src +# + +# Opcode prefixes which need their own opcode tables +# LONGER PREFIXES FIRST! +@disasm_prefixes = qw(0F24 0F25 0F38 0F3A 0F7A 0FA6 0FA7 0F); + +print STDERR "Reading insns.dat...\n"; + +@args = (); +undef $output; +foreach $arg ( @ARGV ) { + if ( $arg =~ /^\-/ ) { + if ( $arg =~ /^\-([adins])$/ ) { + $output = $1; + } else { + die "$0: Unknown option: ${arg}\n"; + } + } else { + push (@args, $arg); + } +} + +$fname = "../insns.dat" unless $fname = $args[0]; +open (F, $fname) || die "unable to open $fname"; +print STDERR "Writing inslist.src...\n"; +open S, ">inslist.src"; +$line = 0; +$insns = 0; +while (<F>) { + $line++; + next if (/^\s*$/); # blank lines + if ( /^\s*;/ ) # comments + { + if ( /^\s*;\#\s*(.+)/ ) # section subheader + { + print S "\n\\S{} $1\n\n"; + } + next; + } + chomp; + unless (/^\s*(\S+)\s+(\S+)\s+(\S+|\[.*\])\s+(\S+)\s*$/) { + warn "line $line does not contain four fields\n"; + next; + } + my @entry = ($1, $2, $3, $4); + + $entry[1] =~ s/ignore//; + $entry[1] =~ s/void//; + $entry[3] =~ s/ignore//; + $entry[3] =~ s/,SB//; + $entry[3] =~ s/,SM//; + $entry[3] =~ s/,SM2//; + $entry[3] =~ s/,SQ//; + $entry[3] =~ s/,AR2//; + printf S "\\c %-16s %-24s %s\n",$entry[0],$entry[1],$entry[3]; + $insns++; +} +print S "\n"; +close S; +close F; +printf STDERR "Done: %d instructions\n", $insns; + diff --git a/doc/internal.doc b/doc/internal.doc new file mode 100644 index 0000000..88f06bc --- /dev/null +++ b/doc/internal.doc @@ -0,0 +1,290 @@ +Internals of the Netwide Assembler +================================== + +The Netwide Assembler is intended to be a modular, re-usable x86 +assembler, which can be embedded in other programs, for example as +the back end to a compiler. + +The assembler is composed of modules. The interfaces between them +look like: + + +--- preproc.c ----+ + | | + +---- parser.c ----+ + | | | + | float.c | + | | + +--- assemble.c ---+ + | | | + nasm.c ---+ insnsa.c +--- nasmlib.c + | | + +--- listing.c ----+ + | | + +---- labels.c ----+ + | | + +--- outform.c ----+ + | | + +----- *out.c -----+ + +In other words, each of `preproc.c', `parser.c', `assemble.c', +`labels.c', `listing.c', `outform.c' and each of the output format +modules `*out.c' are independent modules, which do not directly +inter-communicate except through the main program. + +The Netwide *Disassembler* is not intended to be particularly +portable or reusable or anything, however. So I won't bother +documenting it here. :-) + +nasmlib.c +--------- + +This is a library module; it contains simple library routines which +may be referenced by all other modules. Among these are a set of +wrappers around the standard `malloc' routines, which will report a +fatal error if they run out of memory, rather than returning NULL. + +preproc.c +--------- + +This contains a macro preprocessor, which takes a file name as input +and returns a sequence of preprocessed source lines. The only symbol +exported from the module is `nasmpp', which is a data structure of +type `Preproc', declared in nasm.h. This structure contains pointers +to all the functions designed to be callable from outside the +module. + +parser.c +-------- + +This contains a source-line parser. It parses `canonical' assembly +source lines, containing some combination of the `label', `opcode', +`operand' and `comment' fields: it does not process directives or +macros. It exports two functions: `parse_line' and `cleanup_insn'. + +`parse_line' is the main parser function: you pass it a source line +in ASCII text form, and it returns you an `insn' structure +containing all the details of the instruction on that line. The +parameters it requires are: + +- The location (segment, offset) where the instruction on this line + will eventually be placed. This is necessary in order to evaluate + expressions containing the Here token, `$'. + +- A function which can be called to retrieve the value of any + symbols the source line references. + +- Which pass the assembler is on: an undefined symbol only causes an + error condition on pass two. + +- The source line to be parsed. + +- A structure to fill with the results of the parse. + +- A function which can be called to report errors. + +Some instructions (DB, DW, DD for example) can require an arbitrary +amount of storage, and so some of the members of the resulting +`insn' structure will be dynamically allocated. The other function +exported by `parser.c' is `cleanup_insn', which can be called to +deallocate any dynamic storage associated with the results of a +parse. + +names.c +------- + +This doesn't count as a module - it defines a few arrays which are +shared between NASM and NDISASM, so it's a separate file which is +#included by both parser.c and disasm.c. + +float.c +------- + +This is essentially a library module: it exports one function, +`float_const', which converts an ASCII representation of a +floating-point number into an x86-compatible binary representation, +without using any built-in floating-point arithmetic (so it will run +on any platform, portably). It calls nothing, and is called only by +`parser.c'. Note that the function `float_const' must be passed an +error reporting routine. + +assemble.c +---------- + +This module contains the code generator: it translates `insn' +structures as returned from the parser module into actual generated +code which can be placed in an output file. It exports two +functions, `assemble' and `insn_size'. + +`insn_size' is designed to be called on pass one of assembly: it +takes an `insn' structure as input, and returns the amount of space +that would be taken up if the instruction described in the structure +were to be converted to real machine code. `insn_size' also requires +to be told the location (as a segment/offset pair) where the +instruction would be assembled, the mode of assembly (16/32 bit +default), and a function it can call to report errors. + +`assemble' is designed to be called on pass two: it takes all the +parameters that `insn_size' does, but has an extra parameter which +is an output driver. `assemble' actually converts the input +instruction into machine code, and outputs the machine code by means +of calling the `output' function of the driver. + +insnsa.c +-------- + +This is another library module: it exports one very big array of +instruction translations. It is generated automatically from the +insns.dat file by the insns.pl script. + +labels.c +-------- + +This module contains a label manager. It exports six functions: + +`init_labels' should be called before any other function in the +module. `cleanup_labels' may be called after all other use of the +module has finished, to deallocate storage. + +`define_label' is called to define new labels: you pass it the name +of the label to be defined, and the (segment,offset) pair giving the +value of the label. It is also passed an error-reporting function, +and an output driver structure (so that it can call the output +driver's label-definition function). `define_label' mentally +prepends the name of the most recently defined non-local label to +any label beginning with a period. + +`define_label_stub' is designed to be called in pass two, once all +the labels have already been defined: it does nothing except to +update the "most-recently-defined-non-local-label" status, so that +references to local labels in pass two will work correctly. + +`declare_as_global' is used to declare that a label should be +global. It must be called _before_ the label in question is defined. + +Finally, `lookup_label' attempts to translate a label name into a +(segment,offset) pair. It returns non-zero on success. + +The label manager module is (theoretically :) restartable: after +calling `cleanup_labels', you can call `init_labels' again, and +start a new assembly with a new set of symbols. + +listing.c +--------- + +This file contains the listing file generator. The interface to the +module is through the one symbol it exports, `nasmlist', which is a +structure containing six function pointers. The calling semantics of +these functions isn't terribly well thought out, as yet, but it +works (just about) so it's going to get left alone for now... + +outform.c +--------- + +This small module contains a set of routines to manage a list of +output formats, and select one given a keyword. It contains three +small routines: `ofmt_register' which registers an output driver as +part of the managed list, `ofmt_list' which lists the available +drivers on stdout, and `ofmt_find' which tries to find the driver +corresponding to a given name. + +The output modules +------------------ + +Each of the output modules, `outbin.o', `outelf.o' and so on, +exports only one symbol, which is an output driver data structure +containing pointers to all the functions needed to produce output +files of the appropriate type. + +The exception to this is `outcoff.o', which exports _two_ output +driver structures, since COFF and Win32 object file formats are very +similar and most of the code is shared between them. + +nasm.c +------ + +This is the main program: it calls all the functions in the above +modules, and puts them together to form a working assembler. We +hope. :-) + +Segment Mechanism +----------------- + +In NASM, the term `segment' is used to separate the different +sections/segments/groups of which an object file is composed. +Essentially, every address NASM is capable of understanding is +expressed as an offset from the beginning of some segment. + +The defining property of a segment is that if two symbols are +declared in the same segment, then the distance between them is +fixed at assembly time. Hence every externally-declared variable +must be declared in its own segment, since none of the locations of +these are known, and so no distances may be computed at assembly +time. + +The special segment value NO_SEG (-1) is used to denote an absolute +value, e.g. a constant whose value does not depend on relocation, +such as the _size_ of a data object. + +Apart from NO_SEG, segment indices all have their least significant +bit clear, if they refer to actual in-memory segments. For each +segment of this type, there is an auxiliary segment value, defined +to be the same number but with the LSB set, which denotes the +segment-base value of that segment, for object formats which support +it (Microsoft .OBJ, for example). + +Hence, if `textsym' is declared in a code segment with index 2, then +referencing `SEG textsym' would return zero offset from +segment-index 3. Or, in object formats which don't understand such +references, it would return an error instead. + +The next twist is SEG_ABS. Some symbols may be declared with a +segment value of SEG_ABS plus a 16-bit constant: this indicates that +they are far-absolute symbols, such as the BIOS keyboard buffer +under MS-DOS, which always resides at 0040h:001Eh. Far-absolutes are +handled with care in the parser, since they are supposed to evaluate +simply to their offset part within expressions, but applying SEG to +one should yield its segment part. A far-absolute should never find +its way _out_ of the parser, unless it is enclosed in a WRT clause, +in which case Microsoft 16-bit object formats will want to know +about it. + +Porting Issues +-------------- + +We have tried to write NASM in portable ANSI C: we do not assume +little-endianness or any hardware characteristics (in order that +NASM should work as a cross-assembler for x86 platforms, even when +run on other, stranger machines). + +Assumptions we _have_ made are: + +- We assume that `short' is at least 16 bits, and `long' at least + 32. This really _shouldn't_ be a problem, since Kernighan and + Ritchie tell us we are entitled to do so. + +- We rely on having more than 6 characters of significance on + externally linked symbols in the NASM sources. This may get fixed + at some point. We haven't yet come across a linker brain-dead + enough to get it wrong anyway. + +- We assume that `fopen' using the mode "wb" can be used to write + binary data files. This may be wrong on systems like VMS, with a + strange file system. Though why you'd want to run NASM on VMS is + beyond me anyway. + +That's it. Subject to those caveats, NASM should be completely +portable. If not, we _really_ want to know about it. + +Porting Non-Issues +------------------ + +The following is _not_ a portability problem, although it looks like +one. + +- When compiling with some versions of DJGPP, you may get errors + such as `warning: ANSI C forbids braced-groups within + expressions'. This isn't NASM's fault - the problem seems to be + that DJGPP's definitions of the <ctype.h> macros include a + GNU-specific C extension. So when compiling using -ansi and + -pedantic, DJGPP complains about its own header files. It isn't a + problem anyway, since it still generates correct code. diff --git a/doc/makedocs.bat b/doc/makedocs.bat new file mode 100644 index 0000000..5372394 --- /dev/null +++ b/doc/makedocs.bat @@ -0,0 +1,255 @@ +@echo off +if "%1"=="clean" goto makeclean +if "%1"=="CLEAN" goto makeclean +if "%1"=="spotless" goto spotless +if "%1"=="SPOTLESS" goto spotless +if "%1"=="install" goto install +if "%1"=="INSTALL" goto install + +cls +echo. +echo. +echo. +echo Usage: +echo. +echo makedocs - no parameters - makes all Docs +echo makedocs install - installs already made docs in subdirectories +echo makedocs clean - removes docs from current directory +echo makedocs spotless - removes all - including default install dirs +echo. +echo. +echo. +echo. +echo Makedocs(.bat), with no parameters will create Nasm Documentation +echo in several formats: plain ascii text, ps, html, rtf, Windows help +echo format, and if you've got an "info" system installed, info format. +echo. +echo. +echo This requires Perl, and almost 4MB disk space. +echo. +echo. +choice " Proceed with making docs? " +if errorlevel 2 goto exit + +:makeall + +echo. +echo. +echo This takes a while. Stretch! +echo. +echo. + +perl inslist.pl +perl rdsrc.pl<nasmdoc.src +echo. +echo. +choice " Make *info* files? " +if errorlevel 2 goto noinfo +:makeinfo +echo. +echo. +makeinfo nasmdoc.tex + +:noinfo + +:install + +if not exist nasmdoc.txt goto nofiles +if not exist nasmdoc0.htm goto nofiles +if not exist nasmdo10.htm goto nofiles +if not exist nasmdoc.hpj goto nofiles +if not exist nasmdoc.rtf goto nofiles +if not exist nasmdoc.ps goto nofiles +if not exist nasmdoc.tex goto nofiles +goto gotfiles +:nofiles +echo. +echo. +echo. +echo. +echo Alert! Files missing! +echo. +echo. +choice " Would you like to make them now? " +if errorlevel 2 goto exit +goto makeall + +:gotfiles + +:: get current path + +set oldprompt=%prompt% +echo @prompt set nasdoc=$p>temp1.bat +command /c temp1.bat>temp2.bat +call temp2 +del temp1.bat +del temp2.bat +set prompt=%oldprompt% +set oldprompt= + +echo. +echo. +echo. +echo. +echo Current Directory is %nasdoc% +echo Nasm Documentation will be installed under this +echo as %nasdoc%\text\nasmdoc.txt, etc. +echo. +echo. +choice " Change this directory? " +if errorlevel 2 goto dirok + +echo. +echo. +echo. +echo. +echo Directory *above* the directory you name (at least) should exist. +echo Nasm documentation will be installed *under* the directory you +echo name. E.G. \docs\nasm\html, etc. No trailing backslash! +echo. +echo. + +echo Enter new name for base directory: +set input= +fc con nul /lb1 /n|date|find "1:">magic.bat +echo set input=%%5>enter.bat +call magic +set nasdoc=%input% +del magic.bat +del enter.bat +set input= + +echo. +echo. +md %nasdoc% +echo. +echo. + +choice " Install Text docs in %nasdoc%\text ? " +if errorlevel 2 goto notext +md %nasdoc%\text +copy nasmdoc.txt %nasdoc%\text +:notext + +choice " Install Html docs in %nasdoc%\html ? " +if errorlevel 2 goto nohtml +md %nasdoc%\html +copy *.htm %nasdoc%\html +:nohtml + +choice " Install Info docs in %nasdoc%\info ? " +if errorlevel 2 goto noinfodocs +if not exist nasm.inf goto inofiles +if not exist nasm.i9 goto inofiles +goto gotifiles +:inofiles +echo. +echo. +echo Alert! Files missing! +echo. +echo. +choice " Would you like to make them now? " +if errorlevel 2 goto noinfodocs +if not exist nasmdoc.tex goto makeall +goto makeinfo + +:gotifiles + +md %nasdoc%\info +copy nasm.i* %nasdoc%\info +:noinfodocs + +choice " Install Winhelp docs in %nasdoc%\winhelp ? " +if errorlevel 2 goto nowinhelp +md %nasdoc%\winhelp +copy nasmdoc.rtf %nasdoc%\winhelp +copy nasmdoc.hpj %nasdoc%\winhelp +:nowinhelp + +choice " Install Postscript docs in %nasdoc%\ps ? " +if errorlevel 2 goto nops +md %nasdoc%\ps +copy nasmdoc.ps %nasdoc%\ps +:nops +goto cleanup + +:dirok + +choice " Install Text docs in .\text ? " +if errorlevel 2 goto notext2 +md text +copy nasmdoc.txt text +:notext2 + +choice " Install Html docs in .\html ? " +if errorlevel 2 goto nohtml2 +md html +copy *.htm html +:nohtml2 + +choice " Install Info docs in .\info ? " +if errorlevel 2 goto nid2 + +if not exist nasm.inf goto inof2 +if not exist nasm.i9 goto inof2 +goto gifiles2 +:inof2 +echo. +echo. +echo Alert! Files missing! +echo. +echo. +choice " Would you like to make them now? " +if errorlevel 2 goto nid2 +if not exist nasmdoc.tex goto makeall +goto makeinfo + +:gifiles2 + +md info +copy nasm.i* info +:nid2 + +choice " Install Winhelp docs in .\winhelp ? " +if errorlevel 2 goto nwhelp2 +md winhelp +copy nasmdoc.rtf winhelp +copy nasmdoc.hpj winhelp +:nwhelp2 + +choice " Install Postscript docs in .\ps ? " +if errorlevel 2 goto nops2 +md ps +copy nasmdoc.ps ps +:nops2 + + +:cleanup +set nasdoc= + +echo. +echo. +echo. +echo. +choice " Remove all files created, but not installed?" +if not errorlevel 2 goto makeclean + +goto exit + +:spotless +deltree /y text +deltree /y html +deltree /y info +deltree /y winhelp +deltree /y ps + +:makeclean +del *.htm +del *.rtf +del *.hpj +del *.txt +del *.tex +del *.ps +del nasm.i* + +:exit diff --git a/doc/metrics/pagd8a.ph b/doc/metrics/pagd8a.ph new file mode 100644 index 0000000..729ba29 --- /dev/null +++ b/doc/metrics/pagd8a.ph @@ -0,0 +1,72 @@ +%PS_AvantGarde_Demi = ( + name => 'AvantGarde-Demi', + widths => { + "multiply" => 600, "Ntilde" => 740, "zero" => 560, "eth" => 640, + "Ograve" => 840, "uacute" => 600, "braceleft" => 340, + "Thorn" => 560, "zcaron" => 460, "comma" => 280, "cedilla" => 340, + "plusminus" => 600, "ccedilla" => 640, "circumflex" => 540, + "dotaccent" => 280, "asciitilde" => 600, "colon" => 280, + "onehalf" => 840, "dollar" => 560, "ntilde" => 600, + "Ocircumflex" => 840, "Oacute" => 840, "ogonek" => 340, + "ograve" => 640, "thorn" => 660, "minus" => 600, "degree" => 400, + "yen" => 560, "space" => 280, "registered" => 740, + "questiondown" => 560, "Aring" => 740, "percent" => 860, + "emdash" => 1000, "six" => 560, "Agrave" => 740, + "paragraph" => 600, "three" => 560, "numbersign" => 560, + "two" => 560, "Igrave" => 280, "oacute" => 640, + "ocircumflex" => 640, "A" => 740, "B" => 580, "C" => 780, + "D" => 700, "E" => 520, "onequarter" => 840, "F" => 480, + "G" => 840, "H" => 680, "I" => 280, "J" => 480, "K" => 620, + "L" => 440, "backslash" => 640, "asciicircum" => 600, + "periodcentered" => 280, "M" => 900, "N" => 740, "O" => 840, + "P" => 560, "aring" => 660, "Q" => 840, "R" => 580, + "Aacute" => 740, "caron" => 540, "S" => 520, "T" => 420, + "grave" => 420, "U" => 640, "agrave" => 660, "V" => 700, + "W" => 900, "equal" => 600, "question" => 560, "X" => 680, + "Y" => 620, "Z" => 500, "bracketright" => 320, "Iacute" => 280, + "ampersand" => 680, "four" => 560, "igrave" => 240, "a" => 660, + "b" => 660, "c" => 640, "d" => 660, "plus" => 600, "e" => 640, + "quotesinglbase" => 280, "f" => 280, "g" => 660, "bullet" => 600, + "h" => 600, "i" => 240, "Oslash" => 840, "dagger" => 560, + "j" => 260, "Yacute" => 620, "k" => 580, "l" => 240, "m" => 940, + "n" => 600, "o" => 640, "ordfeminine" => 360, "ring" => 360, + "p" => 660, "threesuperior" => 336, "q" => 660, "acute" => 420, + "r" => 320, "twosuperior" => 336, "aacute" => 660, "s" => 440, + "OE" => 1060, "t" => 300, "divide" => 600, "section" => 560, + "u" => 600, "v" => 560, "w" => 800, "dieresis" => 500, "x" => 560, + "y" => 580, "z" => 460, "iacute" => 240, "quotedblbase" => 480, + "hungarumlaut" => 700, "quotedbl" => 360, "mu" => 576, + "Scaron" => 520, "Lslash" => 480, "semicolon" => 280, + "oslash" => 660, "florin" => 560, "yacute" => 580, "fi" => 520, + "fl" => 520, "Acircumflex" => 740, "parenright" => 380, + "Ecircumflex" => 520, "trademark" => 1000, "Icircumflex" => 280, + "daggerdbl" => 560, "guillemotleft" => 460, "germandbls" => 600, + "macron" => 420, "Otilde" => 840, "seven" => 560, + "ellipsis" => 1000, "scaron" => 440, "ordmasculine" => 360, + "AE" => 900, "Ucircumflex" => 640, "lslash" => 320, + "dotlessi" => 240, "sterling" => 560, "quotedblleft" => 480, + "hyphen" => 420, "guilsinglright" => 240, "quotesingle" => 220, + "eight" => 560, "exclamdown" => 280, "acircumflex" => 660, + "endash" => 500, "oe" => 1080, "ecircumflex" => 640, + "copyright" => 740, "Adieresis" => 740, "Egrave" => 520, + "icircumflex" => 240, "slash" => 460, "braceright" => 340, + "Edieresis" => 520, "quotedblright" => 480, "otilde" => 640, + "Idieresis" => 280, "parenleft" => 380, "one" => 560, + "Odieresis" => 840, "ucircumflex" => 600, "bracketleft" => 320, + "Ugrave" => 640, "cent" => 560, "currency" => 560, + "logicalnot" => 600, "quoteright" => 280, "Udieresis" => 640, + "perthousand" => 1280, "Ydieresis" => 620, "Atilde" => 740, + "breve" => 480, "bar" => 600, "fraction" => 160, "Eacute" => 520, + "less" => 600, "adieresis" => 660, "guilsinglleft" => 240, + "egrave" => 640, "exclam" => 280, "edieresis" => 640, "Eth" => 742, + "idieresis" => 240, "period" => 280, "ae" => 1080, + "asterisk" => 440, "odieresis" => 640, "Uacute" => 640, + "ugrave" => 600, "five" => 560, "nine" => 560, "greater" => 600, + "Zcaron" => 500, "udieresis" => 600, "threequarters" => 840, + "guillemotright" => 460, "Ccedilla" => 780, "ydieresis" => 580, + "tilde" => 480, "atilde" => 660, "at" => 740, "brokenbar" => 600, + "eacute" => 640, "quoteleft" => 280, "underscore" => 500, + "onesuperior" => 336, + } +); +1; diff --git a/doc/metrics/pagdo8a.ph b/doc/metrics/pagdo8a.ph new file mode 100644 index 0000000..727ea00 --- /dev/null +++ b/doc/metrics/pagdo8a.ph @@ -0,0 +1,72 @@ +%PS_AvantGarde_DemiOblique = ( + name => 'AvantGarde-DemiOblique', + widths => { + "multiply" => 600, "Ntilde" => 740, "zero" => 560, "eth" => 640, + "Ograve" => 840, "uacute" => 600, "braceleft" => 340, + "Thorn" => 560, "zcaron" => 460, "comma" => 280, "cedilla" => 340, + "plusminus" => 600, "ccedilla" => 640, "circumflex" => 540, + "dotaccent" => 280, "asciitilde" => 600, "colon" => 280, + "onehalf" => 840, "dollar" => 560, "ntilde" => 600, + "Ocircumflex" => 840, "Oacute" => 840, "ogonek" => 340, + "ograve" => 640, "thorn" => 660, "minus" => 600, "degree" => 400, + "yen" => 560, "space" => 280, "registered" => 740, + "questiondown" => 560, "Aring" => 740, "percent" => 860, + "emdash" => 1000, "six" => 560, "Agrave" => 740, + "paragraph" => 600, "three" => 560, "numbersign" => 560, + "two" => 560, "Igrave" => 280, "oacute" => 640, + "ocircumflex" => 640, "A" => 740, "B" => 580, "C" => 780, + "D" => 700, "E" => 520, "onequarter" => 840, "F" => 480, + "G" => 840, "H" => 680, "I" => 280, "J" => 480, "K" => 620, + "L" => 440, "backslash" => 640, "asciicircum" => 600, + "periodcentered" => 280, "M" => 900, "N" => 740, "O" => 840, + "P" => 560, "aring" => 660, "Q" => 840, "R" => 580, + "Aacute" => 740, "caron" => 540, "S" => 520, "T" => 420, + "grave" => 420, "U" => 640, "agrave" => 660, "V" => 700, + "W" => 900, "equal" => 600, "question" => 560, "X" => 680, + "Y" => 620, "Z" => 500, "bracketright" => 320, "Iacute" => 280, + "ampersand" => 680, "four" => 560, "igrave" => 240, "a" => 660, + "b" => 660, "c" => 640, "d" => 660, "plus" => 600, "e" => 640, + "quotesinglbase" => 280, "f" => 280, "g" => 660, "bullet" => 600, + "h" => 600, "i" => 240, "Oslash" => 840, "dagger" => 560, + "j" => 260, "Yacute" => 620, "k" => 580, "l" => 240, "m" => 940, + "n" => 600, "o" => 640, "ordfeminine" => 360, "ring" => 360, + "p" => 660, "threesuperior" => 336, "q" => 660, "acute" => 420, + "r" => 320, "twosuperior" => 336, "aacute" => 660, "s" => 440, + "OE" => 1060, "t" => 300, "divide" => 600, "section" => 560, + "u" => 600, "v" => 560, "w" => 800, "dieresis" => 500, "x" => 560, + "y" => 580, "z" => 460, "iacute" => 240, "quotedblbase" => 480, + "hungarumlaut" => 700, "quotedbl" => 360, "mu" => 576, + "Scaron" => 520, "Lslash" => 480, "semicolon" => 280, + "oslash" => 660, "florin" => 560, "yacute" => 580, "fi" => 520, + "fl" => 520, "Acircumflex" => 740, "parenright" => 380, + "Ecircumflex" => 520, "trademark" => 1000, "Icircumflex" => 280, + "daggerdbl" => 560, "guillemotleft" => 460, "germandbls" => 600, + "macron" => 420, "Otilde" => 840, "seven" => 560, + "ellipsis" => 1000, "scaron" => 440, "ordmasculine" => 360, + "AE" => 900, "Ucircumflex" => 640, "lslash" => 320, + "dotlessi" => 240, "sterling" => 560, "quotedblleft" => 480, + "hyphen" => 420, "guilsinglright" => 240, "quotesingle" => 220, + "eight" => 560, "exclamdown" => 280, "acircumflex" => 660, + "endash" => 500, "oe" => 1080, "ecircumflex" => 640, + "copyright" => 740, "Adieresis" => 740, "Egrave" => 520, + "icircumflex" => 240, "slash" => 460, "braceright" => 340, + "Edieresis" => 520, "quotedblright" => 480, "otilde" => 640, + "Idieresis" => 280, "parenleft" => 380, "one" => 560, + "Odieresis" => 840, "ucircumflex" => 600, "bracketleft" => 320, + "Ugrave" => 640, "cent" => 560, "currency" => 560, + "logicalnot" => 600, "quoteright" => 280, "Udieresis" => 640, + "perthousand" => 1280, "Ydieresis" => 620, "Atilde" => 740, + "breve" => 480, "bar" => 600, "fraction" => 160, "Eacute" => 520, + "less" => 600, "adieresis" => 660, "guilsinglleft" => 240, + "egrave" => 640, "exclam" => 280, "edieresis" => 640, "Eth" => 742, + "idieresis" => 240, "period" => 280, "ae" => 1080, + "asterisk" => 440, "odieresis" => 640, "Uacute" => 640, + "ugrave" => 600, "five" => 560, "nine" => 560, "greater" => 600, + "Zcaron" => 500, "udieresis" => 600, "threequarters" => 840, + "guillemotright" => 460, "Ccedilla" => 780, "ydieresis" => 580, + "tilde" => 480, "atilde" => 660, "at" => 740, "brokenbar" => 600, + "eacute" => 640, "quoteleft" => 280, "underscore" => 500, + "onesuperior" => 336, + } +); +1; diff --git a/doc/metrics/pagk8a.ph b/doc/metrics/pagk8a.ph new file mode 100644 index 0000000..df90997 --- /dev/null +++ b/doc/metrics/pagk8a.ph @@ -0,0 +1,72 @@ +%PS_AvantGarde_Book = ( + name => 'AvantGarde-Book', + widths => { + "multiply" => 606, "Ntilde" => 740, "zero" => 554, "eth" => 655, + "Ograve" => 869, "uacute" => 608, "braceleft" => 351, + "Thorn" => 592, "zcaron" => 425, "comma" => 277, "cedilla" => 324, + "plusminus" => 606, "ccedilla" => 647, "circumflex" => 502, + "dotaccent" => 222, "asciitilde" => 606, "colon" => 277, + "onehalf" => 831, "dollar" => 554, "ntilde" => 610, + "Ocircumflex" => 869, "Oacute" => 869, "ogonek" => 302, + "ograve" => 655, "thorn" => 682, "minus" => 606, "degree" => 400, + "yen" => 554, "space" => 277, "registered" => 747, + "questiondown" => 591, "Aring" => 740, "percent" => 775, + "emdash" => 1000, "six" => 554, "Agrave" => 740, + "paragraph" => 564, "three" => 554, "numbersign" => 554, + "two" => 554, "Igrave" => 226, "oacute" => 655, + "ocircumflex" => 655, "A" => 740, "B" => 574, "C" => 813, + "D" => 744, "E" => 536, "onequarter" => 831, "F" => 485, + "G" => 872, "H" => 683, "I" => 226, "J" => 482, "K" => 591, + "L" => 462, "backslash" => 605, "asciicircum" => 606, + "periodcentered" => 277, "M" => 919, "N" => 740, "O" => 869, + "P" => 592, "aring" => 683, "Q" => 871, "R" => 607, + "Aacute" => 740, "caron" => 502, "S" => 498, "T" => 426, + "grave" => 378, "U" => 655, "agrave" => 683, "V" => 702, + "W" => 960, "equal" => 606, "question" => 591, "X" => 609, + "Y" => 592, "Z" => 480, "bracketright" => 351, "Iacute" => 226, + "ampersand" => 757, "four" => 554, "igrave" => 200, "a" => 683, + "b" => 682, "c" => 647, "d" => 685, "plus" => 606, "e" => 650, + "quotesinglbase" => 354, "f" => 314, "g" => 673, "bullet" => 606, + "h" => 610, "i" => 200, "Oslash" => 868, "dagger" => 553, + "j" => 203, "Yacute" => 592, "k" => 502, "l" => 200, "m" => 938, + "n" => 610, "o" => 655, "ordfeminine" => 369, "ring" => 332, + "p" => 682, "threesuperior" => 332, "q" => 682, "acute" => 375, + "r" => 301, "twosuperior" => 332, "aacute" => 683, "s" => 388, + "OE" => 1194, "t" => 339, "divide" => 606, "section" => 615, + "u" => 608, "v" => 554, "w" => 831, "dieresis" => 369, "x" => 480, + "y" => 536, "z" => 425, "iacute" => 200, "quotedblbase" => 502, + "hungarumlaut" => 552, "quotedbl" => 309, "mu" => 608, + "Scaron" => 498, "Lslash" => 517, "semicolon" => 277, + "oslash" => 653, "florin" => 554, "yacute" => 536, "fi" => 487, + "fl" => 485, "Acircumflex" => 740, "parenright" => 369, + "Ecircumflex" => 536, "trademark" => 1000, "Icircumflex" => 226, + "daggerdbl" => 553, "guillemotleft" => 425, "germandbls" => 554, + "macron" => 485, "Otilde" => 869, "seven" => 554, + "ellipsis" => 1000, "scaron" => 388, "ordmasculine" => 369, + "AE" => 992, "Ucircumflex" => 655, "lslash" => 300, + "dotlessi" => 200, "sterling" => 554, "quotedblleft" => 502, + "hyphen" => 332, "guilsinglright" => 251, "quotesingle" => 198, + "eight" => 554, "exclamdown" => 295, "acircumflex" => 683, + "endash" => 500, "oe" => 1137, "ecircumflex" => 650, + "copyright" => 747, "Adieresis" => 740, "Egrave" => 536, + "icircumflex" => 200, "slash" => 437, "braceright" => 351, + "Edieresis" => 536, "quotedblright" => 484, "otilde" => 655, + "Idieresis" => 226, "parenleft" => 369, "one" => 554, + "Odieresis" => 869, "ucircumflex" => 608, "bracketleft" => 351, + "Ugrave" => 655, "cent" => 554, "currency" => 554, + "logicalnot" => 606, "quoteright" => 351, "Udieresis" => 655, + "perthousand" => 1174, "Ydieresis" => 592, "Atilde" => 740, + "breve" => 453, "bar" => 672, "fraction" => 166, "Eacute" => 536, + "less" => 606, "adieresis" => 683, "guilsinglleft" => 251, + "egrave" => 650, "exclam" => 295, "edieresis" => 650, "Eth" => 790, + "idieresis" => 200, "period" => 277, "ae" => 1157, + "asterisk" => 425, "odieresis" => 655, "Uacute" => 655, + "ugrave" => 608, "five" => 554, "nine" => 554, "greater" => 606, + "Zcaron" => 480, "udieresis" => 608, "threequarters" => 831, + "guillemotright" => 425, "Ccedilla" => 813, "ydieresis" => 536, + "tilde" => 439, "atilde" => 683, "at" => 867, "brokenbar" => 672, + "eacute" => 650, "quoteleft" => 351, "underscore" => 500, + "onesuperior" => 332, + } +); +1; diff --git a/doc/metrics/pagko8a.ph b/doc/metrics/pagko8a.ph new file mode 100644 index 0000000..0e9ae31 --- /dev/null +++ b/doc/metrics/pagko8a.ph @@ -0,0 +1,72 @@ +%PS_AvantGarde_BookOblique = ( + name => 'AvantGarde-BookOblique', + widths => { + "multiply" => 606, "Ntilde" => 740, "zero" => 554, "eth" => 655, + "Ograve" => 869, "uacute" => 608, "braceleft" => 351, + "Thorn" => 592, "zcaron" => 425, "comma" => 277, "cedilla" => 324, + "plusminus" => 606, "ccedilla" => 647, "circumflex" => 502, + "dotaccent" => 222, "asciitilde" => 606, "colon" => 277, + "onehalf" => 831, "dollar" => 554, "ntilde" => 610, + "Ocircumflex" => 869, "Oacute" => 869, "ogonek" => 302, + "ograve" => 655, "thorn" => 682, "minus" => 606, "degree" => 400, + "yen" => 554, "space" => 277, "registered" => 747, + "questiondown" => 591, "Aring" => 740, "percent" => 775, + "emdash" => 1000, "six" => 554, "Agrave" => 740, + "paragraph" => 564, "three" => 554, "numbersign" => 554, + "two" => 554, "Igrave" => 226, "oacute" => 655, + "ocircumflex" => 655, "A" => 740, "B" => 574, "C" => 813, + "D" => 744, "E" => 536, "onequarter" => 831, "F" => 485, + "G" => 872, "H" => 683, "I" => 226, "J" => 482, "K" => 591, + "L" => 462, "backslash" => 605, "asciicircum" => 606, + "periodcentered" => 277, "M" => 919, "N" => 740, "O" => 869, + "P" => 592, "aring" => 683, "Q" => 871, "R" => 607, + "Aacute" => 740, "caron" => 502, "S" => 498, "T" => 426, + "grave" => 378, "U" => 655, "agrave" => 683, "V" => 702, + "W" => 960, "equal" => 606, "question" => 591, "X" => 609, + "Y" => 592, "Z" => 480, "bracketright" => 351, "Iacute" => 226, + "ampersand" => 757, "four" => 554, "igrave" => 200, "a" => 683, + "b" => 682, "c" => 647, "d" => 685, "plus" => 606, "e" => 650, + "quotesinglbase" => 354, "f" => 314, "g" => 673, "bullet" => 606, + "h" => 610, "i" => 200, "Oslash" => 868, "dagger" => 553, + "j" => 203, "Yacute" => 592, "k" => 502, "l" => 200, "m" => 938, + "n" => 610, "o" => 655, "ordfeminine" => 369, "ring" => 332, + "p" => 682, "threesuperior" => 332, "q" => 682, "acute" => 375, + "r" => 301, "twosuperior" => 332, "aacute" => 683, "s" => 388, + "OE" => 1194, "t" => 339, "divide" => 606, "section" => 615, + "u" => 608, "v" => 554, "w" => 831, "dieresis" => 369, "x" => 480, + "y" => 536, "z" => 425, "iacute" => 200, "quotedblbase" => 502, + "hungarumlaut" => 552, "quotedbl" => 309, "mu" => 608, + "Scaron" => 498, "Lslash" => 517, "semicolon" => 277, + "oslash" => 653, "florin" => 554, "yacute" => 536, "fi" => 487, + "fl" => 485, "Acircumflex" => 740, "parenright" => 369, + "Ecircumflex" => 536, "trademark" => 1000, "Icircumflex" => 226, + "daggerdbl" => 553, "guillemotleft" => 425, "germandbls" => 554, + "macron" => 485, "Otilde" => 869, "seven" => 554, + "ellipsis" => 1000, "scaron" => 388, "ordmasculine" => 369, + "AE" => 992, "Ucircumflex" => 655, "lslash" => 300, + "dotlessi" => 200, "sterling" => 554, "quotedblleft" => 502, + "hyphen" => 332, "guilsinglright" => 251, "quotesingle" => 198, + "eight" => 554, "exclamdown" => 295, "acircumflex" => 683, + "endash" => 500, "oe" => 1137, "ecircumflex" => 650, + "copyright" => 747, "Adieresis" => 740, "Egrave" => 536, + "icircumflex" => 200, "slash" => 437, "braceright" => 351, + "Edieresis" => 536, "quotedblright" => 484, "otilde" => 655, + "Idieresis" => 226, "parenleft" => 369, "one" => 554, + "Odieresis" => 869, "ucircumflex" => 608, "bracketleft" => 351, + "Ugrave" => 655, "cent" => 554, "currency" => 554, + "logicalnot" => 606, "quoteright" => 351, "Udieresis" => 655, + "perthousand" => 1174, "Ydieresis" => 592, "Atilde" => 740, + "breve" => 453, "bar" => 672, "fraction" => 166, "Eacute" => 536, + "less" => 606, "adieresis" => 683, "guilsinglleft" => 251, + "egrave" => 650, "exclam" => 295, "edieresis" => 650, "Eth" => 790, + "idieresis" => 200, "period" => 277, "ae" => 1157, + "asterisk" => 425, "odieresis" => 655, "Uacute" => 655, + "ugrave" => 608, "five" => 554, "nine" => 554, "greater" => 606, + "Zcaron" => 480, "udieresis" => 608, "threequarters" => 831, + "guillemotright" => 425, "Ccedilla" => 813, "ydieresis" => 536, + "tilde" => 439, "atilde" => 683, "at" => 867, "brokenbar" => 672, + "eacute" => 650, "quoteleft" => 351, "underscore" => 500, + "onesuperior" => 332, + } +); +1; diff --git a/doc/metrics/pbkd8a.ph b/doc/metrics/pbkd8a.ph new file mode 100644 index 0000000..5d80089 --- /dev/null +++ b/doc/metrics/pbkd8a.ph @@ -0,0 +1,72 @@ +%PS_Bookman_Demi = ( + name => 'Bookman-Demi', + widths => { + "multiply" => 600, "Ntilde" => 740, "zero" => 660, "eth" => 620, + "Ograve" => 800, "uacute" => 660, "braceleft" => 320, + "Thorn" => 660, "zcaron" => 560, "comma" => 340, "cedilla" => 360, + "plusminus" => 600, "ccedilla" => 580, "circumflex" => 500, + "dotaccent" => 320, "asciitilde" => 600, "colon" => 340, + "onehalf" => 990, "dollar" => 660, "ntilde" => 680, + "Ocircumflex" => 800, "Oacute" => 800, "ogonek" => 320, + "ograve" => 620, "thorn" => 640, "minus" => 600, "degree" => 400, + "yen" => 660, "space" => 340, "registered" => 740, + "questiondown" => 660, "Aring" => 720, "percent" => 940, + "emdash" => 1000, "six" => 660, "Agrave" => 720, + "paragraph" => 800, "three" => 660, "numbersign" => 660, + "two" => 660, "Igrave" => 400, "oacute" => 620, + "ocircumflex" => 620, "A" => 720, "B" => 720, "C" => 740, + "D" => 780, "E" => 720, "onequarter" => 990, "F" => 680, + "G" => 780, "H" => 820, "I" => 400, "J" => 640, "K" => 800, + "L" => 640, "backslash" => 600, "asciicircum" => 600, + "periodcentered" => 340, "M" => 940, "N" => 740, "O" => 800, + "P" => 660, "aring" => 580, "Q" => 800, "R" => 780, + "Aacute" => 720, "caron" => 500, "S" => 660, "T" => 700, + "grave" => 400, "U" => 740, "agrave" => 580, "V" => 720, + "W" => 940, "equal" => 600, "question" => 660, "X" => 780, + "Y" => 700, "Z" => 640, "bracketright" => 300, "Iacute" => 400, + "ampersand" => 800, "four" => 660, "igrave" => 360, "a" => 580, + "b" => 600, "c" => 580, "d" => 640, "plus" => 600, "e" => 580, + "quotesinglbase" => 320, "f" => 380, "g" => 580, "bullet" => 460, + "h" => 680, "i" => 360, "Oslash" => 800, "dagger" => 440, + "j" => 340, "Yacute" => 700, "k" => 660, "l" => 340, "m" => 1000, + "n" => 680, "o" => 620, "ordfeminine" => 400, "ring" => 340, + "p" => 640, "threesuperior" => 396, "q" => 620, "acute" => 400, + "r" => 460, "twosuperior" => 396, "aacute" => 580, "s" => 520, + "OE" => 1220, "t" => 460, "divide" => 600, "section" => 600, + "u" => 660, "v" => 600, "w" => 800, "dieresis" => 500, "x" => 600, + "y" => 620, "z" => 560, "iacute" => 360, "quotedblbase" => 540, + "hungarumlaut" => 440, "quotedbl" => 420, "mu" => 660, + "Scaron" => 660, "Lslash" => 640, "semicolon" => 340, + "oslash" => 620, "florin" => 660, "yacute" => 620, "fi" => 740, + "fl" => 740, "Acircumflex" => 720, "parenright" => 320, + "Ecircumflex" => 720, "trademark" => 980, "Icircumflex" => 400, + "daggerdbl" => 380, "guillemotleft" => 400, "germandbls" => 660, + "macron" => 460, "Otilde" => 800, "seven" => 660, + "ellipsis" => 1000, "scaron" => 520, "ordmasculine" => 400, + "AE" => 1140, "Ucircumflex" => 740, "lslash" => 340, + "dotlessi" => 360, "sterling" => 660, "quotedblleft" => 540, + "hyphen" => 360, "guilsinglright" => 220, "quotesingle" => 240, + "eight" => 660, "exclamdown" => 360, "acircumflex" => 580, + "endash" => 500, "oe" => 940, "ecircumflex" => 580, + "copyright" => 740, "Adieresis" => 720, "Egrave" => 720, + "icircumflex" => 360, "slash" => 600, "braceright" => 320, + "Edieresis" => 720, "quotedblright" => 540, "otilde" => 620, + "Idieresis" => 400, "parenleft" => 320, "one" => 660, + "Odieresis" => 800, "ucircumflex" => 660, "bracketleft" => 300, + "Ugrave" => 740, "cent" => 660, "currency" => 660, + "logicalnot" => 600, "quoteright" => 320, "Udieresis" => 740, + "perthousand" => 1360, "Ydieresis" => 700, "Atilde" => 720, + "breve" => 500, "bar" => 600, "fraction" => 120, "Eacute" => 720, + "less" => 600, "adieresis" => 580, "guilsinglleft" => 220, + "egrave" => 580, "exclam" => 360, "edieresis" => 580, "Eth" => 780, + "idieresis" => 360, "period" => 340, "ae" => 880, + "asterisk" => 460, "odieresis" => 620, "Uacute" => 740, + "ugrave" => 660, "five" => 660, "nine" => 660, "greater" => 600, + "Zcaron" => 640, "udieresis" => 660, "threequarters" => 990, + "guillemotright" => 400, "Ccedilla" => 740, "ydieresis" => 620, + "tilde" => 480, "atilde" => 580, "at" => 820, "brokenbar" => 600, + "eacute" => 580, "quoteleft" => 320, "underscore" => 500, + "onesuperior" => 396, + } +); +1; diff --git a/doc/metrics/pbkdi8a.ph b/doc/metrics/pbkdi8a.ph new file mode 100644 index 0000000..8bf5e25 --- /dev/null +++ b/doc/metrics/pbkdi8a.ph @@ -0,0 +1,72 @@ +%PS_Bookman_DemiItalic = ( + name => 'Bookman-DemiItalic', + widths => { + "multiply" => 600, "Ntilde" => 740, "zero" => 680, "eth" => 600, + "Ograve" => 760, "uacute" => 680, "braceleft" => 300, + "Thorn" => 640, "zcaron" => 560, "comma" => 340, "cedilla" => 360, + "plusminus" => 600, "ccedilla" => 560, "circumflex" => 480, + "dotaccent" => 380, "asciitilde" => 620, "colon" => 340, + "onehalf" => 1020, "dollar" => 680, "ntilde" => 680, + "Ocircumflex" => 760, "Oacute" => 760, "ogonek" => 320, + "ograve" => 600, "thorn" => 660, "minus" => 600, "degree" => 400, + "yen" => 680, "space" => 340, "registered" => 780, + "questiondown" => 620, "Aring" => 720, "percent" => 880, + "emdash" => 1000, "six" => 680, "Agrave" => 720, + "paragraph" => 680, "three" => 680, "numbersign" => 680, + "two" => 680, "Igrave" => 380, "oacute" => 600, + "ocircumflex" => 600, "A" => 720, "B" => 720, "C" => 700, + "D" => 760, "E" => 720, "onequarter" => 1020, "F" => 660, + "G" => 760, "H" => 800, "I" => 380, "J" => 620, "K" => 780, + "L" => 640, "backslash" => 580, "asciicircum" => 620, + "periodcentered" => 340, "M" => 860, "N" => 740, "O" => 760, + "P" => 640, "aring" => 680, "Q" => 760, "R" => 740, + "Aacute" => 720, "caron" => 480, "S" => 700, "T" => 700, + "grave" => 380, "U" => 740, "agrave" => 680, "V" => 660, + "W" => 1000, "equal" => 600, "question" => 620, "X" => 740, + "Y" => 660, "Z" => 680, "bracketright" => 260, "Iacute" => 380, + "ampersand" => 980, "four" => 680, "igrave" => 380, "a" => 680, + "b" => 600, "c" => 560, "d" => 680, "plus" => 600, "e" => 560, + "quotesinglbase" => 300, "f" => 420, "g" => 620, "bullet" => 360, + "h" => 700, "i" => 380, "Oslash" => 760, "dagger" => 420, + "j" => 320, "Yacute" => 660, "k" => 700, "l" => 380, "m" => 960, + "n" => 680, "o" => 600, "ordfeminine" => 440, "ring" => 360, + "p" => 660, "threesuperior" => 408, "q" => 620, "acute" => 340, + "r" => 500, "twosuperior" => 408, "aacute" => 680, "s" => 540, + "OE" => 1180, "t" => 440, "divide" => 600, "section" => 620, + "u" => 680, "v" => 540, "w" => 860, "dieresis" => 520, "x" => 620, + "y" => 600, "z" => 560, "iacute" => 380, "quotedblbase" => 520, + "hungarumlaut" => 560, "quotedbl" => 380, "mu" => 680, + "Scaron" => 700, "Lslash" => 640, "semicolon" => 340, + "oslash" => 600, "florin" => 680, "yacute" => 600, "fi" => 820, + "fl" => 820, "Acircumflex" => 720, "parenright" => 260, + "Ecircumflex" => 720, "trademark" => 940, "Icircumflex" => 380, + "daggerdbl" => 420, "guillemotleft" => 380, "germandbls" => 660, + "macron" => 480, "Otilde" => 760, "seven" => 680, + "ellipsis" => 1000, "scaron" => 540, "ordmasculine" => 440, + "AE" => 1140, "Ucircumflex" => 740, "lslash" => 380, + "dotlessi" => 380, "sterling" => 680, "quotedblleft" => 520, + "hyphen" => 280, "guilsinglright" => 220, "quotesingle" => 180, + "eight" => 680, "exclamdown" => 320, "acircumflex" => 680, + "endash" => 500, "oe" => 920, "ecircumflex" => 560, + "copyright" => 780, "Adieresis" => 720, "Egrave" => 720, + "icircumflex" => 380, "slash" => 360, "braceright" => 300, + "Edieresis" => 720, "quotedblright" => 520, "otilde" => 600, + "Idieresis" => 380, "parenleft" => 260, "one" => 680, + "Odieresis" => 760, "ucircumflex" => 680, "bracketleft" => 260, + "Ugrave" => 740, "cent" => 680, "currency" => 680, + "logicalnot" => 620, "quoteright" => 320, "Udieresis" => 740, + "perthousand" => 1360, "Ydieresis" => 660, "Atilde" => 720, + "breve" => 460, "bar" => 620, "fraction" => 120, "Eacute" => 720, + "less" => 620, "adieresis" => 680, "guilsinglleft" => 220, + "egrave" => 560, "exclam" => 320, "edieresis" => 560, "Eth" => 760, + "idieresis" => 380, "period" => 340, "ae" => 880, + "asterisk" => 460, "odieresis" => 600, "Uacute" => 740, + "ugrave" => 680, "five" => 680, "nine" => 680, "greater" => 620, + "Zcaron" => 680, "udieresis" => 680, "threequarters" => 1020, + "guillemotright" => 380, "Ccedilla" => 700, "ydieresis" => 600, + "tilde" => 480, "atilde" => 680, "at" => 780, "brokenbar" => 620, + "eacute" => 560, "quoteleft" => 320, "underscore" => 500, + "onesuperior" => 408, + } +); +1; diff --git a/doc/metrics/pbkl8a.ph b/doc/metrics/pbkl8a.ph new file mode 100644 index 0000000..bcc2a74 --- /dev/null +++ b/doc/metrics/pbkl8a.ph @@ -0,0 +1,72 @@ +%PS_Bookman_Light = ( + name => 'Bookman-Light', + widths => { + "multiply" => 600, "Ntilde" => 740, "zero" => 620, "eth" => 560, + "Ograve" => 800, "uacute" => 680, "braceleft" => 280, + "Thorn" => 620, "zcaron" => 480, "comma" => 320, "cedilla" => 320, + "plusminus" => 600, "ccedilla" => 520, "circumflex" => 420, + "dotaccent" => 260, "asciitilde" => 600, "colon" => 320, + "onehalf" => 930, "dollar" => 620, "ntilde" => 660, + "Ocircumflex" => 800, "Oacute" => 800, "ogonek" => 320, + "ograve" => 560, "thorn" => 620, "minus" => 600, "degree" => 400, + "yen" => 620, "space" => 320, "registered" => 740, + "questiondown" => 540, "Aring" => 680, "percent" => 900, + "emdash" => 1000, "six" => 620, "Agrave" => 680, + "paragraph" => 600, "three" => 620, "numbersign" => 620, + "two" => 620, "Igrave" => 340, "oacute" => 560, + "ocircumflex" => 560, "A" => 680, "B" => 740, "C" => 740, + "D" => 800, "E" => 720, "onequarter" => 930, "F" => 640, + "G" => 800, "H" => 800, "I" => 340, "J" => 600, "K" => 720, + "L" => 600, "backslash" => 600, "asciicircum" => 600, + "periodcentered" => 320, "M" => 920, "N" => 740, "O" => 800, + "P" => 620, "aring" => 580, "Q" => 820, "R" => 720, + "Aacute" => 680, "caron" => 420, "S" => 660, "T" => 620, + "grave" => 340, "U" => 780, "agrave" => 580, "V" => 700, + "W" => 960, "equal" => 600, "question" => 540, "X" => 720, + "Y" => 640, "Z" => 640, "bracketright" => 300, "Iacute" => 340, + "ampersand" => 800, "four" => 620, "igrave" => 300, "a" => 580, + "b" => 620, "c" => 520, "d" => 620, "plus" => 600, "e" => 520, + "quotesinglbase" => 220, "f" => 320, "g" => 540, "bullet" => 460, + "h" => 660, "i" => 300, "Oslash" => 800, "dagger" => 540, + "j" => 300, "Yacute" => 640, "k" => 620, "l" => 300, "m" => 940, + "n" => 660, "o" => 560, "ordfeminine" => 420, "ring" => 320, + "p" => 620, "threesuperior" => 372, "q" => 580, "acute" => 340, + "r" => 440, "twosuperior" => 372, "aacute" => 580, "s" => 520, + "OE" => 1240, "t" => 380, "divide" => 600, "section" => 520, + "u" => 680, "v" => 520, "w" => 780, "dieresis" => 420, "x" => 560, + "y" => 540, "z" => 480, "iacute" => 300, "quotedblbase" => 400, + "hungarumlaut" => 380, "quotedbl" => 380, "mu" => 680, + "Scaron" => 660, "Lslash" => 600, "semicolon" => 320, + "oslash" => 560, "florin" => 620, "yacute" => 540, "fi" => 620, + "fl" => 620, "Acircumflex" => 680, "parenright" => 300, + "Ecircumflex" => 720, "trademark" => 980, "Icircumflex" => 340, + "daggerdbl" => 540, "guillemotleft" => 360, "germandbls" => 660, + "macron" => 440, "Otilde" => 800, "seven" => 620, + "ellipsis" => 1000, "scaron" => 520, "ordmasculine" => 420, + "AE" => 1260, "Ucircumflex" => 780, "lslash" => 320, + "dotlessi" => 300, "sterling" => 620, "quotedblleft" => 400, + "hyphen" => 400, "guilsinglright" => 240, "quotesingle" => 220, + "eight" => 620, "exclamdown" => 300, "acircumflex" => 580, + "endash" => 500, "oe" => 900, "ecircumflex" => 520, + "copyright" => 740, "Adieresis" => 680, "Egrave" => 720, + "icircumflex" => 300, "slash" => 600, "braceright" => 280, + "Edieresis" => 720, "quotedblright" => 400, "otilde" => 560, + "Idieresis" => 340, "parenleft" => 300, "one" => 620, + "Odieresis" => 800, "ucircumflex" => 680, "bracketleft" => 300, + "Ugrave" => 780, "cent" => 620, "currency" => 620, + "logicalnot" => 600, "quoteright" => 220, "Udieresis" => 780, + "perthousand" => 1280, "Ydieresis" => 640, "Atilde" => 680, + "breve" => 460, "bar" => 600, "fraction" => 140, "Eacute" => 720, + "less" => 600, "adieresis" => 580, "guilsinglleft" => 240, + "egrave" => 520, "exclam" => 300, "edieresis" => 520, "Eth" => 800, + "idieresis" => 300, "period" => 320, "ae" => 860, + "asterisk" => 440, "odieresis" => 560, "Uacute" => 780, + "ugrave" => 680, "five" => 620, "nine" => 620, "greater" => 600, + "Zcaron" => 640, "udieresis" => 680, "threequarters" => 930, + "guillemotright" => 360, "Ccedilla" => 740, "ydieresis" => 540, + "tilde" => 440, "atilde" => 580, "at" => 820, "brokenbar" => 600, + "eacute" => 520, "quoteleft" => 220, "underscore" => 500, + "onesuperior" => 372, + } +); +1; diff --git a/doc/metrics/pbkli8a.ph b/doc/metrics/pbkli8a.ph new file mode 100644 index 0000000..7c5ded3 --- /dev/null +++ b/doc/metrics/pbkli8a.ph @@ -0,0 +1,72 @@ +%PS_Bookman_LightItalic = ( + name => 'Bookman-LightItalic', + widths => { + "multiply" => 600, "Ntilde" => 720, "zero" => 620, "eth" => 540, + "Ograve" => 760, "uacute" => 620, "braceleft" => 360, + "Thorn" => 600, "zcaron" => 520, "comma" => 300, "cedilla" => 320, + "plusminus" => 600, "ccedilla" => 480, "circumflex" => 440, + "dotaccent" => 260, "asciitilde" => 600, "colon" => 300, + "onehalf" => 930, "dollar" => 620, "ntilde" => 620, + "Ocircumflex" => 760, "Oacute" => 760, "ogonek" => 260, + "ograve" => 540, "thorn" => 600, "minus" => 600, "degree" => 400, + "yen" => 620, "space" => 300, "registered" => 740, + "questiondown" => 540, "Aring" => 700, "percent" => 800, + "emdash" => 1000, "six" => 620, "Agrave" => 700, + "paragraph" => 620, "three" => 620, "numbersign" => 620, + "two" => 620, "Igrave" => 320, "oacute" => 540, + "ocircumflex" => 540, "A" => 700, "B" => 720, "C" => 720, + "D" => 740, "E" => 680, "onequarter" => 930, "F" => 620, + "G" => 760, "H" => 800, "I" => 320, "J" => 560, "K" => 720, + "L" => 580, "backslash" => 600, "asciicircum" => 600, + "periodcentered" => 300, "M" => 860, "N" => 720, "O" => 760, + "P" => 600, "aring" => 620, "Q" => 780, "R" => 700, + "Aacute" => 700, "caron" => 440, "S" => 640, "T" => 600, + "grave" => 340, "U" => 720, "agrave" => 620, "V" => 680, + "W" => 960, "equal" => 600, "question" => 540, "X" => 700, + "Y" => 660, "Z" => 580, "bracketright" => 260, "Iacute" => 320, + "ampersand" => 820, "four" => 620, "igrave" => 280, "a" => 620, + "b" => 600, "c" => 480, "d" => 640, "plus" => 600, "e" => 540, + "quotesinglbase" => 320, "f" => 340, "g" => 560, "bullet" => 460, + "h" => 620, "i" => 280, "Oslash" => 760, "dagger" => 620, + "j" => 280, "Yacute" => 660, "k" => 600, "l" => 280, "m" => 880, + "n" => 620, "o" => 540, "ordfeminine" => 440, "ring" => 300, + "p" => 600, "threesuperior" => 372, "q" => 560, "acute" => 320, + "r" => 400, "twosuperior" => 372, "aacute" => 620, "s" => 540, + "OE" => 1180, "t" => 340, "divide" => 600, "section" => 620, + "u" => 620, "v" => 540, "w" => 880, "dieresis" => 420, "x" => 540, + "y" => 600, "z" => 520, "iacute" => 280, "quotedblbase" => 480, + "hungarumlaut" => 340, "quotedbl" => 360, "mu" => 620, + "Scaron" => 640, "Lslash" => 580, "semicolon" => 300, + "oslash" => 540, "florin" => 620, "yacute" => 600, "fi" => 640, + "fl" => 660, "Acircumflex" => 700, "parenright" => 280, + "Ecircumflex" => 680, "trademark" => 980, "Icircumflex" => 320, + "daggerdbl" => 620, "guillemotleft" => 300, "germandbls" => 620, + "macron" => 440, "Otilde" => 760, "seven" => 620, + "ellipsis" => 1000, "scaron" => 540, "ordmasculine" => 400, + "AE" => 1220, "Ucircumflex" => 720, "lslash" => 340, + "dotlessi" => 280, "sterling" => 620, "quotedblleft" => 440, + "hyphen" => 320, "guilsinglright" => 180, "quotesingle" => 200, + "eight" => 620, "exclamdown" => 320, "acircumflex" => 620, + "endash" => 500, "oe" => 900, "ecircumflex" => 540, + "copyright" => 740, "Adieresis" => 700, "Egrave" => 680, + "icircumflex" => 280, "slash" => 600, "braceright" => 380, + "Edieresis" => 680, "quotedblright" => 440, "otilde" => 540, + "Idieresis" => 320, "parenleft" => 280, "one" => 620, + "Odieresis" => 760, "ucircumflex" => 620, "bracketleft" => 260, + "Ugrave" => 720, "cent" => 620, "currency" => 620, + "logicalnot" => 600, "quoteright" => 280, "Udieresis" => 720, + "perthousand" => 1180, "Ydieresis" => 660, "Atilde" => 700, + "breve" => 440, "bar" => 600, "fraction" => 20, "Eacute" => 680, + "less" => 600, "adieresis" => 620, "guilsinglleft" => 180, + "egrave" => 540, "exclam" => 320, "edieresis" => 540, "Eth" => 740, + "idieresis" => 280, "period" => 300, "ae" => 880, + "asterisk" => 440, "odieresis" => 540, "Uacute" => 720, + "ugrave" => 620, "five" => 620, "nine" => 620, "greater" => 600, + "Zcaron" => 580, "udieresis" => 620, "threequarters" => 930, + "guillemotright" => 300, "Ccedilla" => 720, "ydieresis" => 600, + "tilde" => 440, "atilde" => 620, "at" => 780, "brokenbar" => 600, + "eacute" => 540, "quoteleft" => 280, "underscore" => 500, + "onesuperior" => 372, + } +); +1; diff --git a/doc/metrics/pcrb8a.ph b/doc/metrics/pcrb8a.ph new file mode 100644 index 0000000..e4300d7 --- /dev/null +++ b/doc/metrics/pcrb8a.ph @@ -0,0 +1,82 @@ +%PS_Courier_Bold = ( + name => 'Courier-Bold', + widths => { + "Ntilde" => 600, "comma" => 600, "cedilla" => 600, + "arrowup" => 600, "plusminus" => 600, "circumflex" => 600, + "dotaccent" => 600, "LL" => 600, "asciitilde" => 600, + "colon" => 600, "onehalf" => 600, "dollar" => 600, "ntilde" => 600, + "left" => 600, "minus" => 600, "yen" => 600, "space" => 600, + "questiondown" => 600, "emdash" => 600, "Agrave" => 600, + "three" => 600, "numbersign" => 600, "A" => 600, "B" => 600, + "C" => 600, "D" => 600, "E" => 600, "onequarter" => 600, + "F" => 600, "G" => 600, "H" => 600, "I" => 600, "J" => 600, + "K" => 600, "L" => 600, "backslash" => 600, + "periodcentered" => 600, "M" => 600, "N" => 600, "O" => 600, + "P" => 600, "Q" => 600, "R" => 600, "Aacute" => 600, + "caron" => 600, "S" => 600, "T" => 600, "U" => 600, + "agrave" => 600, "V" => 600, "tab" => 600, "W" => 600, "ll" => 600, + "equal" => 600, "question" => 600, "X" => 600, "Y" => 600, + "Z" => 600, "four" => 600, "a" => 600, "b" => 600, "c" => 600, + "d" => 600, "e" => 600, "f" => 600, "g" => 600, "bullet" => 600, + "h" => 600, "i" => 600, "Oslash" => 600, "dagger" => 600, + "j" => 600, "k" => 600, "l" => 600, "m" => 600, "n" => 600, + "o" => 600, "ordfeminine" => 600, "ring" => 600, "p" => 600, + "q" => 600, "r" => 600, "aacute" => 600, "largebullet" => 600, + "twosuperior" => 600, "s" => 600, "OE" => 600, "t" => 600, + "divide" => 600, "u" => 600, "v" => 600, "w" => 600, "x" => 600, + "y" => 600, "z" => 600, "hungarumlaut" => 600, "quotedbl" => 600, + "mu" => 600, "Scaron" => 600, "Lslash" => 600, "semicolon" => 600, + "oslash" => 600, "parenright" => 600, "Ecircumflex" => 600, + "trademark" => 600, "daggerdbl" => 600, "macron" => 600, + "Otilde" => 600, "ellipsis" => 600, "scaron" => 600, "AE" => 600, + "Ucircumflex" => 600, "lslash" => 600, "lira" => 600, + "quotedblleft" => 600, "hyphen" => 600, "guilsinglright" => 600, + "quotesingle" => 600, "eight" => 600, "exclamdown" => 600, + "endash" => 600, "oe" => 600, "ecircumflex" => 600, + "Adieresis" => 600, "copyright" => 600, "Egrave" => 600, + "slash" => 600, "Edieresis" => 600, "otilde" => 600, + "Idieresis" => 600, "parenleft" => 600, "one" => 600, + "ucircumflex" => 600, "Odieresis" => 600, "bracketleft" => 600, + "Ugrave" => 600, "quoteright" => 600, "Udieresis" => 600, + "perthousand" => 600, "Ydieresis" => 600, "Eacute" => 600, + "adieresis" => 600, "egrave" => 600, "edieresis" => 600, + "idieresis" => 600, "Eth" => 600, "ae" => 600, "asterisk" => 600, + "Uacute" => 600, "odieresis" => 600, "ugrave" => 600, + "five" => 600, "nine" => 600, "udieresis" => 600, "Zcaron" => 600, + "threequarters" => 600, "guillemotright" => 600, + "ydieresis" => 600, "Ccedilla" => 600, "tilde" => 600, "at" => 600, + "eacute" => 600, "Gcaron" => 600, "underscore" => 600, + "zero" => 600, "multiply" => 600, "eth" => 600, "Scedilla" => 600, + "Ograve" => 600, "uacute" => 600, "braceleft" => 600, + "Thorn" => 600, "zcaron" => 600, "ccedilla" => 600, + "gcaron" => 600, "Ocircumflex" => 600, "Oacute" => 600, + "scedilla" => 600, "ogonek" => 600, "arrowdown" => 600, + "ograve" => 600, "thorn" => 600, "degree" => 600, + "registered" => 600, "percent" => 600, "Aring" => 600, + "six" => 600, "paragraph" => 600, "two" => 600, "Igrave" => 600, + "oacute" => 600, "ocircumflex" => 600, "asciicircum" => 600, + "aring" => 600, "square" => 600, "grave" => 600, + "bracketright" => 600, "ampersand" => 600, "Iacute" => 600, + "igrave" => 600, "return" => 600, "plus" => 600, + "quotesinglbase" => 600, "Yacute" => 600, "threesuperior" => 600, + "acute" => 600, "notegraphic" => 600, "section" => 600, + "arrowleft" => 600, "dieresis" => 600, "quotedblbase" => 600, + "iacute" => 600, "up" => 600, "florin" => 600, "yacute" => 600, + "fi" => 600, "fl" => 600, "Acircumflex" => 600, + "Icircumflex" => 600, "guillemotleft" => 600, "germandbls" => 600, + "seven" => 600, "prescription" => 600, "indent" => 600, + "dectab" => 600, "ordmasculine" => 600, "dotlessi" => 600, + "sterling" => 600, "IJ" => 600, "acircumflex" => 600, + "overscore" => 600, "icircumflex" => 600, "braceright" => 600, + "graybox" => 600, "quotedblright" => 600, "center" => 600, + "stop" => 600, "cent" => 600, "currency" => 600, + "logicalnot" => 600, "merge" => 600, "Idot" => 600, + "Atilde" => 600, "breve" => 600, "bar" => 600, "fraction" => 600, + "less" => 600, "down" => 600, "guilsinglleft" => 600, + "exclam" => 600, "period" => 600, "format" => 600, + "arrowright" => 600, "greater" => 600, "ij" => 600, + "atilde" => 600, "brokenbar" => 600, "arrowboth" => 600, + "quoteleft" => 600, "onesuperior" => 600, + } +); +1; diff --git a/doc/metrics/pcrbo8a.ph b/doc/metrics/pcrbo8a.ph new file mode 100644 index 0000000..c1554b2 --- /dev/null +++ b/doc/metrics/pcrbo8a.ph @@ -0,0 +1,82 @@ +%PS_Courier_BoldOblique = ( + name => 'Courier-BoldOblique', + widths => { + "Ntilde" => 600, "comma" => 600, "cedilla" => 600, + "arrowup" => 600, "plusminus" => 600, "circumflex" => 600, + "dotaccent" => 600, "LL" => 600, "asciitilde" => 600, + "colon" => 600, "onehalf" => 600, "dollar" => 600, "ntilde" => 600, + "left" => 600, "minus" => 600, "yen" => 600, "space" => 600, + "questiondown" => 600, "emdash" => 600, "Agrave" => 600, + "three" => 600, "numbersign" => 600, "A" => 600, "B" => 600, + "C" => 600, "D" => 600, "E" => 600, "onequarter" => 600, + "F" => 600, "G" => 600, "H" => 600, "I" => 600, "J" => 600, + "K" => 600, "L" => 600, "backslash" => 600, + "periodcentered" => 600, "M" => 600, "N" => 600, "O" => 600, + "P" => 600, "Q" => 600, "R" => 600, "Aacute" => 600, + "caron" => 600, "S" => 600, "T" => 600, "U" => 600, + "agrave" => 600, "V" => 600, "tab" => 600, "W" => 600, "ll" => 600, + "equal" => 600, "question" => 600, "X" => 600, "Y" => 600, + "Z" => 600, "four" => 600, "a" => 600, "b" => 600, "c" => 600, + "d" => 600, "e" => 600, "f" => 600, "g" => 600, "bullet" => 600, + "h" => 600, "i" => 600, "Oslash" => 600, "dagger" => 600, + "j" => 600, "k" => 600, "l" => 600, "m" => 600, "n" => 600, + "o" => 600, "ordfeminine" => 600, "ring" => 600, "p" => 600, + "q" => 600, "r" => 600, "aacute" => 600, "largebullet" => 600, + "twosuperior" => 600, "s" => 600, "OE" => 600, "t" => 600, + "divide" => 600, "u" => 600, "v" => 600, "w" => 600, "x" => 600, + "y" => 600, "z" => 600, "hungarumlaut" => 600, "quotedbl" => 600, + "mu" => 600, "Scaron" => 600, "Lslash" => 600, "semicolon" => 600, + "oslash" => 600, "parenright" => 600, "Ecircumflex" => 600, + "trademark" => 600, "daggerdbl" => 600, "macron" => 600, + "Otilde" => 600, "ellipsis" => 600, "scaron" => 600, "AE" => 600, + "Ucircumflex" => 600, "lslash" => 600, "lira" => 600, + "quotedblleft" => 600, "hyphen" => 600, "guilsinglright" => 600, + "quotesingle" => 600, "eight" => 600, "exclamdown" => 600, + "endash" => 600, "oe" => 600, "ecircumflex" => 600, + "Adieresis" => 600, "copyright" => 600, "Egrave" => 600, + "slash" => 600, "Edieresis" => 600, "otilde" => 600, + "Idieresis" => 600, "parenleft" => 600, "one" => 600, + "ucircumflex" => 600, "Odieresis" => 600, "bracketleft" => 600, + "Ugrave" => 600, "quoteright" => 600, "Udieresis" => 600, + "perthousand" => 600, "Ydieresis" => 600, "Eacute" => 600, + "adieresis" => 600, "egrave" => 600, "edieresis" => 600, + "idieresis" => 600, "Eth" => 600, "ae" => 600, "asterisk" => 600, + "Uacute" => 600, "odieresis" => 600, "ugrave" => 600, + "five" => 600, "nine" => 600, "udieresis" => 600, "Zcaron" => 600, + "threequarters" => 600, "guillemotright" => 600, + "ydieresis" => 600, "Ccedilla" => 600, "tilde" => 600, "at" => 600, + "eacute" => 600, "Gcaron" => 600, "underscore" => 600, + "zero" => 600, "multiply" => 600, "eth" => 600, "Scedilla" => 600, + "Ograve" => 600, "uacute" => 600, "braceleft" => 600, + "Thorn" => 600, "zcaron" => 600, "ccedilla" => 600, + "gcaron" => 600, "Ocircumflex" => 600, "Oacute" => 600, + "scedilla" => 600, "ogonek" => 600, "arrowdown" => 600, + "ograve" => 600, "thorn" => 600, "degree" => 600, + "registered" => 600, "percent" => 600, "Aring" => 600, + "six" => 600, "paragraph" => 600, "two" => 600, "Igrave" => 600, + "oacute" => 600, "ocircumflex" => 600, "asciicircum" => 600, + "aring" => 600, "square" => 600, "grave" => 600, + "bracketright" => 600, "ampersand" => 600, "Iacute" => 600, + "igrave" => 600, "return" => 600, "plus" => 600, + "quotesinglbase" => 600, "Yacute" => 600, "threesuperior" => 600, + "acute" => 600, "notegraphic" => 600, "section" => 600, + "arrowleft" => 600, "dieresis" => 600, "quotedblbase" => 600, + "iacute" => 600, "up" => 600, "florin" => 600, "yacute" => 600, + "fi" => 600, "fl" => 600, "Acircumflex" => 600, + "Icircumflex" => 600, "guillemotleft" => 600, "germandbls" => 600, + "seven" => 600, "prescription" => 600, "indent" => 600, + "dectab" => 600, "ordmasculine" => 600, "dotlessi" => 600, + "sterling" => 600, "IJ" => 600, "acircumflex" => 600, + "overscore" => 600, "icircumflex" => 600, "braceright" => 600, + "graybox" => 600, "quotedblright" => 600, "center" => 600, + "stop" => 600, "cent" => 600, "currency" => 600, + "logicalnot" => 600, "merge" => 600, "Idot" => 600, + "Atilde" => 600, "breve" => 600, "bar" => 600, "fraction" => 600, + "less" => 600, "down" => 600, "guilsinglleft" => 600, + "exclam" => 600, "period" => 600, "format" => 600, + "arrowright" => 600, "greater" => 600, "ij" => 600, + "atilde" => 600, "brokenbar" => 600, "arrowboth" => 600, + "quoteleft" => 600, "onesuperior" => 600, + } +); +1; diff --git a/doc/metrics/pcrr8a.ph b/doc/metrics/pcrr8a.ph new file mode 100644 index 0000000..a8fbb14 --- /dev/null +++ b/doc/metrics/pcrr8a.ph @@ -0,0 +1,82 @@ +%PS_Courier = ( + name => 'Courier', + widths => { + "Ntilde" => 600, "comma" => 600, "cedilla" => 600, + "arrowup" => 600, "plusminus" => 600, "circumflex" => 600, + "dotaccent" => 600, "LL" => 600, "asciitilde" => 600, + "colon" => 600, "onehalf" => 600, "dollar" => 600, "ntilde" => 600, + "left" => 600, "minus" => 600, "yen" => 600, "space" => 600, + "questiondown" => 600, "emdash" => 600, "Agrave" => 600, + "three" => 600, "numbersign" => 600, "A" => 600, "B" => 600, + "C" => 600, "D" => 600, "E" => 600, "onequarter" => 600, + "F" => 600, "G" => 600, "H" => 600, "I" => 600, "J" => 600, + "K" => 600, "L" => 600, "backslash" => 600, + "periodcentered" => 600, "M" => 600, "N" => 600, "O" => 600, + "P" => 600, "Q" => 600, "R" => 600, "Aacute" => 600, + "caron" => 600, "S" => 600, "T" => 600, "U" => 600, + "agrave" => 600, "V" => 600, "tab" => 600, "W" => 600, "ll" => 600, + "equal" => 600, "question" => 600, "X" => 600, "Y" => 600, + "Z" => 600, "four" => 600, "a" => 600, "b" => 600, "c" => 600, + "d" => 600, "e" => 600, "f" => 600, "g" => 600, "bullet" => 600, + "h" => 600, "i" => 600, "Oslash" => 600, "dagger" => 600, + "j" => 600, "k" => 600, "l" => 600, "m" => 600, "n" => 600, + "o" => 600, "ordfeminine" => 600, "ring" => 600, "p" => 600, + "q" => 600, "r" => 600, "aacute" => 600, "largebullet" => 600, + "twosuperior" => 600, "s" => 600, "OE" => 600, "t" => 600, + "divide" => 600, "u" => 600, "v" => 600, "w" => 600, "x" => 600, + "y" => 600, "z" => 600, "hungarumlaut" => 600, "quotedbl" => 600, + "mu" => 600, "Scaron" => 600, "Lslash" => 600, "semicolon" => 600, + "oslash" => 600, "parenright" => 600, "Ecircumflex" => 600, + "trademark" => 600, "daggerdbl" => 600, "macron" => 600, + "Otilde" => 600, "ellipsis" => 600, "scaron" => 600, "AE" => 600, + "Ucircumflex" => 600, "lslash" => 600, "lira" => 600, + "quotedblleft" => 600, "hyphen" => 600, "guilsinglright" => 600, + "quotesingle" => 600, "eight" => 600, "exclamdown" => 600, + "endash" => 600, "oe" => 600, "ecircumflex" => 600, + "Adieresis" => 600, "copyright" => 600, "Egrave" => 600, + "slash" => 600, "Edieresis" => 600, "otilde" => 600, + "Idieresis" => 600, "parenleft" => 600, "one" => 600, + "ucircumflex" => 600, "Odieresis" => 600, "bracketleft" => 600, + "Ugrave" => 600, "quoteright" => 600, "Udieresis" => 600, + "perthousand" => 600, "Ydieresis" => 600, "Eacute" => 600, + "adieresis" => 600, "egrave" => 600, "edieresis" => 600, + "idieresis" => 600, "Eth" => 600, "ae" => 600, "asterisk" => 600, + "Uacute" => 600, "odieresis" => 600, "ugrave" => 600, + "five" => 600, "nine" => 600, "udieresis" => 600, "Zcaron" => 600, + "threequarters" => 600, "guillemotright" => 600, + "ydieresis" => 600, "Ccedilla" => 600, "tilde" => 600, "at" => 600, + "eacute" => 600, "Gcaron" => 600, "underscore" => 600, + "zero" => 600, "multiply" => 600, "eth" => 600, "Scedilla" => 600, + "Ograve" => 600, "uacute" => 600, "braceleft" => 600, + "Thorn" => 600, "zcaron" => 600, "ccedilla" => 600, + "gcaron" => 600, "Ocircumflex" => 600, "Oacute" => 600, + "scedilla" => 600, "ogonek" => 600, "arrowdown" => 600, + "ograve" => 600, "thorn" => 600, "degree" => 600, + "registered" => 600, "percent" => 600, "Aring" => 600, + "six" => 600, "paragraph" => 600, "two" => 600, "Igrave" => 600, + "oacute" => 600, "ocircumflex" => 600, "asciicircum" => 600, + "aring" => 600, "square" => 600, "grave" => 600, + "bracketright" => 600, "ampersand" => 600, "Iacute" => 600, + "igrave" => 600, "return" => 600, "plus" => 600, + "quotesinglbase" => 600, "Yacute" => 600, "threesuperior" => 600, + "acute" => 600, "notegraphic" => 600, "section" => 600, + "arrowleft" => 600, "dieresis" => 600, "quotedblbase" => 600, + "iacute" => 600, "up" => 600, "florin" => 600, "yacute" => 600, + "fi" => 600, "fl" => 600, "Acircumflex" => 600, + "Icircumflex" => 600, "guillemotleft" => 600, "germandbls" => 600, + "seven" => 600, "prescription" => 600, "indent" => 600, + "dectab" => 600, "ordmasculine" => 600, "dotlessi" => 600, + "sterling" => 600, "IJ" => 600, "acircumflex" => 600, + "overscore" => 600, "icircumflex" => 600, "braceright" => 600, + "graybox" => 600, "quotedblright" => 600, "center" => 600, + "stop" => 600, "cent" => 600, "currency" => 600, + "logicalnot" => 600, "merge" => 600, "Idot" => 600, + "Atilde" => 600, "breve" => 600, "bar" => 600, "fraction" => 600, + "less" => 600, "down" => 600, "guilsinglleft" => 600, + "exclam" => 600, "period" => 600, "format" => 600, + "arrowright" => 600, "greater" => 600, "ij" => 600, + "atilde" => 600, "brokenbar" => 600, "arrowboth" => 600, + "quoteleft" => 600, "onesuperior" => 600, + } +); +1; diff --git a/doc/metrics/pcrro8a.ph b/doc/metrics/pcrro8a.ph new file mode 100644 index 0000000..59e5026 --- /dev/null +++ b/doc/metrics/pcrro8a.ph @@ -0,0 +1,82 @@ +%PS_Courier_Oblique = ( + name => 'Courier-Oblique', + widths => { + "Ntilde" => 600, "comma" => 600, "cedilla" => 600, + "arrowup" => 600, "plusminus" => 600, "circumflex" => 600, + "dotaccent" => 600, "LL" => 600, "asciitilde" => 600, + "colon" => 600, "onehalf" => 600, "dollar" => 600, "ntilde" => 600, + "left" => 600, "minus" => 600, "yen" => 600, "space" => 600, + "questiondown" => 600, "emdash" => 600, "Agrave" => 600, + "three" => 600, "numbersign" => 600, "A" => 600, "B" => 600, + "C" => 600, "D" => 600, "E" => 600, "onequarter" => 600, + "F" => 600, "G" => 600, "H" => 600, "I" => 600, "J" => 600, + "K" => 600, "L" => 600, "backslash" => 600, + "periodcentered" => 600, "M" => 600, "N" => 600, "O" => 600, + "P" => 600, "Q" => 600, "R" => 600, "Aacute" => 600, + "caron" => 600, "S" => 600, "T" => 600, "U" => 600, + "agrave" => 600, "V" => 600, "tab" => 600, "W" => 600, "ll" => 600, + "equal" => 600, "question" => 600, "X" => 600, "Y" => 600, + "Z" => 600, "four" => 600, "a" => 600, "b" => 600, "c" => 600, + "d" => 600, "e" => 600, "f" => 600, "g" => 600, "bullet" => 600, + "h" => 600, "i" => 600, "Oslash" => 600, "dagger" => 600, + "j" => 600, "k" => 600, "l" => 600, "m" => 600, "n" => 600, + "o" => 600, "ordfeminine" => 600, "ring" => 600, "p" => 600, + "q" => 600, "r" => 600, "aacute" => 600, "largebullet" => 600, + "twosuperior" => 600, "s" => 600, "OE" => 600, "t" => 600, + "divide" => 600, "u" => 600, "v" => 600, "w" => 600, "x" => 600, + "y" => 600, "z" => 600, "hungarumlaut" => 600, "quotedbl" => 600, + "mu" => 600, "Scaron" => 600, "Lslash" => 600, "semicolon" => 600, + "oslash" => 600, "parenright" => 600, "Ecircumflex" => 600, + "trademark" => 600, "daggerdbl" => 600, "macron" => 600, + "Otilde" => 600, "ellipsis" => 600, "scaron" => 600, "AE" => 600, + "Ucircumflex" => 600, "lslash" => 600, "lira" => 600, + "quotedblleft" => 600, "hyphen" => 600, "guilsinglright" => 600, + "quotesingle" => 600, "eight" => 600, "exclamdown" => 600, + "endash" => 600, "oe" => 600, "ecircumflex" => 600, + "Adieresis" => 600, "copyright" => 600, "Egrave" => 600, + "slash" => 600, "Edieresis" => 600, "otilde" => 600, + "Idieresis" => 600, "parenleft" => 600, "one" => 600, + "ucircumflex" => 600, "Odieresis" => 600, "bracketleft" => 600, + "Ugrave" => 600, "quoteright" => 600, "Udieresis" => 600, + "perthousand" => 600, "Ydieresis" => 600, "Eacute" => 600, + "adieresis" => 600, "egrave" => 600, "edieresis" => 600, + "idieresis" => 600, "Eth" => 600, "ae" => 600, "asterisk" => 600, + "Uacute" => 600, "odieresis" => 600, "ugrave" => 600, + "five" => 600, "nine" => 600, "udieresis" => 600, "Zcaron" => 600, + "threequarters" => 600, "guillemotright" => 600, + "ydieresis" => 600, "Ccedilla" => 600, "tilde" => 600, "at" => 600, + "eacute" => 600, "Gcaron" => 600, "underscore" => 600, + "zero" => 600, "multiply" => 600, "eth" => 600, "Scedilla" => 600, + "Ograve" => 600, "uacute" => 600, "braceleft" => 600, + "Thorn" => 600, "zcaron" => 600, "ccedilla" => 600, + "gcaron" => 600, "Ocircumflex" => 600, "Oacute" => 600, + "scedilla" => 600, "ogonek" => 600, "arrowdown" => 600, + "ograve" => 600, "thorn" => 600, "degree" => 600, + "registered" => 600, "percent" => 600, "Aring" => 600, + "six" => 600, "paragraph" => 600, "two" => 600, "Igrave" => 600, + "oacute" => 600, "ocircumflex" => 600, "asciicircum" => 600, + "aring" => 600, "square" => 600, "grave" => 600, + "bracketright" => 600, "ampersand" => 600, "Iacute" => 600, + "igrave" => 600, "return" => 600, "plus" => 600, + "quotesinglbase" => 600, "Yacute" => 600, "threesuperior" => 600, + "acute" => 600, "notegraphic" => 600, "section" => 600, + "arrowleft" => 600, "dieresis" => 600, "quotedblbase" => 600, + "iacute" => 600, "up" => 600, "florin" => 600, "yacute" => 600, + "fi" => 600, "fl" => 600, "Acircumflex" => 600, + "Icircumflex" => 600, "guillemotleft" => 600, "germandbls" => 600, + "seven" => 600, "prescription" => 600, "indent" => 600, + "dectab" => 600, "ordmasculine" => 600, "dotlessi" => 600, + "sterling" => 600, "IJ" => 600, "acircumflex" => 600, + "overscore" => 600, "icircumflex" => 600, "braceright" => 600, + "graybox" => 600, "quotedblright" => 600, "center" => 600, + "stop" => 600, "cent" => 600, "currency" => 600, + "logicalnot" => 600, "merge" => 600, "Idot" => 600, + "Atilde" => 600, "breve" => 600, "bar" => 600, "fraction" => 600, + "less" => 600, "down" => 600, "guilsinglleft" => 600, + "exclam" => 600, "period" => 600, "format" => 600, + "arrowright" => 600, "greater" => 600, "ij" => 600, + "atilde" => 600, "brokenbar" => 600, "arrowboth" => 600, + "quoteleft" => 600, "onesuperior" => 600, + } +); +1; diff --git a/doc/metrics/phvb8a.ph b/doc/metrics/phvb8a.ph new file mode 100644 index 0000000..3c692f1 --- /dev/null +++ b/doc/metrics/phvb8a.ph @@ -0,0 +1,72 @@ +%PS_Helvetica_Bold = ( + name => 'Helvetica-Bold', + widths => { + "multiply" => 584, "Ntilde" => 722, "zero" => 556, "eth" => 611, + "Ograve" => 778, "uacute" => 611, "braceleft" => 389, + "Thorn" => 667, "zcaron" => 500, "comma" => 278, "cedilla" => 333, + "plusminus" => 584, "ccedilla" => 556, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 584, "colon" => 333, + "onehalf" => 834, "dollar" => 556, "ntilde" => 611, + "Oacute" => 778, "Ocircumflex" => 778, "ogonek" => 333, + "ograve" => 611, "thorn" => 611, "degree" => 400, "minus" => 584, + "yen" => 556, "space" => 278, "registered" => 737, + "questiondown" => 611, "Aring" => 722, "percent" => 889, + "emdash" => 1000, "six" => 556, "Agrave" => 722, + "paragraph" => 556, "three" => 556, "numbersign" => 556, + "two" => 556, "Igrave" => 278, "oacute" => 611, + "ocircumflex" => 611, "A" => 722, "B" => 722, "C" => 722, + "D" => 722, "E" => 667, "onequarter" => 834, "F" => 611, + "G" => 778, "H" => 722, "I" => 278, "J" => 556, "K" => 722, + "L" => 611, "backslash" => 278, "asciicircum" => 584, + "periodcentered" => 278, "M" => 833, "N" => 722, "O" => 778, + "P" => 667, "aring" => 556, "Q" => 778, "R" => 722, + "Aacute" => 722, "caron" => 333, "S" => 667, "T" => 611, + "grave" => 333, "U" => 722, "agrave" => 556, "V" => 667, + "W" => 944, "equal" => 584, "question" => 611, "X" => 667, + "Y" => 667, "Z" => 611, "bracketright" => 333, "Iacute" => 278, + "ampersand" => 722, "four" => 556, "igrave" => 278, "a" => 556, + "b" => 611, "c" => 556, "d" => 611, "plus" => 584, "e" => 556, + "quotesinglbase" => 278, "f" => 333, "g" => 611, "bullet" => 350, + "h" => 611, "i" => 278, "Oslash" => 778, "dagger" => 556, + "j" => 278, "Yacute" => 667, "k" => 556, "l" => 278, "m" => 889, + "n" => 611, "o" => 611, "ordfeminine" => 370, "ring" => 333, + "p" => 611, "threesuperior" => 333, "q" => 611, "acute" => 333, + "r" => 389, "aacute" => 556, "twosuperior" => 333, "s" => 556, + "OE" => 1000, "t" => 333, "divide" => 584, "section" => 556, + "u" => 611, "v" => 556, "w" => 778, "dieresis" => 333, "x" => 556, + "y" => 556, "z" => 500, "iacute" => 278, "quotedblbase" => 500, + "hungarumlaut" => 333, "quotedbl" => 474, "mu" => 611, + "Scaron" => 667, "Lslash" => 611, "semicolon" => 333, + "oslash" => 611, "florin" => 556, "yacute" => 556, "fi" => 611, + "fl" => 611, "Acircumflex" => 722, "parenright" => 333, + "Ecircumflex" => 667, "Icircumflex" => 278, "trademark" => 1000, + "daggerdbl" => 556, "guillemotleft" => 556, "germandbls" => 611, + "macron" => 333, "Otilde" => 778, "seven" => 556, + "ellipsis" => 1000, "scaron" => 556, "ordmasculine" => 365, + "AE" => 1000, "Ucircumflex" => 722, "lslash" => 278, + "dotlessi" => 278, "sterling" => 556, "quotedblleft" => 500, + "hyphen" => 333, "guilsinglright" => 333, "quotesingle" => 238, + "eight" => 556, "exclamdown" => 333, "acircumflex" => 556, + "endash" => 556, "oe" => 944, "ecircumflex" => 556, + "Adieresis" => 722, "copyright" => 737, "Egrave" => 667, + "icircumflex" => 278, "slash" => 278, "braceright" => 389, + "Edieresis" => 667, "quotedblright" => 500, "Idieresis" => 278, + "otilde" => 611, "parenleft" => 333, "one" => 556, + "Odieresis" => 778, "ucircumflex" => 611, "bracketleft" => 333, + "Ugrave" => 722, "cent" => 556, "currency" => 556, + "logicalnot" => 584, "quoteright" => 278, "Udieresis" => 722, + "perthousand" => 1000, "Ydieresis" => 667, "Atilde" => 722, + "breve" => 333, "bar" => 280, "fraction" => 167, "Eacute" => 667, + "less" => 584, "adieresis" => 556, "guilsinglleft" => 333, + "egrave" => 556, "exclam" => 333, "edieresis" => 556, + "idieresis" => 278, "Eth" => 722, "period" => 278, "ae" => 889, + "asterisk" => 389, "odieresis" => 611, "Uacute" => 722, + "ugrave" => 611, "five" => 556, "nine" => 556, "greater" => 584, + "udieresis" => 611, "Zcaron" => 611, "threequarters" => 834, + "guillemotright" => 556, "Ccedilla" => 722, "ydieresis" => 556, + "tilde" => 333, "atilde" => 556, "at" => 975, "brokenbar" => 280, + "eacute" => 556, "quoteleft" => 278, "underscore" => 556, + "onesuperior" => 333, + } +); +1; diff --git a/doc/metrics/phvb8an.ph b/doc/metrics/phvb8an.ph new file mode 100644 index 0000000..cb2c96f --- /dev/null +++ b/doc/metrics/phvb8an.ph @@ -0,0 +1,71 @@ +%PS_Helvetica_Narrow_Bold = ( + name => 'Helvetica-Narrow-Bold', + widths => { + "multiply" => 479, "Ntilde" => 592, "zero" => 456, "eth" => 501, + "Ograve" => 638, "uacute" => 501, "braceleft" => 319, + "Thorn" => 547, "zcaron" => 410, "comma" => 228, "cedilla" => 273, + "plusminus" => 479, "ccedilla" => 456, "circumflex" => 273, + "dotaccent" => 273, "asciitilde" => 479, "colon" => 273, + "onehalf" => 684, "dollar" => 456, "ntilde" => 501, + "Oacute" => 638, "Ocircumflex" => 638, "ogonek" => 273, + "ograve" => 501, "thorn" => 501, "degree" => 328, "minus" => 479, + "yen" => 456, "space" => 228, "registered" => 604, + "questiondown" => 501, "Aring" => 592, "percent" => 729, + "emdash" => 820, "six" => 456, "Agrave" => 592, "paragraph" => 456, + "three" => 456, "numbersign" => 456, "two" => 456, "Igrave" => 228, + "oacute" => 501, "ocircumflex" => 501, "A" => 592, "B" => 592, + "C" => 592, "D" => 592, "E" => 547, "onequarter" => 684, + "F" => 501, "G" => 638, "H" => 592, "I" => 228, "J" => 456, + "K" => 592, "L" => 501, "backslash" => 228, "asciicircum" => 479, + "periodcentered" => 228, "M" => 683, "N" => 592, "O" => 638, + "P" => 547, "aring" => 456, "Q" => 638, "R" => 592, + "Aacute" => 592, "caron" => 273, "S" => 547, "T" => 501, + "grave" => 273, "U" => 592, "agrave" => 456, "V" => 547, + "W" => 774, "equal" => 479, "question" => 501, "X" => 547, + "Y" => 547, "Z" => 501, "bracketright" => 273, "Iacute" => 228, + "ampersand" => 592, "four" => 456, "igrave" => 228, "a" => 456, + "b" => 501, "c" => 456, "d" => 501, "plus" => 479, "e" => 456, + "quotesinglbase" => 228, "f" => 273, "g" => 501, "bullet" => 287, + "h" => 501, "i" => 228, "Oslash" => 638, "dagger" => 456, + "j" => 228, "Yacute" => 547, "k" => 456, "l" => 228, "m" => 729, + "n" => 501, "o" => 501, "ordfeminine" => 303, "ring" => 273, + "p" => 501, "threesuperior" => 273, "q" => 501, "acute" => 273, + "r" => 319, "aacute" => 456, "twosuperior" => 273, "s" => 456, + "OE" => 820, "t" => 273, "divide" => 479, "section" => 456, + "u" => 501, "v" => 456, "w" => 638, "dieresis" => 273, "x" => 456, + "y" => 456, "z" => 410, "iacute" => 228, "quotedblbase" => 410, + "hungarumlaut" => 273, "quotedbl" => 389, "mu" => 501, + "Scaron" => 547, "Lslash" => 501, "semicolon" => 273, + "oslash" => 501, "florin" => 456, "yacute" => 456, "fi" => 501, + "fl" => 501, "Acircumflex" => 592, "parenright" => 273, + "Ecircumflex" => 547, "Icircumflex" => 228, "trademark" => 820, + "daggerdbl" => 456, "guillemotleft" => 456, "germandbls" => 501, + "macron" => 273, "Otilde" => 638, "seven" => 456, + "ellipsis" => 820, "scaron" => 456, "ordmasculine" => 299, + "AE" => 820, "Ucircumflex" => 592, "lslash" => 228, + "dotlessi" => 228, "sterling" => 456, "quotedblleft" => 410, + "hyphen" => 273, "guilsinglright" => 273, "quotesingle" => 195, + "eight" => 456, "exclamdown" => 273, "acircumflex" => 456, + "endash" => 456, "oe" => 774, "ecircumflex" => 456, + "Adieresis" => 592, "copyright" => 604, "Egrave" => 547, + "icircumflex" => 228, "slash" => 228, "braceright" => 319, + "Edieresis" => 547, "quotedblright" => 410, "Idieresis" => 228, + "otilde" => 501, "parenleft" => 273, "one" => 456, + "Odieresis" => 638, "ucircumflex" => 501, "bracketleft" => 273, + "Ugrave" => 592, "cent" => 456, "currency" => 456, + "logicalnot" => 479, "quoteright" => 228, "Udieresis" => 592, + "perthousand" => 820, "Ydieresis" => 547, "Atilde" => 592, + "breve" => 273, "bar" => 230, "fraction" => 137, "Eacute" => 547, + "less" => 479, "adieresis" => 456, "guilsinglleft" => 273, + "egrave" => 456, "exclam" => 273, "edieresis" => 456, + "idieresis" => 228, "Eth" => 592, "period" => 228, "ae" => 729, + "asterisk" => 319, "odieresis" => 501, "Uacute" => 592, + "ugrave" => 501, "five" => 456, "nine" => 456, "greater" => 479, + "udieresis" => 501, "Zcaron" => 501, "threequarters" => 684, + "guillemotright" => 456, "Ccedilla" => 592, "ydieresis" => 456, + "tilde" => 273, "atilde" => 456, "at" => 800, "brokenbar" => 230, + "eacute" => 456, "quoteleft" => 228, "underscore" => 456, + "onesuperior" => 273, + } +); +1; diff --git a/doc/metrics/phvbo8a.ph b/doc/metrics/phvbo8a.ph new file mode 100644 index 0000000..644a0f9 --- /dev/null +++ b/doc/metrics/phvbo8a.ph @@ -0,0 +1,72 @@ +%PS_Helvetica_BoldOblique = ( + name => 'Helvetica-BoldOblique', + widths => { + "multiply" => 584, "Ntilde" => 722, "zero" => 556, "eth" => 611, + "Ograve" => 778, "uacute" => 611, "braceleft" => 389, + "Thorn" => 667, "zcaron" => 500, "comma" => 278, "cedilla" => 333, + "plusminus" => 584, "ccedilla" => 556, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 584, "colon" => 333, + "onehalf" => 834, "dollar" => 556, "ntilde" => 611, + "Oacute" => 778, "Ocircumflex" => 778, "ogonek" => 333, + "ograve" => 611, "thorn" => 611, "degree" => 400, "minus" => 584, + "yen" => 556, "space" => 278, "registered" => 737, + "questiondown" => 611, "Aring" => 722, "percent" => 889, + "emdash" => 1000, "six" => 556, "Agrave" => 722, + "paragraph" => 556, "three" => 556, "numbersign" => 556, + "two" => 556, "Igrave" => 278, "oacute" => 611, + "ocircumflex" => 611, "A" => 722, "B" => 722, "C" => 722, + "D" => 722, "E" => 667, "onequarter" => 834, "F" => 611, + "G" => 778, "H" => 722, "I" => 278, "J" => 556, "K" => 722, + "L" => 611, "backslash" => 278, "asciicircum" => 584, + "periodcentered" => 278, "M" => 833, "N" => 722, "O" => 778, + "P" => 667, "aring" => 556, "Q" => 778, "R" => 722, + "Aacute" => 722, "caron" => 333, "S" => 667, "T" => 611, + "grave" => 333, "U" => 722, "agrave" => 556, "V" => 667, + "W" => 944, "equal" => 584, "question" => 611, "X" => 667, + "Y" => 667, "Z" => 611, "bracketright" => 333, "Iacute" => 278, + "ampersand" => 722, "four" => 556, "igrave" => 278, "a" => 556, + "b" => 611, "c" => 556, "d" => 611, "plus" => 584, "e" => 556, + "quotesinglbase" => 278, "f" => 333, "g" => 611, "bullet" => 350, + "h" => 611, "i" => 278, "Oslash" => 778, "dagger" => 556, + "j" => 278, "Yacute" => 667, "k" => 556, "l" => 278, "m" => 889, + "n" => 611, "o" => 611, "ordfeminine" => 370, "ring" => 333, + "p" => 611, "threesuperior" => 333, "q" => 611, "acute" => 333, + "r" => 389, "aacute" => 556, "twosuperior" => 333, "s" => 556, + "OE" => 1000, "t" => 333, "divide" => 584, "section" => 556, + "u" => 611, "v" => 556, "w" => 778, "dieresis" => 333, "x" => 556, + "y" => 556, "z" => 500, "iacute" => 278, "quotedblbase" => 500, + "hungarumlaut" => 333, "quotedbl" => 474, "mu" => 611, + "Scaron" => 667, "Lslash" => 611, "semicolon" => 333, + "oslash" => 611, "florin" => 556, "yacute" => 556, "fi" => 611, + "fl" => 611, "Acircumflex" => 722, "parenright" => 333, + "Ecircumflex" => 667, "Icircumflex" => 278, "trademark" => 1000, + "daggerdbl" => 556, "guillemotleft" => 556, "germandbls" => 611, + "macron" => 333, "Otilde" => 778, "seven" => 556, + "ellipsis" => 1000, "scaron" => 556, "ordmasculine" => 365, + "AE" => 1000, "Ucircumflex" => 722, "lslash" => 278, + "dotlessi" => 278, "sterling" => 556, "quotedblleft" => 500, + "hyphen" => 333, "guilsinglright" => 333, "quotesingle" => 238, + "eight" => 556, "exclamdown" => 333, "acircumflex" => 556, + "endash" => 556, "oe" => 944, "ecircumflex" => 556, + "Adieresis" => 722, "copyright" => 737, "Egrave" => 667, + "icircumflex" => 278, "slash" => 278, "braceright" => 389, + "Edieresis" => 667, "quotedblright" => 500, "Idieresis" => 278, + "otilde" => 611, "parenleft" => 333, "one" => 556, + "Odieresis" => 778, "ucircumflex" => 611, "bracketleft" => 333, + "Ugrave" => 722, "cent" => 556, "currency" => 556, + "logicalnot" => 584, "quoteright" => 278, "Udieresis" => 722, + "perthousand" => 1000, "Ydieresis" => 667, "Atilde" => 722, + "breve" => 333, "bar" => 280, "fraction" => 167, "Eacute" => 667, + "less" => 584, "adieresis" => 556, "guilsinglleft" => 333, + "egrave" => 556, "exclam" => 333, "edieresis" => 556, + "idieresis" => 278, "Eth" => 722, "period" => 278, "ae" => 889, + "asterisk" => 389, "odieresis" => 611, "Uacute" => 722, + "ugrave" => 611, "five" => 556, "nine" => 556, "greater" => 584, + "udieresis" => 611, "Zcaron" => 611, "threequarters" => 834, + "guillemotright" => 556, "Ccedilla" => 722, "ydieresis" => 556, + "tilde" => 333, "atilde" => 556, "at" => 975, "brokenbar" => 280, + "eacute" => 556, "quoteleft" => 278, "underscore" => 556, + "onesuperior" => 333, + } +); +1; diff --git a/doc/metrics/phvbo8an.ph b/doc/metrics/phvbo8an.ph new file mode 100644 index 0000000..6e8b448 --- /dev/null +++ b/doc/metrics/phvbo8an.ph @@ -0,0 +1,71 @@ +%PS_Helvetica_Narrow_BoldOblique = ( + name => 'Helvetica-Narrow-BoldOblique', + widths => { + "multiply" => 479, "Ntilde" => 592, "zero" => 456, "eth" => 501, + "Ograve" => 638, "uacute" => 501, "braceleft" => 319, + "Thorn" => 547, "zcaron" => 410, "comma" => 228, "cedilla" => 273, + "plusminus" => 479, "ccedilla" => 456, "circumflex" => 273, + "dotaccent" => 273, "asciitilde" => 479, "colon" => 273, + "onehalf" => 684, "dollar" => 456, "ntilde" => 501, + "Oacute" => 638, "Ocircumflex" => 638, "ogonek" => 273, + "ograve" => 501, "thorn" => 501, "degree" => 328, "minus" => 479, + "yen" => 456, "space" => 228, "registered" => 604, + "questiondown" => 501, "Aring" => 592, "percent" => 729, + "emdash" => 820, "six" => 456, "Agrave" => 592, "paragraph" => 456, + "three" => 456, "numbersign" => 456, "two" => 456, "Igrave" => 228, + "oacute" => 501, "ocircumflex" => 501, "A" => 592, "B" => 592, + "C" => 592, "D" => 592, "E" => 547, "onequarter" => 684, + "F" => 501, "G" => 638, "H" => 592, "I" => 228, "J" => 456, + "K" => 592, "L" => 501, "backslash" => 228, "asciicircum" => 479, + "periodcentered" => 228, "M" => 683, "N" => 592, "O" => 638, + "P" => 547, "aring" => 456, "Q" => 638, "R" => 592, + "Aacute" => 592, "caron" => 273, "S" => 547, "T" => 501, + "grave" => 273, "U" => 592, "agrave" => 456, "V" => 547, + "W" => 774, "equal" => 479, "question" => 501, "X" => 547, + "Y" => 547, "Z" => 501, "bracketright" => 273, "Iacute" => 228, + "ampersand" => 592, "four" => 456, "igrave" => 228, "a" => 456, + "b" => 501, "c" => 456, "d" => 501, "plus" => 479, "e" => 456, + "quotesinglbase" => 228, "f" => 273, "g" => 501, "bullet" => 287, + "h" => 501, "i" => 228, "Oslash" => 638, "dagger" => 456, + "j" => 228, "Yacute" => 547, "k" => 456, "l" => 228, "m" => 729, + "n" => 501, "o" => 501, "ordfeminine" => 303, "ring" => 273, + "p" => 501, "threesuperior" => 273, "q" => 501, "acute" => 273, + "r" => 319, "aacute" => 456, "twosuperior" => 273, "s" => 456, + "OE" => 820, "t" => 273, "divide" => 479, "section" => 456, + "u" => 501, "v" => 456, "w" => 638, "dieresis" => 273, "x" => 456, + "y" => 456, "z" => 410, "iacute" => 228, "quotedblbase" => 410, + "hungarumlaut" => 273, "quotedbl" => 389, "mu" => 501, + "Scaron" => 547, "Lslash" => 501, "semicolon" => 273, + "oslash" => 501, "florin" => 456, "yacute" => 456, "fi" => 501, + "fl" => 501, "Acircumflex" => 592, "parenright" => 273, + "Ecircumflex" => 547, "Icircumflex" => 228, "trademark" => 820, + "daggerdbl" => 456, "guillemotleft" => 456, "germandbls" => 501, + "macron" => 273, "Otilde" => 638, "seven" => 456, + "ellipsis" => 820, "scaron" => 456, "ordmasculine" => 299, + "AE" => 820, "Ucircumflex" => 592, "lslash" => 228, + "dotlessi" => 228, "sterling" => 456, "quotedblleft" => 410, + "hyphen" => 273, "guilsinglright" => 273, "quotesingle" => 195, + "eight" => 456, "exclamdown" => 273, "acircumflex" => 456, + "endash" => 456, "oe" => 774, "ecircumflex" => 456, + "Adieresis" => 592, "copyright" => 604, "Egrave" => 547, + "icircumflex" => 228, "slash" => 228, "braceright" => 319, + "Edieresis" => 547, "quotedblright" => 410, "Idieresis" => 228, + "otilde" => 501, "parenleft" => 273, "one" => 456, + "Odieresis" => 638, "ucircumflex" => 501, "bracketleft" => 273, + "Ugrave" => 592, "cent" => 456, "currency" => 456, + "logicalnot" => 479, "quoteright" => 228, "Udieresis" => 592, + "perthousand" => 820, "Ydieresis" => 547, "Atilde" => 592, + "breve" => 273, "bar" => 230, "fraction" => 137, "Eacute" => 547, + "less" => 479, "adieresis" => 456, "guilsinglleft" => 273, + "egrave" => 456, "exclam" => 273, "edieresis" => 456, + "idieresis" => 228, "Eth" => 592, "period" => 228, "ae" => 729, + "asterisk" => 319, "odieresis" => 501, "Uacute" => 592, + "ugrave" => 501, "five" => 456, "nine" => 456, "greater" => 479, + "udieresis" => 501, "Zcaron" => 501, "threequarters" => 684, + "guillemotright" => 456, "Ccedilla" => 592, "ydieresis" => 456, + "tilde" => 273, "atilde" => 456, "at" => 800, "brokenbar" => 230, + "eacute" => 456, "quoteleft" => 228, "underscore" => 456, + "onesuperior" => 273, + } +); +1; diff --git a/doc/metrics/phvl8a.ph b/doc/metrics/phvl8a.ph new file mode 100644 index 0000000..bcd1a18 --- /dev/null +++ b/doc/metrics/phvl8a.ph @@ -0,0 +1,72 @@ +%PS_Helvetica_Light = ( + name => 'Helvetica-Light', + widths => { + "multiply" => 660, "Ntilde" => 722, "zero" => 556, "eth" => 556, + "Ograve" => 778, "uacute" => 556, "braceleft" => 333, + "Thorn" => 611, "zcaron" => 500, "comma" => 278, "cedilla" => 333, + "plusminus" => 660, "ccedilla" => 556, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 660, "colon" => 278, + "onehalf" => 834, "dollar" => 556, "ntilde" => 556, + "Ocircumflex" => 778, "Oacute" => 778, "ogonek" => 333, + "ograve" => 556, "thorn" => 611, "minus" => 660, "degree" => 400, + "yen" => 556, "space" => 278, "registered" => 800, + "questiondown" => 500, "Aring" => 667, "percent" => 889, + "emdash" => 1000, "six" => 556, "Agrave" => 667, + "paragraph" => 650, "three" => 556, "numbersign" => 556, + "two" => 556, "Igrave" => 278, "ocircumflex" => 556, + "oacute" => 556, "A" => 667, "B" => 667, "C" => 722, "D" => 722, + "E" => 611, "onequarter" => 834, "F" => 556, "G" => 778, + "H" => 722, "I" => 278, "J" => 500, "K" => 667, "L" => 556, + "backslash" => 278, "asciicircum" => 660, "periodcentered" => 278, + "M" => 833, "N" => 722, "O" => 778, "P" => 611, "aring" => 556, + "Q" => 778, "R" => 667, "Aacute" => 667, "caron" => 333, + "S" => 611, "T" => 556, "grave" => 333, "U" => 722, + "agrave" => 556, "V" => 611, "W" => 889, "equal" => 660, + "question" => 500, "X" => 611, "Y" => 611, "Z" => 611, + "bracketright" => 333, "Iacute" => 278, "ampersand" => 667, + "four" => 556, "igrave" => 222, "a" => 556, "b" => 611, "c" => 556, + "d" => 611, "plus" => 660, "e" => 556, "quotesinglbase" => 222, + "f" => 278, "g" => 611, "bullet" => 500, "h" => 556, "i" => 222, + "Oslash" => 778, "dagger" => 556, "j" => 222, "Yacute" => 611, + "k" => 500, "l" => 222, "m" => 833, "n" => 556, "o" => 556, + "ordfeminine" => 334, "ring" => 333, "p" => 611, + "threesuperior" => 333, "q" => 611, "acute" => 333, "r" => 333, + "twosuperior" => 333, "aacute" => 556, "s" => 500, "OE" => 1000, + "t" => 278, "divide" => 660, "section" => 556, "u" => 556, + "v" => 500, "w" => 722, "dieresis" => 333, "x" => 500, "y" => 500, + "z" => 500, "iacute" => 222, "quotedblbase" => 389, + "hungarumlaut" => 333, "quotedbl" => 278, "mu" => 556, + "Scaron" => 611, "Lslash" => 556, "semicolon" => 278, + "oslash" => 556, "florin" => 556, "yacute" => 500, "fi" => 500, + "fl" => 500, "Acircumflex" => 667, "parenright" => 333, + "Ecircumflex" => 611, "trademark" => 940, "Icircumflex" => 278, + "daggerdbl" => 556, "guillemotleft" => 556, "germandbls" => 500, + "macron" => 333, "Otilde" => 778, "seven" => 556, + "ellipsis" => 1000, "scaron" => 500, "ordmasculine" => 334, + "AE" => 1000, "Ucircumflex" => 722, "lslash" => 222, + "dotlessi" => 222, "sterling" => 556, "quotedblleft" => 389, + "hyphen" => 333, "guilsinglright" => 389, "quotesingle" => 222, + "eight" => 556, "exclamdown" => 333, "acircumflex" => 556, + "endash" => 500, "oe" => 944, "ecircumflex" => 556, + "copyright" => 800, "Adieresis" => 667, "Egrave" => 611, + "icircumflex" => 222, "slash" => 278, "braceright" => 333, + "Edieresis" => 611, "quotedblright" => 389, "otilde" => 556, + "Idieresis" => 278, "parenleft" => 333, "one" => 556, + "ucircumflex" => 556, "Odieresis" => 778, "bracketleft" => 333, + "Ugrave" => 722, "cent" => 556, "currency" => 556, + "logicalnot" => 660, "quoteright" => 222, "Udieresis" => 722, + "perthousand" => 1000, "Ydieresis" => 611, "Atilde" => 667, + "breve" => 333, "bar" => 222, "fraction" => 167, "Eacute" => 611, + "less" => 660, "adieresis" => 556, "guilsinglleft" => 389, + "egrave" => 556, "exclam" => 333, "edieresis" => 556, + "idieresis" => 222, "Eth" => 722, "period" => 278, "ae" => 889, + "asterisk" => 389, "odieresis" => 556, "Uacute" => 722, + "ugrave" => 556, "five" => 556, "nine" => 556, "greater" => 660, + "udieresis" => 556, "Zcaron" => 611, "threequarters" => 834, + "guillemotright" => 556, "ydieresis" => 500, "Ccedilla" => 722, + "tilde" => 333, "atilde" => 556, "at" => 800, "brokenbar" => 222, + "eacute" => 556, "quoteleft" => 222, "underscore" => 500, + "onesuperior" => 333, + } +); +1; diff --git a/doc/metrics/phvlo8a.ph b/doc/metrics/phvlo8a.ph new file mode 100644 index 0000000..af45efd --- /dev/null +++ b/doc/metrics/phvlo8a.ph @@ -0,0 +1,72 @@ +%PS_Helvetica_LightOblique = ( + name => 'Helvetica-LightOblique', + widths => { + "multiply" => 660, "Ntilde" => 722, "zero" => 556, "eth" => 556, + "Ograve" => 778, "uacute" => 556, "braceleft" => 333, + "Thorn" => 611, "zcaron" => 500, "comma" => 278, "cedilla" => 333, + "plusminus" => 660, "ccedilla" => 556, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 660, "colon" => 278, + "onehalf" => 834, "dollar" => 556, "ntilde" => 556, + "Ocircumflex" => 778, "Oacute" => 778, "ogonek" => 333, + "ograve" => 556, "thorn" => 611, "minus" => 660, "degree" => 400, + "yen" => 556, "space" => 278, "registered" => 800, + "questiondown" => 500, "Aring" => 667, "percent" => 889, + "emdash" => 1000, "six" => 556, "Agrave" => 667, + "paragraph" => 650, "three" => 556, "numbersign" => 556, + "two" => 556, "Igrave" => 278, "ocircumflex" => 556, + "oacute" => 556, "A" => 667, "B" => 667, "C" => 722, "D" => 722, + "E" => 611, "onequarter" => 834, "F" => 556, "G" => 778, + "H" => 722, "I" => 278, "J" => 500, "K" => 667, "L" => 556, + "backslash" => 278, "asciicircum" => 660, "periodcentered" => 278, + "M" => 833, "N" => 722, "O" => 778, "P" => 611, "aring" => 556, + "Q" => 778, "R" => 667, "Aacute" => 667, "caron" => 333, + "S" => 611, "T" => 556, "grave" => 333, "U" => 722, + "agrave" => 556, "V" => 611, "W" => 889, "equal" => 660, + "question" => 500, "X" => 611, "Y" => 611, "Z" => 611, + "bracketright" => 333, "Iacute" => 278, "ampersand" => 667, + "four" => 556, "igrave" => 222, "a" => 556, "b" => 611, "c" => 556, + "d" => 611, "plus" => 660, "e" => 556, "quotesinglbase" => 222, + "f" => 278, "g" => 611, "bullet" => 500, "h" => 556, "i" => 222, + "Oslash" => 778, "dagger" => 556, "j" => 222, "Yacute" => 611, + "k" => 500, "l" => 222, "m" => 833, "n" => 556, "o" => 556, + "ordfeminine" => 334, "ring" => 333, "p" => 611, + "threesuperior" => 333, "q" => 611, "acute" => 333, "r" => 333, + "twosuperior" => 333, "aacute" => 556, "s" => 500, "OE" => 1000, + "t" => 278, "divide" => 660, "section" => 556, "u" => 556, + "v" => 500, "w" => 722, "dieresis" => 333, "x" => 500, "y" => 500, + "z" => 500, "iacute" => 222, "quotedblbase" => 389, + "hungarumlaut" => 333, "quotedbl" => 278, "mu" => 556, + "Scaron" => 611, "Lslash" => 556, "semicolon" => 278, + "oslash" => 556, "florin" => 556, "yacute" => 500, "fi" => 500, + "fl" => 500, "Acircumflex" => 667, "parenright" => 333, + "Ecircumflex" => 611, "trademark" => 940, "Icircumflex" => 278, + "daggerdbl" => 556, "guillemotleft" => 556, "germandbls" => 500, + "macron" => 333, "Otilde" => 778, "seven" => 556, + "ellipsis" => 1000, "scaron" => 500, "ordmasculine" => 334, + "AE" => 1000, "Ucircumflex" => 722, "lslash" => 222, + "dotlessi" => 222, "sterling" => 556, "quotedblleft" => 389, + "hyphen" => 333, "guilsinglright" => 389, "quotesingle" => 222, + "eight" => 556, "exclamdown" => 333, "acircumflex" => 556, + "endash" => 500, "oe" => 944, "ecircumflex" => 556, + "copyright" => 800, "Adieresis" => 667, "Egrave" => 611, + "icircumflex" => 222, "slash" => 278, "braceright" => 333, + "Edieresis" => 611, "quotedblright" => 389, "otilde" => 556, + "Idieresis" => 278, "parenleft" => 333, "one" => 556, + "ucircumflex" => 556, "Odieresis" => 778, "bracketleft" => 333, + "Ugrave" => 722, "cent" => 556, "currency" => 556, + "logicalnot" => 660, "quoteright" => 222, "Udieresis" => 722, + "perthousand" => 1000, "Ydieresis" => 611, "Atilde" => 667, + "breve" => 333, "bar" => 222, "fraction" => 167, "Eacute" => 611, + "less" => 660, "adieresis" => 556, "guilsinglleft" => 389, + "egrave" => 556, "exclam" => 333, "edieresis" => 556, + "idieresis" => 222, "Eth" => 722, "period" => 278, "ae" => 889, + "asterisk" => 389, "odieresis" => 556, "Uacute" => 722, + "ugrave" => 556, "five" => 556, "nine" => 556, "greater" => 660, + "udieresis" => 556, "Zcaron" => 611, "threequarters" => 834, + "guillemotright" => 556, "ydieresis" => 500, "Ccedilla" => 722, + "tilde" => 333, "atilde" => 556, "at" => 800, "brokenbar" => 222, + "eacute" => 556, "quoteleft" => 222, "underscore" => 500, + "onesuperior" => 333, + } +); +1; diff --git a/doc/metrics/phvr8a.ph b/doc/metrics/phvr8a.ph new file mode 100644 index 0000000..70dad5b --- /dev/null +++ b/doc/metrics/phvr8a.ph @@ -0,0 +1,72 @@ +%PS_Helvetica = ( + name => 'Helvetica', + widths => { + "multiply" => 584, "Ntilde" => 722, "zero" => 556, "eth" => 556, + "Ograve" => 778, "uacute" => 556, "braceleft" => 334, + "Thorn" => 667, "zcaron" => 500, "comma" => 278, "cedilla" => 333, + "plusminus" => 584, "ccedilla" => 500, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 584, "colon" => 278, + "onehalf" => 834, "dollar" => 556, "ntilde" => 556, + "Oacute" => 778, "Ocircumflex" => 778, "ogonek" => 333, + "ograve" => 556, "thorn" => 556, "degree" => 400, "minus" => 584, + "yen" => 556, "space" => 278, "registered" => 737, + "questiondown" => 611, "Aring" => 667, "percent" => 889, + "emdash" => 1000, "six" => 556, "Agrave" => 667, + "paragraph" => 537, "three" => 556, "numbersign" => 556, + "two" => 556, "Igrave" => 278, "oacute" => 556, + "ocircumflex" => 556, "A" => 667, "B" => 667, "C" => 722, + "D" => 722, "E" => 667, "onequarter" => 834, "F" => 611, + "G" => 778, "H" => 722, "I" => 278, "J" => 500, "K" => 667, + "L" => 556, "backslash" => 278, "asciicircum" => 469, + "periodcentered" => 278, "M" => 833, "N" => 722, "O" => 778, + "P" => 667, "aring" => 556, "Q" => 778, "R" => 722, + "Aacute" => 667, "caron" => 333, "S" => 667, "T" => 611, + "grave" => 333, "U" => 722, "agrave" => 556, "V" => 667, + "W" => 944, "equal" => 584, "question" => 556, "X" => 667, + "Y" => 667, "Z" => 611, "bracketright" => 278, "Iacute" => 278, + "ampersand" => 667, "four" => 556, "igrave" => 278, "a" => 556, + "b" => 556, "c" => 500, "d" => 556, "plus" => 584, "e" => 556, + "quotesinglbase" => 222, "f" => 278, "g" => 556, "bullet" => 350, + "h" => 556, "i" => 222, "Oslash" => 778, "dagger" => 556, + "j" => 222, "Yacute" => 667, "k" => 500, "l" => 222, "m" => 833, + "n" => 556, "o" => 556, "ordfeminine" => 370, "ring" => 333, + "p" => 556, "threesuperior" => 333, "q" => 556, "acute" => 333, + "r" => 333, "aacute" => 556, "twosuperior" => 333, "s" => 500, + "OE" => 1000, "t" => 278, "divide" => 584, "section" => 556, + "u" => 556, "v" => 500, "w" => 722, "dieresis" => 333, "x" => 500, + "y" => 500, "z" => 500, "iacute" => 278, "quotedblbase" => 333, + "hungarumlaut" => 333, "quotedbl" => 355, "mu" => 556, + "Scaron" => 667, "Lslash" => 556, "semicolon" => 278, + "oslash" => 611, "florin" => 556, "yacute" => 500, "fi" => 500, + "fl" => 500, "Acircumflex" => 667, "parenright" => 333, + "Ecircumflex" => 667, "Icircumflex" => 278, "trademark" => 1000, + "daggerdbl" => 556, "guillemotleft" => 556, "germandbls" => 611, + "macron" => 333, "Otilde" => 778, "seven" => 556, + "ellipsis" => 1000, "scaron" => 500, "ordmasculine" => 365, + "AE" => 1000, "Ucircumflex" => 722, "lslash" => 222, + "dotlessi" => 278, "sterling" => 556, "quotedblleft" => 333, + "hyphen" => 333, "guilsinglright" => 333, "quotesingle" => 191, + "eight" => 556, "exclamdown" => 333, "acircumflex" => 556, + "endash" => 556, "oe" => 944, "ecircumflex" => 556, + "Adieresis" => 667, "copyright" => 737, "Egrave" => 667, + "icircumflex" => 278, "slash" => 278, "braceright" => 334, + "Edieresis" => 667, "quotedblright" => 333, "Idieresis" => 278, + "otilde" => 556, "parenleft" => 333, "one" => 556, + "Odieresis" => 778, "ucircumflex" => 556, "bracketleft" => 278, + "Ugrave" => 722, "cent" => 556, "currency" => 556, + "logicalnot" => 584, "quoteright" => 222, "Udieresis" => 722, + "perthousand" => 1000, "Ydieresis" => 667, "Atilde" => 667, + "breve" => 333, "bar" => 260, "fraction" => 167, "Eacute" => 667, + "less" => 584, "adieresis" => 556, "guilsinglleft" => 333, + "egrave" => 556, "exclam" => 278, "edieresis" => 556, + "idieresis" => 278, "Eth" => 722, "period" => 278, "ae" => 889, + "asterisk" => 389, "odieresis" => 556, "Uacute" => 722, + "ugrave" => 556, "five" => 556, "nine" => 556, "greater" => 584, + "udieresis" => 556, "Zcaron" => 611, "threequarters" => 834, + "guillemotright" => 556, "Ccedilla" => 722, "ydieresis" => 500, + "tilde" => 333, "atilde" => 556, "at" => 1015, "brokenbar" => 260, + "eacute" => 556, "quoteleft" => 222, "underscore" => 556, + "onesuperior" => 333, + } +); +1; diff --git a/doc/metrics/phvr8an.ph b/doc/metrics/phvr8an.ph new file mode 100644 index 0000000..7112c03 --- /dev/null +++ b/doc/metrics/phvr8an.ph @@ -0,0 +1,71 @@ +%PS_Helvetica_Narrow = ( + name => 'Helvetica-Narrow', + widths => { + "multiply" => 479, "Ntilde" => 592, "zero" => 456, "eth" => 456, + "Ograve" => 638, "uacute" => 456, "braceleft" => 274, + "Thorn" => 547, "zcaron" => 410, "comma" => 228, "cedilla" => 273, + "plusminus" => 479, "ccedilla" => 410, "circumflex" => 273, + "dotaccent" => 273, "asciitilde" => 479, "colon" => 228, + "onehalf" => 684, "dollar" => 456, "ntilde" => 456, + "Oacute" => 638, "Ocircumflex" => 638, "ogonek" => 273, + "ograve" => 456, "thorn" => 456, "degree" => 328, "minus" => 479, + "yen" => 456, "space" => 228, "registered" => 604, + "questiondown" => 501, "Aring" => 547, "percent" => 729, + "emdash" => 820, "six" => 456, "Agrave" => 547, "paragraph" => 440, + "three" => 456, "numbersign" => 456, "two" => 456, "Igrave" => 228, + "oacute" => 456, "ocircumflex" => 456, "A" => 547, "B" => 547, + "C" => 592, "D" => 592, "E" => 547, "onequarter" => 684, + "F" => 501, "G" => 638, "H" => 592, "I" => 228, "J" => 410, + "K" => 547, "L" => 456, "backslash" => 228, "asciicircum" => 385, + "periodcentered" => 228, "M" => 683, "N" => 592, "O" => 638, + "P" => 547, "aring" => 456, "Q" => 638, "R" => 592, + "Aacute" => 547, "caron" => 273, "S" => 547, "T" => 501, + "grave" => 273, "U" => 592, "agrave" => 456, "V" => 547, + "W" => 774, "equal" => 479, "question" => 456, "X" => 547, + "Y" => 547, "Z" => 501, "bracketright" => 228, "Iacute" => 228, + "ampersand" => 547, "four" => 456, "igrave" => 228, "a" => 456, + "b" => 456, "c" => 410, "d" => 456, "plus" => 479, "e" => 456, + "quotesinglbase" => 182, "f" => 228, "g" => 456, "bullet" => 287, + "h" => 456, "i" => 182, "Oslash" => 638, "dagger" => 456, + "j" => 182, "Yacute" => 547, "k" => 410, "l" => 182, "m" => 683, + "n" => 456, "o" => 456, "ordfeminine" => 303, "ring" => 273, + "p" => 456, "threesuperior" => 273, "q" => 456, "acute" => 273, + "r" => 273, "aacute" => 456, "twosuperior" => 273, "s" => 410, + "OE" => 820, "t" => 228, "divide" => 479, "section" => 456, + "u" => 456, "v" => 410, "w" => 592, "dieresis" => 273, "x" => 410, + "y" => 410, "z" => 410, "iacute" => 228, "quotedblbase" => 273, + "hungarumlaut" => 273, "quotedbl" => 291, "mu" => 456, + "Scaron" => 547, "Lslash" => 456, "semicolon" => 228, + "oslash" => 501, "florin" => 456, "yacute" => 410, "fi" => 410, + "fl" => 410, "Acircumflex" => 547, "parenright" => 273, + "Ecircumflex" => 547, "Icircumflex" => 228, "trademark" => 820, + "daggerdbl" => 456, "guillemotleft" => 456, "germandbls" => 501, + "macron" => 273, "Otilde" => 638, "seven" => 456, + "ellipsis" => 820, "scaron" => 410, "ordmasculine" => 299, + "AE" => 820, "Ucircumflex" => 592, "lslash" => 182, + "dotlessi" => 228, "sterling" => 456, "quotedblleft" => 273, + "hyphen" => 273, "guilsinglright" => 273, "quotesingle" => 157, + "eight" => 456, "exclamdown" => 273, "acircumflex" => 456, + "endash" => 456, "oe" => 774, "ecircumflex" => 456, + "Adieresis" => 547, "copyright" => 604, "Egrave" => 547, + "icircumflex" => 228, "slash" => 228, "braceright" => 274, + "Edieresis" => 547, "quotedblright" => 273, "Idieresis" => 228, + "otilde" => 456, "parenleft" => 273, "one" => 456, + "Odieresis" => 638, "ucircumflex" => 456, "bracketleft" => 228, + "Ugrave" => 592, "cent" => 456, "currency" => 456, + "logicalnot" => 479, "quoteright" => 182, "Udieresis" => 592, + "perthousand" => 820, "Ydieresis" => 547, "Atilde" => 547, + "breve" => 273, "bar" => 213, "fraction" => 137, "Eacute" => 547, + "less" => 479, "adieresis" => 456, "guilsinglleft" => 273, + "egrave" => 456, "exclam" => 228, "edieresis" => 456, + "idieresis" => 228, "Eth" => 592, "period" => 228, "ae" => 729, + "asterisk" => 319, "odieresis" => 456, "Uacute" => 592, + "ugrave" => 456, "five" => 456, "nine" => 456, "greater" => 479, + "udieresis" => 456, "Zcaron" => 501, "threequarters" => 684, + "guillemotright" => 456, "Ccedilla" => 592, "ydieresis" => 410, + "tilde" => 273, "atilde" => 456, "at" => 832, "brokenbar" => 213, + "eacute" => 456, "quoteleft" => 182, "underscore" => 456, + "onesuperior" => 273, + } +); +1; diff --git a/doc/metrics/phvro8a.ph b/doc/metrics/phvro8a.ph new file mode 100644 index 0000000..010903e --- /dev/null +++ b/doc/metrics/phvro8a.ph @@ -0,0 +1,72 @@ +%PS_Helvetica_Oblique = ( + name => 'Helvetica-Oblique', + widths => { + "multiply" => 584, "Ntilde" => 722, "zero" => 556, "eth" => 556, + "Ograve" => 778, "uacute" => 556, "braceleft" => 334, + "Thorn" => 667, "zcaron" => 500, "comma" => 278, "cedilla" => 333, + "plusminus" => 584, "ccedilla" => 500, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 584, "colon" => 278, + "onehalf" => 834, "dollar" => 556, "ntilde" => 556, + "Oacute" => 778, "Ocircumflex" => 778, "ogonek" => 333, + "ograve" => 556, "thorn" => 556, "degree" => 400, "minus" => 584, + "yen" => 556, "space" => 278, "registered" => 737, + "questiondown" => 611, "Aring" => 667, "percent" => 889, + "emdash" => 1000, "six" => 556, "Agrave" => 667, + "paragraph" => 537, "three" => 556, "numbersign" => 556, + "two" => 556, "Igrave" => 278, "oacute" => 556, + "ocircumflex" => 556, "A" => 667, "B" => 667, "C" => 722, + "D" => 722, "E" => 667, "onequarter" => 834, "F" => 611, + "G" => 778, "H" => 722, "I" => 278, "J" => 500, "K" => 667, + "L" => 556, "backslash" => 278, "asciicircum" => 469, + "periodcentered" => 278, "M" => 833, "N" => 722, "O" => 778, + "P" => 667, "aring" => 556, "Q" => 778, "R" => 722, + "Aacute" => 667, "caron" => 333, "S" => 667, "T" => 611, + "grave" => 333, "U" => 722, "agrave" => 556, "V" => 667, + "W" => 944, "equal" => 584, "question" => 556, "X" => 667, + "Y" => 667, "Z" => 611, "bracketright" => 278, "Iacute" => 278, + "ampersand" => 667, "four" => 556, "igrave" => 278, "a" => 556, + "b" => 556, "c" => 500, "d" => 556, "plus" => 584, "e" => 556, + "quotesinglbase" => 222, "f" => 278, "g" => 556, "bullet" => 350, + "h" => 556, "i" => 222, "Oslash" => 778, "dagger" => 556, + "j" => 222, "Yacute" => 667, "k" => 500, "l" => 222, "m" => 833, + "n" => 556, "o" => 556, "ordfeminine" => 370, "ring" => 333, + "p" => 556, "threesuperior" => 333, "q" => 556, "acute" => 333, + "r" => 333, "aacute" => 556, "twosuperior" => 333, "s" => 500, + "OE" => 1000, "t" => 278, "divide" => 584, "section" => 556, + "u" => 556, "v" => 500, "w" => 722, "dieresis" => 333, "x" => 500, + "y" => 500, "z" => 500, "iacute" => 278, "quotedblbase" => 333, + "hungarumlaut" => 333, "quotedbl" => 355, "mu" => 556, + "Scaron" => 667, "Lslash" => 556, "semicolon" => 278, + "oslash" => 611, "florin" => 556, "yacute" => 500, "fi" => 500, + "fl" => 500, "Acircumflex" => 667, "parenright" => 333, + "Ecircumflex" => 667, "Icircumflex" => 278, "trademark" => 1000, + "daggerdbl" => 556, "guillemotleft" => 556, "germandbls" => 611, + "macron" => 333, "Otilde" => 778, "seven" => 556, + "ellipsis" => 1000, "scaron" => 500, "ordmasculine" => 365, + "AE" => 1000, "Ucircumflex" => 722, "lslash" => 222, + "dotlessi" => 278, "sterling" => 556, "quotedblleft" => 333, + "hyphen" => 333, "guilsinglright" => 333, "quotesingle" => 191, + "eight" => 556, "exclamdown" => 333, "acircumflex" => 556, + "endash" => 556, "oe" => 944, "ecircumflex" => 556, + "Adieresis" => 667, "copyright" => 737, "Egrave" => 667, + "icircumflex" => 278, "slash" => 278, "braceright" => 334, + "Edieresis" => 667, "quotedblright" => 333, "Idieresis" => 278, + "otilde" => 556, "parenleft" => 333, "one" => 556, + "Odieresis" => 778, "ucircumflex" => 556, "bracketleft" => 278, + "Ugrave" => 722, "cent" => 556, "currency" => 556, + "logicalnot" => 584, "quoteright" => 222, "Udieresis" => 722, + "perthousand" => 1000, "Ydieresis" => 667, "Atilde" => 667, + "breve" => 333, "bar" => 260, "fraction" => 167, "Eacute" => 667, + "less" => 584, "adieresis" => 556, "guilsinglleft" => 333, + "egrave" => 556, "exclam" => 278, "edieresis" => 556, + "idieresis" => 278, "Eth" => 722, "period" => 278, "ae" => 889, + "asterisk" => 389, "odieresis" => 556, "Uacute" => 722, + "ugrave" => 556, "five" => 556, "nine" => 556, "greater" => 584, + "udieresis" => 556, "Zcaron" => 611, "threequarters" => 834, + "guillemotright" => 556, "Ccedilla" => 722, "ydieresis" => 500, + "tilde" => 333, "atilde" => 556, "at" => 1015, "brokenbar" => 260, + "eacute" => 556, "quoteleft" => 222, "underscore" => 556, + "onesuperior" => 333, + } +); +1; diff --git a/doc/metrics/phvro8an.ph b/doc/metrics/phvro8an.ph new file mode 100644 index 0000000..717e18e --- /dev/null +++ b/doc/metrics/phvro8an.ph @@ -0,0 +1,71 @@ +%PS_Helvetica_Narrow_Oblique = ( + name => 'Helvetica-Narrow-Oblique', + widths => { + "multiply" => 479, "Ntilde" => 592, "zero" => 456, "eth" => 456, + "Ograve" => 638, "uacute" => 456, "braceleft" => 274, + "Thorn" => 547, "zcaron" => 410, "comma" => 228, "cedilla" => 273, + "plusminus" => 479, "ccedilla" => 410, "circumflex" => 273, + "dotaccent" => 273, "asciitilde" => 479, "colon" => 228, + "onehalf" => 684, "dollar" => 456, "ntilde" => 456, + "Oacute" => 638, "Ocircumflex" => 638, "ogonek" => 273, + "ograve" => 456, "thorn" => 456, "degree" => 328, "minus" => 479, + "yen" => 456, "space" => 228, "registered" => 604, + "questiondown" => 501, "Aring" => 547, "percent" => 729, + "emdash" => 820, "six" => 456, "Agrave" => 547, "paragraph" => 440, + "three" => 456, "numbersign" => 456, "two" => 456, "Igrave" => 228, + "oacute" => 456, "ocircumflex" => 456, "A" => 547, "B" => 547, + "C" => 592, "D" => 592, "E" => 547, "onequarter" => 684, + "F" => 501, "G" => 638, "H" => 592, "I" => 228, "J" => 410, + "K" => 547, "L" => 456, "backslash" => 228, "asciicircum" => 385, + "periodcentered" => 228, "M" => 683, "N" => 592, "O" => 638, + "P" => 547, "aring" => 456, "Q" => 638, "R" => 592, + "Aacute" => 547, "caron" => 273, "S" => 547, "T" => 501, + "grave" => 273, "U" => 592, "agrave" => 456, "V" => 547, + "W" => 774, "equal" => 479, "question" => 456, "X" => 547, + "Y" => 547, "Z" => 501, "bracketright" => 228, "Iacute" => 228, + "ampersand" => 547, "four" => 456, "igrave" => 228, "a" => 456, + "b" => 456, "c" => 410, "d" => 456, "plus" => 479, "e" => 456, + "quotesinglbase" => 182, "f" => 228, "g" => 456, "bullet" => 287, + "h" => 456, "i" => 182, "Oslash" => 638, "dagger" => 456, + "j" => 182, "Yacute" => 547, "k" => 410, "l" => 182, "m" => 683, + "n" => 456, "o" => 456, "ordfeminine" => 303, "ring" => 273, + "p" => 456, "threesuperior" => 273, "q" => 456, "acute" => 273, + "r" => 273, "aacute" => 456, "twosuperior" => 273, "s" => 410, + "OE" => 820, "t" => 228, "divide" => 479, "section" => 456, + "u" => 456, "v" => 410, "w" => 592, "dieresis" => 273, "x" => 410, + "y" => 410, "z" => 410, "iacute" => 228, "quotedblbase" => 273, + "hungarumlaut" => 273, "quotedbl" => 291, "mu" => 456, + "Scaron" => 547, "Lslash" => 456, "semicolon" => 228, + "oslash" => 501, "florin" => 456, "yacute" => 410, "fi" => 410, + "fl" => 410, "Acircumflex" => 547, "parenright" => 273, + "Ecircumflex" => 547, "Icircumflex" => 228, "trademark" => 820, + "daggerdbl" => 456, "guillemotleft" => 456, "germandbls" => 501, + "macron" => 273, "Otilde" => 638, "seven" => 456, + "ellipsis" => 820, "scaron" => 410, "ordmasculine" => 299, + "AE" => 820, "Ucircumflex" => 592, "lslash" => 182, + "dotlessi" => 228, "sterling" => 456, "quotedblleft" => 273, + "hyphen" => 273, "guilsinglright" => 273, "quotesingle" => 157, + "eight" => 456, "exclamdown" => 273, "acircumflex" => 456, + "endash" => 456, "oe" => 774, "ecircumflex" => 456, + "Adieresis" => 547, "copyright" => 604, "Egrave" => 547, + "icircumflex" => 228, "slash" => 228, "braceright" => 274, + "Edieresis" => 547, "quotedblright" => 273, "Idieresis" => 228, + "otilde" => 456, "parenleft" => 273, "one" => 456, + "Odieresis" => 638, "ucircumflex" => 456, "bracketleft" => 228, + "Ugrave" => 592, "cent" => 456, "currency" => 456, + "logicalnot" => 479, "quoteright" => 182, "Udieresis" => 592, + "perthousand" => 820, "Ydieresis" => 547, "Atilde" => 547, + "breve" => 273, "bar" => 213, "fraction" => 137, "Eacute" => 547, + "less" => 479, "adieresis" => 456, "guilsinglleft" => 273, + "egrave" => 456, "exclam" => 228, "edieresis" => 456, + "idieresis" => 228, "Eth" => 592, "period" => 228, "ae" => 729, + "asterisk" => 319, "odieresis" => 456, "Uacute" => 592, + "ugrave" => 456, "five" => 456, "nine" => 456, "greater" => 479, + "udieresis" => 456, "Zcaron" => 501, "threequarters" => 684, + "guillemotright" => 456, "Ccedilla" => 592, "ydieresis" => 410, + "tilde" => 273, "atilde" => 456, "at" => 832, "brokenbar" => 213, + "eacute" => 456, "quoteleft" => 182, "underscore" => 456, + "onesuperior" => 273, + } +); +1; diff --git a/doc/metrics/pncb8a.ph b/doc/metrics/pncb8a.ph new file mode 100644 index 0000000..009ab6d --- /dev/null +++ b/doc/metrics/pncb8a.ph @@ -0,0 +1,72 @@ +%PS_NewCenturySchlbk_Bold = ( + name => 'NewCenturySchlbk-Bold', + widths => { + "multiply" => 606, "Ntilde" => 833, "zero" => 574, "eth" => 611, + "Ograve" => 833, "uacute" => 685, "braceleft" => 389, + "Thorn" => 759, "zcaron" => 537, "comma" => 278, "cedilla" => 333, + "plusminus" => 606, "ccedilla" => 556, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 606, "colon" => 278, + "onehalf" => 861, "dollar" => 574, "ntilde" => 685, + "Ocircumflex" => 833, "Oacute" => 833, "ogonek" => 333, + "ograve" => 611, "thorn" => 667, "minus" => 606, "degree" => 400, + "yen" => 574, "space" => 287, "registered" => 747, + "questiondown" => 500, "Aring" => 759, "percent" => 833, + "emdash" => 1000, "six" => 574, "Agrave" => 759, + "paragraph" => 747, "three" => 574, "numbersign" => 574, + "two" => 574, "Igrave" => 444, "oacute" => 611, + "ocircumflex" => 611, "A" => 759, "B" => 778, "C" => 778, + "D" => 833, "E" => 759, "onequarter" => 861, "F" => 722, + "G" => 833, "H" => 870, "I" => 444, "J" => 648, "K" => 815, + "L" => 722, "backslash" => 606, "asciicircum" => 606, + "periodcentered" => 278, "M" => 981, "N" => 833, "O" => 833, + "P" => 759, "aring" => 611, "Q" => 833, "R" => 815, + "Aacute" => 759, "caron" => 333, "S" => 667, "T" => 722, + "grave" => 333, "U" => 833, "agrave" => 611, "V" => 759, + "W" => 981, "equal" => 606, "question" => 500, "X" => 722, + "Y" => 722, "Z" => 667, "bracketright" => 389, "Iacute" => 444, + "ampersand" => 852, "four" => 574, "igrave" => 370, "a" => 611, + "b" => 648, "c" => 556, "d" => 667, "plus" => 606, "e" => 574, + "quotesinglbase" => 241, "f" => 389, "g" => 611, "bullet" => 606, + "h" => 685, "i" => 370, "Oslash" => 833, "dagger" => 500, + "j" => 352, "Yacute" => 722, "k" => 667, "l" => 352, "m" => 963, + "n" => 685, "o" => 611, "ordfeminine" => 367, "ring" => 333, + "p" => 667, "threesuperior" => 344, "q" => 648, "acute" => 333, + "r" => 519, "twosuperior" => 344, "aacute" => 611, "s" => 500, + "OE" => 1000, "t" => 426, "divide" => 606, "section" => 500, + "u" => 685, "v" => 611, "w" => 889, "dieresis" => 333, "x" => 611, + "y" => 611, "z" => 537, "iacute" => 370, "quotedblbase" => 481, + "hungarumlaut" => 333, "quotedbl" => 333, "mu" => 685, + "Scaron" => 667, "Lslash" => 722, "semicolon" => 278, + "oslash" => 611, "florin" => 574, "yacute" => 611, "fi" => 685, + "fl" => 685, "Acircumflex" => 759, "parenright" => 389, + "Ecircumflex" => 759, "trademark" => 1000, "Icircumflex" => 444, + "daggerdbl" => 500, "guillemotleft" => 500, "germandbls" => 611, + "macron" => 333, "Otilde" => 833, "seven" => 574, + "ellipsis" => 1000, "scaron" => 500, "ordmasculine" => 367, + "AE" => 981, "Ucircumflex" => 833, "lslash" => 352, + "dotlessi" => 370, "sterling" => 574, "quotedblleft" => 481, + "hyphen" => 333, "guilsinglright" => 333, "quotesingle" => 241, + "eight" => 574, "exclamdown" => 296, "acircumflex" => 611, + "endash" => 500, "oe" => 907, "ecircumflex" => 574, + "copyright" => 747, "Adieresis" => 759, "Egrave" => 759, + "icircumflex" => 370, "slash" => 278, "braceright" => 389, + "Edieresis" => 759, "quotedblright" => 481, "otilde" => 611, + "Idieresis" => 444, "parenleft" => 389, "one" => 574, + "Odieresis" => 833, "ucircumflex" => 685, "bracketleft" => 389, + "Ugrave" => 833, "cent" => 574, "currency" => 574, + "logicalnot" => 606, "quoteright" => 241, "Udieresis" => 833, + "perthousand" => 1000, "Ydieresis" => 722, "Atilde" => 759, + "breve" => 333, "bar" => 606, "fraction" => 167, "Eacute" => 759, + "less" => 606, "adieresis" => 611, "guilsinglleft" => 333, + "egrave" => 574, "exclam" => 296, "edieresis" => 574, "Eth" => 833, + "idieresis" => 370, "period" => 278, "ae" => 870, + "asterisk" => 500, "odieresis" => 611, "Uacute" => 833, + "ugrave" => 685, "five" => 574, "nine" => 574, "greater" => 606, + "Zcaron" => 667, "udieresis" => 685, "threequarters" => 861, + "guillemotright" => 500, "Ccedilla" => 778, "ydieresis" => 611, + "tilde" => 333, "atilde" => 611, "at" => 747, "brokenbar" => 606, + "eacute" => 574, "quoteleft" => 241, "underscore" => 500, + "onesuperior" => 344, + } +); +1; diff --git a/doc/metrics/pncbi8a.ph b/doc/metrics/pncbi8a.ph new file mode 100644 index 0000000..76ce18b --- /dev/null +++ b/doc/metrics/pncbi8a.ph @@ -0,0 +1,72 @@ +%PS_NewCenturySchlbk_BoldItalic = ( + name => 'NewCenturySchlbk-BoldItalic', + widths => { + "multiply" => 606, "Ntilde" => 852, "zero" => 574, "eth" => 574, + "Ograve" => 833, "uacute" => 685, "braceleft" => 407, + "Thorn" => 741, "zcaron" => 519, "comma" => 287, "cedilla" => 333, + "plusminus" => 606, "ccedilla" => 537, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 606, "colon" => 287, + "onehalf" => 861, "dollar" => 574, "ntilde" => 685, + "Ocircumflex" => 833, "Oacute" => 833, "ogonek" => 333, + "ograve" => 574, "thorn" => 648, "minus" => 606, "degree" => 400, + "yen" => 574, "space" => 287, "registered" => 747, + "questiondown" => 481, "Aring" => 741, "percent" => 889, + "emdash" => 1000, "six" => 574, "Agrave" => 741, + "paragraph" => 650, "three" => 574, "numbersign" => 574, + "two" => 574, "Igrave" => 444, "oacute" => 574, + "ocircumflex" => 574, "A" => 741, "B" => 759, "C" => 759, + "D" => 833, "E" => 741, "onequarter" => 861, "F" => 704, + "G" => 815, "H" => 870, "I" => 444, "J" => 667, "K" => 778, + "L" => 704, "backslash" => 606, "asciicircum" => 606, + "periodcentered" => 287, "M" => 944, "N" => 852, "O" => 833, + "P" => 741, "aring" => 667, "Q" => 833, "R" => 796, + "Aacute" => 741, "caron" => 333, "S" => 685, "T" => 722, + "grave" => 333, "U" => 833, "agrave" => 667, "V" => 741, + "W" => 944, "equal" => 606, "question" => 481, "X" => 741, + "Y" => 704, "Z" => 704, "bracketright" => 407, "Iacute" => 444, + "ampersand" => 889, "four" => 574, "igrave" => 389, "a" => 667, + "b" => 611, "c" => 537, "d" => 667, "plus" => 606, "e" => 519, + "quotesinglbase" => 259, "f" => 389, "g" => 611, "bullet" => 606, + "h" => 685, "i" => 389, "Oslash" => 833, "dagger" => 500, + "j" => 370, "Yacute" => 704, "k" => 648, "l" => 389, "m" => 944, + "n" => 685, "o" => 574, "ordfeminine" => 412, "ring" => 333, + "p" => 648, "threesuperior" => 344, "q" => 630, "acute" => 333, + "r" => 519, "twosuperior" => 344, "aacute" => 667, "s" => 481, + "OE" => 963, "t" => 407, "divide" => 606, "section" => 500, + "u" => 685, "v" => 556, "w" => 833, "dieresis" => 333, "x" => 574, + "y" => 519, "z" => 519, "iacute" => 389, "quotedblbase" => 481, + "hungarumlaut" => 333, "quotedbl" => 400, "mu" => 685, + "Scaron" => 685, "Lslash" => 704, "semicolon" => 287, + "oslash" => 574, "florin" => 574, "yacute" => 519, "fi" => 685, + "fl" => 685, "Acircumflex" => 741, "parenright" => 407, + "Ecircumflex" => 741, "trademark" => 950, "Icircumflex" => 444, + "daggerdbl" => 500, "guillemotleft" => 481, "germandbls" => 574, + "macron" => 333, "Otilde" => 833, "seven" => 574, + "ellipsis" => 1000, "scaron" => 481, "ordmasculine" => 356, + "AE" => 889, "Ucircumflex" => 833, "lslash" => 389, + "dotlessi" => 389, "sterling" => 574, "quotedblleft" => 481, + "hyphen" => 333, "guilsinglright" => 278, "quotesingle" => 287, + "eight" => 574, "exclamdown" => 333, "acircumflex" => 667, + "endash" => 500, "oe" => 852, "ecircumflex" => 519, + "copyright" => 747, "Adieresis" => 741, "Egrave" => 741, + "icircumflex" => 389, "slash" => 278, "braceright" => 407, + "Edieresis" => 741, "quotedblright" => 481, "otilde" => 574, + "Idieresis" => 444, "parenleft" => 407, "one" => 574, + "Odieresis" => 833, "ucircumflex" => 685, "bracketleft" => 407, + "Ugrave" => 833, "cent" => 574, "currency" => 574, + "logicalnot" => 606, "quoteright" => 259, "Udieresis" => 833, + "perthousand" => 1167, "Ydieresis" => 704, "Atilde" => 741, + "breve" => 333, "bar" => 606, "fraction" => 167, "Eacute" => 741, + "less" => 606, "adieresis" => 667, "guilsinglleft" => 278, + "egrave" => 519, "exclam" => 333, "edieresis" => 519, "Eth" => 833, + "idieresis" => 389, "period" => 287, "ae" => 815, + "asterisk" => 500, "odieresis" => 574, "Uacute" => 833, + "ugrave" => 685, "five" => 574, "nine" => 574, "greater" => 606, + "Zcaron" => 704, "udieresis" => 685, "threequarters" => 861, + "guillemotright" => 481, "Ccedilla" => 759, "ydieresis" => 519, + "tilde" => 333, "atilde" => 667, "at" => 747, "brokenbar" => 606, + "eacute" => 519, "quoteleft" => 259, "underscore" => 500, + "onesuperior" => 344, + } +); +1; diff --git a/doc/metrics/pncr8a.ph b/doc/metrics/pncr8a.ph new file mode 100644 index 0000000..d42c2f9 --- /dev/null +++ b/doc/metrics/pncr8a.ph @@ -0,0 +1,72 @@ +%PS_NewCenturySchlbk_Roman = ( + name => 'NewCenturySchlbk-Roman', + widths => { + "multiply" => 606, "Ntilde" => 815, "zero" => 556, "eth" => 500, + "Ograve" => 778, "uacute" => 611, "braceleft" => 333, + "Thorn" => 667, "zcaron" => 481, "comma" => 278, "cedilla" => 333, + "plusminus" => 606, "ccedilla" => 444, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 606, "colon" => 278, + "onehalf" => 834, "dollar" => 556, "ntilde" => 611, + "Ocircumflex" => 778, "Oacute" => 778, "ogonek" => 333, + "ograve" => 500, "thorn" => 574, "minus" => 606, "degree" => 400, + "yen" => 556, "space" => 278, "registered" => 737, + "questiondown" => 444, "Aring" => 722, "percent" => 833, + "emdash" => 1000, "six" => 556, "Agrave" => 722, + "paragraph" => 606, "three" => 556, "numbersign" => 556, + "two" => 556, "Igrave" => 407, "oacute" => 500, + "ocircumflex" => 500, "A" => 722, "B" => 722, "C" => 722, + "D" => 778, "E" => 722, "onequarter" => 834, "F" => 667, + "G" => 778, "H" => 833, "I" => 407, "J" => 556, "K" => 778, + "L" => 667, "backslash" => 606, "asciicircum" => 606, + "periodcentered" => 278, "M" => 944, "N" => 815, "O" => 778, + "P" => 667, "aring" => 556, "Q" => 778, "R" => 722, + "Aacute" => 722, "caron" => 333, "S" => 630, "T" => 667, + "grave" => 333, "U" => 815, "agrave" => 556, "V" => 722, + "W" => 981, "equal" => 606, "question" => 444, "X" => 704, + "Y" => 704, "Z" => 611, "bracketright" => 333, "Iacute" => 407, + "ampersand" => 815, "four" => 556, "igrave" => 315, "a" => 556, + "b" => 556, "c" => 444, "d" => 574, "plus" => 606, "e" => 500, + "quotesinglbase" => 204, "f" => 333, "g" => 537, "bullet" => 606, + "h" => 611, "i" => 315, "Oslash" => 778, "dagger" => 500, + "j" => 296, "Yacute" => 704, "k" => 593, "l" => 315, "m" => 889, + "n" => 611, "o" => 500, "ordfeminine" => 334, "ring" => 333, + "p" => 574, "threesuperior" => 333, "q" => 556, "acute" => 333, + "r" => 444, "twosuperior" => 333, "aacute" => 556, "s" => 463, + "OE" => 1000, "t" => 389, "divide" => 606, "section" => 500, + "u" => 611, "v" => 537, "w" => 778, "dieresis" => 333, "x" => 537, + "y" => 537, "z" => 481, "iacute" => 315, "quotedblbase" => 389, + "hungarumlaut" => 333, "quotedbl" => 389, "mu" => 611, + "Scaron" => 630, "Lslash" => 667, "semicolon" => 278, + "oslash" => 500, "florin" => 556, "yacute" => 537, "fi" => 611, + "fl" => 611, "Acircumflex" => 722, "parenright" => 333, + "Ecircumflex" => 722, "trademark" => 1000, "Icircumflex" => 407, + "daggerdbl" => 500, "guillemotleft" => 426, "germandbls" => 574, + "macron" => 333, "Otilde" => 778, "seven" => 556, + "ellipsis" => 1000, "scaron" => 463, "ordmasculine" => 300, + "AE" => 1000, "Ucircumflex" => 815, "lslash" => 315, + "dotlessi" => 315, "sterling" => 556, "quotedblleft" => 389, + "hyphen" => 333, "guilsinglright" => 259, "quotesingle" => 204, + "eight" => 556, "exclamdown" => 296, "acircumflex" => 556, + "endash" => 556, "oe" => 833, "ecircumflex" => 500, + "copyright" => 737, "Adieresis" => 722, "Egrave" => 722, + "icircumflex" => 315, "slash" => 278, "braceright" => 333, + "Edieresis" => 722, "quotedblright" => 389, "otilde" => 500, + "Idieresis" => 407, "parenleft" => 333, "one" => 556, + "Odieresis" => 778, "ucircumflex" => 611, "bracketleft" => 333, + "Ugrave" => 815, "cent" => 556, "currency" => 556, + "logicalnot" => 606, "quoteright" => 204, "Udieresis" => 815, + "perthousand" => 1000, "Ydieresis" => 704, "Atilde" => 722, + "breve" => 333, "bar" => 606, "fraction" => 167, "Eacute" => 722, + "less" => 606, "adieresis" => 556, "guilsinglleft" => 259, + "egrave" => 500, "exclam" => 296, "edieresis" => 500, "Eth" => 778, + "idieresis" => 315, "period" => 278, "ae" => 796, + "asterisk" => 500, "odieresis" => 500, "Uacute" => 815, + "ugrave" => 611, "five" => 556, "nine" => 556, "greater" => 606, + "Zcaron" => 611, "udieresis" => 611, "threequarters" => 834, + "guillemotright" => 426, "Ccedilla" => 722, "ydieresis" => 537, + "tilde" => 333, "atilde" => 556, "at" => 737, "brokenbar" => 606, + "eacute" => 500, "quoteleft" => 204, "underscore" => 500, + "onesuperior" => 333, + } +); +1; diff --git a/doc/metrics/pncri8a.ph b/doc/metrics/pncri8a.ph new file mode 100644 index 0000000..c4c700f --- /dev/null +++ b/doc/metrics/pncri8a.ph @@ -0,0 +1,72 @@ +%PS_NewCenturySchlbk_Italic = ( + name => 'NewCenturySchlbk-Italic', + widths => { + "multiply" => 606, "Ntilde" => 815, "zero" => 556, "eth" => 500, + "Ograve" => 778, "uacute" => 611, "braceleft" => 333, + "Thorn" => 667, "zcaron" => 463, "comma" => 278, "cedilla" => 333, + "plusminus" => 606, "ccedilla" => 444, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 606, "colon" => 278, + "onehalf" => 834, "dollar" => 556, "ntilde" => 611, + "Ocircumflex" => 778, "Oacute" => 778, "ogonek" => 333, + "ograve" => 500, "thorn" => 574, "minus" => 606, "degree" => 400, + "yen" => 556, "space" => 278, "registered" => 747, + "questiondown" => 444, "Aring" => 704, "percent" => 833, + "emdash" => 1000, "six" => 556, "Agrave" => 704, + "paragraph" => 650, "three" => 556, "numbersign" => 556, + "two" => 556, "Igrave" => 407, "oacute" => 500, + "ocircumflex" => 500, "A" => 704, "B" => 722, "C" => 722, + "D" => 778, "E" => 722, "onequarter" => 834, "F" => 667, + "G" => 778, "H" => 833, "I" => 407, "J" => 611, "K" => 741, + "L" => 667, "backslash" => 606, "asciicircum" => 606, + "periodcentered" => 278, "M" => 944, "N" => 815, "O" => 778, + "P" => 667, "aring" => 574, "Q" => 778, "R" => 741, + "Aacute" => 704, "caron" => 333, "S" => 667, "T" => 685, + "grave" => 333, "U" => 815, "agrave" => 574, "V" => 704, + "W" => 926, "equal" => 606, "question" => 444, "X" => 704, + "Y" => 685, "Z" => 667, "bracketright" => 333, "Iacute" => 407, + "ampersand" => 852, "four" => 556, "igrave" => 333, "a" => 574, + "b" => 556, "c" => 444, "d" => 611, "plus" => 606, "e" => 444, + "quotesinglbase" => 204, "f" => 333, "g" => 537, "bullet" => 606, + "h" => 611, "i" => 333, "Oslash" => 778, "dagger" => 500, + "j" => 315, "Yacute" => 685, "k" => 556, "l" => 333, "m" => 889, + "n" => 611, "o" => 500, "ordfeminine" => 422, "ring" => 333, + "p" => 574, "threesuperior" => 333, "q" => 556, "acute" => 333, + "r" => 444, "twosuperior" => 333, "aacute" => 574, "s" => 444, + "OE" => 981, "t" => 352, "divide" => 606, "section" => 500, + "u" => 611, "v" => 519, "w" => 778, "dieresis" => 333, "x" => 500, + "y" => 500, "z" => 463, "iacute" => 333, "quotedblbase" => 389, + "hungarumlaut" => 333, "quotedbl" => 400, "mu" => 611, + "Scaron" => 667, "Lslash" => 667, "semicolon" => 278, + "oslash" => 500, "florin" => 556, "yacute" => 500, "fi" => 611, + "fl" => 611, "Acircumflex" => 704, "parenright" => 333, + "Ecircumflex" => 722, "trademark" => 950, "Icircumflex" => 407, + "daggerdbl" => 500, "guillemotleft" => 426, "germandbls" => 556, + "macron" => 333, "Otilde" => 778, "seven" => 556, + "ellipsis" => 1000, "scaron" => 444, "ordmasculine" => 372, + "AE" => 870, "Ucircumflex" => 815, "lslash" => 333, + "dotlessi" => 333, "sterling" => 556, "quotedblleft" => 389, + "hyphen" => 333, "guilsinglright" => 333, "quotesingle" => 278, + "eight" => 556, "exclamdown" => 333, "acircumflex" => 574, + "endash" => 500, "oe" => 778, "ecircumflex" => 444, + "copyright" => 747, "Adieresis" => 704, "Egrave" => 722, + "icircumflex" => 333, "slash" => 606, "braceright" => 333, + "Edieresis" => 722, "quotedblright" => 389, "otilde" => 500, + "Idieresis" => 407, "parenleft" => 333, "one" => 556, + "Odieresis" => 778, "ucircumflex" => 611, "bracketleft" => 333, + "Ugrave" => 815, "cent" => 556, "currency" => 556, + "logicalnot" => 606, "quoteright" => 204, "Udieresis" => 815, + "perthousand" => 1000, "Ydieresis" => 685, "Atilde" => 704, + "breve" => 333, "bar" => 606, "fraction" => 167, "Eacute" => 722, + "less" => 606, "adieresis" => 574, "guilsinglleft" => 333, + "egrave" => 444, "exclam" => 333, "edieresis" => 444, "Eth" => 778, + "idieresis" => 333, "period" => 278, "ae" => 722, + "asterisk" => 500, "odieresis" => 500, "Uacute" => 815, + "ugrave" => 611, "five" => 556, "nine" => 556, "greater" => 606, + "Zcaron" => 667, "udieresis" => 611, "threequarters" => 834, + "guillemotright" => 426, "Ccedilla" => 722, "ydieresis" => 500, + "tilde" => 333, "atilde" => 574, "at" => 747, "brokenbar" => 606, + "eacute" => 444, "quoteleft" => 204, "underscore" => 500, + "onesuperior" => 333, + } +); +1; diff --git a/doc/metrics/pplb8a.ph b/doc/metrics/pplb8a.ph new file mode 100644 index 0000000..c624356 --- /dev/null +++ b/doc/metrics/pplb8a.ph @@ -0,0 +1,72 @@ +%PS_Palatino_Bold = ( + name => 'Palatino-Bold', + widths => { + "multiply" => 606, "Ntilde" => 833, "zero" => 500, "eth" => 556, + "Ograve" => 833, "uacute" => 611, "braceleft" => 310, + "Thorn" => 611, "zcaron" => 500, "comma" => 250, "cedilla" => 333, + "plusminus" => 606, "ccedilla" => 444, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 606, "colon" => 250, + "onehalf" => 750, "dollar" => 500, "ntilde" => 611, + "Oacute" => 833, "Ocircumflex" => 833, "ogonek" => 333, + "ograve" => 556, "thorn" => 611, "degree" => 400, "minus" => 606, + "yen" => 500, "space" => 250, "registered" => 747, + "questiondown" => 444, "Aring" => 778, "percent" => 889, + "emdash" => 1000, "six" => 500, "Agrave" => 778, + "paragraph" => 641, "three" => 500, "numbersign" => 500, + "two" => 500, "Igrave" => 389, "oacute" => 556, + "ocircumflex" => 556, "A" => 778, "B" => 667, "C" => 722, + "D" => 833, "E" => 611, "onequarter" => 750, "F" => 556, + "G" => 833, "H" => 833, "I" => 389, "J" => 389, "K" => 778, + "L" => 611, "backslash" => 606, "asciicircum" => 606, + "periodcentered" => 250, "M" => 1000, "N" => 833, "O" => 833, + "P" => 611, "aring" => 500, "Q" => 833, "R" => 722, + "Aacute" => 778, "caron" => 333, "S" => 611, "T" => 667, + "grave" => 333, "U" => 778, "agrave" => 500, "V" => 778, + "W" => 1000, "equal" => 606, "question" => 444, "X" => 667, + "Y" => 667, "Z" => 667, "bracketright" => 333, "Iacute" => 389, + "ampersand" => 833, "four" => 500, "igrave" => 333, "a" => 500, + "b" => 611, "c" => 444, "d" => 611, "plus" => 606, "e" => 500, + "quotesinglbase" => 333, "f" => 389, "g" => 556, "bullet" => 606, + "h" => 611, "i" => 333, "Oslash" => 833, "dagger" => 500, + "j" => 333, "Yacute" => 667, "k" => 611, "l" => 333, "m" => 889, + "n" => 611, "o" => 556, "ordfeminine" => 438, "ring" => 333, + "p" => 611, "threesuperior" => 300, "q" => 611, "acute" => 333, + "r" => 389, "aacute" => 500, "twosuperior" => 300, "s" => 444, + "OE" => 1000, "t" => 333, "divide" => 606, "section" => 500, + "u" => 611, "v" => 556, "w" => 833, "dieresis" => 333, "x" => 500, + "y" => 556, "z" => 500, "iacute" => 333, "quotedblbase" => 500, + "hungarumlaut" => 333, "quotedbl" => 402, "mu" => 611, + "Scaron" => 611, "Lslash" => 611, "semicolon" => 250, + "oslash" => 556, "florin" => 500, "yacute" => 556, "fi" => 611, + "fl" => 611, "Acircumflex" => 778, "parenright" => 333, + "Ecircumflex" => 611, "Icircumflex" => 389, "trademark" => 998, + "daggerdbl" => 500, "guillemotleft" => 500, "germandbls" => 611, + "macron" => 333, "Otilde" => 833, "seven" => 500, + "ellipsis" => 1000, "scaron" => 444, "ordmasculine" => 488, + "AE" => 1000, "Ucircumflex" => 778, "lslash" => 333, + "dotlessi" => 333, "sterling" => 500, "quotedblleft" => 500, + "hyphen" => 333, "guilsinglright" => 389, "quotesingle" => 227, + "eight" => 500, "exclamdown" => 278, "acircumflex" => 500, + "endash" => 500, "oe" => 833, "ecircumflex" => 500, + "Adieresis" => 778, "copyright" => 747, "Egrave" => 611, + "icircumflex" => 333, "slash" => 296, "braceright" => 310, + "Edieresis" => 611, "quotedblright" => 500, "Idieresis" => 389, + "otilde" => 556, "parenleft" => 333, "one" => 500, + "Odieresis" => 833, "ucircumflex" => 611, "bracketleft" => 333, + "Ugrave" => 778, "cent" => 500, "currency" => 500, + "logicalnot" => 606, "quoteright" => 278, "Udieresis" => 778, + "perthousand" => 1000, "Ydieresis" => 667, "Atilde" => 778, + "breve" => 333, "bar" => 606, "fraction" => 167, "Eacute" => 611, + "less" => 606, "adieresis" => 500, "guilsinglleft" => 389, + "egrave" => 500, "exclam" => 278, "edieresis" => 500, + "idieresis" => 333, "Eth" => 833, "period" => 250, "ae" => 778, + "asterisk" => 444, "odieresis" => 556, "Uacute" => 778, + "ugrave" => 611, "five" => 500, "nine" => 500, "greater" => 606, + "udieresis" => 611, "Zcaron" => 667, "threequarters" => 750, + "guillemotright" => 500, "Ccedilla" => 722, "ydieresis" => 556, + "tilde" => 333, "atilde" => 500, "at" => 747, "brokenbar" => 606, + "eacute" => 500, "quoteleft" => 278, "underscore" => 500, + "onesuperior" => 300, + } +); +1; diff --git a/doc/metrics/pplbi8a.ph b/doc/metrics/pplbi8a.ph new file mode 100644 index 0000000..31cf0a7 --- /dev/null +++ b/doc/metrics/pplbi8a.ph @@ -0,0 +1,72 @@ +%PS_Palatino_BoldItalic = ( + name => 'Palatino-BoldItalic', + widths => { + "multiply" => 606, "Ntilde" => 778, "zero" => 500, "eth" => 556, + "Ograve" => 833, "uacute" => 556, "braceleft" => 333, + "Thorn" => 667, "zcaron" => 500, "comma" => 250, "cedilla" => 333, + "plusminus" => 606, "ccedilla" => 444, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 606, "colon" => 250, + "onehalf" => 750, "dollar" => 500, "ntilde" => 556, + "Oacute" => 833, "Ocircumflex" => 833, "ogonek" => 333, + "ograve" => 556, "thorn" => 556, "degree" => 400, "minus" => 606, + "yen" => 500, "space" => 250, "registered" => 747, + "questiondown" => 444, "Aring" => 722, "percent" => 889, + "emdash" => 1000, "six" => 500, "Agrave" => 722, + "paragraph" => 556, "three" => 500, "numbersign" => 500, + "two" => 500, "Igrave" => 389, "oacute" => 556, + "ocircumflex" => 556, "A" => 722, "B" => 667, "C" => 685, + "D" => 778, "E" => 611, "onequarter" => 750, "F" => 556, + "G" => 778, "H" => 778, "I" => 389, "J" => 389, "K" => 722, + "L" => 611, "backslash" => 606, "asciicircum" => 606, + "periodcentered" => 250, "M" => 944, "N" => 778, "O" => 833, + "P" => 667, "aring" => 556, "Q" => 833, "R" => 722, + "Aacute" => 722, "caron" => 333, "S" => 556, "T" => 611, + "grave" => 333, "U" => 778, "agrave" => 556, "V" => 667, + "W" => 1000, "equal" => 606, "question" => 444, "X" => 722, + "Y" => 611, "Z" => 667, "bracketright" => 333, "Iacute" => 389, + "ampersand" => 833, "four" => 500, "igrave" => 333, "a" => 556, + "b" => 537, "c" => 444, "d" => 556, "plus" => 606, "e" => 444, + "quotesinglbase" => 250, "f" => 333, "g" => 500, "bullet" => 606, + "h" => 556, "i" => 333, "Oslash" => 833, "dagger" => 556, + "j" => 333, "Yacute" => 611, "k" => 556, "l" => 333, "m" => 833, + "n" => 556, "o" => 556, "ordfeminine" => 333, "ring" => 556, + "p" => 556, "threesuperior" => 300, "q" => 537, "acute" => 333, + "r" => 389, "aacute" => 556, "twosuperior" => 300, "s" => 444, + "OE" => 944, "t" => 389, "divide" => 606, "section" => 556, + "u" => 556, "v" => 556, "w" => 833, "dieresis" => 333, "x" => 500, + "y" => 556, "z" => 500, "iacute" => 333, "quotedblbase" => 500, + "hungarumlaut" => 333, "quotedbl" => 500, "mu" => 556, + "Scaron" => 556, "Lslash" => 611, "semicolon" => 250, + "oslash" => 556, "florin" => 500, "yacute" => 556, "fi" => 611, + "fl" => 611, "Acircumflex" => 722, "parenright" => 333, + "Ecircumflex" => 611, "Icircumflex" => 389, "trademark" => 1000, + "daggerdbl" => 556, "guillemotleft" => 500, "germandbls" => 556, + "macron" => 333, "Otilde" => 833, "seven" => 500, + "ellipsis" => 1000, "scaron" => 444, "ordmasculine" => 333, + "AE" => 944, "Ucircumflex" => 778, "lslash" => 333, + "dotlessi" => 333, "sterling" => 500, "quotedblleft" => 500, + "hyphen" => 389, "guilsinglright" => 333, "quotesingle" => 250, + "eight" => 500, "exclamdown" => 333, "acircumflex" => 556, + "endash" => 500, "oe" => 778, "ecircumflex" => 444, + "Adieresis" => 722, "copyright" => 747, "Egrave" => 611, + "icircumflex" => 333, "slash" => 315, "braceright" => 333, + "Edieresis" => 611, "quotedblright" => 500, "Idieresis" => 389, + "otilde" => 556, "parenleft" => 333, "one" => 500, + "Odieresis" => 833, "ucircumflex" => 556, "bracketleft" => 333, + "Ugrave" => 778, "cent" => 500, "currency" => 500, + "logicalnot" => 606, "quoteright" => 278, "Udieresis" => 778, + "perthousand" => 1000, "Ydieresis" => 611, "Atilde" => 722, + "breve" => 333, "bar" => 606, "fraction" => 167, "Eacute" => 611, + "less" => 606, "adieresis" => 556, "guilsinglleft" => 333, + "egrave" => 444, "exclam" => 333, "edieresis" => 444, + "idieresis" => 333, "Eth" => 778, "period" => 250, "ae" => 738, + "asterisk" => 444, "odieresis" => 556, "Uacute" => 778, + "ugrave" => 556, "five" => 500, "nine" => 500, "greater" => 606, + "udieresis" => 556, "Zcaron" => 667, "threequarters" => 750, + "guillemotright" => 500, "Ccedilla" => 685, "ydieresis" => 556, + "tilde" => 333, "atilde" => 556, "at" => 833, "brokenbar" => 606, + "eacute" => 444, "quoteleft" => 278, "underscore" => 500, + "onesuperior" => 300, + } +); +1; diff --git a/doc/metrics/pplr8a.ph b/doc/metrics/pplr8a.ph new file mode 100644 index 0000000..4cbd1c9 --- /dev/null +++ b/doc/metrics/pplr8a.ph @@ -0,0 +1,72 @@ +%PS_Palatino_Roman = ( + name => 'Palatino-Roman', + widths => { + "multiply" => 606, "Ntilde" => 831, "zero" => 500, "eth" => 546, + "Ograve" => 786, "uacute" => 603, "braceleft" => 333, + "Thorn" => 604, "zcaron" => 500, "comma" => 250, "cedilla" => 333, + "plusminus" => 606, "ccedilla" => 444, "circumflex" => 333, + "dotaccent" => 250, "asciitilde" => 606, "colon" => 250, + "onehalf" => 750, "dollar" => 500, "ntilde" => 582, + "Oacute" => 786, "Ocircumflex" => 786, "ogonek" => 313, + "ograve" => 546, "thorn" => 601, "degree" => 400, "minus" => 606, + "yen" => 500, "space" => 250, "registered" => 747, + "questiondown" => 444, "Aring" => 778, "percent" => 840, + "emdash" => 1000, "six" => 500, "Agrave" => 778, + "paragraph" => 628, "three" => 500, "numbersign" => 500, + "two" => 500, "Igrave" => 337, "oacute" => 546, + "ocircumflex" => 546, "A" => 778, "B" => 611, "C" => 709, + "D" => 774, "E" => 611, "onequarter" => 750, "F" => 556, + "G" => 763, "H" => 832, "I" => 337, "J" => 333, "K" => 726, + "L" => 611, "backslash" => 606, "asciicircum" => 606, + "periodcentered" => 250, "M" => 946, "N" => 831, "O" => 786, + "P" => 604, "aring" => 500, "Q" => 786, "R" => 668, + "Aacute" => 778, "caron" => 333, "S" => 525, "T" => 613, + "grave" => 333, "U" => 778, "agrave" => 500, "V" => 722, + "W" => 1000, "equal" => 606, "question" => 444, "X" => 667, + "Y" => 667, "Z" => 667, "bracketright" => 333, "Iacute" => 337, + "ampersand" => 778, "four" => 500, "igrave" => 287, "a" => 500, + "b" => 553, "c" => 444, "d" => 611, "plus" => 606, "e" => 479, + "quotesinglbase" => 278, "f" => 333, "g" => 556, "bullet" => 606, + "h" => 582, "i" => 291, "Oslash" => 833, "dagger" => 500, + "j" => 234, "Yacute" => 667, "k" => 556, "l" => 291, "m" => 883, + "n" => 582, "o" => 546, "ordfeminine" => 333, "ring" => 333, + "p" => 601, "threesuperior" => 300, "q" => 560, "acute" => 333, + "r" => 395, "aacute" => 500, "twosuperior" => 300, "s" => 424, + "OE" => 998, "t" => 326, "divide" => 606, "section" => 500, + "u" => 603, "v" => 565, "w" => 834, "dieresis" => 333, "x" => 516, + "y" => 556, "z" => 500, "iacute" => 287, "quotedblbase" => 500, + "hungarumlaut" => 380, "quotedbl" => 371, "mu" => 603, + "Scaron" => 525, "Lslash" => 611, "semicolon" => 250, + "oslash" => 556, "florin" => 500, "yacute" => 556, "fi" => 605, + "fl" => 608, "Acircumflex" => 778, "parenright" => 333, + "Ecircumflex" => 611, "Icircumflex" => 337, "trademark" => 979, + "daggerdbl" => 500, "guillemotleft" => 500, "germandbls" => 556, + "macron" => 333, "Otilde" => 786, "seven" => 500, + "ellipsis" => 1000, "scaron" => 424, "ordmasculine" => 333, + "AE" => 944, "Ucircumflex" => 778, "lslash" => 291, + "dotlessi" => 287, "sterling" => 500, "quotedblleft" => 500, + "hyphen" => 333, "guilsinglright" => 331, "quotesingle" => 208, + "eight" => 500, "exclamdown" => 278, "acircumflex" => 500, + "endash" => 500, "oe" => 827, "ecircumflex" => 479, + "Adieresis" => 778, "copyright" => 747, "Egrave" => 611, + "icircumflex" => 287, "slash" => 606, "braceright" => 333, + "Edieresis" => 611, "quotedblright" => 500, "Idieresis" => 337, + "otilde" => 546, "parenleft" => 333, "one" => 500, + "Odieresis" => 786, "ucircumflex" => 603, "bracketleft" => 333, + "Ugrave" => 778, "cent" => 500, "currency" => 500, + "logicalnot" => 606, "quoteright" => 278, "Udieresis" => 778, + "perthousand" => 1144, "Ydieresis" => 667, "Atilde" => 778, + "breve" => 333, "bar" => 606, "fraction" => 167, "Eacute" => 611, + "less" => 606, "adieresis" => 500, "guilsinglleft" => 331, + "egrave" => 479, "exclam" => 278, "edieresis" => 479, + "idieresis" => 287, "Eth" => 774, "period" => 250, "ae" => 758, + "asterisk" => 389, "odieresis" => 546, "Uacute" => 778, + "ugrave" => 603, "five" => 500, "nine" => 500, "greater" => 606, + "udieresis" => 603, "Zcaron" => 667, "threequarters" => 750, + "guillemotright" => 500, "Ccedilla" => 709, "ydieresis" => 556, + "tilde" => 333, "atilde" => 500, "at" => 747, "brokenbar" => 606, + "eacute" => 479, "quoteleft" => 278, "underscore" => 500, + "onesuperior" => 300, + } +); +1; diff --git a/doc/metrics/pplri8a.ph b/doc/metrics/pplri8a.ph new file mode 100644 index 0000000..b4a5224 --- /dev/null +++ b/doc/metrics/pplri8a.ph @@ -0,0 +1,72 @@ +%PS_Palatino_Italic = ( + name => 'Palatino-Italic', + widths => { + "multiply" => 606, "Ntilde" => 778, "zero" => 500, "eth" => 444, + "Ograve" => 778, "uacute" => 556, "braceleft" => 333, + "Thorn" => 611, "zcaron" => 444, "comma" => 250, "cedilla" => 333, + "plusminus" => 606, "ccedilla" => 407, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 606, "colon" => 250, + "onehalf" => 750, "dollar" => 500, "ntilde" => 556, + "Oacute" => 778, "Ocircumflex" => 778, "ogonek" => 333, + "ograve" => 444, "thorn" => 500, "degree" => 400, "minus" => 606, + "yen" => 500, "space" => 250, "registered" => 747, + "questiondown" => 500, "Aring" => 722, "percent" => 889, + "emdash" => 1000, "six" => 500, "Agrave" => 722, + "paragraph" => 500, "three" => 500, "numbersign" => 500, + "two" => 500, "Igrave" => 333, "oacute" => 444, + "ocircumflex" => 444, "A" => 722, "B" => 611, "C" => 667, + "D" => 778, "E" => 611, "onequarter" => 750, "F" => 556, + "G" => 722, "H" => 778, "I" => 333, "J" => 333, "K" => 667, + "L" => 556, "backslash" => 606, "asciicircum" => 606, + "periodcentered" => 250, "M" => 944, "N" => 778, "O" => 778, + "P" => 611, "aring" => 444, "Q" => 778, "R" => 667, + "Aacute" => 722, "caron" => 333, "S" => 556, "T" => 611, + "grave" => 333, "U" => 778, "agrave" => 444, "V" => 722, + "W" => 944, "equal" => 606, "question" => 500, "X" => 722, + "Y" => 667, "Z" => 667, "bracketright" => 333, "Iacute" => 333, + "ampersand" => 778, "four" => 500, "igrave" => 278, "a" => 444, + "b" => 463, "c" => 407, "d" => 500, "plus" => 606, "e" => 389, + "quotesinglbase" => 278, "f" => 278, "g" => 500, "bullet" => 500, + "h" => 500, "i" => 278, "Oslash" => 778, "dagger" => 500, + "j" => 278, "Yacute" => 667, "k" => 444, "l" => 278, "m" => 778, + "n" => 556, "o" => 444, "ordfeminine" => 333, "ring" => 333, + "p" => 500, "threesuperior" => 300, "q" => 463, "acute" => 333, + "r" => 389, "aacute" => 444, "twosuperior" => 300, "s" => 389, + "OE" => 1028, "t" => 333, "divide" => 606, "section" => 500, + "u" => 556, "v" => 500, "w" => 722, "dieresis" => 333, "x" => 500, + "y" => 500, "z" => 444, "iacute" => 278, "quotedblbase" => 500, + "hungarumlaut" => 333, "quotedbl" => 500, "mu" => 556, + "Scaron" => 556, "Lslash" => 556, "semicolon" => 250, + "oslash" => 444, "florin" => 500, "yacute" => 500, "fi" => 528, + "fl" => 545, "Acircumflex" => 722, "parenright" => 333, + "Ecircumflex" => 611, "Icircumflex" => 333, "trademark" => 1000, + "daggerdbl" => 500, "guillemotleft" => 500, "germandbls" => 500, + "macron" => 333, "Otilde" => 778, "seven" => 500, + "ellipsis" => 1000, "scaron" => 389, "ordmasculine" => 333, + "AE" => 941, "Ucircumflex" => 778, "lslash" => 278, + "dotlessi" => 278, "sterling" => 500, "quotedblleft" => 500, + "hyphen" => 333, "guilsinglright" => 333, "quotesingle" => 333, + "eight" => 500, "exclamdown" => 333, "acircumflex" => 444, + "endash" => 500, "oe" => 669, "ecircumflex" => 389, + "Adieresis" => 722, "copyright" => 747, "Egrave" => 611, + "icircumflex" => 278, "slash" => 296, "braceright" => 333, + "Edieresis" => 611, "quotedblright" => 500, "Idieresis" => 333, + "otilde" => 444, "parenleft" => 333, "one" => 500, + "Odieresis" => 778, "ucircumflex" => 556, "bracketleft" => 333, + "Ugrave" => 778, "cent" => 500, "currency" => 500, + "logicalnot" => 606, "quoteright" => 278, "Udieresis" => 778, + "perthousand" => 1000, "Ydieresis" => 667, "Atilde" => 722, + "breve" => 333, "bar" => 606, "fraction" => 167, "Eacute" => 611, + "less" => 606, "adieresis" => 444, "guilsinglleft" => 333, + "egrave" => 389, "exclam" => 333, "edieresis" => 389, + "idieresis" => 278, "Eth" => 778, "period" => 250, "ae" => 638, + "asterisk" => 389, "odieresis" => 444, "Uacute" => 778, + "ugrave" => 556, "five" => 500, "nine" => 500, "greater" => 606, + "udieresis" => 556, "Zcaron" => 667, "threequarters" => 750, + "guillemotright" => 500, "Ccedilla" => 667, "ydieresis" => 500, + "tilde" => 333, "atilde" => 444, "at" => 747, "brokenbar" => 606, + "eacute" => 389, "quoteleft" => 278, "underscore" => 500, + "onesuperior" => 300, + } +); +1; diff --git a/doc/metrics/psyr.ph b/doc/metrics/psyr.ph new file mode 100644 index 0000000..86dd97b --- /dev/null +++ b/doc/metrics/psyr.ph @@ -0,0 +1,68 @@ +%PS_Symbol = ( + name => 'Symbol', + widths => { + "multiply" => 549, "zero" => 500, "bracketleftex" => 384, + "partialdiff" => 494, "alpha" => 631, "angle" => 768, + "arrowdblleft" => 987, "braceleft" => 480, "union" => 768, + "infinity" => 713, "comma" => 250, "copyrightsans" => 790, + "plusminus" => 549, "arrowup" => 603, "parenrightex" => 384, + "Rfraktur" => 795, "apple" => 790, "Zeta" => 611, + "parenleftbt" => 384, "braceex" => 494, "notelement" => 713, + "colon" => 278, "beta" => 549, "braceleftbt" => 494, + "Lambda" => 686, "Phi" => 763, "arrowdblup" => 603, + "arrowdown" => 603, "Ifraktur" => 686, "degree" => 400, + "space" => 250, "minus" => 549, "Iota" => 333, + "perpendicular" => 658, "radical" => 549, "asteriskmath" => 500, + "Sigma" => 592, "percent" => 833, "approxequal" => 549, + "minute" => 247, "zeta" => 494, "six" => 500, "circleplus" => 768, + "Omicron" => 722, "three" => 500, "numbersign" => 500, + "two" => 500, "weierstrass" => 987, "summation" => 713, + "bracketrighttp" => 384, "carriagereturn" => 658, "lambda" => 549, + "phi" => 521, "suchthat" => 439, "arrowvertex" => 603, + "aleph" => 823, "Delta" => 612, "Tau" => 611, "spade" => 753, + "iota" => 329, "logicaland" => 603, "sigma" => 603, + "propersuperset" => 713, "arrowhorizex" => 1000, + "bracketrightex" => 384, "omicron" => 549, "equal" => 549, + "question" => 444, "Epsilon" => 611, "bracketright" => 333, + "emptyset" => 823, "ampersand" => 778, "diamond" => 753, + "four" => 500, "Mu" => 889, "plus" => 549, "parenlefttp" => 384, + "club" => 753, "bullet" => 460, "proportional" => 713, + "Omega" => 768, "tau" => 439, "delta" => 494, "Upsilon" => 690, + "bracelefttp" => 494, "copyrightserif" => 790, "heart" => 753, + "bracerightmid" => 494, "divide" => 549, "arrowleft" => 987, + "epsilon" => 439, "logicalor" => 603, "second" => 411, + "parenleftex" => 384, "mu" => 576, "greaterequal" => 549, + "Nu" => 722, "therefore" => 863, "notsubset" => 713, + "semicolon" => 278, "omega" => 686, "arrowdblboth" => 1042, + "element" => 713, "existential" => 549, "upsilon" => 576, + "florin" => 500, "integralbt" => 686, "Psi" => 795, + "lessequal" => 549, "bracerightbt" => 494, "phi1" => 603, + "lozenge" => 494, "trademarkserif" => 890, "parenright" => 333, + "bracketleftbt" => 384, "reflexsuperset" => 713, "seven" => 500, + "braceleftmid" => 494, "sigma1" => 439, "Gamma" => 603, + "nu" => 521, "angleright" => 329, "ellipsis" => 1000, "Rho" => 556, + "notequal" => 549, "parenrightbt" => 384, "psi" => 686, + "radicalex" => 500, "eight" => 500, "angleleft" => 329, + "equivalence" => 549, "arrowdbldown" => 603, "congruent" => 549, + "Theta" => 741, "intersection" => 768, "universal" => 713, + "Pi" => 768, "arrowdblright" => 987, "slash" => 278, + "braceright" => 480, "reflexsubset" => 713, "registerserif" => 790, + "Xi" => 645, "parenleft" => 333, "one" => 500, "gamma" => 411, + "bracketleft" => 333, "theta1" => 631, "rho" => 549, + "logicalnot" => 713, "Kappa" => 722, "similar" => 549, + "circlemultiply" => 768, "Chi" => 722, "bar" => 200, + "theta" => 521, "fraction" => 167, "less" => 549, "pi" => 549, + "integraltp" => 686, "registersans" => 790, "Eta" => 722, + "exclam" => 333, "omega1" => 713, "Upsilon1" => 620, + "bracerighttp" => 494, "product" => 823, "xi" => 493, + "period" => 250, "Alpha" => 722, "arrowright" => 987, + "five" => 500, "nine" => 500, "greater" => 549, + "bracketlefttp" => 384, "kappa" => 549, "gradient" => 713, + "propersubset" => 713, "bracketrightbt" => 384, + "trademarksans" => 786, "dotmath" => 250, "integralex" => 686, + "chi" => 549, "integral" => 274, "parenrighttp" => 384, + "arrowboth" => 1042, "underscore" => 500, "eta" => 603, + "Beta" => 667, + } +); +1; diff --git a/doc/metrics/ptmb8a.ph b/doc/metrics/ptmb8a.ph new file mode 100644 index 0000000..5cf9564 --- /dev/null +++ b/doc/metrics/ptmb8a.ph @@ -0,0 +1,72 @@ +%PS_Times_Bold = ( + name => 'Times-Bold', + widths => { + "multiply" => 570, "Ntilde" => 722, "zero" => 500, "eth" => 500, + "Ograve" => 778, "uacute" => 556, "braceleft" => 394, + "Thorn" => 611, "zcaron" => 444, "comma" => 250, "cedilla" => 333, + "plusminus" => 570, "ccedilla" => 444, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 520, "colon" => 333, + "onehalf" => 750, "dollar" => 500, "ntilde" => 556, + "Oacute" => 778, "Ocircumflex" => 778, "ogonek" => 333, + "ograve" => 500, "thorn" => 556, "degree" => 400, "minus" => 570, + "yen" => 500, "space" => 250, "registered" => 747, + "questiondown" => 500, "Aring" => 722, "percent" => 1000, + "emdash" => 1000, "six" => 500, "Agrave" => 722, + "paragraph" => 540, "three" => 500, "numbersign" => 500, + "two" => 500, "Igrave" => 389, "oacute" => 500, + "ocircumflex" => 500, "A" => 722, "B" => 667, "C" => 722, + "D" => 722, "E" => 667, "onequarter" => 750, "F" => 611, + "G" => 778, "H" => 778, "I" => 389, "J" => 500, "K" => 778, + "L" => 667, "backslash" => 278, "asciicircum" => 581, + "periodcentered" => 250, "M" => 944, "N" => 722, "O" => 778, + "P" => 611, "aring" => 500, "Q" => 778, "R" => 722, + "Aacute" => 722, "caron" => 333, "S" => 556, "T" => 667, + "grave" => 333, "U" => 722, "agrave" => 500, "V" => 722, + "W" => 1000, "equal" => 570, "question" => 500, "X" => 722, + "Y" => 722, "Z" => 667, "bracketright" => 333, "Iacute" => 389, + "ampersand" => 833, "four" => 500, "igrave" => 278, "a" => 500, + "b" => 556, "c" => 444, "d" => 556, "plus" => 570, "e" => 444, + "quotesinglbase" => 333, "f" => 333, "g" => 500, "bullet" => 350, + "h" => 556, "i" => 278, "Oslash" => 778, "dagger" => 500, + "j" => 333, "Yacute" => 722, "k" => 556, "l" => 278, "m" => 833, + "n" => 556, "o" => 500, "ordfeminine" => 300, "ring" => 333, + "p" => 556, "threesuperior" => 300, "q" => 556, "acute" => 333, + "r" => 444, "aacute" => 500, "twosuperior" => 300, "s" => 389, + "OE" => 1000, "t" => 333, "divide" => 570, "section" => 500, + "u" => 556, "v" => 500, "w" => 722, "dieresis" => 333, "x" => 500, + "y" => 500, "z" => 444, "iacute" => 278, "quotedblbase" => 500, + "hungarumlaut" => 333, "quotedbl" => 555, "mu" => 556, + "Scaron" => 556, "Lslash" => 667, "semicolon" => 333, + "oslash" => 500, "florin" => 500, "yacute" => 500, "fi" => 556, + "fl" => 556, "Acircumflex" => 722, "parenright" => 333, + "Ecircumflex" => 667, "Icircumflex" => 389, "trademark" => 1000, + "daggerdbl" => 500, "guillemotleft" => 500, "germandbls" => 556, + "macron" => 333, "Otilde" => 778, "seven" => 500, + "ellipsis" => 1000, "scaron" => 389, "ordmasculine" => 330, + "AE" => 1000, "Ucircumflex" => 722, "lslash" => 278, + "dotlessi" => 278, "sterling" => 500, "quotedblleft" => 500, + "hyphen" => 333, "guilsinglright" => 333, "quotesingle" => 278, + "eight" => 500, "exclamdown" => 333, "acircumflex" => 500, + "endash" => 500, "oe" => 722, "ecircumflex" => 444, + "Adieresis" => 722, "copyright" => 747, "Egrave" => 667, + "icircumflex" => 278, "slash" => 278, "braceright" => 394, + "Edieresis" => 667, "quotedblright" => 500, "Idieresis" => 389, + "otilde" => 500, "parenleft" => 333, "one" => 500, + "Odieresis" => 778, "ucircumflex" => 556, "bracketleft" => 333, + "Ugrave" => 722, "cent" => 500, "currency" => 500, + "logicalnot" => 570, "quoteright" => 333, "Udieresis" => 722, + "perthousand" => 1000, "Ydieresis" => 722, "Atilde" => 722, + "breve" => 333, "bar" => 220, "fraction" => 167, "Eacute" => 667, + "less" => 570, "adieresis" => 500, "guilsinglleft" => 333, + "egrave" => 444, "exclam" => 333, "edieresis" => 444, + "idieresis" => 278, "Eth" => 722, "period" => 250, "ae" => 722, + "asterisk" => 500, "odieresis" => 500, "Uacute" => 722, + "ugrave" => 556, "five" => 500, "nine" => 500, "greater" => 570, + "udieresis" => 556, "Zcaron" => 667, "threequarters" => 750, + "guillemotright" => 500, "Ccedilla" => 722, "ydieresis" => 500, + "tilde" => 333, "atilde" => 500, "at" => 930, "brokenbar" => 220, + "eacute" => 444, "quoteleft" => 333, "underscore" => 500, + "onesuperior" => 300, + } +); +1; diff --git a/doc/metrics/ptmbi8a.ph b/doc/metrics/ptmbi8a.ph new file mode 100644 index 0000000..ada7e23 --- /dev/null +++ b/doc/metrics/ptmbi8a.ph @@ -0,0 +1,72 @@ +%PS_Times_BoldItalic = ( + name => 'Times-BoldItalic', + widths => { + "multiply" => 570, "Ntilde" => 722, "zero" => 500, "eth" => 500, + "Ograve" => 722, "uacute" => 556, "braceleft" => 348, + "Thorn" => 611, "zcaron" => 389, "comma" => 250, "cedilla" => 333, + "plusminus" => 570, "ccedilla" => 444, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 570, "colon" => 333, + "onehalf" => 750, "dollar" => 500, "ntilde" => 556, + "Oacute" => 722, "Ocircumflex" => 722, "ogonek" => 333, + "ograve" => 500, "thorn" => 500, "degree" => 400, "minus" => 606, + "yen" => 500, "space" => 250, "registered" => 747, + "questiondown" => 500, "Aring" => 667, "percent" => 833, + "emdash" => 1000, "six" => 500, "Agrave" => 667, + "paragraph" => 500, "three" => 500, "numbersign" => 500, + "two" => 500, "Igrave" => 389, "oacute" => 500, + "ocircumflex" => 500, "A" => 667, "B" => 667, "C" => 667, + "D" => 722, "E" => 667, "onequarter" => 750, "F" => 667, + "G" => 722, "H" => 778, "I" => 389, "J" => 500, "K" => 667, + "L" => 611, "backslash" => 278, "asciicircum" => 570, + "periodcentered" => 250, "M" => 889, "N" => 722, "O" => 722, + "P" => 611, "aring" => 500, "Q" => 722, "R" => 667, + "Aacute" => 667, "caron" => 333, "S" => 556, "T" => 611, + "grave" => 333, "U" => 722, "agrave" => 500, "V" => 667, + "W" => 889, "equal" => 570, "question" => 500, "X" => 667, + "Y" => 611, "Z" => 611, "bracketright" => 333, "Iacute" => 389, + "ampersand" => 778, "four" => 500, "igrave" => 278, "a" => 500, + "b" => 500, "c" => 444, "d" => 500, "plus" => 570, "e" => 444, + "quotesinglbase" => 333, "f" => 333, "g" => 500, "bullet" => 350, + "h" => 556, "i" => 278, "Oslash" => 722, "dagger" => 500, + "j" => 278, "Yacute" => 611, "k" => 500, "l" => 278, "m" => 778, + "n" => 556, "o" => 500, "ordfeminine" => 266, "ring" => 333, + "p" => 500, "threesuperior" => 300, "q" => 500, "acute" => 333, + "r" => 389, "aacute" => 500, "twosuperior" => 300, "s" => 389, + "OE" => 944, "t" => 278, "divide" => 570, "section" => 500, + "u" => 556, "v" => 444, "w" => 667, "dieresis" => 333, "x" => 500, + "y" => 444, "z" => 389, "iacute" => 278, "quotedblbase" => 500, + "hungarumlaut" => 333, "quotedbl" => 555, "mu" => 576, + "Scaron" => 556, "Lslash" => 611, "semicolon" => 333, + "oslash" => 500, "florin" => 500, "yacute" => 444, "fi" => 556, + "fl" => 556, "Acircumflex" => 667, "parenright" => 333, + "Ecircumflex" => 667, "Icircumflex" => 389, "trademark" => 1000, + "daggerdbl" => 500, "guillemotleft" => 500, "germandbls" => 500, + "macron" => 333, "Otilde" => 722, "seven" => 500, + "ellipsis" => 1000, "scaron" => 389, "ordmasculine" => 300, + "AE" => 944, "Ucircumflex" => 722, "lslash" => 278, + "dotlessi" => 278, "sterling" => 500, "quotedblleft" => 500, + "hyphen" => 333, "guilsinglright" => 333, "quotesingle" => 278, + "eight" => 500, "exclamdown" => 389, "acircumflex" => 500, + "endash" => 500, "oe" => 722, "ecircumflex" => 444, + "Adieresis" => 667, "copyright" => 747, "Egrave" => 667, + "icircumflex" => 278, "slash" => 278, "braceright" => 348, + "Edieresis" => 667, "quotedblright" => 500, "Idieresis" => 389, + "otilde" => 500, "parenleft" => 333, "one" => 500, + "Odieresis" => 722, "ucircumflex" => 556, "bracketleft" => 333, + "Ugrave" => 722, "cent" => 500, "currency" => 500, + "logicalnot" => 606, "quoteright" => 333, "Udieresis" => 722, + "perthousand" => 1000, "Ydieresis" => 611, "Atilde" => 667, + "breve" => 333, "bar" => 220, "fraction" => 167, "Eacute" => 667, + "less" => 570, "adieresis" => 500, "guilsinglleft" => 333, + "egrave" => 444, "exclam" => 389, "edieresis" => 444, + "idieresis" => 278, "Eth" => 722, "period" => 250, "ae" => 722, + "asterisk" => 500, "odieresis" => 500, "Uacute" => 722, + "ugrave" => 556, "five" => 500, "nine" => 500, "greater" => 570, + "udieresis" => 556, "Zcaron" => 611, "threequarters" => 750, + "guillemotright" => 500, "Ccedilla" => 667, "ydieresis" => 444, + "tilde" => 333, "atilde" => 500, "at" => 832, "brokenbar" => 220, + "eacute" => 444, "quoteleft" => 333, "underscore" => 500, + "onesuperior" => 300, + } +); +1; diff --git a/doc/metrics/ptmr8a.ph b/doc/metrics/ptmr8a.ph new file mode 100644 index 0000000..a25fd3e --- /dev/null +++ b/doc/metrics/ptmr8a.ph @@ -0,0 +1,72 @@ +%PS_Times_Roman = ( + name => 'Times-Roman', + widths => { + "multiply" => 564, "Ntilde" => 722, "zero" => 500, "eth" => 500, + "Ograve" => 722, "uacute" => 500, "braceleft" => 480, + "Thorn" => 556, "zcaron" => 444, "comma" => 250, "cedilla" => 333, + "plusminus" => 564, "ccedilla" => 444, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 541, "colon" => 278, + "onehalf" => 750, "dollar" => 500, "ntilde" => 500, + "Oacute" => 722, "Ocircumflex" => 722, "ogonek" => 333, + "ograve" => 500, "thorn" => 500, "degree" => 400, "minus" => 564, + "yen" => 500, "space" => 250, "registered" => 760, + "questiondown" => 444, "Aring" => 722, "percent" => 833, + "emdash" => 1000, "six" => 500, "Agrave" => 722, + "paragraph" => 453, "three" => 500, "numbersign" => 500, + "two" => 500, "Igrave" => 333, "oacute" => 500, + "ocircumflex" => 500, "A" => 722, "B" => 667, "C" => 667, + "D" => 722, "E" => 611, "onequarter" => 750, "F" => 556, + "G" => 722, "H" => 722, "I" => 333, "J" => 389, "K" => 722, + "L" => 611, "backslash" => 278, "asciicircum" => 469, + "periodcentered" => 250, "M" => 889, "N" => 722, "O" => 722, + "P" => 556, "aring" => 444, "Q" => 722, "R" => 667, + "Aacute" => 722, "caron" => 333, "S" => 556, "T" => 611, + "grave" => 333, "U" => 722, "agrave" => 444, "V" => 722, + "W" => 944, "equal" => 564, "question" => 444, "X" => 722, + "Y" => 722, "Z" => 611, "bracketright" => 333, "Iacute" => 333, + "ampersand" => 778, "four" => 500, "igrave" => 278, "a" => 444, + "b" => 500, "c" => 444, "d" => 500, "plus" => 564, "e" => 444, + "quotesinglbase" => 333, "f" => 333, "g" => 500, "bullet" => 350, + "h" => 500, "i" => 278, "Oslash" => 722, "dagger" => 500, + "j" => 278, "Yacute" => 722, "k" => 500, "l" => 278, "m" => 778, + "n" => 500, "o" => 500, "ordfeminine" => 276, "ring" => 333, + "p" => 500, "threesuperior" => 300, "q" => 500, "acute" => 333, + "r" => 333, "aacute" => 444, "twosuperior" => 300, "s" => 389, + "OE" => 889, "t" => 278, "divide" => 564, "section" => 500, + "u" => 500, "v" => 500, "w" => 722, "dieresis" => 333, "x" => 500, + "y" => 500, "z" => 444, "iacute" => 278, "quotedblbase" => 444, + "hungarumlaut" => 333, "quotedbl" => 408, "mu" => 500, + "Scaron" => 556, "Lslash" => 611, "semicolon" => 278, + "oslash" => 500, "florin" => 500, "yacute" => 500, "fi" => 556, + "fl" => 556, "Acircumflex" => 722, "parenright" => 333, + "Ecircumflex" => 611, "Icircumflex" => 333, "trademark" => 980, + "daggerdbl" => 500, "guillemotleft" => 500, "germandbls" => 500, + "macron" => 333, "Otilde" => 722, "seven" => 500, + "ellipsis" => 1000, "scaron" => 389, "ordmasculine" => 310, + "AE" => 889, "Ucircumflex" => 722, "lslash" => 278, + "dotlessi" => 278, "sterling" => 500, "quotedblleft" => 444, + "hyphen" => 333, "guilsinglright" => 333, "quotesingle" => 180, + "eight" => 500, "exclamdown" => 333, "acircumflex" => 444, + "endash" => 500, "oe" => 722, "ecircumflex" => 444, + "Adieresis" => 722, "copyright" => 760, "Egrave" => 611, + "icircumflex" => 278, "slash" => 278, "braceright" => 480, + "Edieresis" => 611, "quotedblright" => 444, "Idieresis" => 333, + "otilde" => 500, "parenleft" => 333, "one" => 500, + "Odieresis" => 722, "ucircumflex" => 500, "bracketleft" => 333, + "Ugrave" => 722, "cent" => 500, "currency" => 500, + "logicalnot" => 564, "quoteright" => 333, "Udieresis" => 722, + "perthousand" => 1000, "Ydieresis" => 722, "Atilde" => 722, + "breve" => 333, "bar" => 200, "fraction" => 167, "Eacute" => 611, + "less" => 564, "adieresis" => 444, "guilsinglleft" => 333, + "egrave" => 444, "exclam" => 333, "edieresis" => 444, + "idieresis" => 278, "Eth" => 722, "period" => 250, "ae" => 667, + "asterisk" => 500, "odieresis" => 500, "Uacute" => 722, + "ugrave" => 500, "five" => 500, "nine" => 500, "greater" => 564, + "udieresis" => 500, "Zcaron" => 611, "threequarters" => 750, + "guillemotright" => 500, "Ccedilla" => 667, "ydieresis" => 500, + "tilde" => 333, "atilde" => 444, "at" => 921, "brokenbar" => 200, + "eacute" => 444, "quoteleft" => 333, "underscore" => 500, + "onesuperior" => 300, + } +); +1; diff --git a/doc/metrics/ptmri8a.ph b/doc/metrics/ptmri8a.ph new file mode 100644 index 0000000..2edb4ff --- /dev/null +++ b/doc/metrics/ptmri8a.ph @@ -0,0 +1,71 @@ +%PS_Times_Italic = ( + name => 'Times-Italic', + widths => { + "multiply" => 675, "Ntilde" => 667, "zero" => 500, "eth" => 500, + "Ograve" => 722, "uacute" => 500, "braceleft" => 400, + "Thorn" => 611, "zcaron" => 389, "comma" => 250, "cedilla" => 333, + "plusminus" => 675, "ccedilla" => 444, "circumflex" => 333, + "dotaccent" => 333, "asciitilde" => 541, "colon" => 333, + "onehalf" => 750, "dollar" => 500, "ntilde" => 500, + "Oacute" => 722, "Ocircumflex" => 722, "ogonek" => 333, + "ograve" => 500, "thorn" => 500, "degree" => 400, "minus" => 675, + "yen" => 500, "space" => 250, "registered" => 760, + "questiondown" => 500, "Aring" => 611, "percent" => 833, + "emdash" => 889, "six" => 500, "Agrave" => 611, "paragraph" => 523, + "three" => 500, "numbersign" => 500, "two" => 500, "Igrave" => 333, + "oacute" => 500, "ocircumflex" => 500, "A" => 611, "B" => 611, + "C" => 667, "D" => 722, "E" => 611, "onequarter" => 750, + "F" => 611, "G" => 722, "H" => 722, "I" => 333, "J" => 444, + "K" => 667, "L" => 556, "backslash" => 278, "asciicircum" => 422, + "periodcentered" => 250, "M" => 833, "N" => 667, "O" => 722, + "P" => 611, "aring" => 500, "Q" => 722, "R" => 611, + "Aacute" => 611, "caron" => 333, "S" => 500, "T" => 556, + "grave" => 333, "U" => 722, "agrave" => 500, "V" => 611, + "W" => 833, "equal" => 675, "question" => 500, "X" => 611, + "Y" => 556, "Z" => 556, "bracketright" => 389, "Iacute" => 333, + "ampersand" => 778, "four" => 500, "igrave" => 278, "a" => 500, + "b" => 500, "c" => 444, "d" => 500, "plus" => 675, "e" => 444, + "quotesinglbase" => 333, "f" => 278, "g" => 500, "bullet" => 350, + "h" => 500, "i" => 278, "Oslash" => 722, "dagger" => 500, + "j" => 278, "Yacute" => 556, "k" => 444, "l" => 278, "m" => 722, + "n" => 500, "o" => 500, "ordfeminine" => 276, "ring" => 333, + "p" => 500, "threesuperior" => 300, "q" => 500, "acute" => 333, + "r" => 389, "aacute" => 500, "twosuperior" => 300, "s" => 389, + "OE" => 944, "t" => 278, "divide" => 675, "section" => 500, + "u" => 500, "v" => 444, "w" => 667, "dieresis" => 333, "x" => 444, + "y" => 444, "z" => 389, "iacute" => 278, "quotedblbase" => 556, + "hungarumlaut" => 333, "quotedbl" => 420, "mu" => 500, + "Scaron" => 500, "Lslash" => 556, "semicolon" => 333, + "oslash" => 500, "florin" => 500, "yacute" => 444, "fi" => 500, + "fl" => 500, "Acircumflex" => 611, "parenright" => 333, + "Ecircumflex" => 611, "Icircumflex" => 333, "trademark" => 980, + "daggerdbl" => 500, "guillemotleft" => 500, "germandbls" => 500, + "macron" => 333, "Otilde" => 722, "seven" => 500, + "ellipsis" => 889, "scaron" => 389, "ordmasculine" => 310, + "AE" => 889, "Ucircumflex" => 722, "lslash" => 278, + "dotlessi" => 278, "sterling" => 500, "quotedblleft" => 556, + "hyphen" => 333, "guilsinglright" => 333, "quotesingle" => 214, + "eight" => 500, "exclamdown" => 389, "acircumflex" => 500, + "endash" => 500, "oe" => 667, "ecircumflex" => 444, + "Adieresis" => 611, "copyright" => 760, "Egrave" => 611, + "icircumflex" => 278, "slash" => 278, "braceright" => 400, + "Edieresis" => 611, "quotedblright" => 556, "Idieresis" => 333, + "otilde" => 500, "parenleft" => 333, "one" => 500, + "Odieresis" => 722, "ucircumflex" => 500, "bracketleft" => 389, + "Ugrave" => 722, "cent" => 500, "currency" => 500, + "logicalnot" => 675, "quoteright" => 333, "Udieresis" => 722, + "perthousand" => 1000, "Ydieresis" => 556, "Atilde" => 611, + "breve" => 333, "bar" => 275, "fraction" => 167, "Eacute" => 611, + "less" => 675, "adieresis" => 500, "guilsinglleft" => 333, + "egrave" => 444, "exclam" => 333, "edieresis" => 444, + "idieresis" => 278, "Eth" => 722, "period" => 250, "ae" => 667, + "asterisk" => 500, "odieresis" => 500, "Uacute" => 722, + "ugrave" => 500, "five" => 500, "nine" => 500, "greater" => 675, + "udieresis" => 500, "Zcaron" => 556, "threequarters" => 750, + "guillemotright" => 500, "Ccedilla" => 667, "ydieresis" => 444, + "tilde" => 333, "atilde" => 500, "at" => 920, "brokenbar" => 275, + "eacute" => 444, "quoteleft" => 333, "underscore" => 500, + "onesuperior" => 300, + } +); +1; diff --git a/doc/metrics/putb8a.ph b/doc/metrics/putb8a.ph new file mode 100644 index 0000000..fe8b24d --- /dev/null +++ b/doc/metrics/putb8a.ph @@ -0,0 +1,72 @@ +%PS_Utopia_Bold = ( + name => 'Utopia-Bold', + widths => { + "Ntilde" => 739, "multiply" => 600, "zero" => 560, "eth" => 585, + "Ograve" => 768, "uacute" => 629, "braceleft" => 365, + "Thorn" => 640, "zcaron" => 483, "comma" => 280, "cedilla" => 430, + "plusminus" => 600, "ccedilla" => 494, "circumflex" => 430, + "dotaccent" => 430, "asciitilde" => 600, "colon" => 280, + "onehalf" => 900, "dollar" => 560, "ntilde" => 638, + "Ocircumflex" => 768, "Oacute" => 768, "ogonek" => 430, + "ograve" => 585, "thorn" => 609, "degree" => 396, "minus" => 600, + "yen" => 560, "space" => 210, "registered" => 800, + "questiondown" => 456, "Aring" => 644, "percent" => 887, + "emdash" => 1000, "six" => 560, "Agrave" => 644, + "paragraph" => 552, "three" => 560, "numbersign" => 560, + "two" => 560, "Igrave" => 384, "ocircumflex" => 585, + "oacute" => 585, "A" => 644, "B" => 683, "C" => 689, "D" => 777, + "E" => 629, "onequarter" => 900, "F" => 593, "G" => 726, + "H" => 807, "I" => 384, "J" => 386, "K" => 707, "L" => 585, + "backslash" => 379, "asciicircum" => 600, "periodcentered" => 280, + "M" => 918, "N" => 739, "O" => 768, "P" => 650, "aring" => 544, + "Q" => 768, "R" => 684, "Aacute" => 644, "caron" => 430, + "S" => 561, "T" => 624, "grave" => 430, "U" => 786, + "agrave" => 544, "V" => 645, "W" => 933, "equal" => 600, + "question" => 456, "X" => 634, "Y" => 617, "Z" => 614, + "bracketright" => 335, "Iacute" => 384, "ampersand" => 748, + "four" => 560, "igrave" => 316, "a" => 544, "b" => 605, "c" => 494, + "d" => 605, "plus" => 600, "e" => 519, "quotesinglbase" => 252, + "f" => 342, "g" => 533, "bullet" => 455, "h" => 631, "i" => 316, + "Oslash" => 768, "dagger" => 510, "j" => 316, "Yacute" => 617, + "k" => 582, "l" => 309, "m" => 948, "n" => 638, "o" => 585, + "ordfeminine" => 405, "ring" => 430, "p" => 615, + "threesuperior" => 402, "q" => 597, "acute" => 430, "r" => 440, + "aacute" => 544, "twosuperior" => 402, "s" => 446, "OE" => 1049, + "t" => 370, "divide" => 600, "section" => 566, "u" => 629, + "v" => 520, "w" => 774, "dieresis" => 430, "x" => 522, "y" => 524, + "z" => 483, "iacute" => 316, "quotedblbase" => 473, + "hungarumlaut" => 430, "quotedbl" => 473, "mu" => 629, + "Scaron" => 561, "Lslash" => 591, "semicolon" => 280, + "oslash" => 585, "florin" => 560, "yacute" => 524, "fi" => 639, + "fl" => 639, "Acircumflex" => 644, "parenright" => 365, + "Ecircumflex" => 629, "Icircumflex" => 384, "trademark" => 1090, + "daggerdbl" => 486, "guillemotleft" => 487, "germandbls" => 662, + "macron" => 430, "Otilde" => 768, "seven" => 560, + "ellipsis" => 1000, "scaron" => 446, "ordmasculine" => 427, + "AE" => 879, "Ucircumflex" => 786, "lslash" => 321, + "dotlessi" => 316, "sterling" => 560, "quotedblleft" => 473, + "hyphen" => 392, "guilsinglright" => 287, "quotesingle" => 252, + "eight" => 560, "exclamdown" => 278, "acircumflex" => 544, + "endash" => 500, "oe" => 866, "ecircumflex" => 519, + "copyright" => 800, "Adieresis" => 644, "Egrave" => 629, + "icircumflex" => 316, "slash" => 378, "braceright" => 365, + "Edieresis" => 629, "quotedblright" => 473, "Idieresis" => 384, + "otilde" => 585, "parenleft" => 365, "one" => 560, + "ucircumflex" => 629, "Odieresis" => 768, "bracketleft" => 335, + "Ugrave" => 786, "cent" => 560, "currency" => 560, + "logicalnot" => 600, "quoteright" => 252, "Udieresis" => 786, + "perthousand" => 1289, "Ydieresis" => 617, "Atilde" => 644, + "breve" => 430, "bar" => 284, "fraction" => 100, "Eacute" => 629, + "less" => 600, "adieresis" => 544, "guilsinglleft" => 287, + "egrave" => 519, "exclam" => 278, "edieresis" => 519, "Eth" => 783, + "idieresis" => 316, "period" => 280, "ae" => 806, + "asterisk" => 442, "Uacute" => 786, "odieresis" => 585, + "ugrave" => 629, "five" => 560, "nine" => 560, "greater" => 600, + "udieresis" => 629, "Zcaron" => 614, "threequarters" => 900, + "guillemotright" => 487, "Ccedilla" => 689, "ydieresis" => 524, + "tilde" => 430, "atilde" => 544, "at" => 833, "brokenbar" => 284, + "eacute" => 519, "quoteleft" => 252, "underscore" => 500, + "onesuperior" => 402, + } +); +1; diff --git a/doc/metrics/putbi8a.ph b/doc/metrics/putbi8a.ph new file mode 100644 index 0000000..aeb8174 --- /dev/null +++ b/doc/metrics/putbi8a.ph @@ -0,0 +1,72 @@ +%PS_Utopia_BoldItalic = ( + name => 'Utopia-BoldItalic', + widths => { + "Ntilde" => 741, "multiply" => 600, "zero" => 560, "eth" => 562, + "Ograve" => 761, "uacute" => 634, "braceleft" => 340, + "Thorn" => 629, "zcaron" => 466, "comma" => 280, "cedilla" => 400, + "plusminus" => 600, "ccedilla" => 456, "circumflex" => 400, + "dotaccent" => 402, "asciitilde" => 600, "colon" => 280, + "onehalf" => 940, "dollar" => 560, "ntilde" => 635, + "Ocircumflex" => 761, "Oacute" => 761, "ogonek" => 350, + "ograve" => 562, "thorn" => 600, "degree" => 375, "minus" => 600, + "yen" => 560, "space" => 210, "registered" => 824, + "questiondown" => 454, "Aring" => 634, "percent" => 896, + "emdash" => 1000, "six" => 560, "Agrave" => 634, + "paragraph" => 580, "three" => 560, "numbersign" => 560, + "two" => 560, "Igrave" => 386, "ocircumflex" => 562, + "oacute" => 562, "A" => 634, "B" => 680, "C" => 672, "D" => 774, + "E" => 622, "onequarter" => 940, "F" => 585, "G" => 726, + "H" => 800, "I" => 386, "J" => 388, "K" => 688, "L" => 586, + "backslash" => 460, "asciicircum" => 600, "periodcentered" => 280, + "M" => 921, "N" => 741, "O" => 761, "P" => 660, "aring" => 596, + "Q" => 761, "R" => 681, "Aacute" => 634, "caron" => 400, + "S" => 551, "T" => 616, "grave" => 400, "U" => 776, + "agrave" => 596, "V" => 630, "W" => 920, "equal" => 600, + "question" => 454, "X" => 630, "Y" => 622, "Z" => 618, + "bracketright" => 350, "Iacute" => 386, "ampersand" => 752, + "four" => 560, "igrave" => 339, "a" => 596, "b" => 586, "c" => 456, + "d" => 609, "plus" => 600, "e" => 476, "quotesinglbase" => 246, + "f" => 348, "g" => 522, "bullet" => 465, "h" => 629, "i" => 339, + "Oslash" => 761, "dagger" => 514, "j" => 333, "Yacute" => 622, + "k" => 570, "l" => 327, "m" => 914, "n" => 635, "o" => 562, + "ordfeminine" => 444, "ring" => 400, "p" => 606, + "threesuperior" => 402, "q" => 584, "acute" => 400, "r" => 440, + "aacute" => 596, "twosuperior" => 402, "s" => 417, "OE" => 1016, + "t" => 359, "divide" => 600, "section" => 568, "u" => 634, + "v" => 518, "w" => 795, "dieresis" => 400, "x" => 516, "y" => 489, + "z" => 466, "iacute" => 339, "quotedblbase" => 455, + "hungarumlaut" => 400, "quotedbl" => 455, "mu" => 634, + "Scaron" => 551, "Lslash" => 592, "semicolon" => 280, + "oslash" => 562, "florin" => 560, "yacute" => 489, "fi" => 651, + "fl" => 652, "Acircumflex" => 634, "parenright" => 350, + "Ecircumflex" => 622, "Icircumflex" => 386, "trademark" => 1100, + "daggerdbl" => 490, "guillemotleft" => 560, "germandbls" => 628, + "macron" => 400, "Otilde" => 761, "seven" => 560, + "ellipsis" => 1000, "scaron" => 417, "ordmasculine" => 412, + "AE" => 890, "Ucircumflex" => 776, "lslash" => 339, + "dotlessi" => 339, "sterling" => 560, "quotedblleft" => 455, + "hyphen" => 392, "guilsinglright" => 360, "quotesingle" => 246, + "eight" => 560, "exclamdown" => 285, "acircumflex" => 596, + "endash" => 500, "oe" => 811, "ecircumflex" => 476, + "copyright" => 824, "Adieresis" => 634, "Egrave" => 622, + "icircumflex" => 339, "slash" => 260, "braceright" => 340, + "Edieresis" => 622, "quotedblright" => 455, "Idieresis" => 386, + "otilde" => 562, "parenleft" => 350, "one" => 560, + "ucircumflex" => 634, "Odieresis" => 761, "bracketleft" => 350, + "Ugrave" => 776, "cent" => 560, "currency" => 560, + "logicalnot" => 600, "quoteright" => 246, "Udieresis" => 776, + "perthousand" => 1297, "Ydieresis" => 622, "Atilde" => 634, + "breve" => 400, "bar" => 265, "fraction" => 100, "Eacute" => 622, + "less" => 600, "adieresis" => 596, "guilsinglleft" => 360, + "egrave" => 476, "exclam" => 285, "edieresis" => 476, "Eth" => 780, + "idieresis" => 339, "period" => 280, "ae" => 789, + "asterisk" => 500, "Uacute" => 776, "odieresis" => 562, + "ugrave" => 634, "five" => 560, "nine" => 560, "greater" => 600, + "udieresis" => 634, "Zcaron" => 618, "threequarters" => 940, + "guillemotright" => 560, "Ccedilla" => 672, "ydieresis" => 489, + "tilde" => 400, "atilde" => 596, "at" => 828, "brokenbar" => 265, + "eacute" => 476, "quoteleft" => 246, "underscore" => 500, + "onesuperior" => 402, + } +); +1; diff --git a/doc/metrics/putr8a.ph b/doc/metrics/putr8a.ph new file mode 100644 index 0000000..7f305b8 --- /dev/null +++ b/doc/metrics/putr8a.ph @@ -0,0 +1,72 @@ +%PS_Utopia_Regular = ( + name => 'Utopia-Regular', + widths => { + "Ntilde" => 780, "multiply" => 570, "zero" => 530, "eth" => 577, + "Ograve" => 762, "uacute" => 606, "braceleft" => 340, + "Thorn" => 593, "zcaron" => 480, "comma" => 265, "cedilla" => 400, + "plusminus" => 570, "ccedilla" => 496, "circumflex" => 400, + "dotaccent" => 400, "asciitilde" => 570, "colon" => 265, + "onehalf" => 860, "dollar" => 530, "ntilde" => 619, + "Ocircumflex" => 762, "Oacute" => 762, "ogonek" => 400, + "ograve" => 577, "thorn" => 606, "degree" => 350, "minus" => 570, + "yen" => 530, "space" => 225, "registered" => 818, + "questiondown" => 389, "Aring" => 627, "percent" => 838, + "emdash" => 1000, "six" => 530, "Agrave" => 635, + "paragraph" => 555, "three" => 530, "numbersign" => 530, + "two" => 530, "Igrave" => 349, "ocircumflex" => 577, + "oacute" => 577, "A" => 635, "B" => 646, "C" => 684, "D" => 779, + "E" => 606, "onequarter" => 860, "F" => 580, "G" => 734, + "H" => 798, "I" => 349, "J" => 350, "K" => 658, "L" => 568, + "backslash" => 460, "asciicircum" => 570, "periodcentered" => 265, + "M" => 944, "N" => 780, "O" => 762, "P" => 600, "aring" => 523, + "Q" => 762, "R" => 644, "Aacute" => 635, "caron" => 400, + "S" => 541, "T" => 621, "grave" => 400, "U" => 791, + "agrave" => 523, "V" => 634, "W" => 940, "equal" => 570, + "question" => 389, "X" => 624, "Y" => 588, "Z" => 610, + "bracketright" => 330, "Iacute" => 349, "ampersand" => 706, + "four" => 530, "igrave" => 291, "a" => 523, "b" => 598, "c" => 496, + "d" => 598, "plus" => 570, "e" => 514, "quotesinglbase" => 278, + "f" => 319, "g" => 520, "bullet" => 409, "h" => 607, "i" => 291, + "Oslash" => 762, "dagger" => 504, "j" => 280, "Yacute" => 588, + "k" => 524, "l" => 279, "m" => 923, "n" => 619, "o" => 577, + "ordfeminine" => 390, "ring" => 400, "p" => 608, + "threesuperior" => 380, "q" => 591, "acute" => 400, "r" => 389, + "aacute" => 523, "twosuperior" => 380, "s" => 436, "OE" => 1025, + "t" => 344, "divide" => 570, "section" => 554, "u" => 606, + "v" => 504, "w" => 768, "dieresis" => 400, "x" => 486, "y" => 506, + "z" => 480, "iacute" => 291, "quotedblbase" => 458, + "hungarumlaut" => 400, "quotedbl" => 458, "mu" => 606, + "Scaron" => 541, "Lslash" => 574, "semicolon" => 265, + "oslash" => 577, "florin" => 530, "yacute" => 506, "fi" => 610, + "fl" => 610, "Acircumflex" => 635, "parenright" => 350, + "Ecircumflex" => 606, "Icircumflex" => 349, "trademark" => 1100, + "daggerdbl" => 488, "guillemotleft" => 442, "germandbls" => 601, + "macron" => 400, "Otilde" => 762, "seven" => 530, + "ellipsis" => 1000, "scaron" => 436, "ordmasculine" => 398, + "AE" => 876, "Ucircumflex" => 791, "lslash" => 294, + "dotlessi" => 291, "sterling" => 530, "quotedblleft" => 458, + "hyphen" => 392, "guilsinglright" => 257, "quotesingle" => 278, + "eight" => 530, "exclamdown" => 242, "acircumflex" => 523, + "endash" => 500, "oe" => 882, "ecircumflex" => 514, + "copyright" => 818, "Adieresis" => 635, "Egrave" => 606, + "icircumflex" => 291, "slash" => 460, "braceright" => 340, + "Edieresis" => 606, "quotedblright" => 458, "Idieresis" => 349, + "otilde" => 577, "parenleft" => 350, "one" => 530, + "ucircumflex" => 606, "Odieresis" => 762, "bracketleft" => 330, + "Ugrave" => 791, "cent" => 530, "currency" => 530, + "logicalnot" => 570, "quoteright" => 278, "Udieresis" => 791, + "perthousand" => 1208, "Ydieresis" => 588, "Atilde" => 635, + "breve" => 400, "bar" => 228, "fraction" => 150, "Eacute" => 606, + "less" => 570, "adieresis" => 523, "guilsinglleft" => 257, + "egrave" => 514, "exclam" => 242, "edieresis" => 514, "Eth" => 785, + "idieresis" => 291, "period" => 265, "ae" => 797, + "asterisk" => 412, "Uacute" => 791, "odieresis" => 577, + "ugrave" => 606, "five" => 530, "nine" => 530, "greater" => 570, + "udieresis" => 606, "Zcaron" => 610, "threequarters" => 860, + "guillemotright" => 442, "Ccedilla" => 680, "ydieresis" => 506, + "tilde" => 400, "atilde" => 523, "at" => 793, "brokenbar" => 228, + "eacute" => 514, "quoteleft" => 278, "underscore" => 500, + "onesuperior" => 380, + } +); +1; diff --git a/doc/metrics/putri8a.ph b/doc/metrics/putri8a.ph new file mode 100644 index 0000000..7cb5321 --- /dev/null +++ b/doc/metrics/putri8a.ph @@ -0,0 +1,72 @@ +%PS_Utopia_Italic = ( + name => 'Utopia-Italic', + widths => { + "Ntilde" => 763, "multiply" => 570, "zero" => 530, "eth" => 537, + "Ograve" => 753, "uacute" => 618, "braceleft" => 340, + "Thorn" => 604, "zcaron" => 468, "comma" => 265, "cedilla" => 400, + "plusminus" => 570, "ccedilla" => 441, "circumflex" => 400, + "dotaccent" => 402, "asciitilde" => 570, "colon" => 265, + "onehalf" => 890, "dollar" => 530, "ntilde" => 618, + "Ocircumflex" => 753, "Oacute" => 753, "ogonek" => 350, + "ograve" => 537, "thorn" => 584, "degree" => 400, "minus" => 570, + "yen" => 530, "space" => 225, "registered" => 836, + "questiondown" => 425, "Aring" => 624, "percent" => 826, + "emdash" => 1000, "six" => 530, "Agrave" => 624, + "paragraph" => 560, "three" => 530, "numbersign" => 530, + "two" => 530, "Igrave" => 345, "ocircumflex" => 537, + "oacute" => 537, "A" => 624, "B" => 632, "C" => 661, "D" => 763, + "E" => 596, "onequarter" => 890, "F" => 571, "G" => 709, + "H" => 775, "I" => 345, "J" => 352, "K" => 650, "L" => 565, + "backslash" => 390, "asciicircum" => 570, "periodcentered" => 265, + "M" => 920, "N" => 763, "O" => 753, "P" => 614, "aring" => 561, + "Q" => 753, "R" => 640, "Aacute" => 624, "caron" => 400, + "S" => 533, "T" => 606, "grave" => 400, "U" => 794, + "agrave" => 561, "V" => 637, "W" => 946, "equal" => 570, + "question" => 425, "X" => 632, "Y" => 591, "Z" => 622, + "bracketright" => 330, "Iacute" => 345, "ampersand" => 725, + "four" => 530, "igrave" => 317, "a" => 561, "b" => 559, "c" => 441, + "d" => 587, "plus" => 570, "e" => 453, "quotesinglbase" => 216, + "f" => 315, "g" => 499, "bullet" => 500, "h" => 607, "i" => 317, + "Oslash" => 753, "dagger" => 500, "j" => 309, "Yacute" => 591, + "k" => 545, "l" => 306, "m" => 912, "n" => 618, "o" => 537, + "ordfeminine" => 425, "ring" => 400, "p" => 590, + "threesuperior" => 370, "q" => 559, "acute" => 400, "r" => 402, + "aacute" => 561, "twosuperior" => 370, "s" => 389, "OE" => 1020, + "t" => 341, "divide" => 570, "section" => 530, "u" => 618, + "v" => 510, "w" => 785, "dieresis" => 400, "x" => 516, "y" => 468, + "z" => 468, "iacute" => 317, "quotedblbase" => 402, + "hungarumlaut" => 400, "quotedbl" => 402, "mu" => 618, + "Scaron" => 533, "Lslash" => 571, "semicolon" => 265, + "oslash" => 537, "florin" => 530, "yacute" => 468, "fi" => 607, + "fl" => 603, "Acircumflex" => 624, "parenright" => 350, + "Ecircumflex" => 596, "Icircumflex" => 345, "trademark" => 1100, + "daggerdbl" => 490, "guillemotleft" => 462, "germandbls" => 577, + "macron" => 400, "Otilde" => 753, "seven" => 530, + "ellipsis" => 1000, "scaron" => 389, "ordmasculine" => 389, + "AE" => 880, "Ucircumflex" => 794, "lslash" => 318, + "dotlessi" => 317, "sterling" => 530, "quotedblleft" => 402, + "hyphen" => 392, "guilsinglright" => 277, "quotesingle" => 216, + "eight" => 530, "exclamdown" => 240, "acircumflex" => 561, + "endash" => 500, "oe" => 806, "ecircumflex" => 453, + "copyright" => 836, "Adieresis" => 624, "Egrave" => 596, + "icircumflex" => 317, "slash" => 270, "braceright" => 340, + "Edieresis" => 596, "quotedblright" => 402, "Idieresis" => 345, + "otilde" => 537, "parenleft" => 350, "one" => 530, + "ucircumflex" => 618, "Odieresis" => 753, "bracketleft" => 330, + "Ugrave" => 794, "cent" => 530, "currency" => 530, + "logicalnot" => 570, "quoteright" => 216, "Udieresis" => 794, + "perthousand" => 1200, "Ydieresis" => 591, "Atilde" => 624, + "breve" => 400, "bar" => 270, "fraction" => 100, "Eacute" => 596, + "less" => 570, "adieresis" => 561, "guilsinglleft" => 277, + "egrave" => 453, "exclam" => 240, "edieresis" => 453, "Eth" => 770, + "idieresis" => 317, "period" => 265, "ae" => 779, + "asterisk" => 412, "Uacute" => 794, "odieresis" => 537, + "ugrave" => 618, "five" => 530, "nine" => 530, "greater" => 570, + "udieresis" => 618, "Zcaron" => 622, "threequarters" => 890, + "guillemotright" => 462, "Ccedilla" => 661, "ydieresis" => 468, + "tilde" => 400, "atilde" => 561, "at" => 794, "brokenbar" => 270, + "eacute" => 453, "quoteleft" => 216, "underscore" => 500, + "onesuperior" => 370, + } +); +1; diff --git a/doc/metrics/pzcmi8a.ph b/doc/metrics/pzcmi8a.ph new file mode 100644 index 0000000..a840d26 --- /dev/null +++ b/doc/metrics/pzcmi8a.ph @@ -0,0 +1,72 @@ +%PS_ZapfChancery_MediumItalic = ( + name => 'ZapfChancery-MediumItalic', + widths => { + "multiply" => 520, "Ntilde" => 700, "zero" => 440, "eth" => 400, + "Ograve" => 600, "uacute" => 460, "braceleft" => 240, + "Thorn" => 540, "zcaron" => 440, "comma" => 220, "cedilla" => 300, + "plusminus" => 520, "ccedilla" => 340, "circumflex" => 340, + "dotaccent" => 220, "asciitilde" => 520, "colon" => 260, + "onehalf" => 660, "dollar" => 440, "ntilde" => 460, + "Ocircumflex" => 600, "Oacute" => 600, "ogonek" => 280, + "ograve" => 400, "thorn" => 440, "minus" => 520, "degree" => 400, + "yen" => 440, "space" => 220, "registered" => 740, + "questiondown" => 400, "Aring" => 620, "percent" => 680, + "emdash" => 1000, "six" => 440, "Agrave" => 620, + "paragraph" => 500, "three" => 440, "numbersign" => 440, + "two" => 440, "Igrave" => 380, "oacute" => 400, + "ocircumflex" => 400, "A" => 620, "B" => 600, "C" => 520, + "D" => 700, "E" => 620, "onequarter" => 660, "F" => 580, + "G" => 620, "H" => 680, "I" => 380, "J" => 400, "K" => 660, + "L" => 580, "backslash" => 480, "asciicircum" => 520, + "periodcentered" => 220, "M" => 840, "N" => 700, "O" => 600, + "P" => 540, "aring" => 420, "Q" => 600, "R" => 600, + "Aacute" => 620, "caron" => 340, "S" => 460, "T" => 500, + "grave" => 220, "U" => 740, "agrave" => 420, "V" => 640, + "W" => 880, "equal" => 520, "question" => 380, "X" => 560, + "Y" => 560, "Z" => 620, "bracketright" => 320, "Iacute" => 380, + "ampersand" => 780, "four" => 440, "igrave" => 240, "a" => 420, + "b" => 420, "c" => 340, "d" => 440, "plus" => 520, "e" => 340, + "quotesinglbase" => 180, "f" => 320, "g" => 400, "bullet" => 600, + "h" => 440, "i" => 240, "Oslash" => 660, "dagger" => 460, + "j" => 220, "Yacute" => 560, "k" => 440, "l" => 240, "m" => 620, + "n" => 460, "o" => 400, "ordfeminine" => 260, "ring" => 300, + "p" => 440, "threesuperior" => 264, "q" => 400, "acute" => 300, + "r" => 300, "twosuperior" => 264, "aacute" => 420, "s" => 320, + "OE" => 820, "t" => 320, "divide" => 520, "section" => 420, + "u" => 460, "v" => 440, "w" => 680, "dieresis" => 360, "x" => 420, + "y" => 400, "z" => 440, "iacute" => 240, "quotedblbase" => 280, + "hungarumlaut" => 400, "quotedbl" => 220, "mu" => 460, + "Scaron" => 460, "Lslash" => 580, "semicolon" => 240, + "oslash" => 440, "florin" => 440, "yacute" => 400, "fi" => 520, + "fl" => 520, "Acircumflex" => 620, "parenright" => 220, + "Ecircumflex" => 620, "trademark" => 1000, "Icircumflex" => 380, + "daggerdbl" => 480, "guillemotleft" => 340, "germandbls" => 420, + "macron" => 440, "Otilde" => 600, "seven" => 440, + "ellipsis" => 1000, "scaron" => 320, "ordmasculine" => 260, + "AE" => 740, "Ucircumflex" => 740, "lslash" => 300, + "dotlessi" => 240, "sterling" => 440, "quotedblleft" => 340, + "hyphen" => 280, "guilsinglright" => 260, "quotesingle" => 160, + "eight" => 440, "exclamdown" => 280, "acircumflex" => 420, + "endash" => 500, "oe" => 560, "ecircumflex" => 340, + "copyright" => 740, "Adieresis" => 620, "Egrave" => 620, + "icircumflex" => 240, "slash" => 340, "braceright" => 240, + "Edieresis" => 620, "quotedblright" => 360, "otilde" => 400, + "Idieresis" => 380, "parenleft" => 260, "one" => 440, + "Odieresis" => 600, "ucircumflex" => 460, "bracketleft" => 240, + "Ugrave" => 740, "cent" => 440, "currency" => 440, + "logicalnot" => 520, "quoteright" => 240, "Udieresis" => 740, + "perthousand" => 960, "Ydieresis" => 560, "Atilde" => 620, + "breve" => 440, "bar" => 520, "fraction" => 60, "Eacute" => 620, + "less" => 520, "adieresis" => 420, "guilsinglleft" => 240, + "egrave" => 340, "exclam" => 280, "edieresis" => 340, "Eth" => 700, + "idieresis" => 240, "period" => 220, "ae" => 540, + "asterisk" => 420, "odieresis" => 400, "Uacute" => 740, + "ugrave" => 460, "five" => 440, "nine" => 440, "greater" => 520, + "Zcaron" => 620, "udieresis" => 460, "threequarters" => 660, + "guillemotright" => 380, "Ccedilla" => 520, "ydieresis" => 400, + "tilde" => 440, "atilde" => 420, "at" => 700, "brokenbar" => 520, + "eacute" => 340, "quoteleft" => 240, "underscore" => 500, + "onesuperior" => 264, + } +); +1; diff --git a/doc/metrics/pzdr.ph b/doc/metrics/pzdr.ph new file mode 100644 index 0000000..115caac --- /dev/null +++ b/doc/metrics/pzdr.ph @@ -0,0 +1,57 @@ +%PS_ZapfDingbats = ( + name => 'ZapfDingbats', + widths => { + "a81" => 438, "a82" => 138, "a83" => 277, "a84" => 415, + "a85" => 509, "a86" => 410, "a87" => 234, "a88" => 234, + "a89" => 390, "a140" => 788, "a141" => 788, "a142" => 788, + "a143" => 788, "a144" => 788, "a145" => 788, "a146" => 788, + "a147" => 788, "a148" => 788, "a149" => 788, "a10" => 692, + "a11" => 960, "a12" => 939, "a13" => 549, "a14" => 855, + "a15" => 911, "a16" => 933, "a17" => 945, "a90" => 390, + "a18" => 974, "a91" => 276, "a19" => 755, "a92" => 276, + "space" => 278, "a93" => 317, "a94" => 317, "a95" => 334, + "a96" => 334, "a97" => 392, "a98" => 392, "a99" => 668, + "a150" => 788, "a151" => 788, "a152" => 788, "a153" => 788, + "a154" => 788, "a155" => 788, "a156" => 788, "a157" => 788, + "a158" => 788, "a159" => 788, "a20" => 846, "a21" => 762, + "a22" => 761, "a23" => 571, "a24" => 677, "a25" => 763, + "a26" => 760, "a27" => 759, "a28" => 754, "a29" => 786, + "a160" => 894, "a161" => 838, "a162" => 924, "a163" => 1016, + "a164" => 458, "a165" => 924, "a166" => 918, "a167" => 927, + "a168" => 928, "a169" => 928, "a30" => 788, "a31" => 788, + "a32" => 790, "a33" => 793, "a34" => 794, "a35" => 816, + "a36" => 823, "a37" => 789, "a38" => 841, "a39" => 823, + "a170" => 834, "a171" => 873, "a172" => 828, "a173" => 924, + "a174" => 917, "a175" => 930, "a176" => 931, "a177" => 463, + "a178" => 883, "a179" => 836, "a40" => 833, "a41" => 816, + "a42" => 831, "a43" => 923, "a44" => 744, "a45" => 723, + "a46" => 749, "a47" => 790, "a48" => 792, "a49" => 695, + "a100" => 668, "a101" => 732, "a102" => 544, "a103" => 544, + "a104" => 910, "a105" => 911, "a106" => 667, "a107" => 760, + "a180" => 867, "a108" => 760, "a181" => 696, "a109" => 626, + "a182" => 874, "a183" => 760, "a184" => 946, "a185" => 865, + "a186" => 967, "a187" => 831, "a188" => 873, "a189" => 927, + "a50" => 776, "a51" => 768, "a52" => 792, "a53" => 759, + "a54" => 707, "a55" => 708, "a56" => 682, "a57" => 701, + "a58" => 826, "a59" => 815, "a1" => 974, "a2" => 961, + "a110" => 694, "a3" => 980, "a111" => 595, "a4" => 719, + "a112" => 776, "a5" => 789, "a6" => 494, "a7" => 552, "a8" => 537, + "a117" => 690, "a9" => 577, "a190" => 970, "a118" => 791, + "a191" => 918, "a119" => 790, "a192" => 748, "a193" => 836, + "a194" => 771, "a195" => 888, "a196" => 748, "a197" => 771, + "a198" => 888, "a199" => 867, "a60" => 789, "a61" => 789, + "a62" => 707, "a63" => 687, "a64" => 696, "a65" => 689, + "a66" => 786, "a67" => 787, "a68" => 713, "a69" => 791, + "a200" => 696, "a201" => 874, "a120" => 788, "a202" => 974, + "a121" => 788, "a203" => 762, "a122" => 788, "a204" => 759, + "a123" => 788, "a205" => 509, "a124" => 788, "a206" => 410, + "a125" => 788, "a126" => 788, "a127" => 788, "a128" => 788, + "a129" => 788, "a70" => 785, "a71" => 791, "a72" => 873, + "a73" => 761, "a74" => 762, "a75" => 759, "a76" => 892, + "a77" => 892, "a78" => 788, "a79" => 784, "a130" => 788, + "a131" => 788, "a132" => 788, "a133" => 788, "a134" => 788, + "a135" => 788, "a136" => 788, "a137" => 788, "a138" => 788, + "a139" => 788, + } +); +1; diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src new file mode 100644 index 0000000..b98c3be --- /dev/null +++ b/doc/nasmdoc.src @@ -0,0 +1,7930 @@ +\# -------------------------------------------------------------------------- +\# +\# Copyright 1996-2009 The NASM Authors - All Rights Reserved +\# See the file AUTHORS included with the NASM distribution for +\# the specific copyright holders. +\# +\# Redistribution and use in source and binary forms, with or without +\# modification, are permitted provided that the following +\# conditions are met: +\# +\# * Redistributions of source code must retain the above copyright +\# notice, this list of conditions and the following disclaimer. +\# * Redistributions in binary form must reproduce the above +\# copyright notice, this list of conditions and the following +\# disclaimer in the documentation and/or other materials provided +\# with the distribution. +\# +\# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +\# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +\# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +\# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +\# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +\# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +\# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +\# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +\# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +\# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +\# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +\# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +\# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +\# +\# -------------------------------------------------------------------------- +\# +\# Source code to NASM documentation +\# +\M{category}{Programming} +\M{title}{NASM - The Netwide Assembler} +\M{year}{1996-2009} +\M{author}{The NASM Development Team} +\M{copyright_tail}{-- All Rights Reserved} +\M{license}{This document is redistributable under the license given in the file "COPYING" distributed in the NASM archive.} +\M{auxinfo}{This release is dedicated to the memory of Charles A. Crayne. We miss you, Chuck.} +\M{summary}{This file documents NASM, the Netwide Assembler: an assembler targetting the Intel x86 series of processors, with portable source.} +\M{infoname}{NASM} +\M{infofile}{nasm} +\M{infotitle}{The Netwide Assembler for x86} +\M{epslogo}{nasmlogo.eps} +\IR{-D} \c{-D} option +\IR{-E} \c{-E} option +\IR{-F} \c{-F} option +\IR{-I} \c{-I} option +\IR{-M} \c{-M} option +\IR{-MD} \c{-MD} option +\IR{-MF} \c{-MF} option +\IR{-MG} \c{-MG} option +\IR{-MP} \c{-MP} option +\IR{-MQ} \c{-MQ} option +\IR{-MT} \c{-MT} option +\IR{-O} \c{-O} option +\IR{-P} \c{-P} option +\IR{-U} \c{-U} option +\IR{-X} \c{-X} option +\IR{-a} \c{-a} option +\IR{-d} \c{-d} option +\IR{-e} \c{-e} option +\IR{-f} \c{-f} option +\IR{-g} \c{-g} option +\IR{-i} \c{-i} option +\IR{-l} \c{-l} option +\IR{-o} \c{-o} option +\IR{-p} \c{-p} option +\IR{-s} \c{-s} option +\IR{-u} \c{-u} option +\IR{-v} \c{-v} option +\IR{-W} \c{-W} option +\IR{-w} \c{-w} option +\IR{-y} \c{-y} option +\IR{-Z} \c{-Z} option +\IR{!=} \c{!=} operator +\IR{$, here} \c{$}, Here token +\IR{$, prefix} \c{$}, prefix +\IR{$$} \c{$$} token +\IR{%} \c{%} operator +\IR{%%} \c{%%} operator +\IR{%+1} \c{%+1} and \c{%-1} syntax +\IA{%-1}{%+1} +\IR{%0} \c{%0} parameter count +\IR{&} \c{&} operator +\IR{&&} \c{&&} operator +\IR{*} \c{*} operator +\IR{..@} \c{..@} symbol prefix +\IR{/} \c{/} operator +\IR{//} \c{//} operator +\IR{<} \c{<} operator +\IR{<<} \c{<<} operator +\IR{<=} \c{<=} operator +\IR{<>} \c{<>} operator +\IR{=} \c{=} operator +\IR{==} \c{==} operator +\IR{>} \c{>} operator +\IR{>=} \c{>=} operator +\IR{>>} \c{>>} operator +\IR{?} \c{?} MASM syntax +\IR{^} \c{^} operator +\IR{^^} \c{^^} operator +\IR{|} \c{|} operator +\IR{||} \c{||} operator +\IR{~} \c{~} operator +\IR{%$} \c{%$} and \c{%$$} prefixes +\IA{%$$}{%$} +\IR{+ opaddition} \c{+} operator, binary +\IR{+ opunary} \c{+} operator, unary +\IR{+ modifier} \c{+} modifier +\IR{- opsubtraction} \c{-} operator, binary +\IR{- opunary} \c{-} operator, unary +\IR{! opunary} \c{!} operator, unary +\IR{alignment, in bin sections} alignment, in \c{bin} sections +\IR{alignment, in elf sections} alignment, in \c{elf} sections +\IR{alignment, in win32 sections} alignment, in \c{win32} sections +\IR{alignment, of elf common variables} alignment, of \c{elf} common +variables +\IR{alignment, in obj sections} alignment, in \c{obj} sections +\IR{a.out, bsd version} \c{a.out}, BSD version +\IR{a.out, linux version} \c{a.out}, Linux version +\IR{autoconf} Autoconf +\IR{bin} bin +\IR{bitwise and} bitwise AND +\IR{bitwise or} bitwise OR +\IR{bitwise xor} bitwise XOR +\IR{block ifs} block IFs +\IR{borland pascal} Borland, Pascal +\IR{borland's win32 compilers} Borland, Win32 compilers +\IR{braces, after % sign} braces, after \c{%} sign +\IR{bsd} BSD +\IR{c calling convention} C calling convention +\IR{c symbol names} C symbol names +\IA{critical expressions}{critical expression} +\IA{command line}{command-line} +\IA{case sensitivity}{case sensitive} +\IA{case-sensitive}{case sensitive} +\IA{case-insensitive}{case sensitive} +\IA{character constants}{character constant} +\IR{common object file format} Common Object File Format +\IR{common variables, alignment in elf} common variables, alignment +in \c{elf} +\IR{common, elf extensions to} \c{COMMON}, \c{elf} extensions to +\IR{common, obj extensions to} \c{COMMON}, \c{obj} extensions to +\IR{declaring structure} declaring structures +\IR{default-wrt mechanism} default-\c{WRT} mechanism +\IR{devpac} DevPac +\IR{djgpp} DJGPP +\IR{dll symbols, exporting} DLL symbols, exporting +\IR{dll symbols, importing} DLL symbols, importing +\IR{dos} DOS +\IR{dos archive} DOS archive +\IR{dos source archive} DOS source archive +\IA{effective address}{effective addresses} +\IA{effective-address}{effective addresses} +\IR{elf} ELF +\IR{elf, 16-bit code and} ELF, 16-bit code and +\IR{elf shared libraries} ELF, shared libraries +\IR{elf32} \c{elf32} +\IR{elf64} \c{elf64} +\IR{executable and linkable format} Executable and Linkable Format +\IR{extern, obj extensions to} \c{EXTERN}, \c{obj} extensions to +\IR{extern, rdf extensions to} \c{EXTERN}, \c{rdf} extensions to +\IR{floating-point, constants} floating-point, constants +\IR{floating-point, packed bcd constants} floating-point, packed BCD constants +\IR{freebsd} FreeBSD +\IR{freelink} FreeLink +\IR{functions, c calling convention} functions, C calling convention +\IR{functions, pascal calling convention} functions, Pascal calling +convention +\IR{global, aoutb extensions to} \c{GLOBAL}, \c{aoutb} extensions to +\IR{global, elf extensions to} \c{GLOBAL}, \c{elf} extensions to +\IR{global, rdf extensions to} \c{GLOBAL}, \c{rdf} extensions to +\IR{got} GOT +\IR{got relocations} \c{GOT} relocations +\IR{gotoff relocation} \c{GOTOFF} relocations +\IR{gotpc relocation} \c{GOTPC} relocations +\IR{intel number formats} Intel number formats +\IR{linux, elf} Linux, ELF +\IR{linux, a.out} Linux, \c{a.out} +\IR{linux, as86} Linux, \c{as86} +\IR{logical and} logical AND +\IR{logical or} logical OR +\IR{logical xor} logical XOR +\IR{mach object file format} Mach, object file format +\IR{mach-o} Mach-O +\IR{macho32} \c{macho32} +\IR{macho64} \c{macho64} +\IR{macos x} MacOS X +\IR{masm} MASM +\IA{memory reference}{memory references} +\IR{minix} Minix +\IA{misc directory}{misc subdirectory} +\IR{misc subdirectory} \c{misc} subdirectory +\IR{microsoft omf} Microsoft OMF +\IR{mmx registers} MMX registers +\IA{modr/m}{modr/m byte} +\IR{modr/m byte} ModR/M byte +\IR{ms-dos} MS-DOS +\IR{ms-dos device drivers} MS-DOS device drivers +\IR{multipush} \c{multipush} macro +\IR{nan} NaN +\IR{nasm version} NASM version +\IR{netbsd} NetBSD +\IR{omf} OMF +\IR{openbsd} OpenBSD +\IR{operating system} operating system +\IR{os/2} OS/2 +\IR{pascal calling convention}Pascal calling convention +\IR{passes} passes, assembly +\IR{perl} Perl +\IR{pic} PIC +\IR{pharlap} PharLap +\IR{plt} PLT +\IR{plt} \c{PLT} relocations +\IA{pre-defining macros}{pre-define} +\IA{preprocessor expressions}{preprocessor, expressions} +\IA{preprocessor loops}{preprocessor, loops} +\IA{preprocessor variables}{preprocessor, variables} +\IA{rdoff subdirectory}{rdoff} +\IR{rdoff} \c{rdoff} subdirectory +\IR{relocatable dynamic object file format} Relocatable Dynamic +Object File Format +\IR{relocations, pic-specific} relocations, PIC-specific +\IA{repeating}{repeating code} +\IR{section alignment, in elf} section alignment, in \c{elf} +\IR{section alignment, in bin} section alignment, in \c{bin} +\IR{section alignment, in obj} section alignment, in \c{obj} +\IR{section alignment, in win32} section alignment, in \c{win32} +\IR{section, elf extensions to} \c{SECTION}, \c{elf} extensions to +\IR{section, win32 extensions to} \c{SECTION}, \c{win32} extensions to +\IR{segment alignment, in bin} segment alignment, in \c{bin} +\IR{segment alignment, in obj} segment alignment, in \c{obj} +\IR{segment, obj extensions to} \c{SEGMENT}, \c{elf} extensions to +\IR{segment names, borland pascal} segment names, Borland Pascal +\IR{shift command} \c{shift} command +\IA{sib}{sib byte} +\IR{sib byte} SIB byte +\IR{align, smart} \c{ALIGN}, smart +\IR{solaris x86} Solaris x86 +\IA{standard section names}{standardized section names} +\IR{symbols, exporting from dlls} symbols, exporting from DLLs +\IR{symbols, importing from dlls} symbols, importing from DLLs +\IR{test subdirectory} \c{test} subdirectory +\IR{tlink} \c{TLINK} +\IR{underscore, in c symbols} underscore, in C symbols +\IR{unicode} Unicode +\IR{unix} Unix +\IR{utf-8} UTF-8 +\IR{utf-16} UTF-16 +\IR{utf-32} UTF-32 +\IA{sco unix}{unix, sco} +\IR{unix, sco} Unix, SCO +\IA{unix source archive}{unix, source archive} +\IR{unix, source archive} Unix, source archive +\IA{unix system v}{unix, system v} +\IR{unix, system v} Unix, System V +\IR{unixware} UnixWare +\IR{val} VAL +\IR{version number of nasm} version number of NASM +\IR{visual c++} Visual C++ +\IR{www page} WWW page +\IR{win32} Win32 +\IR{win32} Win64 +\IR{windows} Windows +\IR{windows 95} Windows 95 +\IR{windows nt} Windows NT +\# \IC{program entry point}{entry point, program} +\# \IC{program entry point}{start point, program} +\# \IC{MS-DOS device drivers}{device drivers, MS-DOS} +\# \IC{16-bit mode, versus 32-bit mode}{32-bit mode, versus 16-bit mode} +\# \IC{c symbol names}{symbol names, in C} + + +\C{intro} Introduction + +\H{whatsnasm} What Is NASM? + +The Netwide Assembler, NASM, is an 80x86 and x86-64 assembler designed +for portability and modularity. It supports a range of object file +formats, including Linux and \c{*BSD} \c{a.out}, \c{ELF}, \c{COFF}, +\c{Mach-O}, Microsoft 16-bit \c{OBJ}, \c{Win32} and \c{Win64}. It will +also output plain binary files. Its syntax is designed to be simple +and easy to understand, similar to Intel's but less complex. It +supports all currently known x86 architectural extensions, and has +strong support for macros. + + +\S{yaasm} Why Yet Another Assembler? + +The Netwide Assembler grew out of an idea on \i\c{comp.lang.asm.x86} +(or possibly \i\c{alt.lang.asm} - I forget which), which was +essentially that there didn't seem to be a good \e{free} x86-series +assembler around, and that maybe someone ought to write one. + +\b \i\c{a86} is good, but not free, and in particular you don't get any +32-bit capability until you pay. It's DOS only, too. + +\b \i\c{gas} is free, and ports over to DOS and Unix, but it's not +very good, since it's designed to be a back end to \i\c{gcc}, which +always feeds it correct code. So its error checking is minimal. Also, +its syntax is horrible, from the point of view of anyone trying to +actually \e{write} anything in it. Plus you can't write 16-bit code in +it (properly.) + +\b \i\c{as86} is specific to Minix and Linux, and (my version at least) +doesn't seem to have much (or any) documentation. + +\b \i\c{MASM} isn't very good, and it's (was) expensive, and it runs only under +DOS. + +\b \i\c{TASM} is better, but still strives for MASM compatibility, +which means millions of directives and tons of red tape. And its syntax +is essentially MASM's, with the contradictions and quirks that +entails (although it sorts out some of those by means of Ideal mode.) +It's expensive too. And it's DOS-only. + +So here, for your coding pleasure, is NASM. At present it's +still in prototype stage - we don't promise that it can outperform +any of these assemblers. But please, \e{please} send us bug reports, +fixes, helpful information, and anything else you can get your hands +on (and thanks to the many people who've done this already! You all +know who you are), and we'll improve it out of all recognition. +Again. + + +\S{legal} \i{License} Conditions + +Please see the file \c{LICENSE}, supplied as part of any NASM +distribution archive, for the license conditions under which you may +use NASM. NASM is now under the so-called 2-clause BSD license, also +known as the simplified BSD license. + +Copyright 1996-2009 the NASM Authors - All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +\b Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +\b Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +\H{contact} Contact Information + +The current version of NASM (since about 0.98.08) is maintained by a +team of developers, accessible through the \c{nasm-devel} mailing list +(see below for the link). +If you want to report a bug, please read \k{bugs} first. + +NASM has a \i{website} at +\W{http://www.nasm.us/}\c{http://www.nasm.us/}. If it's not there, +google for us! + +\i{New releases}, \i{release candidates}, and \I{snapshots, daily +development}\i{daily development snapshots} of NASM are available from +the official web site. + +Announcements are posted to +\W{news:comp.lang.asm.x86}\i\c{comp.lang.asm.x86}, +and to the web site +\W{http://www.freshmeat.net/}\c{http://www.freshmeat.net/}. + +If you want information about the current development status, please +subscribe to the \i\c{nasm-devel} email list; see link from the +website. + + +\H{install} Installation + +\S{instdos} \i{Installing} NASM under MS-\i{DOS} or Windows + +Once you've obtained the appropriate archive for NASM, +\i\c{nasm-XXX-dos.zip} or \i\c{nasm-XXX-win32.zip} (where \c{XXX} +denotes the version number of NASM contained in the archive), unpack +it into its own directory (for example \c{c:\\nasm}). + +The archive will contain a set of executable files: the NASM +executable file \i\c{nasm.exe}, the NDISASM executable file +\i\c{ndisasm.exe}, and possibly additional utilities to handle the +RDOFF file format. + +The only file NASM needs to run is its own executable, so copy +\c{nasm.exe} to a directory on your PATH, or alternatively edit +\i\c{autoexec.bat} to add the \c{nasm} directory to your +\i\c{PATH} (to do that under Windows XP, go to Start > Control Panel > +System > Advanced > Environment Variables; these instructions may work +under other versions of Windows as well.) + +That's it - NASM is installed. You don't need the nasm directory +to be present to run NASM (unless you've added it to your \c{PATH}), +so you can delete it if you need to save space; however, you may +want to keep the documentation or test programs. + +If you've downloaded the \i{DOS source archive}, \i\c{nasm-XXX.zip}, +the \c{nasm} directory will also contain the full NASM \i{source +code}, and a selection of \i{Makefiles} you can (hopefully) use to +rebuild your copy of NASM from scratch. See the file \c{INSTALL} in +the source archive. + +Note that a number of files are generated from other files by Perl +scripts. Although the NASM source distribution includes these +generated files, you will need to rebuild them (and hence, will need a +Perl interpreter) if you change insns.dat, standard.mac or the +documentation. It is possible future source distributions may not +include these files at all. Ports of \i{Perl} for a variety of +platforms, including DOS and Windows, are available from +\W{http://www.cpan.org/ports/}\i{www.cpan.org}. + + +\S{instdos} Installing NASM under \i{Unix} + +Once you've obtained the \i{Unix source archive} for NASM, +\i\c{nasm-XXX.tar.gz} (where \c{XXX} denotes the version number of +NASM contained in the archive), unpack it into a directory such +as \c{/usr/local/src}. The archive, when unpacked, will create its +own subdirectory \c{nasm-XXX}. + +NASM is an \I{Autoconf}\I\c{configure}auto-configuring package: once +you've unpacked it, \c{cd} to the directory it's been unpacked into +and type \c{./configure}. This shell script will find the best C +compiler to use for building NASM and set up \i{Makefiles} +accordingly. + +Once NASM has auto-configured, you can type \i\c{make} to build the +\c{nasm} and \c{ndisasm} binaries, and then \c{make install} to +install them in \c{/usr/local/bin} and install the \i{man pages} +\i\c{nasm.1} and \i\c{ndisasm.1} in \c{/usr/local/man/man1}. +Alternatively, you can give options such as \c{--prefix} to the +configure script (see the file \i\c{INSTALL} for more details), or +install the programs yourself. + +NASM also comes with a set of utilities for handling the \c{RDOFF} +custom object-file format, which are in the \i\c{rdoff} subdirectory +of the NASM archive. You can build these with \c{make rdf} and +install them with \c{make rdf_install}, if you want them. + + +\C{running} Running NASM + +\H{syntax} NASM \i{Command-Line} Syntax + +To assemble a file, you issue a command of the form + +\c nasm -f <format> <filename> [-o <output>] + +For example, + +\c nasm -f elf myfile.asm + +will assemble \c{myfile.asm} into an \c{ELF} object file \c{myfile.o}. And + +\c nasm -f bin myfile.asm -o myfile.com + +will assemble \c{myfile.asm} into a raw binary file \c{myfile.com}. + +To produce a listing file, with the hex codes output from NASM +displayed on the left of the original sources, use the \c{-l} option +to give a listing file name, for example: + +\c nasm -f coff myfile.asm -l myfile.lst + +To get further usage instructions from NASM, try typing + +\c nasm -h + +As \c{-hf}, this will also list the available output file formats, and what they +are. + +If you use Linux but aren't sure whether your system is \c{a.out} +or \c{ELF}, type + +\c file nasm + +(in the directory in which you put the NASM binary when you +installed it). If it says something like + +\c nasm: ELF 32-bit LSB executable i386 (386 and up) Version 1 + +then your system is \c{ELF}, and you should use the option \c{-f elf} +when you want NASM to produce Linux object files. If it says + +\c nasm: Linux/i386 demand-paged executable (QMAGIC) + +or something similar, your system is \c{a.out}, and you should use +\c{-f aout} instead (Linux \c{a.out} systems have long been obsolete, +and are rare these days.) + +Like Unix compilers and assemblers, NASM is silent unless it +goes wrong: you won't see any output at all, unless it gives error +messages. + + +\S{opt-o} The \i\c{-o} Option: Specifying the Output File Name + +NASM will normally choose the name of your output file for you; +precisely how it does this is dependent on the object file format. +For Microsoft object file formats (\c{obj}, \c{win32} and \c{win64}), +it will remove the \c{.asm} \i{extension} (or whatever extension you +like to use - NASM doesn't care) from your source file name and +substitute \c{.obj}. For Unix object file formats (\c{aout}, \c{as86}, +\c{coff}, \c{elf32}, \c{elf64}, \c{ieee}, \c{macho32} and \c{macho64}) +it will substitute \c{.o}. For \c{dbg}, \c{rdf}, \c{ith} and \c{srec}, +it will use \c{.dbg}, \c{.rdf}, \c{.ith} and \c{.srec}, respectively, +and for the \c{bin} format it will simply remove the extension, so +that \c{myfile.asm} produces the output file \c{myfile}. + +If the output file already exists, NASM will overwrite it, unless it +has the same name as the input file, in which case it will give a +warning and use \i\c{nasm.out} as the output file name instead. + +For situations in which this behaviour is unacceptable, NASM +provides the \c{-o} command-line option, which allows you to specify +your desired output file name. You invoke \c{-o} by following it +with the name you wish for the output file, either with or without +an intervening space. For example: + +\c nasm -f bin program.asm -o program.com +\c nasm -f bin driver.asm -odriver.sys + +Note that this is a small o, and is different from a capital O , which +is used to specify the number of optimisation passes required. See \k{opt-O}. + + +\S{opt-f} The \i\c{-f} Option: Specifying the \i{Output File Format} + +If you do not supply the \c{-f} option to NASM, it will choose an +output file format for you itself. In the distribution versions of +NASM, the default is always \i\c{bin}; if you've compiled your own +copy of NASM, you can redefine \i\c{OF_DEFAULT} at compile time and +choose what you want the default to be. + +Like \c{-o}, the intervening space between \c{-f} and the output +file format is optional; so \c{-f elf} and \c{-felf} are both valid. + +A complete list of the available output file formats can be given by +issuing the command \i\c{nasm -hf}. + + +\S{opt-l} The \i\c{-l} Option: Generating a \i{Listing File} + +If you supply the \c{-l} option to NASM, followed (with the usual +optional space) by a file name, NASM will generate a +\i{source-listing file} for you, in which addresses and generated +code are listed on the left, and the actual source code, with +expansions of multi-line macros (except those which specifically +request no expansion in source listings: see \k{nolist}) on the +right. For example: + +\c nasm -f elf myfile.asm -l myfile.lst + +If a list file is selected, you may turn off listing for a +section of your source with \c{[list -]}, and turn it back on +with \c{[list +]}, (the default, obviously). There is no "user +form" (without the brackets). This can be used to list only +sections of interest, avoiding excessively long listings. + + +\S{opt-M} The \i\c{-M} Option: Generate \i{Makefile Dependencies} + +This option can be used to generate makefile dependencies on stdout. +This can be redirected to a file for further processing. For example: + +\c nasm -M myfile.asm > myfile.dep + + +\S{opt-MG} The \i\c{-MG} Option: Generate \i{Makefile Dependencies} + +This option can be used to generate makefile dependencies on stdout. +This differs from the \c{-M} option in that if a nonexisting file is +encountered, it is assumed to be a generated file and is added to the +dependency list without a prefix. + + +\S{opt-MF} The \i\c\{-MF} Option: Set Makefile Dependency File + +This option can be used with the \c{-M} or \c{-MG} options to send the +output to a file, rather than to stdout. For example: + +\c nasm -M -MF myfile.dep myfile.asm + + +\S{opt-MD} The \i\c{-MD} Option: Assemble and Generate Dependencies + +The \c{-MD} option acts as the combination of the \c{-M} and \c{-MF} +options (i.e. a filename has to be specified.) However, unlike the +\c{-M} or \c{-MG} options, \c{-MD} does \e{not} inhibit the normal +operation of the assembler. Use this to automatically generate +updated dependencies with every assembly session. For example: + +\c nasm -f elf -o myfile.o -MD myfile.dep myfile.asm + + +\S{opt-MT} The \i\c{-MT} Option: Dependency Target Name + +The \c{-MT} option can be used to override the default name of the +dependency target. This is normally the same as the output filename, +specified by the \c{-o} option. + + +\S{opt-MQ} The \i\c{-MQ} Option: Dependency Target Name (Quoted) + +The \c{-MQ} option acts as the \c{-MT} option, except it tries to +quote characters that have special meaning in Makefile syntax. This +is not foolproof, as not all characters with special meaning are +quotable in Make. + + +\S{opt-MP} The \i\c{-MP} Option: Emit phony targets + +When used with any of the dependency generation options, the \c{-MP} +option causes NASM to emit a phony target without dependencies for +each header file. This prevents Make from complaining if a header +file has been removed. + + +\S{opt-F} The \i\c{-F} Option: Selecting a \i{Debug Information Format} + +This option is used to select the format of the debug information +emitted into the output file, to be used by a debugger (or \e{will} +be). Prior to version 2.03.01, the use of this switch did \e{not} enable +output of the selected debug info format. Use \c{-g}, see \k{opt-g}, +to enable output. Versions 2.03.01 and later automatically enable \c{-g} +if \c{-F} is specified. + +A complete list of the available debug file formats for an output +format can be seen by issuing the command \c{nasm -f <format> -y}. Not +all output formats currently support debugging output. See \k{opt-y}. + +This should not be confused with the \c{-f dbg} output format option which +is not built into NASM by default. For information on how +to enable it when building from the sources, see \k{dbgfmt}. + + +\S{opt-g} The \i\c{-g} Option: Enabling \i{Debug Information}. + +This option can be used to generate debugging information in the specified +format. See \k{opt-F}. Using \c{-g} without \c{-F} results in emitting +debug info in the default format, if any, for the selected output format. +If no debug information is currently implemented in the selected output +format, \c{-g} is \e{silently ignored}. + + +\S{opt-X} The \i\c{-X} Option: Selecting an \i{Error Reporting Format} + +This option can be used to select an error reporting format for any +error messages that might be produced by NASM. + +Currently, two error reporting formats may be selected. They are +the \c{-Xvc} option and the \c{-Xgnu} option. The GNU format is +the default and looks like this: + +\c filename.asm:65: error: specific error message + +where \c{filename.asm} is the name of the source file in which the +error was detected, \c{65} is the source file line number on which +the error was detected, \c{error} is the severity of the error (this +could be \c{warning}), and \c{specific error message} is a more +detailed text message which should help pinpoint the exact problem. + +The other format, specified by \c{-Xvc} is the style used by Microsoft +Visual C++ and some other programs. It looks like this: + +\c filename.asm(65) : error: specific error message + +where the only difference is that the line number is in parentheses +instead of being delimited by colons. + +See also the \c{Visual C++} output format, \k{win32fmt}. + +\S{opt-Z} The \i\c{-Z} Option: Send Errors to a File + +Under \I{DOS}\c{MS-DOS} it can be difficult (though there are ways) to +redirect the standard-error output of a program to a file. Since +NASM usually produces its warning and \i{error messages} on +\i\c{stderr}, this can make it hard to capture the errors if (for +example) you want to load them into an editor. + +NASM therefore provides the \c{-Z} option, taking a filename argument +which causes errors to be sent to the specified files rather than +standard error. Therefore you can \I{redirecting errors}redirect +the errors into a file by typing + +\c nasm -Z myfile.err -f obj myfile.asm + +In earlier versions of NASM, this option was called \c{-E}, but it was +changed since \c{-E} is an option conventionally used for +preprocessing only, with disastrous results. See \k{opt-E}. + +\S{opt-s} The \i\c{-s} Option: Send Errors to \i\c{stdout} + +The \c{-s} option redirects \i{error messages} to \c{stdout} rather +than \c{stderr}, so it can be redirected under \I{DOS}\c{MS-DOS}. To +assemble the file \c{myfile.asm} and pipe its output to the \c{more} +program, you can type: + +\c nasm -s -f obj myfile.asm | more + +See also the \c{-Z} option, \k{opt-Z}. + + +\S{opt-i} The \i\c{-i}\I\c{-I} Option: Include File Search Directories + +When NASM sees the \i\c{%include} or \i\c{%pathsearch} directive in a +source file (see \k{include}, \k{pathsearch} or \k{incbin}), it will +search for the given file not only in the current directory, but also +in any directories specified on the command line by the use of the +\c{-i} option. Therefore you can include files from a \i{macro +library}, for example, by typing + +\c nasm -ic:\macrolib\ -f obj myfile.asm + +(As usual, a space between \c{-i} and the path name is allowed, and +optional). + +NASM, in the interests of complete source-code portability, does not +understand the file naming conventions of the OS it is running on; +the string you provide as an argument to the \c{-i} option will be +prepended exactly as written to the name of the include file. +Therefore the trailing backslash in the above example is necessary. +Under Unix, a trailing forward slash is similarly necessary. + +(You can use this to your advantage, if you're really \i{perverse}, +by noting that the option \c{-ifoo} will cause \c{%include "bar.i"} +to search for the file \c{foobar.i}...) + +If you want to define a \e{standard} \i{include search path}, +similar to \c{/usr/include} on Unix systems, you should place one or +more \c{-i} directives in the \c{NASMENV} environment variable (see +\k{nasmenv}). + +For Makefile compatibility with many C compilers, this option can also +be specified as \c{-I}. + + +\S{opt-p} The \i\c{-p}\I\c{-P} Option: \I{pre-including files}Pre-Include a File + +\I\c{%include}NASM allows you to specify files to be +\e{pre-included} into your source file, by the use of the \c{-p} +option. So running + +\c nasm myfile.asm -p myinc.inc + +is equivalent to running \c{nasm myfile.asm} and placing the +directive \c{%include "myinc.inc"} at the start of the file. + +For consistency with the \c{-I}, \c{-D} and \c{-U} options, this +option can also be specified as \c{-P}. + + +\S{opt-d} The \i\c{-d}\I\c{-D} Option: \I{pre-defining macros}Pre-Define a Macro + +\I\c{%define}Just as the \c{-p} option gives an alternative to placing +\c{%include} directives at the start of a source file, the \c{-d} +option gives an alternative to placing a \c{%define} directive. You +could code + +\c nasm myfile.asm -dFOO=100 + +as an alternative to placing the directive + +\c %define FOO 100 + +at the start of the file. You can miss off the macro value, as well: +the option \c{-dFOO} is equivalent to coding \c{%define FOO}. This +form of the directive may be useful for selecting \i{assembly-time +options} which are then tested using \c{%ifdef}, for example +\c{-dDEBUG}. + +For Makefile compatibility with many C compilers, this option can also +be specified as \c{-D}. + + +\S{opt-u} The \i\c{-u}\I\c{-U} Option: \I{Undefining macros}Undefine a Macro + +\I\c{%undef}The \c{-u} option undefines a macro that would otherwise +have been pre-defined, either automatically or by a \c{-p} or \c{-d} +option specified earlier on the command lines. + +For example, the following command line: + +\c nasm myfile.asm -dFOO=100 -uFOO + +would result in \c{FOO} \e{not} being a predefined macro in the +program. This is useful to override options specified at a different +point in a Makefile. + +For Makefile compatibility with many C compilers, this option can also +be specified as \c{-U}. + + +\S{opt-E} The \i\c{-E}\I{-e} Option: Preprocess Only + +NASM allows the \i{preprocessor} to be run on its own, up to a +point. Using the \c{-E} option (which requires no arguments) will +cause NASM to preprocess its input file, expand all the macro +references, remove all the comments and preprocessor directives, and +print the resulting file on standard output (or save it to a file, +if the \c{-o} option is also used). + +This option cannot be applied to programs which require the +preprocessor to evaluate \I{preprocessor expressions}\i{expressions} +which depend on the values of symbols: so code such as + +\c %assign tablesize ($-tablestart) + +will cause an error in \i{preprocess-only mode}. + +For compatiblity with older version of NASM, this option can also be +written \c{-e}. \c{-E} in older versions of NASM was the equivalent +of the current \c{-Z} option, \k{opt-Z}. + +\S{opt-a} The \i\c{-a} Option: Don't Preprocess At All + +If NASM is being used as the back end to a compiler, it might be +desirable to \I{suppressing preprocessing}suppress preprocessing +completely and assume the compiler has already done it, to save time +and increase compilation speeds. The \c{-a} option, requiring no +argument, instructs NASM to replace its powerful \i{preprocessor} +with a \i{stub preprocessor} which does nothing. + + +\S{opt-O} The \i\c{-O} Option: Specifying \i{Multipass Optimization} + +NASM defaults to not optimizing operands which can fit into a signed byte. +This means that if you want the shortest possible object code, +you have to enable optimization. + +Using the \c{-O} option, you can tell NASM to carry out different +levels of optimization. The syntax is: + +\b \c{-O0}: No optimization. All operands take their long forms, + if a short form is not specified, except conditional jumps. + This is intended to match NASM 0.98 behavior. + +\b \c{-O1}: Minimal optimization. As above, but immediate operands + which will fit in a signed byte are optimized, + unless the long form is specified. Conditional jumps default + to the long form unless otherwise specified. + +\b \c{-Ox} (where \c{x} is the actual letter \c{x}): Multipass optimization. + Minimize branch offsets and signed immediate bytes, + overriding size specification unless the \c{strict} keyword + has been used (see \k{strict}). For compatability with earlier + releases, the letter \c{x} may also be any number greater than + one. This number has no effect on the actual number of passes. + +The \c{-Ox} mode is recommended for most uses. + +Note that this is a capital \c{O}, and is different from a small \c{o}, which +is used to specify the output file name. See \k{opt-o}. + + +\S{opt-t} The \i\c{-t} Option: Enable TASM Compatibility Mode + +NASM includes a limited form of compatibility with Borland's \i\c{TASM}. +When NASM's \c{-t} option is used, the following changes are made: + +\b local labels may be prefixed with \c{@@} instead of \c{.} + +\b size override is supported within brackets. In TASM compatible mode, +a size override inside square brackets changes the size of the operand, +and not the address type of the operand as it does in NASM syntax. E.g. +\c{mov eax,[DWORD val]} is valid syntax in TASM compatibility mode. +Note that you lose the ability to override the default address type for +the instruction. + +\b unprefixed forms of some directives supported (\c{arg}, \c{elif}, +\c{else}, \c{endif}, \c{if}, \c{ifdef}, \c{ifdifi}, \c{ifndef}, +\c{include}, \c{local}) + +\S{opt-w} The \i\c{-w} and \i\c{-W} Options: Enable or Disable Assembly \i{Warnings} + +NASM can observe many conditions during the course of assembly which +are worth mentioning to the user, but not a sufficiently severe +error to justify NASM refusing to generate an output file. These +conditions are reported like errors, but come up with the word +`warning' before the message. Warnings do not prevent NASM from +generating an output file and returning a success status to the +operating system. + +Some conditions are even less severe than that: they are only +sometimes worth mentioning to the user. Therefore NASM supports the +\c{-w} command-line option, which enables or disables certain +classes of assembly warning. Such warning classes are described by a +name, for example \c{orphan-labels}; you can enable warnings of +this class by the command-line option \c{-w+orphan-labels} and +disable it by \c{-w-orphan-labels}. + +The \i{suppressible warning} classes are: + +\b \i\c{macro-params} covers warnings about \i{multi-line macros} +being invoked with the wrong number of parameters. This warning +class is enabled by default; see \k{mlmacover} for an example of why +you might want to disable it. + +\b \i\c{macro-selfref} warns if a macro references itself. This +warning class is disabled by default. + +\b\i\c{macro-defaults} warns when a macro has more default +parameters than optional parameters. This warning class +is enabled by default; see \k{mlmacdef} for why you might want to disable it. + +\b \i\c{orphan-labels} covers warnings about source lines which +contain no instruction but define a label without a trailing colon. +NASM warns about this somewhat obscure condition by default; +see \k{syntax} for more information. + +\b \i\c{number-overflow} covers warnings about numeric constants which +don't fit in 64 bits. This warning class is enabled by default. + +\b \i\c{gnu-elf-extensions} warns if 8-bit or 16-bit relocations +are used in \c{-f elf} format. The GNU extensions allow this. +This warning class is disabled by default. + +\b \i\c{float-overflow} warns about floating point overflow. +Enabled by default. + +\b \i\c{float-denorm} warns about floating point denormals. +Disabled by default. + +\b \i\c{float-underflow} warns about floating point underflow. +Disabled by default. + +\b \i\c{float-toolong} warns about too many digits in floating-point numbers. +Enabled by default. + +\b \i\c{user} controls \c{%warning} directives (see \k{pperror}). +Enabled by default. + +\b \i\c{error} causes warnings to be treated as errors. Disabled by +default. + +\b \i\c{all} is an alias for \e{all} suppressible warning classes (not +including \c{error}). Thus, \c{-w+all} enables all available warnings. + +In addition, you can set warning classes across sections. +Warning classes may be enabled with \i\c{[warning +warning-name]}, +disabled with \i\c{[warning -warning-name]} or reset to their +original value with \i\c{[warning *warning-name]}. No "user form" +(without the brackets) exists. + +Since version 2.00, NASM has also supported the gcc-like syntax +\c{-Wwarning} and \c{-Wno-warning} instead of \c{-w+warning} and +\c{-w-warning}, respectively. + + +\S{opt-v} The \i\c{-v} Option: Display \i{Version} Info + +Typing \c{NASM -v} will display the version of NASM which you are using, +and the date on which it was compiled. + +You will need the version number if you report a bug. + +\S{opt-y} The \i\c{-y} Option: Display Available Debug Info Formats + +Typing \c{nasm -f <option> -y} will display a list of the available +debug info formats for the given output format. The default format +is indicated by an asterisk. For example: + +\c nasm -f elf -y + +\c valid debug formats for 'elf32' output format are +\c ('*' denotes default): +\c * stabs ELF32 (i386) stabs debug format for Linux +\c dwarf elf32 (i386) dwarf debug format for Linux + + +\S{opt-pfix} The \i\c{--prefix} and \i\c{--postfix} Options. + +The \c{--prefix} and \c{--postfix} options prepend or append +(respectively) the given argument to all \c{global} or +\c{extern} variables. E.g. \c{--prefix _} will prepend the +underscore to all global and external variables, as C sometimes +(but not always) likes it. + + +\S{nasmenv} The \i\c{NASMENV} \i{Environment} Variable + +If you define an environment variable called \c{NASMENV}, the program +will interpret it as a list of extra command-line options, which are +processed before the real command line. You can use this to define +standard search directories for include files, by putting \c{-i} +options in the \c{NASMENV} variable. + +The value of the variable is split up at white space, so that the +value \c{-s -ic:\\nasmlib\\} will be treated as two separate options. +However, that means that the value \c{-dNAME="my name"} won't do +what you might want, because it will be split at the space and the +NASM command-line processing will get confused by the two +nonsensical words \c{-dNAME="my} and \c{name"}. + +To get round this, NASM provides a feature whereby, if you begin the +\c{NASMENV} environment variable with some character that isn't a minus +sign, then NASM will treat this character as the \i{separator +character} for options. So setting the \c{NASMENV} variable to the +value \c{!-s!-ic:\\nasmlib\\} is equivalent to setting it to \c{-s +-ic:\\nasmlib\\}, but \c{!-dNAME="my name"} will work. + +This environment variable was previously called \c{NASM}. This was +changed with version 0.98.31. + + +\H{qstart} \i{Quick Start} for \i{MASM} Users + +If you're used to writing programs with MASM, or with \i{TASM} in +MASM-compatible (non-Ideal) mode, or with \i\c{a86}, this section +attempts to outline the major differences between MASM's syntax and +NASM's. If you're not already used to MASM, it's probably worth +skipping this section. + + +\S{qscs} NASM Is \I{case sensitivity}Case-Sensitive + +One simple difference is that NASM is case-sensitive. It makes a +difference whether you call your label \c{foo}, \c{Foo} or \c{FOO}. +If you're assembling to \c{DOS} or \c{OS/2} \c{.OBJ} files, you can +invoke the \i\c{UPPERCASE} directive (documented in \k{objfmt}) to +ensure that all symbols exported to other code modules are forced +to be upper case; but even then, \e{within} a single module, NASM +will distinguish between labels differing only in case. + + +\S{qsbrackets} NASM Requires \i{Square Brackets} For \i{Memory References} + +NASM was designed with simplicity of syntax in mind. One of the +\i{design goals} of NASM is that it should be possible, as far as is +practical, for the user to look at a single line of NASM code +and tell what opcode is generated by it. You can't do this in MASM: +if you declare, for example, + +\c foo equ 1 +\c bar dw 2 + +then the two lines of code + +\c mov ax,foo +\c mov ax,bar + +generate completely different opcodes, despite having +identical-looking syntaxes. + +NASM avoids this undesirable situation by having a much simpler +syntax for memory references. The rule is simply that any access to +the \e{contents} of a memory location requires square brackets +around the address, and any access to the \e{address} of a variable +doesn't. So an instruction of the form \c{mov ax,foo} will +\e{always} refer to a compile-time constant, whether it's an \c{EQU} +or the address of a variable; and to access the \e{contents} of the +variable \c{bar}, you must code \c{mov ax,[bar]}. + +This also means that NASM has no need for MASM's \i\c{OFFSET} +keyword, since the MASM code \c{mov ax,offset bar} means exactly the +same thing as NASM's \c{mov ax,bar}. If you're trying to get +large amounts of MASM code to assemble sensibly under NASM, you +can always code \c{%idefine offset} to make the preprocessor treat +the \c{OFFSET} keyword as a no-op. + +This issue is even more confusing in \i\c{a86}, where declaring a +label with a trailing colon defines it to be a `label' as opposed to +a `variable' and causes \c{a86} to adopt NASM-style semantics; so in +\c{a86}, \c{mov ax,var} has different behaviour depending on whether +\c{var} was declared as \c{var: dw 0} (a label) or \c{var dw 0} (a +word-size variable). NASM is very simple by comparison: +\e{everything} is a label. + +NASM, in the interests of simplicity, also does not support the +\i{hybrid syntaxes} supported by MASM and its clones, such as +\c{mov ax,table[bx]}, where a memory reference is denoted by one +portion outside square brackets and another portion inside. The +correct syntax for the above is \c{mov ax,[table+bx]}. Likewise, +\c{mov ax,es:[di]} is wrong and \c{mov ax,[es:di]} is right. + + +\S{qstypes} NASM Doesn't Store \i{Variable Types} + +NASM, by design, chooses not to remember the types of variables you +declare. Whereas MASM will remember, on seeing \c{var dw 0}, that +you declared \c{var} as a word-size variable, and will then be able +to fill in the \i{ambiguity} in the size of the instruction \c{mov +var,2}, NASM will deliberately remember nothing about the symbol +\c{var} except where it begins, and so you must explicitly code +\c{mov word [var],2}. + +For this reason, NASM doesn't support the \c{LODS}, \c{MOVS}, +\c{STOS}, \c{SCAS}, \c{CMPS}, \c{INS}, or \c{OUTS} instructions, +but only supports the forms such as \c{LODSB}, \c{MOVSW}, and +\c{SCASD}, which explicitly specify the size of the components of +the strings being manipulated. + + +\S{qsassume} NASM Doesn't \i\c{ASSUME} + +As part of NASM's drive for simplicity, it also does not support the +\c{ASSUME} directive. NASM will not keep track of what values you +choose to put in your segment registers, and will never +\e{automatically} generate a \i{segment override} prefix. + + +\S{qsmodel} NASM Doesn't Support \i{Memory Models} + +NASM also does not have any directives to support different 16-bit +memory models. The programmer has to keep track of which functions +are supposed to be called with a \i{far call} and which with a +\i{near call}, and is responsible for putting the correct form of +\c{RET} instruction (\c{RETN} or \c{RETF}; NASM accepts \c{RET} +itself as an alternate form for \c{RETN}); in addition, the +programmer is responsible for coding CALL FAR instructions where +necessary when calling \e{external} functions, and must also keep +track of which external variable definitions are far and which are +near. + + +\S{qsfpu} \i{Floating-Point} Differences + +NASM uses different names to refer to floating-point registers from +MASM: where MASM would call them \c{ST(0)}, \c{ST(1)} and so on, and +\i\c{a86} would call them simply \c{0}, \c{1} and so on, NASM +chooses to call them \c{st0}, \c{st1} etc. + +As of version 0.96, NASM now treats the instructions with +\i{`nowait'} forms in the same way as MASM-compatible assemblers. +The idiosyncratic treatment employed by 0.95 and earlier was based +on a misunderstanding by the authors. + + +\S{qsother} Other Differences + +For historical reasons, NASM uses the keyword \i\c{TWORD} where MASM +and compatible assemblers use \i\c{TBYTE}. + +NASM does not declare \i{uninitialized storage} in the same way as +MASM: where a MASM programmer might use \c{stack db 64 dup (?)}, +NASM requires \c{stack resb 64}, intended to be read as `reserve 64 +bytes'. For a limited amount of compatibility, since NASM treats +\c{?} as a valid character in symbol names, you can code \c{? equ 0} +and then writing \c{dw ?} will at least do something vaguely useful. +\I\c{RESB}\i\c{DUP} is still not a supported syntax, however. + +In addition to all of this, macros and directives work completely +differently to MASM. See \k{preproc} and \k{directive} for further +details. + + +\C{lang} The NASM Language + +\H{syntax} Layout of a NASM Source Line + +Like most assemblers, each NASM source line contains (unless it +is a macro, a preprocessor directive or an assembler directive: see +\k{preproc} and \k{directive}) some combination of the four fields + +\c label: instruction operands ; comment + +As usual, most of these fields are optional; the presence or absence +of any combination of a label, an instruction and a comment is allowed. +Of course, the operand field is either required or forbidden by the +presence and nature of the instruction field. + +NASM uses backslash (\\) as the line continuation character; if a line +ends with backslash, the next line is considered to be a part of the +backslash-ended line. + +NASM places no restrictions on white space within a line: labels may +have white space before them, or instructions may have no space +before them, or anything. The \i{colon} after a label is also +optional. (Note that this means that if you intend to code \c{lodsb} +alone on a line, and type \c{lodab} by accident, then that's still a +valid source line which does nothing but define a label. Running +NASM with the command-line option +\I{orphan-labels}\c{-w+orphan-labels} will cause it to warn you if +you define a label alone on a line without a \i{trailing colon}.) + +\i{Valid characters} in labels are letters, numbers, \c{_}, \c{$}, +\c{#}, \c{@}, \c{~}, \c{.}, and \c{?}. The only characters which may +be used as the \e{first} character of an identifier are letters, +\c{.} (with special meaning: see \k{locallab}), \c{_} and \c{?}. +An identifier may also be prefixed with a \I{$, prefix}\c{$} to +indicate that it is intended to be read as an identifier and not a +reserved word; thus, if some other module you are linking with +defines a symbol called \c{eax}, you can refer to \c{$eax} in NASM +code to distinguish the symbol from the register. Maximum length of +an identifier is 4095 characters. + +The instruction field may contain any machine instruction: Pentium +and P6 instructions, FPU instructions, MMX instructions and even +undocumented instructions are all supported. The instruction may be +prefixed by \c{LOCK}, \c{REP}, \c{REPE}/\c{REPZ} or +\c{REPNE}/\c{REPNZ}, in the usual way. Explicit \I{address-size +prefixes}address-size and \i{operand-size prefixes} \i\c{A16}, +\i\c{A32}, \i\c{A64}, \i\c{O16} and \i\c{O32}, \i\c{O64} are provided - one example of their use +is given in \k{mixsize}. You can also use the name of a \I{segment +override}segment register as an instruction prefix: coding +\c{es mov [bx],ax} is equivalent to coding \c{mov [es:bx],ax}. We +recommend the latter syntax, since it is consistent with other +syntactic features of the language, but for instructions such as +\c{LODSB}, which has no operands and yet can require a segment +override, there is no clean syntactic way to proceed apart from +\c{es lodsb}. + +An instruction is not required to use a prefix: prefixes such as +\c{CS}, \c{A32}, \c{LOCK} or \c{REPE} can appear on a line by +themselves, and NASM will just generate the prefix bytes. + +In addition to actual machine instructions, NASM also supports a +number of pseudo-instructions, described in \k{pseudop}. + +Instruction \i{operands} may take a number of forms: they can be +registers, described simply by the register name (e.g. \c{ax}, +\c{bp}, \c{ebx}, \c{cr0}: NASM does not use the \c{gas}-style +syntax in which register names must be prefixed by a \c{%} sign), or +they can be \i{effective addresses} (see \k{effaddr}), constants +(\k{const}) or expressions (\k{expr}). + +For x87 \i{floating-point} instructions, NASM accepts a wide range of +syntaxes: you can use two-operand forms like MASM supports, or you +can use NASM's native single-operand forms in most cases. +\# Details of +\# all forms of each supported instruction are given in +\# \k{iref}. +For example, you can code: + +\c fadd st1 ; this sets st0 := st0 + st1 +\c fadd st0,st1 ; so does this +\c +\c fadd st1,st0 ; this sets st1 := st1 + st0 +\c fadd to st1 ; so does this + +Almost any x87 floating-point instruction that references memory must +use one of the prefixes \i\c{DWORD}, \i\c{QWORD} or \i\c{TWORD} to +indicate what size of \i{memory operand} it refers to. + + +\H{pseudop} \i{Pseudo-Instructions} + +Pseudo-instructions are things which, though not real x86 machine +instructions, are used in the instruction field anyway because that's +the most convenient place to put them. The current pseudo-instructions +are \i\c{DB}, \i\c{DW}, \i\c{DD}, \i\c{DQ}, \i\c{DT}, \i\c{DO} and +\i\c{DY}; their \i{uninitialized} counterparts \i\c{RESB}, \i\c{RESW}, +\i\c{RESD}, \i\c{RESQ}, \i\c{REST}, \i\c{RESO} and \i\c{RESY}; the +\i\c{INCBIN} command, the \i\c{EQU} command, and the \i\c{TIMES} +prefix. + + +\S{db} \c{DB} and Friends: Declaring Initialized Data + +\i\c{DB}, \i\c{DW}, \i\c{DD}, \i\c{DQ}, \i\c{DT}, \i\c{DO} and +\i\c{DY} are used, much as in MASM, to declare initialized data in the +output file. They can be invoked in a wide range of ways: +\I{floating-point}\I{character constant}\I{string constant} + +\c db 0x55 ; just the byte 0x55 +\c db 0x55,0x56,0x57 ; three bytes in succession +\c db 'a',0x55 ; character constants are OK +\c db 'hello',13,10,'$' ; so are string constants +\c dw 0x1234 ; 0x34 0x12 +\c dw 'a' ; 0x61 0x00 (it's just a number) +\c dw 'ab' ; 0x61 0x62 (character constant) +\c dw 'abc' ; 0x61 0x62 0x63 0x00 (string) +\c dd 0x12345678 ; 0x78 0x56 0x34 0x12 +\c dd 1.234567e20 ; floating-point constant +\c dq 0x123456789abcdef0 ; eight byte constant +\c dq 1.234567e20 ; double-precision float +\c dt 1.234567e20 ; extended-precision float + +\c{DT}, \c{DO} and \c{DY} do not accept \i{numeric constants} as operands. + + +\S{resb} \c{RESB} and Friends: Declaring \i{Uninitialized} Data + +\i\c{RESB}, \i\c{RESW}, \i\c{RESD}, \i\c{RESQ}, \i\c{REST}, \i\c{RESO} +and \i\c{RESY} are designed to be used in the BSS section of a module: +they declare \e{uninitialized} storage space. Each takes a single +operand, which is the number of bytes, words, doublewords or whatever +to reserve. As stated in \k{qsother}, NASM does not support the +MASM/TASM syntax of reserving uninitialized space by writing +\I\c{?}\c{DW ?} or similar things: this is what it does instead. The +operand to a \c{RESB}-type pseudo-instruction is a \i\e{critical +expression}: see \k{crit}. + +For example: + +\c buffer: resb 64 ; reserve 64 bytes +\c wordvar: resw 1 ; reserve a word +\c realarray resq 10 ; array of ten reals +\c ymmval: resy 1 ; one YMM register + +\S{incbin} \i\c{INCBIN}: Including External \i{Binary Files} + +\c{INCBIN} is borrowed from the old Amiga assembler \i{DevPac}: it +includes a binary file verbatim into the output file. This can be +handy for (for example) including \i{graphics} and \i{sound} data +directly into a game executable file. It can be called in one of +these three ways: + +\c incbin "file.dat" ; include the whole file +\c incbin "file.dat",1024 ; skip the first 1024 bytes +\c incbin "file.dat",1024,512 ; skip the first 1024, and +\c ; actually include at most 512 + +\c{INCBIN} is both a directive and a standard macro; the standard +macro version searches for the file in the include file search path +and adds the file to the dependency lists. This macro can be +overridden if desired. + + +\S{equ} \i\c{EQU}: Defining Constants + +\c{EQU} defines a symbol to a given constant value: when \c{EQU} is +used, the source line must contain a label. The action of \c{EQU} is +to define the given label name to the value of its (only) operand. +This definition is absolute, and cannot change later. So, for +example, + +\c message db 'hello, world' +\c msglen equ $-message + +defines \c{msglen} to be the constant 12. \c{msglen} may not then be +redefined later. This is not a \i{preprocessor} definition either: +the value of \c{msglen} is evaluated \e{once}, using the value of +\c{$} (see \k{expr} for an explanation of \c{$}) at the point of +definition, rather than being evaluated wherever it is referenced +and using the value of \c{$} at the point of reference. + + +\S{times} \i\c{TIMES}: \i{Repeating} Instructions or Data + +The \c{TIMES} prefix causes the instruction to be assembled multiple +times. This is partly present as NASM's equivalent of the \i\c{DUP} +syntax supported by \i{MASM}-compatible assemblers, in that you can +code + +\c zerobuf: times 64 db 0 + +or similar things; but \c{TIMES} is more versatile than that. The +argument to \c{TIMES} is not just a numeric constant, but a numeric +\e{expression}, so you can do things like + +\c buffer: db 'hello, world' +\c times 64-$+buffer db ' ' + +which will store exactly enough spaces to make the total length of +\c{buffer} up to 64. Finally, \c{TIMES} can be applied to ordinary +instructions, so you can code trivial \i{unrolled loops} in it: + +\c times 100 movsb + +Note that there is no effective difference between \c{times 100 resb +1} and \c{resb 100}, except that the latter will be assembled about +100 times faster due to the internal structure of the assembler. + +The operand to \c{TIMES} is a critical expression (\k{crit}). + +Note also that \c{TIMES} can't be applied to \i{macros}: the reason +for this is that \c{TIMES} is processed after the macro phase, which +allows the argument to \c{TIMES} to contain expressions such as +\c{64-$+buffer} as above. To repeat more than one line of code, or a +complex macro, use the preprocessor \i\c{%rep} directive. + + +\H{effaddr} Effective Addresses + +An \i{effective address} is any operand to an instruction which +\I{memory reference}references memory. Effective addresses, in NASM, +have a very simple syntax: they consist of an expression evaluating +to the desired address, enclosed in \i{square brackets}. For +example: + +\c wordvar dw 123 +\c mov ax,[wordvar] +\c mov ax,[wordvar+1] +\c mov ax,[es:wordvar+bx] + +Anything not conforming to this simple system is not a valid memory +reference in NASM, for example \c{es:wordvar[bx]}. + +More complicated effective addresses, such as those involving more +than one register, work in exactly the same way: + +\c mov eax,[ebx*2+ecx+offset] +\c mov ax,[bp+di+8] + +NASM is capable of doing \i{algebra} on these effective addresses, +so that things which don't necessarily \e{look} legal are perfectly +all right: + +\c mov eax,[ebx*5] ; assembles as [ebx*4+ebx] +\c mov eax,[label1*2-label2] ; ie [label1+(label1-label2)] + +Some forms of effective address have more than one assembled form; +in most such cases NASM will generate the smallest form it can. For +example, there are distinct assembled forms for the 32-bit effective +addresses \c{[eax*2+0]} and \c{[eax+eax]}, and NASM will generally +generate the latter on the grounds that the former requires four +bytes to store a zero offset. + +NASM has a hinting mechanism which will cause \c{[eax+ebx]} and +\c{[ebx+eax]} to generate different opcodes; this is occasionally +useful because \c{[esi+ebp]} and \c{[ebp+esi]} have different +default segment registers. + +However, you can force NASM to generate an effective address in a +particular form by the use of the keywords \c{BYTE}, \c{WORD}, +\c{DWORD} and \c{NOSPLIT}. If you need \c{[eax+3]} to be assembled +using a double-word offset field instead of the one byte NASM will +normally generate, you can code \c{[dword eax+3]}. Similarly, you +can force NASM to use a byte offset for a small value which it +hasn't seen on the first pass (see \k{crit} for an example of such a +code fragment) by using \c{[byte eax+offset]}. As special cases, +\c{[byte eax]} will code \c{[eax+0]} with a byte offset of zero, and +\c{[dword eax]} will code it with a double-word offset of zero. The +normal form, \c{[eax]}, will be coded with no offset field. + +The form described in the previous paragraph is also useful if you +are trying to access data in a 32-bit segment from within 16 bit code. +For more information on this see the section on mixed-size addressing +(\k{mixaddr}). In particular, if you need to access data with a known +offset that is larger than will fit in a 16-bit value, if you don't +specify that it is a dword offset, nasm will cause the high word of +the offset to be lost. + +Similarly, NASM will split \c{[eax*2]} into \c{[eax+eax]} because +that allows the offset field to be absent and space to be saved; in +fact, it will also split \c{[eax*2+offset]} into +\c{[eax+eax+offset]}. You can combat this behaviour by the use of +the \c{NOSPLIT} keyword: \c{[nosplit eax*2]} will force +\c{[eax*2+0]} to be generated literally. + +In 64-bit mode, NASM will by default generate absolute addresses. The +\i\c{REL} keyword makes it produce \c{RIP}-relative addresses. Since +this is frequently the normally desired behaviour, see the \c{DEFAULT} +directive (\k{default}). The keyword \i\c{ABS} overrides \i\c{REL}. + + +\H{const} \i{Constants} + +NASM understands four different types of constant: numeric, +character, string and floating-point. + + +\S{numconst} \i{Numeric Constants} + +A numeric constant is simply a number. NASM allows you to specify +numbers in a variety of number bases, in a variety of ways: you can +suffix \c{H} or \c{X}, \c{Q} or \c{O}, and \c{B} for \i{hexadecimal}, +\i{octal} and \i{binary} respectively, or you can prefix \c{0x} for +hexadecimal in the style of C, or you can prefix \c{$} for hexadecimal +in the style of Borland Pascal. Note, though, that the \I{$, +prefix}\c{$} prefix does double duty as a prefix on identifiers (see +\k{syntax}), so a hex number prefixed with a \c{$} sign must have a +digit after the \c{$} rather than a letter. In addition, current +versions of NASM accept the prefix \c{0h} for hexadecimal, \c{0o} or +\c{0q} for octal, and \c{0b} for binary. Please note that unlike C, a +\c{0} prefix by itself does \e{not} imply an octal constant! + +Numeric constants can have underscores (\c{_}) interspersed to break +up long strings. + +Some examples (all producing exactly the same code): + +\c mov ax,200 ; decimal +\c mov ax,0200 ; still decimal +\c mov ax,0200d ; explicitly decimal +\c mov ax,0d200 ; also decimal +\c mov ax,0c8h ; hex +\c mov ax,$0c8 ; hex again: the 0 is required +\c mov ax,0xc8 ; hex yet again +\c mov ax,0hc8 ; still hex +\c mov ax,310q ; octal +\c mov ax,310o ; octal again +\c mov ax,0o310 ; octal yet again +\c mov ax,0q310 ; hex yet again +\c mov ax,11001000b ; binary +\c mov ax,1100_1000b ; same binary constant +\c mov ax,0b1100_1000 ; same binary constant yet again + +\S{strings} \I{Strings}\i{Character Strings} + +A character string consists of up to eight characters enclosed in +either single quotes (\c{'...'}), double quotes (\c{"..."}) or +backquotes (\c{`...`}). Single or double quotes are equivalent to +NASM (except of course that surrounding the constant with single +quotes allows double quotes to appear within it and vice versa); the +contents of those are represented verbatim. Strings enclosed in +backquotes support C-style \c{\\}-escapes for special characters. + + +The following \i{escape sequences} are recognized by backquoted strings: + +\c \' single quote (') +\c \" double quote (") +\c \` backquote (`) +\c \\\ backslash (\) +\c \? question mark (?) +\c \a BEL (ASCII 7) +\c \b BS (ASCII 8) +\c \t TAB (ASCII 9) +\c \n LF (ASCII 10) +\c \v VT (ASCII 11) +\c \f FF (ASCII 12) +\c \r CR (ASCII 13) +\c \e ESC (ASCII 27) +\c \377 Up to 3 octal digits - literal byte +\c \xFF Up to 2 hexadecimal digits - literal byte +\c \u1234 4 hexadecimal digits - Unicode character +\c \U12345678 8 hexadecimal digits - Unicode character + +All other escape sequences are reserved. Note that \c{\\0}, meaning a +\c{NUL} character (ASCII 0), is a special case of the octal escape +sequence. + +\i{Unicode} characters specified with \c{\\u} or \c{\\U} are converted to +\i{UTF-8}. For example, the following lines are all equivalent: + +\c db `\u263a` ; UTF-8 smiley face +\c db `\xe2\x98\xba` ; UTF-8 smiley face +\c db 0E2h, 098h, 0BAh ; UTF-8 smiley face + + +\S{chrconst} \i{Character Constants} + +A character constant consists of a string up to eight bytes long, used +in an expression context. It is treated as if it was an integer. + +A character constant with more than one byte will be arranged +with \i{little-endian} order in mind: if you code + +\c mov eax,'abcd' + +then the constant generated is not \c{0x61626364}, but +\c{0x64636261}, so that if you were then to store the value into +memory, it would read \c{abcd} rather than \c{dcba}. This is also +the sense of character constants understood by the Pentium's +\i\c{CPUID} instruction. + + +\S{strconst} \i{String Constants} + +String constants are character strings used in the context of some +pseudo-instructions, namely the +\I\c{DW}\I\c{DD}\I\c{DQ}\I\c{DT}\I\c{DO}\I\c{DY}\i\c{DB} family and +\i\c{INCBIN} (where it represents a filename.) They are also used in +certain preprocessor directives. + +A string constant looks like a character constant, only longer. It +is treated as a concatenation of maximum-size character constants +for the conditions. So the following are equivalent: + +\c db 'hello' ; string constant +\c db 'h','e','l','l','o' ; equivalent character constants + +And the following are also equivalent: + +\c dd 'ninechars' ; doubleword string constant +\c dd 'nine','char','s' ; becomes three doublewords +\c db 'ninechars',0,0,0 ; and really looks like this + +Note that when used in a string-supporting context, quoted strings are +treated as a string constants even if they are short enough to be a +character constant, because otherwise \c{db 'ab'} would have the same +effect as \c{db 'a'}, which would be silly. Similarly, three-character +or four-character constants are treated as strings when they are +operands to \c{DW}, and so forth. + +\S{unicode} \I{UTF-16}\I{UTF-32}\i{Unicode} Strings + +The special operators \i\c{__utf16__} and \i\c{__utf32__} allows +definition of Unicode strings. They take a string in UTF-8 format and +converts it to (littleendian) UTF-16 or UTF-32, respectively. + +For example: + +\c %define u(x) __utf16__(x) +\c %define w(x) __utf32__(x) +\c +\c dw u('C:\WINDOWS'), 0 ; Pathname in UTF-16 +\c dd w(`A + B = \u206a`), 0 ; String in UTF-32 + +\c{__utf16__} and \c{__utf32__} can be applied either to strings +passed to the \c{DB} family instructions, or to character constants in +an expression context. + +\S{fltconst} \I{floating-point, constants}Floating-Point Constants + +\i{Floating-point} constants are acceptable only as arguments to +\i\c{DB}, \i\c{DW}, \i\c{DD}, \i\c{DQ}, \i\c{DT}, and \i\c{DO}, or as +arguments to the special operators \i\c{__float8__}, +\i\c{__float16__}, \i\c{__float32__}, \i\c{__float64__}, +\i\c{__float80m__}, \i\c{__float80e__}, \i\c{__float128l__}, and +\i\c{__float128h__}. + +Floating-point constants are expressed in the traditional form: +digits, then a period, then optionally more digits, then optionally an +\c{E} followed by an exponent. The period is mandatory, so that NASM +can distinguish between \c{dd 1}, which declares an integer constant, +and \c{dd 1.0} which declares a floating-point constant. NASM also +support C99-style hexadecimal floating-point: \c{0x}, hexadecimal +digits, period, optionally more hexadeximal digits, then optionally a +\c{P} followed by a \e{binary} (not hexadecimal) exponent in decimal +notation. + +Underscores to break up groups of digits are permitted in +floating-point constants as well. + +Some examples: + +\c db -0.2 ; "Quarter precision" +\c dw -0.5 ; IEEE 754r/SSE5 half precision +\c dd 1.2 ; an easy one +\c dd 1.222_222_222 ; underscores are permitted +\c dd 0x1p+2 ; 1.0x2^2 = 4.0 +\c dq 0x1p+32 ; 1.0x2^32 = 4 294 967 296.0 +\c dq 1.e10 ; 10 000 000 000.0 +\c dq 1.e+10 ; synonymous with 1.e10 +\c dq 1.e-10 ; 0.000 000 000 1 +\c dt 3.141592653589793238462 ; pi +\c do 1.e+4000 ; IEEE 754r quad precision + +The 8-bit "quarter-precision" floating-point format is +sign:exponent:mantissa = 1:4:3 with an exponent bias of 7. This +appears to be the most frequently used 8-bit floating-point format, +although it is not covered by any formal standard. This is sometimes +called a "\i{minifloat}." + +The special operators are used to produce floating-point numbers in +other contexts. They produce the binary representation of a specific +floating-point number as an integer, and can use anywhere integer +constants are used in an expression. \c{__float80m__} and +\c{__float80e__} produce the 64-bit mantissa and 16-bit exponent of an +80-bit floating-point number, and \c{__float128l__} and +\c{__float128h__} produce the lower and upper 64-bit halves of a 128-bit +floating-point number, respectively. + +For example: + +\c mov rax,__float64__(3.141592653589793238462) + +... would assign the binary representation of pi as a 64-bit floating +point number into \c{RAX}. This is exactly equivalent to: + +\c mov rax,0x400921fb54442d18 + +NASM cannot do compile-time arithmetic on floating-point constants. +This is because NASM is designed to be portable - although it always +generates code to run on x86 processors, the assembler itself can +run on any system with an ANSI C compiler. Therefore, the assembler +cannot guarantee the presence of a floating-point unit capable of +handling the \i{Intel number formats}, and so for NASM to be able to +do floating arithmetic it would have to include its own complete set +of floating-point routines, which would significantly increase the +size of the assembler for very little benefit. + +The special tokens \i\c{__Infinity__}, \i\c{__QNaN__} (or +\i\c{__NaN__}) and \i\c{__SNaN__} can be used to generate +\I{infinity}infinities, quiet \i{NaN}s, and signalling NaNs, +respectively. These are normally used as macros: + +\c %define Inf __Infinity__ +\c %define NaN __QNaN__ +\c +\c dq +1.5, -Inf, NaN ; Double-precision constants + +\S{bcdconst} \I{floating-point, packed BCD constants}Packed BCD Constants + +x87-style packed BCD constants can be used in the same contexts as +80-bit floating-point numbers. They are suffixed with \c{p} or +prefixed with \c{0p}, and can include up to 18 decimal digits. + +As with other numeric constants, underscores can be used to separate +digits. + +For example: + +\c dt 12_345_678_901_245_678p +\c dt -12_345_678_901_245_678p +\c dt +0p33 +\c dt 33p + + +\H{expr} \i{Expressions} + +Expressions in NASM are similar in syntax to those in C. Expressions +are evaluated as 64-bit integers which are then adjusted to the +appropriate size. + +NASM supports two special tokens in expressions, allowing +calculations to involve the current assembly position: the +\I{$, here}\c{$} and \i\c{$$} tokens. \c{$} evaluates to the assembly +position at the beginning of the line containing the expression; so +you can code an \i{infinite loop} using \c{JMP $}. \c{$$} evaluates +to the beginning of the current section; so you can tell how far +into the section you are by using \c{($-$$)}. + +The arithmetic \i{operators} provided by NASM are listed here, in +increasing order of \i{precedence}. + + +\S{expor} \i\c{|}: \i{Bitwise OR} Operator + +The \c{|} operator gives a bitwise OR, exactly as performed by the +\c{OR} machine instruction. Bitwise OR is the lowest-priority +arithmetic operator supported by NASM. + + +\S{expxor} \i\c{^}: \i{Bitwise XOR} Operator + +\c{^} provides the bitwise XOR operation. + + +\S{expand} \i\c{&}: \i{Bitwise AND} Operator + +\c{&} provides the bitwise AND operation. + + +\S{expshift} \i\c{<<} and \i\c{>>}: \i{Bit Shift} Operators + +\c{<<} gives a bit-shift to the left, just as it does in C. So \c{5<<3} +evaluates to 5 times 8, or 40. \c{>>} gives a bit-shift to the +right; in NASM, such a shift is \e{always} unsigned, so that +the bits shifted in from the left-hand end are filled with zero +rather than a sign-extension of the previous highest bit. + + +\S{expplmi} \I{+ opaddition}\c{+} and \I{- opsubtraction}\c{-}: +\i{Addition} and \i{Subtraction} Operators + +The \c{+} and \c{-} operators do perfectly ordinary addition and +subtraction. + + +\S{expmul} \i\c{*}, \i\c{/}, \i\c{//}, \i\c{%} and \i\c{%%}: +\i{Multiplication} and \i{Division} + +\c{*} is the multiplication operator. \c{/} and \c{//} are both +division operators: \c{/} is \i{unsigned division} and \c{//} is +\i{signed division}. Similarly, \c{%} and \c{%%} provide \I{unsigned +modulo}\I{modulo operators}unsigned and +\i{signed modulo} operators respectively. + +NASM, like ANSI C, provides no guarantees about the sensible +operation of the signed modulo operator. + +Since the \c{%} character is used extensively by the macro +\i{preprocessor}, you should ensure that both the signed and unsigned +modulo operators are followed by white space wherever they appear. + + +\S{expmul} \i{Unary Operators}: \I{+ opunary}\c{+}, \I{- opunary}\c{-}, +\i\c{~}, \I{! opunary}\c{!} and \i\c{SEG} + +The highest-priority operators in NASM's expression grammar are +those which only apply to one argument. \c{-} negates its operand, +\c{+} does nothing (it's provided for symmetry with \c{-}), \c{~} +computes the \i{one's complement} of its operand, \c{!} is the +\i{logical negation} operator, and \c{SEG} provides the \i{segment address} +of its operand (explained in more detail in \k{segwrt}). + + +\H{segwrt} \i\c{SEG} and \i\c{WRT} + +When writing large 16-bit programs, which must be split into +multiple \i{segments}, it is often necessary to be able to refer to +the \I{segment address}segment part of the address of a symbol. NASM +supports the \c{SEG} operator to perform this function. + +The \c{SEG} operator returns the \i\e{preferred} segment base of a +symbol, defined as the segment base relative to which the offset of +the symbol makes sense. So the code + +\c mov ax,seg symbol +\c mov es,ax +\c mov bx,symbol + +will load \c{ES:BX} with a valid pointer to the symbol \c{symbol}. + +Things can be more complex than this: since 16-bit segments and +\i{groups} may \I{overlapping segments}overlap, you might occasionally +want to refer to some symbol using a different segment base from the +preferred one. NASM lets you do this, by the use of the \c{WRT} +(With Reference To) keyword. So you can do things like + +\c mov ax,weird_seg ; weird_seg is a segment base +\c mov es,ax +\c mov bx,symbol wrt weird_seg + +to load \c{ES:BX} with a different, but functionally equivalent, +pointer to the symbol \c{symbol}. + +NASM supports far (inter-segment) calls and jumps by means of the +syntax \c{call segment:offset}, where \c{segment} and \c{offset} +both represent immediate values. So to call a far procedure, you +could code either of + +\c call (seg procedure):procedure +\c call weird_seg:(procedure wrt weird_seg) + +(The parentheses are included for clarity, to show the intended +parsing of the above instructions. They are not necessary in +practice.) + +NASM supports the syntax \I\c{CALL FAR}\c{call far procedure} as a +synonym for the first of the above usages. \c{JMP} works identically +to \c{CALL} in these examples. + +To declare a \i{far pointer} to a data item in a data segment, you +must code + +\c dw symbol, seg symbol + +NASM supports no convenient synonym for this, though you can always +invent one using the macro processor. + + +\H{strict} \i\c{STRICT}: Inhibiting Optimization + +When assembling with the optimizer set to level 2 or higher (see +\k{opt-O}), NASM will use size specifiers (\c{BYTE}, \c{WORD}, +\c{DWORD}, \c{QWORD}, \c{TWORD}, \c{OWORD} or \c{YWORD}), but will +give them the smallest possible size. The keyword \c{STRICT} can be +used to inhibit optimization and force a particular operand to be +emitted in the specified size. For example, with the optimizer on, and +in \c{BITS 16} mode, + +\c push dword 33 + +is encoded in three bytes \c{66 6A 21}, whereas + +\c push strict dword 33 + +is encoded in six bytes, with a full dword immediate operand \c{66 68 +21 00 00 00}. + +With the optimizer off, the same code (six bytes) is generated whether +the \c{STRICT} keyword was used or not. + + +\H{crit} \i{Critical Expressions} + +Although NASM has an optional multi-pass optimizer, there are some +expressions which must be resolvable on the first pass. These are +called \e{Critical Expressions}. + +The first pass is used to determine the size of all the assembled +code and data, so that the second pass, when generating all the +code, knows all the symbol addresses the code refers to. So one +thing NASM can't handle is code whose size depends on the value of a +symbol declared after the code in question. For example, + +\c times (label-$) db 0 +\c label: db 'Where am I?' + +The argument to \i\c{TIMES} in this case could equally legally +evaluate to anything at all; NASM will reject this example because +it cannot tell the size of the \c{TIMES} line when it first sees it. +It will just as firmly reject the slightly \I{paradox}paradoxical +code + +\c times (label-$+1) db 0 +\c label: db 'NOW where am I?' + +in which \e{any} value for the \c{TIMES} argument is by definition +wrong! + +NASM rejects these examples by means of a concept called a +\e{critical expression}, which is defined to be an expression whose +value is required to be computable in the first pass, and which must +therefore depend only on symbols defined before it. The argument to +the \c{TIMES} prefix is a critical expression. + +\H{locallab} \i{Local Labels} + +NASM gives special treatment to symbols beginning with a \i{period}. +A label beginning with a single period is treated as a \e{local} +label, which means that it is associated with the previous non-local +label. So, for example: + +\c label1 ; some code +\c +\c .loop +\c ; some more code +\c +\c jne .loop +\c ret +\c +\c label2 ; some code +\c +\c .loop +\c ; some more code +\c +\c jne .loop +\c ret + +In the above code fragment, each \c{JNE} instruction jumps to the +line immediately before it, because the two definitions of \c{.loop} +are kept separate by virtue of each being associated with the +previous non-local label. + +This form of local label handling is borrowed from the old Amiga +assembler \i{DevPac}; however, NASM goes one step further, in +allowing access to local labels from other parts of the code. This +is achieved by means of \e{defining} a local label in terms of the +previous non-local label: the first definition of \c{.loop} above is +really defining a symbol called \c{label1.loop}, and the second +defines a symbol called \c{label2.loop}. So, if you really needed +to, you could write + +\c label3 ; some more code +\c ; and some more +\c +\c jmp label1.loop + +Sometimes it is useful - in a macro, for instance - to be able to +define a label which can be referenced from anywhere but which +doesn't interfere with the normal local-label mechanism. Such a +label can't be non-local because it would interfere with subsequent +definitions of, and references to, local labels; and it can't be +local because the macro that defined it wouldn't know the label's +full name. NASM therefore introduces a third type of label, which is +probably only useful in macro definitions: if a label begins with +the \I{label prefix}special prefix \i\c{..@}, then it does nothing +to the local label mechanism. So you could code + +\c label1: ; a non-local label +\c .local: ; this is really label1.local +\c ..@foo: ; this is a special symbol +\c label2: ; another non-local label +\c .local: ; this is really label2.local +\c +\c jmp ..@foo ; this will jump three lines up + +NASM has the capacity to define other special symbols beginning with +a double period: for example, \c{..start} is used to specify the +entry point in the \c{obj} output format (see \k{dotdotstart}). + + +\C{preproc} The NASM \i{Preprocessor} + +NASM contains a powerful \i{macro processor}, which supports +conditional assembly, multi-level file inclusion, two forms of macro +(single-line and multi-line), and a `context stack' mechanism for +extra macro power. Preprocessor directives all begin with a \c{%} +sign. + +The preprocessor collapses all lines which end with a backslash (\\) +character into a single line. Thus: + +\c %define THIS_VERY_LONG_MACRO_NAME_IS_DEFINED_TO \\ +\c THIS_VALUE + +will work like a single-line macro without the backslash-newline +sequence. + +\H{slmacro} \i{Single-Line Macros} + +\S{define} The Normal Way: \I\c{%idefine}\i\c{%define} + +Single-line macros are defined using the \c{%define} preprocessor +directive. The definitions work in a similar way to C; so you can do +things like + +\c %define ctrl 0x1F & +\c %define param(a,b) ((a)+(a)*(b)) +\c +\c mov byte [param(2,ebx)], ctrl 'D' + +which will expand to + +\c mov byte [(2)+(2)*(ebx)], 0x1F & 'D' + +When the expansion of a single-line macro contains tokens which +invoke another macro, the expansion is performed at invocation time, +not at definition time. Thus the code + +\c %define a(x) 1+b(x) +\c %define b(x) 2*x +\c +\c mov ax,a(8) + +will evaluate in the expected way to \c{mov ax,1+2*8}, even though +the macro \c{b} wasn't defined at the time of definition of \c{a}. + +Macros defined with \c{%define} are \i{case sensitive}: after +\c{%define foo bar}, only \c{foo} will expand to \c{bar}: \c{Foo} or +\c{FOO} will not. By using \c{%idefine} instead of \c{%define} (the +`i' stands for `insensitive') you can define all the case variants +of a macro at once, so that \c{%idefine foo bar} would cause +\c{foo}, \c{Foo}, \c{FOO}, \c{fOO} and so on all to expand to +\c{bar}. + +There is a mechanism which detects when a macro call has occurred as +a result of a previous expansion of the same macro, to guard against +\i{circular references} and infinite loops. If this happens, the +preprocessor will only expand the first occurrence of the macro. +Hence, if you code + +\c %define a(x) 1+a(x) +\c +\c mov ax,a(3) + +the macro \c{a(3)} will expand once, becoming \c{1+a(3)}, and will +then expand no further. This behaviour can be useful: see \k{32c} +for an example of its use. + +You can \I{overloading, single-line macros}overload single-line +macros: if you write + +\c %define foo(x) 1+x +\c %define foo(x,y) 1+x*y + +the preprocessor will be able to handle both types of macro call, +by counting the parameters you pass; so \c{foo(3)} will become +\c{1+3} whereas \c{foo(ebx,2)} will become \c{1+ebx*2}. However, if +you define + +\c %define foo bar + +then no other definition of \c{foo} will be accepted: a macro with +no parameters prohibits the definition of the same name as a macro +\e{with} parameters, and vice versa. + +This doesn't prevent single-line macros being \e{redefined}: you can +perfectly well define a macro with + +\c %define foo bar + +and then re-define it later in the same source file with + +\c %define foo baz + +Then everywhere the macro \c{foo} is invoked, it will be expanded +according to the most recent definition. This is particularly useful +when defining single-line macros with \c{%assign} (see \k{assign}). + +You can \i{pre-define} single-line macros using the `-d' option on +the NASM command line: see \k{opt-d}. + + +\S{xdefine} Resolving \c{%define}: \I\c{%ixdefine}\i\c{%xdefine} + +To have a reference to an embedded single-line macro resolved at the +time that the embedding macro is \e{defined}, as opposed to when the +embedding macro is \e{expanded}, you need a different mechanism to the +one offered by \c{%define}. The solution is to use \c{%xdefine}, or +it's \I{case sensitive}case-insensitive counterpart \c{%ixdefine}. + +Suppose you have the following code: + +\c %define isTrue 1 +\c %define isFalse isTrue +\c %define isTrue 0 +\c +\c val1: db isFalse +\c +\c %define isTrue 1 +\c +\c val2: db isFalse + +In this case, \c{val1} is equal to 0, and \c{val2} is equal to 1. +This is because, when a single-line macro is defined using +\c{%define}, it is expanded only when it is called. As \c{isFalse} +expands to \c{isTrue}, the expansion will be the current value of +\c{isTrue}. The first time it is called that is 0, and the second +time it is 1. + +If you wanted \c{isFalse} to expand to the value assigned to the +embedded macro \c{isTrue} at the time that \c{isFalse} was defined, +you need to change the above code to use \c{%xdefine}. + +\c %xdefine isTrue 1 +\c %xdefine isFalse isTrue +\c %xdefine isTrue 0 +\c +\c val1: db isFalse +\c +\c %xdefine isTrue 1 +\c +\c val2: db isFalse + +Now, each time that \c{isFalse} is called, it expands to 1, +as that is what the embedded macro \c{isTrue} expanded to at +the time that \c{isFalse} was defined. + + +\S{indmacro} \i{Macro Indirection}: \I\c{%[}\c{%[...]} + +The \c{%[...]} construct can be used to expand macros in contexts +where macro expansion would otherwise not occur, including in the +names other macros. For example, if you have a set of macros named +\c{Foo16}, \c{Foo32} and \c{Foo64}, you could write: + +\c mov ax,Foo%[__BITS__] ; The Foo value + +to use the builtin macro \c{__BITS__} (see \k{bitsm}) to automatically +select between them. Similarly, the two statements: + +\c %xdefine Bar Quux ; Expands due to %xdefine +\c %define Bar %[Quux] ; Expands due to %[...] + +have, in fact, exactly the same effect. + +\c{%[...]} concatenates to adjacent tokens in the same way that +multi-line macro parameters do, see \k{concat} for details. + + +\S{concat%+} Concatenating Single Line Macro Tokens: \i\c{%+} + +Individual tokens in single line macros can be concatenated, to produce +longer tokens for later processing. This can be useful if there are +several similar macros that perform similar functions. + +Please note that a space is required after \c{%+}, in order to +disambiguate it from the syntax \c{%+1} used in multiline macros. + +As an example, consider the following: + +\c %define BDASTART 400h ; Start of BIOS data area + +\c struc tBIOSDA ; its structure +\c .COM1addr RESW 1 +\c .COM2addr RESW 1 +\c ; ..and so on +\c endstruc + +Now, if we need to access the elements of tBIOSDA in different places, +we can end up with: + +\c mov ax,BDASTART + tBIOSDA.COM1addr +\c mov bx,BDASTART + tBIOSDA.COM2addr + +This will become pretty ugly (and tedious) if used in many places, and +can be reduced in size significantly by using the following macro: + +\c ; Macro to access BIOS variables by their names (from tBDA): + +\c %define BDA(x) BDASTART + tBIOSDA. %+ x + +Now the above code can be written as: + +\c mov ax,BDA(COM1addr) +\c mov bx,BDA(COM2addr) + +Using this feature, we can simplify references to a lot of macros (and, +in turn, reduce typing errors). + + +\S{selfref%?} The Macro Name Itself: \i\c{%?} and \i\c{%??} + +The special symbols \c{%?} and \c{%??} can be used to reference the +macro name itself inside a macro expansion, this is supported for both +single-and multi-line macros. \c{%?} refers to the macro name as +\e{invoked}, whereas \c{%??} refers to the macro name as +\e{declared}. The two are always the same for case-sensitive +macros, but for case-insensitive macros, they can differ. + +For example: + +\c %idefine Foo mov %?,%?? +\c +\c foo +\c FOO + +will expand to: + +\c mov foo,Foo +\c mov FOO,Foo + +The sequence: + +\c %idefine keyword $%? + +can be used to make a keyword "disappear", for example in case a new +instruction has been used as a label in older code. For example: + +\c %idefine pause $%? ; Hide the PAUSE instruction + + +\S{undef} Undefining Single-Line Macros: \i\c{%undef} + +Single-line macros can be removed with the \c{%undef} directive. For +example, the following sequence: + +\c %define foo bar +\c %undef foo +\c +\c mov eax, foo + +will expand to the instruction \c{mov eax, foo}, since after +\c{%undef} the macro \c{foo} is no longer defined. + +Macros that would otherwise be pre-defined can be undefined on the +command-line using the `-u' option on the NASM command line: see +\k{opt-u}. + + +\S{assign} \i{Preprocessor Variables}: \i\c{%assign} + +An alternative way to define single-line macros is by means of the +\c{%assign} command (and its \I{case sensitive}case-insensitive +counterpart \i\c{%iassign}, which differs from \c{%assign} in +exactly the same way that \c{%idefine} differs from \c{%define}). + +\c{%assign} is used to define single-line macros which take no +parameters and have a numeric value. This value can be specified in +the form of an expression, and it will be evaluated once, when the +\c{%assign} directive is processed. + +Like \c{%define}, macros defined using \c{%assign} can be re-defined +later, so you can do things like + +\c %assign i i+1 + +to increment the numeric value of a macro. + +\c{%assign} is useful for controlling the termination of \c{%rep} +preprocessor loops: see \k{rep} for an example of this. Another +use for \c{%assign} is given in \k{16c} and \k{32c}. + +The expression passed to \c{%assign} is a \i{critical expression} +(see \k{crit}), and must also evaluate to a pure number (rather than +a relocatable reference such as a code or data address, or anything +involving a register). + + +\S{defstr} Defining Strings: \I\c{%idefstr}\i\c{%defstr} + +\c{%defstr}, and its case-insensitive counterpart \c{%idefstr}, define +or redefine a single-line macro without parameters but converts the +entire right-hand side, after macro expansion, to a quoted string +before definition. + +For example: + +\c %defstr test TEST + +is equivalent to + +\c %define test 'TEST' + +This can be used, for example, with the \c{%!} construct (see +\k{getenv}): + +\c %defstr PATH %!PATH ; The operating system PATH variable + + +\S{deftok} Defining Tokens: \I\c{%ideftok}\i\c{%deftok} + +\c{%deftok}, and its case-insensitive counterpart \c{%ideftok}, define +or redefine a single-line macro without parameters but converts the +second parameter, after string conversion, to a sequence of tokens. + +For example: + +\c %deftok test 'TEST' + +is equivalent to + +\c %define test TEST + + +\H{strlen} \i{String Manipulation in Macros} + +It's often useful to be able to handle strings in macros. NASM +supports a few simple string handling macro operators from which +more complex operations can be constructed. + +All the string operators define or redefine a value (either a string +or a numeric value) to a single-line macro. When producing a string +value, it may change the style of quoting of the input string or +strings, and possibly use \c{\\}-escapes inside \c{`}-quoted strings. + +\S{strcat} \i{Concatenating Strings}: \i\c{%strcat} + +The \c{%strcat} operator concatenates quoted strings and assign them to +a single-line macro. + +For example: + +\c %strcat alpha "Alpha: ", '12" screen' + +... would assign the value \c{'Alpha: 12" screen'} to \c{alpha}. +Similarly: + +\c %strcat beta '"foo"\', "'bar'" + +... would assign the value \c{`"foo"\\\\'bar'`} to \c{beta}. + +The use of commas to separate strings is permitted but optional. + + +\S{strlen} \i{String Length}: \i\c{%strlen} + +The \c{%strlen} operator assigns the length of a string to a macro. +For example: + +\c %strlen charcnt 'my string' + +In this example, \c{charcnt} would receive the value 9, just as +if an \c{%assign} had been used. In this example, \c{'my string'} +was a literal string but it could also have been a single-line +macro that expands to a string, as in the following example: + +\c %define sometext 'my string' +\c %strlen charcnt sometext + +As in the first case, this would result in \c{charcnt} being +assigned the value of 9. + + +\S{substr} \i{Extracting Substrings}: \i\c{%substr} + +Individual letters or substrings in strings can be extracted using the +\c{%substr} operator. An example of its use is probably more useful +than the description: + +\c %substr mychar 'xyzw' 1 ; equivalent to %define mychar 'x' +\c %substr mychar 'xyzw' 2 ; equivalent to %define mychar 'y' +\c %substr mychar 'xyzw' 3 ; equivalent to %define mychar 'z' +\c %substr mychar 'xyzw' 2,2 ; equivalent to %define mychar 'yz' +\c %substr mychar 'xyzw' 2,-1 ; equivalent to %define mychar 'yzw' +\c %substr mychar 'xyzw' 2,-2 ; equivalent to %define mychar 'yz' + +As with \c{%strlen} (see \k{strlen}), the first parameter is the +single-line macro to be created and the second is the string. The +third parameter specifies the first character to be selected, and the +optional fourth parameter preceeded by comma) is the length. Note +that the first index is 1, not 0 and the last index is equal to the +value that \c{%strlen} would assign given the same string. Index +values out of range result in an empty string. A negative length +means "until N-1 characters before the end of string", i.e. \c{-1} +means until end of string, \c{-2} until one character before, etc. + + +\H{mlmacro} \i{Multi-Line Macros}: \I\c{%imacro}\i\c{%macro} + +Multi-line macros are much more like the type of macro seen in MASM +and TASM: a multi-line macro definition in NASM looks something like +this. + +\c %macro prologue 1 +\c +\c push ebp +\c mov ebp,esp +\c sub esp,%1 +\c +\c %endmacro + +This defines a C-like function prologue as a macro: so you would +invoke the macro with a call such as + +\c myfunc: prologue 12 + +which would expand to the three lines of code + +\c myfunc: push ebp +\c mov ebp,esp +\c sub esp,12 + +The number \c{1} after the macro name in the \c{%macro} line defines +the number of parameters the macro \c{prologue} expects to receive. +The use of \c{%1} inside the macro definition refers to the first +parameter to the macro call. With a macro taking more than one +parameter, subsequent parameters would be referred to as \c{%2}, +\c{%3} and so on. + +Multi-line macros, like single-line macros, are \i{case-sensitive}, +unless you define them using the alternative directive \c{%imacro}. + +If you need to pass a comma as \e{part} of a parameter to a +multi-line macro, you can do that by enclosing the entire parameter +in \I{braces, around macro parameters}braces. So you could code +things like + +\c %macro silly 2 +\c +\c %2: db %1 +\c +\c %endmacro +\c +\c silly 'a', letter_a ; letter_a: db 'a' +\c silly 'ab', string_ab ; string_ab: db 'ab' +\c silly {13,10}, crlf ; crlf: db 13,10 + + +\S{mlrmacro} \i{Recursive Multi-Line Macros}: \I\c{%irmacro}\i\c{%rmacro} + +A multi-line macro cannot be referenced within itself, in order to +prevent accidental infinite recursion. + +Recursive multi-line macros allow for self-referencing, with the +caveat that the user is aware of the existence, use and purpose of +recursive multi-line macros. There is also a generous, but sane, upper +limit to the number of recursions, in order to prevent run-away memory +consumption in case of accidental infinite recursion. + +As with non-recursive multi-line macros, recursive multi-line macros are +\i{case-sensitive}, unless you define them using the alternative +directive \c{%irmacro}. + + +\S{mlmacover} Overloading Multi-Line Macros\I{overloading, multi-line macros} + +As with single-line macros, multi-line macros can be overloaded by +defining the same macro name several times with different numbers of +parameters. This time, no exception is made for macros with no +parameters at all. So you could define + +\c %macro prologue 0 +\c +\c push ebp +\c mov ebp,esp +\c +\c %endmacro + +to define an alternative form of the function prologue which +allocates no local stack space. + +Sometimes, however, you might want to `overload' a machine +instruction; for example, you might want to define + +\c %macro push 2 +\c +\c push %1 +\c push %2 +\c +\c %endmacro + +so that you could code + +\c push ebx ; this line is not a macro call +\c push eax,ecx ; but this one is + +Ordinarily, NASM will give a warning for the first of the above two +lines, since \c{push} is now defined to be a macro, and is being +invoked with a number of parameters for which no definition has been +given. The correct code will still be generated, but the assembler +will give a warning. This warning can be disabled by the use of the +\c{-w-macro-params} command-line option (see \k{opt-w}). + + +\S{maclocal} \i{Macro-Local Labels} + +NASM allows you to define labels within a multi-line macro +definition in such a way as to make them local to the macro call: so +calling the same macro multiple times will use a different label +each time. You do this by prefixing \i\c{%%} to the label name. So +you can invent an instruction which executes a \c{RET} if the \c{Z} +flag is set by doing this: + +\c %macro retz 0 +\c +\c jnz %%skip +\c ret +\c %%skip: +\c +\c %endmacro + +You can call this macro as many times as you want, and every time +you call it NASM will make up a different `real' name to substitute +for the label \c{%%skip}. The names NASM invents are of the form +\c{..@2345.skip}, where the number 2345 changes with every macro +call. The \i\c{..@} prefix prevents macro-local labels from +interfering with the local label mechanism, as described in +\k{locallab}. You should avoid defining your own labels in this form +(the \c{..@} prefix, then a number, then another period) in case +they interfere with macro-local labels. + + +\S{mlmacgre} \i{Greedy Macro Parameters} + +Occasionally it is useful to define a macro which lumps its entire +command line into one parameter definition, possibly after +extracting one or two smaller parameters from the front. An example +might be a macro to write a text string to a file in MS-DOS, where +you might want to be able to write + +\c writefile [filehandle],"hello, world",13,10 + +NASM allows you to define the last parameter of a macro to be +\e{greedy}, meaning that if you invoke the macro with more +parameters than it expects, all the spare parameters get lumped into +the last defined one along with the separating commas. So if you +code: + +\c %macro writefile 2+ +\c +\c jmp %%endstr +\c %%str: db %2 +\c %%endstr: +\c mov dx,%%str +\c mov cx,%%endstr-%%str +\c mov bx,%1 +\c mov ah,0x40 +\c int 0x21 +\c +\c %endmacro + +then the example call to \c{writefile} above will work as expected: +the text before the first comma, \c{[filehandle]}, is used as the +first macro parameter and expanded when \c{%1} is referred to, and +all the subsequent text is lumped into \c{%2} and placed after the +\c{db}. + +The greedy nature of the macro is indicated to NASM by the use of +the \I{+ modifier}\c{+} sign after the parameter count on the +\c{%macro} line. + +If you define a greedy macro, you are effectively telling NASM how +it should expand the macro given \e{any} number of parameters from +the actual number specified up to infinity; in this case, for +example, NASM now knows what to do when it sees a call to +\c{writefile} with 2, 3, 4 or more parameters. NASM will take this +into account when overloading macros, and will not allow you to +define another form of \c{writefile} taking 4 parameters (for +example). + +Of course, the above macro could have been implemented as a +non-greedy macro, in which case the call to it would have had to +look like + +\c writefile [filehandle], {"hello, world",13,10} + +NASM provides both mechanisms for putting \i{commas in macro +parameters}, and you choose which one you prefer for each macro +definition. + +See \k{sectmac} for a better way to write the above macro. + + +\S{mlmacdef} \i{Default Macro Parameters} + +NASM also allows you to define a multi-line macro with a \e{range} +of allowable parameter counts. If you do this, you can specify +defaults for \i{omitted parameters}. So, for example: + +\c %macro die 0-1 "Painful program death has occurred." +\c +\c writefile 2,%1 +\c mov ax,0x4c01 +\c int 0x21 +\c +\c %endmacro + +This macro (which makes use of the \c{writefile} macro defined in +\k{mlmacgre}) can be called with an explicit error message, which it +will display on the error output stream before exiting, or it can be +called with no parameters, in which case it will use the default +error message supplied in the macro definition. + +In general, you supply a minimum and maximum number of parameters +for a macro of this type; the minimum number of parameters are then +required in the macro call, and then you provide defaults for the +optional ones. So if a macro definition began with the line + +\c %macro foobar 1-3 eax,[ebx+2] + +then it could be called with between one and three parameters, and +\c{%1} would always be taken from the macro call. \c{%2}, if not +specified by the macro call, would default to \c{eax}, and \c{%3} if +not specified would default to \c{[ebx+2]}. + +You can provide extra information to a macro by providing +too many default parameters: + +\c %macro quux 1 something + +This will trigger a warning by default; see \k{opt-w} for +more information. +When \c{quux} is invoked, it receives not one but two parameters. +\c{something} can be referred to as \c{%2}. The difference +between passing \c{something} this way and writing \c{something} +in the macro body is that with this way \c{something} is evaluated +when the macro is defined, not when it is expanded. + +You may omit parameter defaults from the macro definition, in which +case the parameter default is taken to be blank. This can be useful +for macros which can take a variable number of parameters, since the +\i\c{%0} token (see \k{percent0}) allows you to determine how many +parameters were really passed to the macro call. + +This defaulting mechanism can be combined with the greedy-parameter +mechanism; so the \c{die} macro above could be made more powerful, +and more useful, by changing the first line of the definition to + +\c %macro die 0-1+ "Painful program death has occurred.",13,10 + +The maximum parameter count can be infinite, denoted by \c{*}. In +this case, of course, it is impossible to provide a \e{full} set of +default parameters. Examples of this usage are shown in \k{rotate}. + + +\S{percent0} \i\c{%0}: \I{counting macro parameters}Macro Parameter Counter + +The parameter reference \c{%0} will return a numeric constant giving the +number of parameters received, that is, if \c{%0} is n then \c{%}n is the +last parameter. \c{%0} is mostly useful for macros that can take a variable +number of parameters. It can be used as an argument to \c{%rep} +(see \k{rep}) in order to iterate through all the parameters of a macro. +Examples are given in \k{rotate}. + + +\S{rotate} \i\c{%rotate}: \i{Rotating Macro Parameters} + +Unix shell programmers will be familiar with the \I{shift +command}\c{shift} shell command, which allows the arguments passed +to a shell script (referenced as \c{$1}, \c{$2} and so on) to be +moved left by one place, so that the argument previously referenced +as \c{$2} becomes available as \c{$1}, and the argument previously +referenced as \c{$1} is no longer available at all. + +NASM provides a similar mechanism, in the form of \c{%rotate}. As +its name suggests, it differs from the Unix \c{shift} in that no +parameters are lost: parameters rotated off the left end of the +argument list reappear on the right, and vice versa. + +\c{%rotate} is invoked with a single numeric argument (which may be +an expression). The macro parameters are rotated to the left by that +many places. If the argument to \c{%rotate} is negative, the macro +parameters are rotated to the right. + +\I{iterating over macro parameters}So a pair of macros to save and +restore a set of registers might work as follows: + +\c %macro multipush 1-* +\c +\c %rep %0 +\c push %1 +\c %rotate 1 +\c %endrep +\c +\c %endmacro + +This macro invokes the \c{PUSH} instruction on each of its arguments +in turn, from left to right. It begins by pushing its first +argument, \c{%1}, then invokes \c{%rotate} to move all the arguments +one place to the left, so that the original second argument is now +available as \c{%1}. Repeating this procedure as many times as there +were arguments (achieved by supplying \c{%0} as the argument to +\c{%rep}) causes each argument in turn to be pushed. + +Note also the use of \c{*} as the maximum parameter count, +indicating that there is no upper limit on the number of parameters +you may supply to the \i\c{multipush} macro. + +It would be convenient, when using this macro, to have a \c{POP} +equivalent, which \e{didn't} require the arguments to be given in +reverse order. Ideally, you would write the \c{multipush} macro +call, then cut-and-paste the line to where the pop needed to be +done, and change the name of the called macro to \c{multipop}, and +the macro would take care of popping the registers in the opposite +order from the one in which they were pushed. + +This can be done by the following definition: + +\c %macro multipop 1-* +\c +\c %rep %0 +\c %rotate -1 +\c pop %1 +\c %endrep +\c +\c %endmacro + +This macro begins by rotating its arguments one place to the +\e{right}, so that the original \e{last} argument appears as \c{%1}. +This is then popped, and the arguments are rotated right again, so +the second-to-last argument becomes \c{%1}. Thus the arguments are +iterated through in reverse order. + + +\S{concat} \i{Concatenating Macro Parameters} + +NASM can concatenate macro parameters and macro indirection constructs +on to other text surrounding them. This allows you to declare a family +of symbols, for example, in a macro definition. If, for example, you +wanted to generate a table of key codes along with offsets into the +table, you could code something like + +\c %macro keytab_entry 2 +\c +\c keypos%1 equ $-keytab +\c db %2 +\c +\c %endmacro +\c +\c keytab: +\c keytab_entry F1,128+1 +\c keytab_entry F2,128+2 +\c keytab_entry Return,13 + +which would expand to + +\c keytab: +\c keyposF1 equ $-keytab +\c db 128+1 +\c keyposF2 equ $-keytab +\c db 128+2 +\c keyposReturn equ $-keytab +\c db 13 + +You can just as easily concatenate text on to the other end of a +macro parameter, by writing \c{%1foo}. + +If you need to append a \e{digit} to a macro parameter, for example +defining labels \c{foo1} and \c{foo2} when passed the parameter +\c{foo}, you can't code \c{%11} because that would be taken as the +eleventh macro parameter. Instead, you must code +\I{braces, after % sign}\c{%\{1\}1}, which will separate the first +\c{1} (giving the number of the macro parameter) from the second +(literal text to be concatenated to the parameter). + +This concatenation can also be applied to other preprocessor in-line +objects, such as macro-local labels (\k{maclocal}) and context-local +labels (\k{ctxlocal}). In all cases, ambiguities in syntax can be +resolved by enclosing everything after the \c{%} sign and before the +literal text in braces: so \c{%\{%foo\}bar} concatenates the text +\c{bar} to the end of the real name of the macro-local label +\c{%%foo}. (This is unnecessary, since the form NASM uses for the +real names of macro-local labels means that the two usages +\c{%\{%foo\}bar} and \c{%%foobar} would both expand to the same +thing anyway; nevertheless, the capability is there.) + +The single-line macro indirection construct, \c{%[...]} +(\k{indmacro}), behaves the same way as macro parameters for the +purpose of concatenation. + +See also the \c{%+} operator, \k{concat%+}. + + +\S{mlmaccc} \i{Condition Codes as Macro Parameters} + +NASM can give special treatment to a macro parameter which contains +a condition code. For a start, you can refer to the macro parameter +\c{%1} by means of the alternative syntax \i\c{%+1}, which informs +NASM that this macro parameter is supposed to contain a condition +code, and will cause the preprocessor to report an error message if +the macro is called with a parameter which is \e{not} a valid +condition code. + +Far more usefully, though, you can refer to the macro parameter by +means of \i\c{%-1}, which NASM will expand as the \e{inverse} +condition code. So the \c{retz} macro defined in \k{maclocal} can be +replaced by a general \i{conditional-return macro} like this: + +\c %macro retc 1 +\c +\c j%-1 %%skip +\c ret +\c %%skip: +\c +\c %endmacro + +This macro can now be invoked using calls like \c{retc ne}, which +will cause the conditional-jump instruction in the macro expansion +to come out as \c{JE}, or \c{retc po} which will make the jump a +\c{JPE}. + +The \c{%+1} macro-parameter reference is quite happy to interpret +the arguments \c{CXZ} and \c{ECXZ} as valid condition codes; +however, \c{%-1} will report an error if passed either of these, +because no inverse condition code exists. + + +\S{nolist} \i{Disabling Listing Expansion}\I\c{.nolist} + +When NASM is generating a listing file from your program, it will +generally expand multi-line macros by means of writing the macro +call and then listing each line of the expansion. This allows you to +see which instructions in the macro expansion are generating what +code; however, for some macros this clutters the listing up +unnecessarily. + +NASM therefore provides the \c{.nolist} qualifier, which you can +include in a macro definition to inhibit the expansion of the macro +in the listing file. The \c{.nolist} qualifier comes directly after +the number of parameters, like this: + +\c %macro foo 1.nolist + +Or like this: + +\c %macro bar 1-5+.nolist a,b,c,d,e,f,g,h + +\S{unmacro} Undefining Multi-Line Macros: \i\c{%unmacro} + +Multi-line macros can be removed with the \c{%unmacro} directive. +Unlike the \c{%undef} directive, however, \c{%unmacro} takes an +argument specification, and will only remove \i{exact matches} with +that argument specification. + +For example: + +\c %macro foo 1-3 +\c ; Do something +\c %endmacro +\c %unmacro foo 1-3 + +removes the previously defined macro \c{foo}, but + +\c %macro bar 1-3 +\c ; Do something +\c %endmacro +\c %unmacro bar 1 + +does \e{not} remove the macro \c{bar}, since the argument +specification does not match exactly. + + +\S{exitmacro} Exiting Multi-Line Macros: \i\c{%exitmacro} + +Multi-line macro expansions can be arbitrarily terminated with +the \c{%exitmacro} directive. + +For example: + +\c %macro foo 1-3 +\c ; Do something +\c %if<condition> +\c %exitmacro +\c %endif +\c ; Do something +\c %endmacro + +\H{condasm} \i{Conditional Assembly}\I\c{%if} + +Similarly to the C preprocessor, NASM allows sections of a source +file to be assembled only if certain conditions are met. The general +syntax of this feature looks like this: + +\c %if<condition> +\c ; some code which only appears if <condition> is met +\c %elif<condition2> +\c ; only appears if <condition> is not met but <condition2> is +\c %else +\c ; this appears if neither <condition> nor <condition2> was met +\c %endif + +The inverse forms \i\c{%ifn} and \i\c{%elifn} are also supported. + +The \i\c{%else} clause is optional, as is the \i\c{%elif} clause. +You can have more than one \c{%elif} clause as well. + +There are a number of variants of the \c{%if} directive. Each has its +corresponding \c{%elif}, \c{%ifn}, and \c{%elifn} directives; for +example, the equivalents to the \c{%ifdef} directive are \c{%elifdef}, +\c{%ifndef}, and \c{%elifndef}. + +\S{ifdef} \i\c{%ifdef}: Testing Single-Line Macro Existence\I{testing, +single-line macro existence} + +Beginning a conditional-assembly block with the line \c{%ifdef +MACRO} will assemble the subsequent code if, and only if, a +single-line macro called \c{MACRO} is defined. If not, then the +\c{%elif} and \c{%else} blocks (if any) will be processed instead. + +For example, when debugging a program, you might want to write code +such as + +\c ; perform some function +\c %ifdef DEBUG +\c writefile 2,"Function performed successfully",13,10 +\c %endif +\c ; go and do something else + +Then you could use the command-line option \c{-dDEBUG} to create a +version of the program which produced debugging messages, and remove +the option to generate the final release version of the program. + +You can test for a macro \e{not} being defined by using +\i\c{%ifndef} instead of \c{%ifdef}. You can also test for macro +definitions in \c{%elif} blocks by using \i\c{%elifdef} and +\i\c{%elifndef}. + + +\S{ifmacro} \i\c{%ifmacro}: Testing Multi-Line Macro +Existence\I{testing, multi-line macro existence} + +The \c{%ifmacro} directive operates in the same way as the \c{%ifdef} +directive, except that it checks for the existence of a multi-line macro. + +For example, you may be working with a large project and not have control +over the macros in a library. You may want to create a macro with one +name if it doesn't already exist, and another name if one with that name +does exist. + +The \c{%ifmacro} is considered true if defining a macro with the given name +and number of arguments would cause a definitions conflict. For example: + +\c %ifmacro MyMacro 1-3 +\c +\c %error "MyMacro 1-3" causes a conflict with an existing macro. +\c +\c %else +\c +\c %macro MyMacro 1-3 +\c +\c ; insert code to define the macro +\c +\c %endmacro +\c +\c %endif + +This will create the macro "MyMacro 1-3" if no macro already exists which +would conflict with it, and emits a warning if there would be a definition +conflict. + +You can test for the macro not existing by using the \i\c{%ifnmacro} instead +of \c{%ifmacro}. Additional tests can be performed in \c{%elif} blocks by using +\i\c{%elifmacro} and \i\c{%elifnmacro}. + + +\S{ifctx} \i\c{%ifctx}: Testing the Context Stack\I{testing, context +stack} + +The conditional-assembly construct \c{%ifctx} will cause the +subsequent code to be assembled if and only if the top context on +the preprocessor's context stack has the same name as one of the arguments. +As with \c{%ifdef}, the inverse and \c{%elif} forms \i\c{%ifnctx}, +\i\c{%elifctx} and \i\c{%elifnctx} are also supported. + +For more details of the context stack, see \k{ctxstack}. For a +sample use of \c{%ifctx}, see \k{blockif}. + + +\S{if} \i\c{%if}: Testing Arbitrary Numeric Expressions\I{testing, +arbitrary numeric expressions} + +The conditional-assembly construct \c{%if expr} will cause the +subsequent code to be assembled if and only if the value of the +numeric expression \c{expr} is non-zero. An example of the use of +this feature is in deciding when to break out of a \c{%rep} +preprocessor loop: see \k{rep} for a detailed example. + +The expression given to \c{%if}, and its counterpart \i\c{%elif}, is +a critical expression (see \k{crit}). + +\c{%if} extends the normal NASM expression syntax, by providing a +set of \i{relational operators} which are not normally available in +expressions. The operators \i\c{=}, \i\c{<}, \i\c{>}, \i\c{<=}, +\i\c{>=} and \i\c{<>} test equality, less-than, greater-than, +less-or-equal, greater-or-equal and not-equal respectively. The +C-like forms \i\c{==} and \i\c{!=} are supported as alternative +forms of \c{=} and \c{<>}. In addition, low-priority logical +operators \i\c{&&}, \i\c{^^} and \i\c{||} are provided, supplying +\i{logical AND}, \i{logical XOR} and \i{logical OR}. These work like +the C logical operators (although C has no logical XOR), in that +they always return either 0 or 1, and treat any non-zero input as 1 +(so that \c{^^}, for example, returns 1 if exactly one of its inputs +is zero, and 0 otherwise). The relational operators also return 1 +for true and 0 for false. + +Like other \c{%if} constructs, \c{%if} has a counterpart +\i\c{%elif}, and negative forms \i\c{%ifn} and \i\c{%elifn}. + +\S{ifidn} \i\c{%ifidn} and \i\c{%ifidni}: Testing Exact Text +Identity\I{testing, exact text identity} + +The construct \c{%ifidn text1,text2} will cause the subsequent code +to be assembled if and only if \c{text1} and \c{text2}, after +expanding single-line macros, are identical pieces of text. +Differences in white space are not counted. + +\c{%ifidni} is similar to \c{%ifidn}, but is \i{case-insensitive}. + +For example, the following macro pushes a register or number on the +stack, and allows you to treat \c{IP} as a real register: + +\c %macro pushparam 1 +\c +\c %ifidni %1,ip +\c call %%label +\c %%label: +\c %else +\c push %1 +\c %endif +\c +\c %endmacro + +Like other \c{%if} constructs, \c{%ifidn} has a counterpart +\i\c{%elifidn}, and negative forms \i\c{%ifnidn} and \i\c{%elifnidn}. +Similarly, \c{%ifidni} has counterparts \i\c{%elifidni}, +\i\c{%ifnidni} and \i\c{%elifnidni}. + +\S{iftyp} \i\c{%ifid}, \i\c{%ifnum}, \i\c{%ifstr}: Testing Token +Types\I{testing, token types} + +Some macros will want to perform different tasks depending on +whether they are passed a number, a string, or an identifier. For +example, a string output macro might want to be able to cope with +being passed either a string constant or a pointer to an existing +string. + +The conditional assembly construct \c{%ifid}, taking one parameter +(which may be blank), assembles the subsequent code if and only if +the first token in the parameter exists and is an identifier. +\c{%ifnum} works similarly, but tests for the token being a numeric +constant; \c{%ifstr} tests for it being a string. + +For example, the \c{writefile} macro defined in \k{mlmacgre} can be +extended to take advantage of \c{%ifstr} in the following fashion: + +\c %macro writefile 2-3+ +\c +\c %ifstr %2 +\c jmp %%endstr +\c %if %0 = 3 +\c %%str: db %2,%3 +\c %else +\c %%str: db %2 +\c %endif +\c %%endstr: mov dx,%%str +\c mov cx,%%endstr-%%str +\c %else +\c mov dx,%2 +\c mov cx,%3 +\c %endif +\c mov bx,%1 +\c mov ah,0x40 +\c int 0x21 +\c +\c %endmacro + +Then the \c{writefile} macro can cope with being called in either of +the following two ways: + +\c writefile [file], strpointer, length +\c writefile [file], "hello", 13, 10 + +In the first, \c{strpointer} is used as the address of an +already-declared string, and \c{length} is used as its length; in +the second, a string is given to the macro, which therefore declares +it itself and works out the address and length for itself. + +Note the use of \c{%if} inside the \c{%ifstr}: this is to detect +whether the macro was passed two arguments (so the string would be a +single string constant, and \c{db %2} would be adequate) or more (in +which case, all but the first two would be lumped together into +\c{%3}, and \c{db %2,%3} would be required). + +The usual \I\c{%elifid}\I\c{%elifnum}\I\c{%elifstr}\c{%elif}..., +\I\c{%ifnid}\I\c{%ifnnum}\I\c{%ifnstr}\c{%ifn}..., and +\I\c{%elifnid}\I\c{%elifnnum}\I\c{%elifnstr}\c{%elifn}... versions +exist for each of \c{%ifid}, \c{%ifnum} and \c{%ifstr}. + +\S{iftoken} \i\c{%iftoken}: Test for a Single Token + +Some macros will want to do different things depending on if it is +passed a single token (e.g. paste it to something else using \c{%+}) +versus a multi-token sequence. + +The conditional assembly construct \c{%iftoken} assembles the +subsequent code if and only if the expanded parameters consist of +exactly one token, possibly surrounded by whitespace. + +For example: + +\c %iftoken 1 + +will assemble the subsequent code, but + +\c %iftoken -1 + +will not, since \c{-1} contains two tokens: the unary minus operator +\c{-}, and the number \c{1}. + +The usual \i\c{%eliftoken}, \i\c\{%ifntoken}, and \i\c{%elifntoken} +variants are also provided. + +\S{ifempty} \i\c{%ifempty}: Test for Empty Expansion + +The conditional assembly construct \c{%ifempty} assembles the +subsequent code if and only if the expanded parameters do not contain +any tokens at all, whitespace excepted. + +The usual \i\c{%elifempty}, \i\c\{%ifnempty}, and \i\c{%elifnempty} +variants are also provided. + +\H{rep} \i{Preprocessor Loops}\I{repeating code}: \i\c{%rep} + +NASM's \c{TIMES} prefix, though useful, cannot be used to invoke a +multi-line macro multiple times, because it is processed by NASM +after macros have already been expanded. Therefore NASM provides +another form of loop, this time at the preprocessor level: \c{%rep}. + +The directives \c{%rep} and \i\c{%endrep} (\c{%rep} takes a numeric +argument, which can be an expression; \c{%endrep} takes no +arguments) can be used to enclose a chunk of code, which is then +replicated as many times as specified by the preprocessor: + +\c %assign i 0 +\c %rep 64 +\c inc word [table+2*i] +\c %assign i i+1 +\c %endrep + +This will generate a sequence of 64 \c{INC} instructions, +incrementing every word of memory from \c{[table]} to +\c{[table+126]}. + +For more complex termination conditions, or to break out of a repeat +loop part way along, you can use the \i\c{%exitrep} directive to +terminate the loop, like this: + +\c fibonacci: +\c %assign i 0 +\c %assign j 1 +\c %rep 100 +\c %if j > 65535 +\c %exitrep +\c %endif +\c dw j +\c %assign k j+i +\c %assign i j +\c %assign j k +\c %endrep +\c +\c fib_number equ ($-fibonacci)/2 + +This produces a list of all the Fibonacci numbers that will fit in +16 bits. Note that a maximum repeat count must still be given to +\c{%rep}. This is to prevent the possibility of NASM getting into an +infinite loop in the preprocessor, which (on multitasking or +multi-user systems) would typically cause all the system memory to +be gradually used up and other applications to start crashing. + + +\H{files} Source Files and Dependencies + +These commands allow you to split your sources into multiple files. + +\S{include} \i\c{%include}: \i{Including Other Files} + +Using, once again, a very similar syntax to the C preprocessor, +NASM's preprocessor lets you include other source files into your +code. This is done by the use of the \i\c{%include} directive: + +\c %include "macros.mac" + +will include the contents of the file \c{macros.mac} into the source +file containing the \c{%include} directive. + +Include files are \I{searching for include files}searched for in the +current directory (the directory you're in when you run NASM, as +opposed to the location of the NASM executable or the location of +the source file), plus any directories specified on the NASM command +line using the \c{-i} option. + +The standard C idiom for preventing a file being included more than +once is just as applicable in NASM: if the file \c{macros.mac} has +the form + +\c %ifndef MACROS_MAC +\c %define MACROS_MAC +\c ; now define some macros +\c %endif + +then including the file more than once will not cause errors, +because the second time the file is included nothing will happen +because the macro \c{MACROS_MAC} will already be defined. + +You can force a file to be included even if there is no \c{%include} +directive that explicitly includes it, by using the \i\c{-p} option +on the NASM command line (see \k{opt-p}). + + +\S{pathsearch} \i\c{%pathsearch}: Search the Include Path + +The \c{%pathsearch} directive takes a single-line macro name and a +filename, and declare or redefines the specified single-line macro to +be the include-path-resolved version of the filename, if the file +exists (otherwise, it is passed unchanged.) + +For example, + +\c %pathsearch MyFoo "foo.bin" + +... with \c{-Ibins/} in the include path may end up defining the macro +\c{MyFoo} to be \c{"bins/foo.bin"}. + + +\S{depend} \i\c{%depend}: Add Dependent Files + +The \c{%depend} directive takes a filename and adds it to the list of +files to be emitted as dependency generation when the \c{-M} options +and its relatives (see \k{opt-M}) are used. It produces no output. + +This is generally used in conjunction with \c{%pathsearch}. For +example, a simplified version of the standard macro wrapper for the +\c{INCBIN} directive looks like: + +\c %imacro incbin 1-2+ 0 +\c %pathsearch dep %1 +\c %depend dep +\c incbin dep,%2 +\c %endmacro + +This first resolves the location of the file into the macro \c{dep}, +then adds it to the dependency lists, and finally issues the +assembler-level \c{INCBIN} directive. + + +\S{use} \i\c{%use}: Include Standard Macro Package + +The \c{%use} directive is similar to \c{%include}, but rather than +including the contents of a file, it includes a named standard macro +package. The standard macro packages are part of NASM, and are +described in \k{macropkg}. + +Unlike the \c{%include} directive, package names for the \c{%use} +directive do not require quotes, but quotes are permitted. In NASM +2.04 and 2.05 the unquoted form would be macro-expanded; this is no +longer true. Thus, the following lines are equivalent: + +\c %use altreg +\c %use 'altreg' + +Standard macro packages are protected from multiple inclusion. When a +standard macro package is used, a testable single-line macro of the +form \c{__USE_}\e{package}\c{__} is also defined, see \k{use_def}. + +\H{ctxstack} The \i{Context Stack} + +Having labels that are local to a macro definition is sometimes not +quite powerful enough: sometimes you want to be able to share labels +between several macro calls. An example might be a \c{REPEAT} ... +\c{UNTIL} loop, in which the expansion of the \c{REPEAT} macro +would need to be able to refer to a label which the \c{UNTIL} macro +had defined. However, for such a macro you would also want to be +able to nest these loops. + +NASM provides this level of power by means of a \e{context stack}. +The preprocessor maintains a stack of \e{contexts}, each of which is +characterized by a name. You add a new context to the stack using +the \i\c{%push} directive, and remove one using \i\c{%pop}. You can +define labels that are local to a particular context on the stack. + + +\S{pushpop} \i\c{%push} and \i\c{%pop}: \I{creating +contexts}\I{removing contexts}Creating and Removing Contexts + +The \c{%push} directive is used to create a new context and place it +on the top of the context stack. \c{%push} takes an optional argument, +which is the name of the context. For example: + +\c %push foobar + +This pushes a new context called \c{foobar} on the stack. You can have +several contexts on the stack with the same name: they can still be +distinguished. If no name is given, the context is unnamed (this is +normally used when both the \c{%push} and the \c{%pop} are inside a +single macro definition.) + +The directive \c{%pop}, taking one optional argument, removes the top +context from the context stack and destroys it, along with any +labels associated with it. If an argument is given, it must match the +name of the current context, otherwise it will issue an error. + + +\S{ctxlocal} \i{Context-Local Labels} + +Just as the usage \c{%%foo} defines a label which is local to the +particular macro call in which it is used, the usage \I{%$}\c{%$foo} +is used to define a label which is local to the context on the top +of the context stack. So the \c{REPEAT} and \c{UNTIL} example given +above could be implemented by means of: + +\c %macro repeat 0 +\c +\c %push repeat +\c %$begin: +\c +\c %endmacro +\c +\c %macro until 1 +\c +\c j%-1 %$begin +\c %pop +\c +\c %endmacro + +and invoked by means of, for example, + +\c mov cx,string +\c repeat +\c add cx,3 +\c scasb +\c until e + +which would scan every fourth byte of a string in search of the byte +in \c{AL}. + +If you need to define, or access, labels local to the context +\e{below} the top one on the stack, you can use \I{%$$}\c{%$$foo}, or +\c{%$$$foo} for the context below that, and so on. + + +\S{ctxdefine} \i{Context-Local Single-Line Macros} + +NASM also allows you to define single-line macros which are local to +a particular context, in just the same way: + +\c %define %$localmac 3 + +will define the single-line macro \c{%$localmac} to be local to the +top context on the stack. Of course, after a subsequent \c{%push}, +it can then still be accessed by the name \c{%$$localmac}. + + +\S{ctxrepl} \i\c{%repl}: \I{renaming contexts}Renaming a Context + +If you need to change the name of the top context on the stack (in +order, for example, to have it respond differently to \c{%ifctx}), +you can execute a \c{%pop} followed by a \c{%push}; but this will +have the side effect of destroying all context-local labels and +macros associated with the context that was just popped. + +NASM provides the directive \c{%repl}, which \e{replaces} a context +with a different name, without touching the associated macros and +labels. So you could replace the destructive code + +\c %pop +\c %push newname + +with the non-destructive version \c{%repl newname}. + + +\S{blockif} Example Use of the \i{Context Stack}: \i{Block IFs} + +This example makes use of almost all the context-stack features, +including the conditional-assembly construct \i\c{%ifctx}, to +implement a block IF statement as a set of macros. + +\c %macro if 1 +\c +\c %push if +\c j%-1 %$ifnot +\c +\c %endmacro +\c +\c %macro else 0 +\c +\c %ifctx if +\c %repl else +\c jmp %$ifend +\c %$ifnot: +\c %else +\c %error "expected `if' before `else'" +\c %endif +\c +\c %endmacro +\c +\c %macro endif 0 +\c +\c %ifctx if +\c %$ifnot: +\c %pop +\c %elifctx else +\c %$ifend: +\c %pop +\c %else +\c %error "expected `if' or `else' before `endif'" +\c %endif +\c +\c %endmacro + +This code is more robust than the \c{REPEAT} and \c{UNTIL} macros +given in \k{ctxlocal}, because it uses conditional assembly to check +that the macros are issued in the right order (for example, not +calling \c{endif} before \c{if}) and issues a \c{%error} if they're +not. + +In addition, the \c{endif} macro has to be able to cope with the two +distinct cases of either directly following an \c{if}, or following +an \c{else}. It achieves this, again, by using conditional assembly +to do different things depending on whether the context on top of +the stack is \c{if} or \c{else}. + +The \c{else} macro has to preserve the context on the stack, in +order to have the \c{%$ifnot} referred to by the \c{if} macro be the +same as the one defined by the \c{endif} macro, but has to change +the context's name so that \c{endif} will know there was an +intervening \c{else}. It does this by the use of \c{%repl}. + +A sample usage of these macros might look like: + +\c cmp ax,bx +\c +\c if ae +\c cmp bx,cx +\c +\c if ae +\c mov ax,cx +\c else +\c mov ax,bx +\c endif +\c +\c else +\c cmp ax,cx +\c +\c if ae +\c mov ax,cx +\c endif +\c +\c endif + +The block-\c{IF} macros handle nesting quite happily, by means of +pushing another context, describing the inner \c{if}, on top of the +one describing the outer \c{if}; thus \c{else} and \c{endif} always +refer to the last unmatched \c{if} or \c{else}. + + +\H{stackrel} \i{Stack Relative Preprocessor Directives} + +The following preprocessor directives provide a way to use +labels to refer to local variables allocated on the stack. + +\b\c{%arg} (see \k{arg}) + +\b\c{%stacksize} (see \k{stacksize}) + +\b\c{%local} (see \k{local}) + + +\S{arg} \i\c{%arg} Directive + +The \c{%arg} directive is used to simplify the handling of +parameters passed on the stack. Stack based parameter passing +is used by many high level languages, including C, C++ and Pascal. + +While NASM has macros which attempt to duplicate this +functionality (see \k{16cmacro}), the syntax is not particularly +convenient to use. and is not TASM compatible. Here is an example +which shows the use of \c{%arg} without any external macros: + +\c some_function: +\c +\c %push mycontext ; save the current context +\c %stacksize large ; tell NASM to use bp +\c %arg i:word, j_ptr:word +\c +\c mov ax,[i] +\c mov bx,[j_ptr] +\c add ax,[bx] +\c ret +\c +\c %pop ; restore original context + +This is similar to the procedure defined in \k{16cmacro} and adds +the value in i to the value pointed to by j_ptr and returns the +sum in the ax register. See \k{pushpop} for an explanation of +\c{push} and \c{pop} and the use of context stacks. + + +\S{stacksize} \i\c{%stacksize} Directive + +The \c{%stacksize} directive is used in conjunction with the +\c{%arg} (see \k{arg}) and the \c{%local} (see \k{local}) directives. +It tells NASM the default size to use for subsequent \c{%arg} and +\c{%local} directives. The \c{%stacksize} directive takes one +required argument which is one of \c{flat}, \c{flat64}, \c{large} or \c{small}. + +\c %stacksize flat + +This form causes NASM to use stack-based parameter addressing +relative to \c{ebp} and it assumes that a near form of call was used +to get to this label (i.e. that \c{eip} is on the stack). + +\c %stacksize flat64 + +This form causes NASM to use stack-based parameter addressing +relative to \c{rbp} and it assumes that a near form of call was used +to get to this label (i.e. that \c{rip} is on the stack). + +\c %stacksize large + +This form uses \c{bp} to do stack-based parameter addressing and +assumes that a far form of call was used to get to this address +(i.e. that \c{ip} and \c{cs} are on the stack). + +\c %stacksize small + +This form also uses \c{bp} to address stack parameters, but it is +different from \c{large} because it also assumes that the old value +of bp is pushed onto the stack (i.e. it expects an \c{ENTER} +instruction). In other words, it expects that \c{bp}, \c{ip} and +\c{cs} are on the top of the stack, underneath any local space which +may have been allocated by \c{ENTER}. This form is probably most +useful when used in combination with the \c{%local} directive +(see \k{local}). + + +\S{local} \i\c{%local} Directive + +The \c{%local} directive is used to simplify the use of local +temporary stack variables allocated in a stack frame. Automatic +local variables in C are an example of this kind of variable. The +\c{%local} directive is most useful when used with the \c{%stacksize} +(see \k{stacksize} and is also compatible with the \c{%arg} directive +(see \k{arg}). It allows simplified reference to variables on the +stack which have been allocated typically by using the \c{ENTER} +instruction. +\# (see \k{insENTER} for a description of that instruction). +An example of its use is the following: + +\c silly_swap: +\c +\c %push mycontext ; save the current context +\c %stacksize small ; tell NASM to use bp +\c %assign %$localsize 0 ; see text for explanation +\c %local old_ax:word, old_dx:word +\c +\c enter %$localsize,0 ; see text for explanation +\c mov [old_ax],ax ; swap ax & bx +\c mov [old_dx],dx ; and swap dx & cx +\c mov ax,bx +\c mov dx,cx +\c mov bx,[old_ax] +\c mov cx,[old_dx] +\c leave ; restore old bp +\c ret ; +\c +\c %pop ; restore original context + +The \c{%$localsize} variable is used internally by the +\c{%local} directive and \e{must} be defined within the +current context before the \c{%local} directive may be used. +Failure to do so will result in one expression syntax error for +each \c{%local} variable declared. It then may be used in +the construction of an appropriately sized ENTER instruction +as shown in the example. + + +\H{pperror} Reporting \i{User-Defined Errors}: \i\c{%error}, \i\c{%warning}, \i\c{%fatal} + +The preprocessor directive \c{%error} will cause NASM to report an +error if it occurs in assembled code. So if other users are going to +try to assemble your source files, you can ensure that they define the +right macros by means of code like this: + +\c %ifdef F1 +\c ; do some setup +\c %elifdef F2 +\c ; do some different setup +\c %else +\c %error "Neither F1 nor F2 was defined." +\c %endif + +Then any user who fails to understand the way your code is supposed +to be assembled will be quickly warned of their mistake, rather than +having to wait until the program crashes on being run and then not +knowing what went wrong. + +Similarly, \c{%warning} issues a warning, but allows assembly to continue: + +\c %ifdef F1 +\c ; do some setup +\c %elifdef F2 +\c ; do some different setup +\c %else +\c %warning "Neither F1 nor F2 was defined, assuming F1." +\c %define F1 +\c %endif + +\c{%error} and \c{%warning} are issued only on the final assembly +pass. This makes them safe to use in conjunction with tests that +depend on symbol values. + +\c{%fatal} terminates assembly immediately, regardless of pass. This +is useful when there is no point in continuing the assembly further, +and doing so is likely just going to cause a spew of confusing error +messages. + +It is optional for the message string after \c{%error}, \c{%warning} +or \c{%fatal} to be quoted. If it is \e{not}, then single-line macros +are expanded in it, which can be used to display more information to +the user. For example: + +\c %if foo > 64 +\c %assign foo_over foo-64 +\c %error foo is foo_over bytes too large +\c %endif + + +\H{otherpreproc} \i{Other Preprocessor Directives} + +NASM also has preprocessor directives which allow access to +information from external sources. Currently they include: + +\b\c{%line} enables NASM to correctly handle the output of another +preprocessor (see \k{line}). + +\b\c{%!} enables NASM to read in the value of an environment variable, +which can then be used in your program (see \k{getenv}). + +\S{line} \i\c{%line} Directive + +The \c{%line} directive is used to notify NASM that the input line +corresponds to a specific line number in another file. Typically +this other file would be an original source file, with the current +NASM input being the output of a pre-processor. The \c{%line} +directive allows NASM to output messages which indicate the line +number of the original source file, instead of the file that is being +read by NASM. + +This preprocessor directive is not generally of use to programmers, +by may be of interest to preprocessor authors. The usage of the +\c{%line} preprocessor directive is as follows: + +\c %line nnn[+mmm] [filename] + +In this directive, \c{nnn} identifies the line of the original source +file which this line corresponds to. \c{mmm} is an optional parameter +which specifies a line increment value; each line of the input file +read in is considered to correspond to \c{mmm} lines of the original +source file. Finally, \c{filename} is an optional parameter which +specifies the file name of the original source file. + +After reading a \c{%line} preprocessor directive, NASM will report +all file name and line numbers relative to the values specified +therein. + + +\S{getenv} \i\c{%!}\c{<env>}: Read an environment variable. + +The \c{%!<env>} directive makes it possible to read the value of an +environment variable at assembly time. This could, for example, be used +to store the contents of an environment variable into a string, which +could be used at some other point in your code. + +For example, suppose that you have an environment variable \c{FOO}, and +you want the contents of \c{FOO} to be embedded in your program. You +could do that as follows: + +\c %defstr FOO %!FOO + +See \k{defstr} for notes on the \c{%defstr} directive. + + +\H{stdmac} \i{Standard Macros} + +NASM defines a set of standard macros, which are already defined +when it starts to process any source file. If you really need a +program to be assembled with no pre-defined macros, you can use the +\i\c{%clear} directive to empty the preprocessor of everything but +context-local preprocessor variables and single-line macros. + +Most \i{user-level assembler directives} (see \k{directive}) are +implemented as macros which invoke primitive directives; these are +described in \k{directive}. The rest of the standard macro set is +described here. + + +\S{stdmacver} \i{NASM Version} Macros + +The single-line macros \i\c{__NASM_MAJOR__}, \i\c{__NASM_MINOR__}, +\i\c{__NASM_SUBMINOR__} and \i\c{___NASM_PATCHLEVEL__} expand to the +major, minor, subminor and patch level parts of the \i{version +number of NASM} being used. So, under NASM 0.98.32p1 for +example, \c{__NASM_MAJOR__} would be defined to be 0, \c{__NASM_MINOR__} +would be defined as 98, \c{__NASM_SUBMINOR__} would be defined to 32, +and \c{___NASM_PATCHLEVEL__} would be defined as 1. + +Additionally, the macro \i\c{__NASM_SNAPSHOT__} is defined for +automatically generated snapshot releases \e{only}. + + +\S{stdmacverid} \i\c{__NASM_VERSION_ID__}: \i{NASM Version ID} + +The single-line macro \c{__NASM_VERSION_ID__} expands to a dword integer +representing the full version number of the version of nasm being used. +The value is the equivalent to \c{__NASM_MAJOR__}, \c{__NASM_MINOR__}, +\c{__NASM_SUBMINOR__} and \c{___NASM_PATCHLEVEL__} concatenated to +produce a single doubleword. Hence, for 0.98.32p1, the returned number +would be equivalent to: + +\c dd 0x00622001 + +or + +\c db 1,32,98,0 + +Note that the above lines are generate exactly the same code, the second +line is used just to give an indication of the order that the separate +values will be present in memory. + + +\S{stdmacverstr} \i\c{__NASM_VER__}: \i{NASM Version string} + +The single-line macro \c{__NASM_VER__} expands to a string which defines +the version number of nasm being used. So, under NASM 0.98.32 for example, + +\c db __NASM_VER__ + +would expand to + +\c db "0.98.32" + + +\S{fileline} \i\c{__FILE__} and \i\c{__LINE__}: File Name and Line Number + +Like the C preprocessor, NASM allows the user to find out the file +name and line number containing the current instruction. The macro +\c{__FILE__} expands to a string constant giving the name of the +current input file (which may change through the course of assembly +if \c{%include} directives are used), and \c{__LINE__} expands to a +numeric constant giving the current line number in the input file. + +These macros could be used, for example, to communicate debugging +information to a macro, since invoking \c{__LINE__} inside a macro +definition (either single-line or multi-line) will return the line +number of the macro \e{call}, rather than \e{definition}. So to +determine where in a piece of code a crash is occurring, for +example, one could write a routine \c{stillhere}, which is passed a +line number in \c{EAX} and outputs something like `line 155: still +here'. You could then write a macro + +\c %macro notdeadyet 0 +\c +\c push eax +\c mov eax,__LINE__ +\c call stillhere +\c pop eax +\c +\c %endmacro + +and then pepper your code with calls to \c{notdeadyet} until you +find the crash point. + + +\S{bitsm} \i\c{__BITS__}: Current BITS Mode + +The \c{__BITS__} standard macro is updated every time that the BITS mode is +set using the \c{BITS XX} or \c{[BITS XX]} directive, where XX is a valid mode +number of 16, 32 or 64. \c{__BITS__} receives the specified mode number and +makes it globally available. This can be very useful for those who utilize +mode-dependent macros. + +\S{ofmtm} \i\c{__OUTPUT_FORMAT__}: Current Output Format + +The \c{__OUTPUT_FORMAT__} standard macro holds the current Output Format, +as given by the \c{-f} option or NASM's default. Type \c{nasm -hf} for a +list. + +\c %ifidn __OUTPUT_FORMAT__, win32 +\c %define NEWLINE 13, 10 +\c %elifidn __OUTPUT_FORMAT__, elf32 +\c %define NEWLINE 10 +\c %endif + + +\S{datetime} Assembly Date and Time Macros + +NASM provides a variety of macros that represent the timestamp of the +assembly session. + +\b The \i\c{__DATE__} and \i\c{__TIME__} macros give the assembly date and +time as strings, in ISO 8601 format (\c{"YYYY-MM-DD"} and \c{"HH:MM:SS"}, +respectively.) + +\b The \i\c{__DATE_NUM__} and \i\c{__TIME_NUM__} macros give the assembly +date and time in numeric form; in the format \c{YYYYMMDD} and +\c{HHMMSS} respectively. + +\b The \i\c{__UTC_DATE__} and \i\c{__UTC_TIME__} macros give the assembly +date and time in universal time (UTC) as strings, in ISO 8601 format +(\c{"YYYY-MM-DD"} and \c{"HH:MM:SS"}, respectively.) If the host +platform doesn't provide UTC time, these macros are undefined. + +\b The \i\c{__UTC_DATE_NUM__} and \i\c{__UTC_TIME_NUM__} macros give the +assembly date and time universal time (UTC) in numeric form; in the +format \c{YYYYMMDD} and \c{HHMMSS} respectively. If the +host platform doesn't provide UTC time, these macros are +undefined. + +\b The \c{__POSIX_TIME__} macro is defined as a number containing the +number of seconds since the POSIX epoch, 1 January 1970 00:00:00 UTC; +excluding any leap seconds. This is computed using UTC time if +available on the host platform, otherwise it is computed using the +local time as if it was UTC. + +All instances of time and date macros in the same assembly session +produce consistent output. For example, in an assembly session +started at 42 seconds after midnight on January 1, 2010 in Moscow +(timezone UTC+3) these macros would have the following values, +assuming, of course, a properly configured environment with a correct +clock: + +\c __DATE__ "2010-01-01" +\c __TIME__ "00:00:42" +\c __DATE_NUM__ 20100101 +\c __TIME_NUM__ 000042 +\c __UTC_DATE__ "2009-12-31" +\c __UTC_TIME__ "21:00:42" +\c __UTC_DATE_NUM__ 20091231 +\c __UTC_TIME_NUM__ 210042 +\c __POSIX_TIME__ 1262293242 + + +\S{use_def} \I\c{__USE_*__}\c{__USE_}\e{package}\c{__}: Package +Include Test + +When a standard macro package (see \k{macropkg}) is included with the +\c{%use} directive (see \k{use}), a single-line macro of the form +\c{__USE_}\e{package}\c{__} is automatically defined. This allows +testing if a particular package is invoked or not. + +For example, if the \c{altreg} package is included (see +\k{pkg_altreg}), then the macro \c{__USE_ALTREG__} is defined. + + +\S{pass_macro} \i\c{__PASS__}: Assembly Pass + +The macro \c{__PASS__} is defined to be \c{1} on preparatory passes, +and \c{2} on the final pass. In preprocess-only mode, it is set to +\c{3}, and when running only to generate dependencies (due to the +\c{-M} or \c{-MG} option, see \k{opt-M}) it is set to \c{0}. + +\e{Avoid using this macro if at all possible. It is tremendously easy +to generate very strange errors by misusing it, and the semantics may +change in future versions of NASM.} + + +\S{struc} \i\c{STRUC} and \i\c{ENDSTRUC}: \i{Declaring Structure} Data Types + +The core of NASM contains no intrinsic means of defining data +structures; instead, the preprocessor is sufficiently powerful that +data structures can be implemented as a set of macros. The macros +\c{STRUC} and \c{ENDSTRUC} are used to define a structure data type. + +\c{STRUC} takes one or two parameters. The first parameter is the name +of the data type. The second, optional parameter is the base offset of +the structure. The name of the data type is defined as a symbol with +the value of the base offset, and the name of the data type with the +suffix \c{_size} appended to it is defined as an \c{EQU} giving the +size of the structure. Once \c{STRUC} has been issued, you are +defining the structure, and should define fields using the \c{RESB} +family of pseudo-instructions, and then invoke \c{ENDSTRUC} to finish +the definition. + +For example, to define a structure called \c{mytype} containing a +longword, a word, a byte and a string of bytes, you might code + +\c struc mytype +\c +\c mt_long: resd 1 +\c mt_word: resw 1 +\c mt_byte: resb 1 +\c mt_str: resb 32 +\c +\c endstruc + +The above code defines six symbols: \c{mt_long} as 0 (the offset +from the beginning of a \c{mytype} structure to the longword field), +\c{mt_word} as 4, \c{mt_byte} as 6, \c{mt_str} as 7, \c{mytype_size} +as 39, and \c{mytype} itself as zero. + +The reason why the structure type name is defined at zero by default +is a side effect of allowing structures to work with the local label +mechanism: if your structure members tend to have the same names in +more than one structure, you can define the above structure like this: + +\c struc mytype +\c +\c .long: resd 1 +\c .word: resw 1 +\c .byte: resb 1 +\c .str: resb 32 +\c +\c endstruc + +This defines the offsets to the structure fields as \c{mytype.long}, +\c{mytype.word}, \c{mytype.byte} and \c{mytype.str}. + +NASM, since it has no \e{intrinsic} structure support, does not +support any form of period notation to refer to the elements of a +structure once you have one (except the above local-label notation), +so code such as \c{mov ax,[mystruc.mt_word]} is not valid. +\c{mt_word} is a constant just like any other constant, so the +correct syntax is \c{mov ax,[mystruc+mt_word]} or \c{mov +ax,[mystruc+mytype.word]}. + +Sometimes you only have the address of the structure displaced by an +offset. For example, consider this standard stack frame setup: + +\c push ebp +\c mov ebp, esp +\c sub esp, 40 + +In this case, you could access an element by subtracting the offset: + +\c mov [ebp - 40 + mytype.word], ax + +However, if you do not want to repeat this offset, you can use -40 as +a base offset: + +\c struc mytype, -40 + +And access an element this way: + +\c mov [ebp + mytype.word], ax + + +\S{istruc} \i\c{ISTRUC}, \i\c{AT} and \i\c{IEND}: Declaring +\i{Instances of Structures} + +Having defined a structure type, the next thing you typically want +to do is to declare instances of that structure in your data +segment. NASM provides an easy way to do this in the \c{ISTRUC} +mechanism. To declare a structure of type \c{mytype} in a program, +you code something like this: + +\c mystruc: +\c istruc mytype +\c +\c at mt_long, dd 123456 +\c at mt_word, dw 1024 +\c at mt_byte, db 'x' +\c at mt_str, db 'hello, world', 13, 10, 0 +\c +\c iend + +The function of the \c{AT} macro is to make use of the \c{TIMES} +prefix to advance the assembly position to the correct point for the +specified structure field, and then to declare the specified data. +Therefore the structure fields must be declared in the same order as +they were specified in the structure definition. + +If the data to go in a structure field requires more than one source +line to specify, the remaining source lines can easily come after +the \c{AT} line. For example: + +\c at mt_str, db 123,134,145,156,167,178,189 +\c db 190,100,0 + +Depending on personal taste, you can also omit the code part of the +\c{AT} line completely, and start the structure field on the next +line: + +\c at mt_str +\c db 'hello, world' +\c db 13,10,0 + + +\S{align} \i\c{ALIGN} and \i\c{ALIGNB}: Data Alignment + +The \c{ALIGN} and \c{ALIGNB} macros provides a convenient way to +align code or data on a word, longword, paragraph or other boundary. +(Some assemblers call this directive \i\c{EVEN}.) The syntax of the +\c{ALIGN} and \c{ALIGNB} macros is + +\c align 4 ; align on 4-byte boundary +\c align 16 ; align on 16-byte boundary +\c align 8,db 0 ; pad with 0s rather than NOPs +\c align 4,resb 1 ; align to 4 in the BSS +\c alignb 4 ; equivalent to previous line + +Both macros require their first argument to be a power of two; they +both compute the number of additional bytes required to bring the +length of the current section up to a multiple of that power of two, +and then apply the \c{TIMES} prefix to their second argument to +perform the alignment. + +If the second argument is not specified, the default for \c{ALIGN} +is \c{NOP}, and the default for \c{ALIGNB} is \c{RESB 1}. So if the +second argument is specified, the two macros are equivalent. +Normally, you can just use \c{ALIGN} in code and data sections and +\c{ALIGNB} in BSS sections, and never need the second argument +except for special purposes. + +\c{ALIGN} and \c{ALIGNB}, being simple macros, perform no error +checking: they cannot warn you if their first argument fails to be a +power of two, or if their second argument generates more than one +byte of code. In each of these cases they will silently do the wrong +thing. + +\c{ALIGNB} (or \c{ALIGN} with a second argument of \c{RESB 1}) can +be used within structure definitions: + +\c struc mytype2 +\c +\c mt_byte: +\c resb 1 +\c alignb 2 +\c mt_word: +\c resw 1 +\c alignb 4 +\c mt_long: +\c resd 1 +\c mt_str: +\c resb 32 +\c +\c endstruc + +This will ensure that the structure members are sensibly aligned +relative to the base of the structure. + +A final caveat: \c{ALIGN} and \c{ALIGNB} work relative to the +beginning of the \e{section}, not the beginning of the address space +in the final executable. Aligning to a 16-byte boundary when the +section you're in is only guaranteed to be aligned to a 4-byte +boundary, for example, is a waste of effort. Again, NASM does not +check that the section's alignment characteristics are sensible for +the use of \c{ALIGN} or \c{ALIGNB}. + +See also the \c{smartalign} standard macro package, \k{pkg_smartalign}. + + +\C{macropkg} \i{Standard Macro Packages} + +The \i\c{%use} directive (see \k{use}) includes one of the standard +macro packages included with the NASM distribution and compiled into +the NASM binary. It operates like the \c{%include} directive (see +\k{include}), but the included contents is provided by NASM itself. + +The names of standard macro packages are case insensitive, and can be +quoted or not. + + +\H{pkg_altreg} \i\c{altreg}: \i{Alternate Register Names} + +The \c{altreg} standard macro package provides alternate register +names. It provides numeric register names for all registers (not just +\c{R8}-\c{R15}), the Intel-defined aliases \c{R8L}-\c{R15L} for the +low bytes of register (as opposed to the NASM/AMD standard names +\c{R8B}-\c{R15B}), and the names \c{R0H}-\c{R3H} (by analogy with +\c{R0L}-\c{R3L}) for \c{AH}, \c{CH}, \c{DH}, and \c{BH}. + +Example use: + +\c %use altreg +\c +\c proc: +\c mov r0l,r3h ; mov al,bh +\c ret + +See also \k{reg64}. + + +\H{pkg_smartalign} \i\c{smartalign}\I{align, smart}: Smart \c{ALIGN} Macro + +The \c{smartalign} standard macro package provides for an \i\c{ALIGN} +macro which is more powerful than the default (and +backwards-compatible) one (see \k{align}). When the \c{smartalign} +package is enabled, when \c{ALIGN} is used without a second argument, +NASM will generate a sequence of instructions more efficient than a +series of \c{NOP}. Furthermore, if the padding exceeds a specific +threshold, then NASM will generate a jump over the entire padding +sequence. + +The specific instructions generated can be controlled with the +new \i\c{ALIGNMODE} macro. This macro takes two parameters: one mode, +and an optional jump threshold override. The modes are as +follows: + +\b \c{generic}: Works on all x86 CPUs and should have reasonable +performance. The default jump threshold is 8. This is the +default. + +\b \c{nop}: Pad out with \c{NOP} instructions. The only difference +compared to the standard \c{ALIGN} macro is that NASM can still jump +over a large padding area. The default jump threshold is 16. + +\b \c{k7}: Optimize for the AMD K7 (Athlon/Althon XP). These +instructions should still work on all x86 CPUs. The default jump +threshold is 16. + +\b \c{k8}: Optimize for the AMD K8 (Opteron/Althon 64). These +instructions should still work on all x86 CPUs. The default jump +threshold is 16. + +\b \c{p6}: Optimize for Intel CPUs. This uses the long \c{NOP} +instructions first introduced in Pentium Pro. This is incompatible +with all CPUs of family 5 or lower, as well as some VIA CPUs and +several virtualization solutions. The default jump threshold is 16. + +The macro \i\c{__ALIGNMODE__} is defined to contain the current +alignment mode. A number of other macros beginning with \c{__ALIGN_} +are used internally by this macro package. + + +\C{directive} \i{Assembler Directives} + +NASM, though it attempts to avoid the bureaucracy of assemblers like +MASM and TASM, is nevertheless forced to support a \e{few} +directives. These are described in this chapter. + +NASM's directives come in two types: \I{user-level +directives}\e{user-level} directives and \I{primitive +directives}\e{primitive} directives. Typically, each directive has a +user-level form and a primitive form. In almost all cases, we +recommend that users use the user-level forms of the directives, +which are implemented as macros which call the primitive forms. + +Primitive directives are enclosed in square brackets; user-level +directives are not. + +In addition to the universal directives described in this chapter, +each object file format can optionally supply extra directives in +order to control particular features of that file format. These +\I{format-specific directives}\e{format-specific} directives are +documented along with the formats that implement them, in \k{outfmt}. + + +\H{bits} \i\c{BITS}: Specifying Target \i{Processor Mode} + +The \c{BITS} directive specifies whether NASM should generate code +\I{16-bit mode, versus 32-bit mode}designed to run on a processor +operating in 16-bit mode, 32-bit mode or 64-bit mode. The syntax is +\c{BITS XX}, where XX is 16, 32 or 64. + +In most cases, you should not need to use \c{BITS} explicitly. The +\c{aout}, \c{coff}, \c{elf}, \c{macho}, \c{win32} and \c{win64} +object formats, which are designed for use in 32-bit or 64-bit +operating systems, all cause NASM to select 32-bit or 64-bit mode, +respectively, by default. The \c{obj} object format allows you +to specify each segment you define as either \c{USE16} or \c{USE32}, +and NASM will set its operating mode accordingly, so the use of the +\c{BITS} directive is once again unnecessary. + +The most likely reason for using the \c{BITS} directive is to write +32-bit or 64-bit code in a flat binary file; this is because the \c{bin} +output format defaults to 16-bit mode in anticipation of it being +used most frequently to write DOS \c{.COM} programs, DOS \c{.SYS} +device drivers and boot loader software. + +You do \e{not} need to specify \c{BITS 32} merely in order to use +32-bit instructions in a 16-bit DOS program; if you do, the +assembler will generate incorrect code because it will be writing +code targeted at a 32-bit platform, to be run on a 16-bit one. + +When NASM is in \c{BITS 16} mode, instructions which use 32-bit +data are prefixed with an 0x66 byte, and those referring to 32-bit +addresses have an 0x67 prefix. In \c{BITS 32} mode, the reverse is +true: 32-bit instructions require no prefixes, whereas instructions +using 16-bit data need an 0x66 and those working on 16-bit addresses +need an 0x67. + +When NASM is in \c{BITS 64} mode, most instructions operate the same +as they do for \c{BITS 32} mode. However, there are 8 more general and +SSE registers, and 16-bit addressing is no longer supported. + +The default address size is 64 bits; 32-bit addressing can be selected +with the 0x67 prefix. The default operand size is still 32 bits, +however, and the 0x66 prefix selects 16-bit operand size. The \c{REX} +prefix is used both to select 64-bit operand size, and to access the +new registers. NASM automatically inserts REX prefixes when +necessary. + +When the \c{REX} prefix is used, the processor does not know how to +address the AH, BH, CH or DH (high 8-bit legacy) registers. Instead, +it is possible to access the the low 8-bits of the SP, BP SI and DI +registers as SPL, BPL, SIL and DIL, respectively; but only when the +REX prefix is used. + +The \c{BITS} directive has an exactly equivalent primitive form, +\c{[BITS 16]}, \c{[BITS 32]} and \c{[BITS 64]}. The user-level form is +a macro which has no function other than to call the primitive form. + +Note that the space is neccessary, e.g. \c{BITS32} will \e{not} work! + +\S{USE16 & USE32} \i\c{USE16} & \i\c{USE32}: Aliases for BITS + +The `\c{USE16}' and `\c{USE32}' directives can be used in place of +`\c{BITS 16}' and `\c{BITS 32}', for compatibility with other assemblers. + + +\H{default} \i\c{DEFAULT}: Change the assembler defaults + +The \c{DEFAULT} directive changes the assembler defaults. Normally, +NASM defaults to a mode where the programmer is expected to explicitly +specify most features directly. However, this is occationally +obnoxious, as the explicit form is pretty much the only one one wishes +to use. + +Currently, the only \c{DEFAULT} that is settable is whether or not +registerless instructions in 64-bit mode are \c{RIP}-relative or not. +By default, they are absolute unless overridden with the \i\c{REL} +specifier (see \k{effaddr}). However, if \c{DEFAULT REL} is +specified, \c{REL} is default, unless overridden with the \c{ABS} +specifier, \e{except when used with an FS or GS segment override}. + +The special handling of \c{FS} and \c{GS} overrides are due to the +fact that these registers are generally used as thread pointers or +other special functions in 64-bit mode, and generating +\c{RIP}-relative addresses would be extremely confusing. + +\c{DEFAULT REL} is disabled with \c{DEFAULT ABS}. + +\H{section} \i\c{SECTION} or \i\c{SEGMENT}: Changing and \i{Defining +Sections} + +\I{changing sections}\I{switching between sections}The \c{SECTION} +directive (\c{SEGMENT} is an exactly equivalent synonym) changes +which section of the output file the code you write will be +assembled into. In some object file formats, the number and names of +sections are fixed; in others, the user may make up as many as they +wish. Hence \c{SECTION} may sometimes give an error message, or may +define a new section, if you try to switch to a section that does +not (yet) exist. + +The Unix object formats, and the \c{bin} object format (but see +\k{multisec}, all support +the \i{standardized section names} \c{.text}, \c{.data} and \c{.bss} +for the code, data and uninitialized-data sections. The \c{obj} +format, by contrast, does not recognize these section names as being +special, and indeed will strip off the leading period of any section +name that has one. + + +\S{sectmac} The \i\c{__SECT__} Macro + +The \c{SECTION} directive is unusual in that its user-level form +functions differently from its primitive form. The primitive form, +\c{[SECTION xyz]}, simply switches the current target section to the +one given. The user-level form, \c{SECTION xyz}, however, first +defines the single-line macro \c{__SECT__} to be the primitive +\c{[SECTION]} directive which it is about to issue, and then issues +it. So the user-level directive + +\c SECTION .text + +expands to the two lines + +\c %define __SECT__ [SECTION .text] +\c [SECTION .text] + +Users may find it useful to make use of this in their own macros. +For example, the \c{writefile} macro defined in \k{mlmacgre} can be +usefully rewritten in the following more sophisticated form: + +\c %macro writefile 2+ +\c +\c [section .data] +\c +\c %%str: db %2 +\c %%endstr: +\c +\c __SECT__ +\c +\c mov dx,%%str +\c mov cx,%%endstr-%%str +\c mov bx,%1 +\c mov ah,0x40 +\c int 0x21 +\c +\c %endmacro + +This form of the macro, once passed a string to output, first +switches temporarily to the data section of the file, using the +primitive form of the \c{SECTION} directive so as not to modify +\c{__SECT__}. It then declares its string in the data section, and +then invokes \c{__SECT__} to switch back to \e{whichever} section +the user was previously working in. It thus avoids the need, in the +previous version of the macro, to include a \c{JMP} instruction to +jump over the data, and also does not fail if, in a complicated +\c{OBJ} format module, the user could potentially be assembling the +code in any of several separate code sections. + + +\H{absolute} \i\c{ABSOLUTE}: Defining Absolute Labels + +The \c{ABSOLUTE} directive can be thought of as an alternative form +of \c{SECTION}: it causes the subsequent code to be directed at no +physical section, but at the hypothetical section starting at the +given absolute address. The only instructions you can use in this +mode are the \c{RESB} family. + +\c{ABSOLUTE} is used as follows: + +\c absolute 0x1A +\c +\c kbuf_chr resw 1 +\c kbuf_free resw 1 +\c kbuf resw 16 + +This example describes a section of the PC BIOS data area, at +segment address 0x40: the above code defines \c{kbuf_chr} to be +0x1A, \c{kbuf_free} to be 0x1C, and \c{kbuf} to be 0x1E. + +The user-level form of \c{ABSOLUTE}, like that of \c{SECTION}, +redefines the \i\c{__SECT__} macro when it is invoked. + +\i\c{STRUC} and \i\c{ENDSTRUC} are defined as macros which use +\c{ABSOLUTE} (and also \c{__SECT__}). + +\c{ABSOLUTE} doesn't have to take an absolute constant as an +argument: it can take an expression (actually, a \i{critical +expression}: see \k{crit}) and it can be a value in a segment. For +example, a TSR can re-use its setup code as run-time BSS like this: + +\c org 100h ; it's a .COM program +\c +\c jmp setup ; setup code comes last +\c +\c ; the resident part of the TSR goes here +\c setup: +\c ; now write the code that installs the TSR here +\c +\c absolute setup +\c +\c runtimevar1 resw 1 +\c runtimevar2 resd 20 +\c +\c tsr_end: + +This defines some variables `on top of' the setup code, so that +after the setup has finished running, the space it took up can be +re-used as data storage for the running TSR. The symbol `tsr_end' +can be used to calculate the total size of the part of the TSR that +needs to be made resident. + + +\H{extern} \i\c{EXTERN}: \i{Importing Symbols} from Other Modules + +\c{EXTERN} is similar to the MASM directive \c{EXTRN} and the C +keyword \c{extern}: it is used to declare a symbol which is not +defined anywhere in the module being assembled, but is assumed to be +defined in some other module and needs to be referred to by this +one. Not every object-file format can support external variables: +the \c{bin} format cannot. + +The \c{EXTERN} directive takes as many arguments as you like. Each +argument is the name of a symbol: + +\c extern _printf +\c extern _sscanf,_fscanf + +Some object-file formats provide extra features to the \c{EXTERN} +directive. In all cases, the extra features are used by suffixing a +colon to the symbol name followed by object-format specific text. +For example, the \c{obj} format allows you to declare that the +default segment base of an external should be the group \c{dgroup} +by means of the directive + +\c extern _variable:wrt dgroup + +The primitive form of \c{EXTERN} differs from the user-level form +only in that it can take only one argument at a time: the support +for multiple arguments is implemented at the preprocessor level. + +You can declare the same variable as \c{EXTERN} more than once: NASM +will quietly ignore the second and later redeclarations. You can't +declare a variable as \c{EXTERN} as well as something else, though. + + +\H{global} \i\c{GLOBAL}: \i{Exporting Symbols} to Other Modules + +\c{GLOBAL} is the other end of \c{EXTERN}: if one module declares a +symbol as \c{EXTERN} and refers to it, then in order to prevent +linker errors, some other module must actually \e{define} the +symbol and declare it as \c{GLOBAL}. Some assemblers use the name +\i\c{PUBLIC} for this purpose. + +The \c{GLOBAL} directive applying to a symbol must appear \e{before} +the definition of the symbol. + +\c{GLOBAL} uses the same syntax as \c{EXTERN}, except that it must +refer to symbols which \e{are} defined in the same module as the +\c{GLOBAL} directive. For example: + +\c global _main +\c _main: +\c ; some code + +\c{GLOBAL}, like \c{EXTERN}, allows object formats to define private +extensions by means of a colon. The \c{elf} object format, for +example, lets you specify whether global data items are functions or +data: + +\c global hashlookup:function, hashtable:data + +Like \c{EXTERN}, the primitive form of \c{GLOBAL} differs from the +user-level form only in that it can take only one argument at a +time. + + +\H{common} \i\c{COMMON}: Defining Common Data Areas + +The \c{COMMON} directive is used to declare \i\e{common variables}. +A common variable is much like a global variable declared in the +uninitialized data section, so that + +\c common intvar 4 + +is similar in function to + +\c global intvar +\c section .bss +\c +\c intvar resd 1 + +The difference is that if more than one module defines the same +common variable, then at link time those variables will be +\e{merged}, and references to \c{intvar} in all modules will point +at the same piece of memory. + +Like \c{GLOBAL} and \c{EXTERN}, \c{COMMON} supports object-format +specific extensions. For example, the \c{obj} format allows common +variables to be NEAR or FAR, and the \c{elf} format allows you to +specify the alignment requirements of a common variable: + +\c common commvar 4:near ; works in OBJ +\c common intarray 100:4 ; works in ELF: 4 byte aligned + +Once again, like \c{EXTERN} and \c{GLOBAL}, the primitive form of +\c{COMMON} differs from the user-level form only in that it can take +only one argument at a time. + + +\H{CPU} \i\c{CPU}: Defining CPU Dependencies + +The \i\c{CPU} directive restricts assembly to those instructions which +are available on the specified CPU. + +Options are: + +\b\c{CPU 8086} Assemble only 8086 instruction set + +\b\c{CPU 186} Assemble instructions up to the 80186 instruction set + +\b\c{CPU 286} Assemble instructions up to the 286 instruction set + +\b\c{CPU 386} Assemble instructions up to the 386 instruction set + +\b\c{CPU 486} 486 instruction set + +\b\c{CPU 586} Pentium instruction set + +\b\c{CPU PENTIUM} Same as 586 + +\b\c{CPU 686} P6 instruction set + +\b\c{CPU PPRO} Same as 686 + +\b\c{CPU P2} Same as 686 + +\b\c{CPU P3} Pentium III (Katmai) instruction sets + +\b\c{CPU KATMAI} Same as P3 + +\b\c{CPU P4} Pentium 4 (Willamette) instruction set + +\b\c{CPU WILLAMETTE} Same as P4 + +\b\c{CPU PRESCOTT} Prescott instruction set + +\b\c{CPU X64} x86-64 (x64/AMD64/Intel 64) instruction set + +\b\c{CPU IA64} IA64 CPU (in x86 mode) instruction set + +All options are case insensitive. All instructions will be selected +only if they apply to the selected CPU or lower. By default, all +instructions are available. + + +\H{FLOAT} \i\c{FLOAT}: Handling of \I{floating-point, constants}floating-point constants + +By default, floating-point constants are rounded to nearest, and IEEE +denormals are supported. The following options can be set to alter +this behaviour: + +\b\c{FLOAT DAZ} Flush denormals to zero + +\b\c{FLOAT NODAZ} Do not flush denormals to zero (default) + +\b\c{FLOAT NEAR} Round to nearest (default) + +\b\c{FLOAT UP} Round up (toward +Infinity) + +\b\c{FLOAT DOWN} Round down (toward -Infinity) + +\b\c{FLOAT ZERO} Round toward zero + +\b\c{FLOAT DEFAULT} Restore default settings + +The standard macros \i\c{__FLOAT_DAZ__}, \i\c{__FLOAT_ROUND__}, and +\i\c{__FLOAT__} contain the current state, as long as the programmer +has avoided the use of the brackeded primitive form, (\c{[FLOAT]}). + +\c{__FLOAT__} contains the full set of floating-point settings; this +value can be saved away and invoked later to restore the setting. + + +\C{outfmt} \i{Output Formats} + +NASM is a portable assembler, designed to be able to compile on any +ANSI C-supporting platform and produce output to run on a variety of +Intel x86 operating systems. For this reason, it has a large number +of available output formats, selected using the \i\c{-f} option on +the NASM \i{command line}. Each of these formats, along with its +extensions to the base NASM syntax, is detailed in this chapter. + +As stated in \k{opt-o}, NASM chooses a \i{default name} for your +output file based on the input file name and the chosen output +format. This will be generated by removing the \i{extension} +(\c{.asm}, \c{.s}, or whatever you like to use) from the input file +name, and substituting an extension defined by the output format. +The extensions are given with each format below. + + +\H{binfmt} \i\c{bin}: \i{Flat-Form Binary}\I{pure binary} Output + +The \c{bin} format does not produce object files: it generates +nothing in the output file except the code you wrote. Such `pure +binary' files are used by \i{MS-DOS}: \i\c{.COM} executables and +\i\c{.SYS} device drivers are pure binary files. Pure binary output +is also useful for \i{operating system} and \i{boot loader} +development. + +The \c{bin} format supports \i{multiple section names}. For details of +how NASM handles sections in the \c{bin} format, see \k{multisec}. + +Using the \c{bin} format puts NASM by default into 16-bit mode (see +\k{bits}). In order to use \c{bin} to write 32-bit or 64-bit code, +such as an OS kernel, you need to explicitly issue the \I\c{BITS}\c{BITS 32} +or \I\c{BITS}\c{BITS 64} directive. + +\c{bin} has no default output file name extension: instead, it +leaves your file name as it is once the original extension has been +removed. Thus, the default is for NASM to assemble \c{binprog.asm} +into a binary file called \c{binprog}. + + +\S{org} \i\c{ORG}: Binary File \i{Program Origin} + +The \c{bin} format provides an additional directive to the list +given in \k{directive}: \c{ORG}. The function of the \c{ORG} +directive is to specify the origin address which NASM will assume +the program begins at when it is loaded into memory. + +For example, the following code will generate the longword +\c{0x00000104}: + +\c org 0x100 +\c dd label +\c label: + +Unlike the \c{ORG} directive provided by MASM-compatible assemblers, +which allows you to jump around in the object file and overwrite +code you have already generated, NASM's \c{ORG} does exactly what +the directive says: \e{origin}. Its sole function is to specify one +offset which is added to all internal address references within the +section; it does not permit any of the trickery that MASM's version +does. See \k{proborg} for further comments. + + +\S{binseg} \c{bin} Extensions to the \c{SECTION} +Directive\I{SECTION, bin extensions to} + +The \c{bin} output format extends the \c{SECTION} (or \c{SEGMENT}) +directive to allow you to specify the alignment requirements of +segments. This is done by appending the \i\c{ALIGN} qualifier to the +end of the section-definition line. For example, + +\c section .data align=16 + +switches to the section \c{.data} and also specifies that it must be +aligned on a 16-byte boundary. + +The parameter to \c{ALIGN} specifies how many low bits of the +section start address must be forced to zero. The alignment value +given may be any power of two.\I{section alignment, in +bin}\I{segment alignment, in bin}\I{alignment, in bin sections} + + +\S{multisec} \i{Multisection}\I{bin, multisection} Support for the \c{bin} Format + +The \c{bin} format allows the use of multiple sections, of arbitrary names, +besides the "known" \c{.text}, \c{.data}, and \c{.bss} names. + +\b Sections may be designated \i\c{progbits} or \i\c{nobits}. Default +is \c{progbits} (except \c{.bss}, which defaults to \c{nobits}, +of course). + +\b Sections can be aligned at a specified boundary following the previous +section with \c{align=}, or at an arbitrary byte-granular position with +\i\c{start=}. + +\b Sections can be given a virtual start address, which will be used +for the calculation of all memory references within that section +with \i\c{vstart=}. + +\b Sections can be ordered using \i\c{follows=}\c{<section>} or +\i\c{vfollows=}\c{<section>} as an alternative to specifying an explicit +start address. + +\b Arguments to \c{org}, \c{start}, \c{vstart}, and \c{align=} are +critical expressions. See \k{crit}. E.g. \c{align=(1 << ALIGN_SHIFT)} +- \c{ALIGN_SHIFT} must be defined before it is used here. + +\b Any code which comes before an explicit \c{SECTION} directive +is directed by default into the \c{.text} section. + +\b If an \c{ORG} statement is not given, \c{ORG 0} is used +by default. + +\b The \c{.bss} section will be placed after the last \c{progbits} +section, unless \c{start=}, \c{vstart=}, \c{follows=}, or \c{vfollows=} +has been specified. + +\b All sections are aligned on dword boundaries, unless a different +alignment has been specified. + +\b Sections may not overlap. + +\b NASM creates the \c{section.<secname>.start} for each section, +which may be used in your code. + +\S{map}\i{Map Files} + +Map files can be generated in \c{-f bin} format by means of the \c{[map]} +option. Map types of \c{all} (default), \c{brief}, \c{sections}, \c{segments}, +or \c{symbols} may be specified. Output may be directed to \c{stdout} +(default), \c{stderr}, or a specified file. E.g. +\c{[map symbols myfile.map]}. No "user form" exists, the square +brackets must be used. + + +\H{ithfmt} \i\c{ith}: \i{Intel Hex} Output + +The \c{ith} file format produces Intel hex-format files. Just as the +\c{bin} format, this is a flat memory image format with no support for +relocation or linking. It is usually used with ROM programmers and +similar utilities. + +All extensions supported by the \c{bin} file format is also supported by +the \c{ith} file format. + +\c{ith} provides a default output file-name extension of \c{.ith}. + + +\H{srecfmt} \i\c{srec}: \i{Motorola S-Records} Output + +The \c{srec} file format produces Motorola S-records files. Just as the +\c{bin} format, this is a flat memory image format with no support for +relocation or linking. It is usually used with ROM programmers and +similar utilities. + +All extensions supported by the \c{bin} file format is also supported by +the \c{srec} file format. + +\c{srec} provides a default output file-name extension of \c{.srec}. + + +\H{objfmt} \i\c{obj}: \i{Microsoft OMF}\I{OMF} Object Files + +The \c{obj} file format (NASM calls it \c{obj} rather than \c{omf} +for historical reasons) is the one produced by \i{MASM} and +\i{TASM}, which is typically fed to 16-bit DOS linkers to produce +\i\c{.EXE} files. It is also the format used by \i{OS/2}. + +\c{obj} provides a default output file-name extension of \c{.obj}. + +\c{obj} is not exclusively a 16-bit format, though: NASM has full +support for the 32-bit extensions to the format. In particular, +32-bit \c{obj} format files are used by \i{Borland's Win32 +compilers}, instead of using Microsoft's newer \i\c{win32} object +file format. + +The \c{obj} format does not define any special segment names: you +can call your segments anything you like. Typical names for segments +in \c{obj} format files are \c{CODE}, \c{DATA} and \c{BSS}. + +If your source file contains code before specifying an explicit +\c{SEGMENT} directive, then NASM will invent its own segment called +\i\c{__NASMDEFSEG} for you. + +When you define a segment in an \c{obj} file, NASM defines the +segment name as a symbol as well, so that you can access the segment +address of the segment. So, for example: + +\c segment data +\c +\c dvar: dw 1234 +\c +\c segment code +\c +\c function: +\c mov ax,data ; get segment address of data +\c mov ds,ax ; and move it into DS +\c inc word [dvar] ; now this reference will work +\c ret + +The \c{obj} format also enables the use of the \i\c{SEG} and +\i\c{WRT} operators, so that you can write code which does things +like + +\c extern foo +\c +\c mov ax,seg foo ; get preferred segment of foo +\c mov ds,ax +\c mov ax,data ; a different segment +\c mov es,ax +\c mov ax,[ds:foo] ; this accesses `foo' +\c mov [es:foo wrt data],bx ; so does this + + +\S{objseg} \c{obj} Extensions to the \c{SEGMENT} +Directive\I{SEGMENT, obj extensions to} + +The \c{obj} output format extends the \c{SEGMENT} (or \c{SECTION}) +directive to allow you to specify various properties of the segment +you are defining. This is done by appending extra qualifiers to the +end of the segment-definition line. For example, + +\c segment code private align=16 + +defines the segment \c{code}, but also declares it to be a private +segment, and requires that the portion of it described in this code +module must be aligned on a 16-byte boundary. + +The available qualifiers are: + +\b \i\c{PRIVATE}, \i\c{PUBLIC}, \i\c{COMMON} and \i\c{STACK} specify +the combination characteristics of the segment. \c{PRIVATE} segments +do not get combined with any others by the linker; \c{PUBLIC} and +\c{STACK} segments get concatenated together at link time; and +\c{COMMON} segments all get overlaid on top of each other rather +than stuck end-to-end. + +\b \i\c{ALIGN} is used, as shown above, to specify how many low bits +of the segment start address must be forced to zero. The alignment +value given may be any power of two from 1 to 4096; in reality, the +only values supported are 1, 2, 4, 16, 256 and 4096, so if 8 is +specified it will be rounded up to 16, and 32, 64 and 128 will all +be rounded up to 256, and so on. Note that alignment to 4096-byte +boundaries is a \i{PharLap} extension to the format and may not be +supported by all linkers.\I{section alignment, in OBJ}\I{segment +alignment, in OBJ}\I{alignment, in OBJ sections} + +\b \i\c{CLASS} can be used to specify the segment class; this feature +indicates to the linker that segments of the same class should be +placed near each other in the output file. The class name can be any +word, e.g. \c{CLASS=CODE}. + +\b \i\c{OVERLAY}, like \c{CLASS}, is specified with an arbitrary word +as an argument, and provides overlay information to an +overlay-capable linker. + +\b Segments can be declared as \i\c{USE16} or \i\c{USE32}, which has +the effect of recording the choice in the object file and also +ensuring that NASM's default assembly mode when assembling in that +segment is 16-bit or 32-bit respectively. + +\b When writing \i{OS/2} object files, you should declare 32-bit +segments as \i\c{FLAT}, which causes the default segment base for +anything in the segment to be the special group \c{FLAT}, and also +defines the group if it is not already defined. + +\b The \c{obj} file format also allows segments to be declared as +having a pre-defined absolute segment address, although no linkers +are currently known to make sensible use of this feature; +nevertheless, NASM allows you to declare a segment such as +\c{SEGMENT SCREEN ABSOLUTE=0xB800} if you need to. The \i\c{ABSOLUTE} +and \c{ALIGN} keywords are mutually exclusive. + +NASM's default segment attributes are \c{PUBLIC}, \c{ALIGN=1}, no +class, no overlay, and \c{USE16}. + + +\S{group} \i\c{GROUP}: Defining Groups of Segments\I{segments, groups of} + +The \c{obj} format also allows segments to be grouped, so that a +single segment register can be used to refer to all the segments in +a group. NASM therefore supplies the \c{GROUP} directive, whereby +you can code + +\c segment data +\c +\c ; some data +\c +\c segment bss +\c +\c ; some uninitialized data +\c +\c group dgroup data bss + +which will define a group called \c{dgroup} to contain the segments +\c{data} and \c{bss}. Like \c{SEGMENT}, \c{GROUP} causes the group +name to be defined as a symbol, so that you can refer to a variable +\c{var} in the \c{data} segment as \c{var wrt data} or as \c{var wrt +dgroup}, depending on which segment value is currently in your +segment register. + +If you just refer to \c{var}, however, and \c{var} is declared in a +segment which is part of a group, then NASM will default to giving +you the offset of \c{var} from the beginning of the \e{group}, not +the \e{segment}. Therefore \c{SEG var}, also, will return the group +base rather than the segment base. + +NASM will allow a segment to be part of more than one group, but +will generate a warning if you do this. Variables declared in a +segment which is part of more than one group will default to being +relative to the first group that was defined to contain the segment. + +A group does not have to contain any segments; you can still make +\c{WRT} references to a group which does not contain the variable +you are referring to. OS/2, for example, defines the special group +\c{FLAT} with no segments in it. + + +\S{uppercase} \i\c{UPPERCASE}: Disabling Case Sensitivity in Output + +Although NASM itself is \i{case sensitive}, some OMF linkers are +not; therefore it can be useful for NASM to output single-case +object files. The \c{UPPERCASE} format-specific directive causes all +segment, group and symbol names that are written to the object file +to be forced to upper case just before being written. Within a +source file, NASM is still case-sensitive; but the object file can +be written entirely in upper case if desired. + +\c{UPPERCASE} is used alone on a line; it requires no parameters. + + +\S{import} \i\c{IMPORT}: Importing DLL Symbols\I{DLL symbols, +importing}\I{symbols, importing from DLLs} + +The \c{IMPORT} format-specific directive defines a symbol to be +imported from a DLL, for use if you are writing a DLL's \i{import +library} in NASM. You still need to declare the symbol as \c{EXTERN} +as well as using the \c{IMPORT} directive. + +The \c{IMPORT} directive takes two required parameters, separated by +white space, which are (respectively) the name of the symbol you +wish to import and the name of the library you wish to import it +from. For example: + +\c import WSAStartup wsock32.dll + +A third optional parameter gives the name by which the symbol is +known in the library you are importing it from, in case this is not +the same as the name you wish the symbol to be known by to your code +once you have imported it. For example: + +\c import asyncsel wsock32.dll WSAAsyncSelect + + +\S{export} \i\c{EXPORT}: Exporting DLL Symbols\I{DLL symbols, +exporting}\I{symbols, exporting from DLLs} + +The \c{EXPORT} format-specific directive defines a global symbol to +be exported as a DLL symbol, for use if you are writing a DLL in +NASM. You still need to declare the symbol as \c{GLOBAL} as well as +using the \c{EXPORT} directive. + +\c{EXPORT} takes one required parameter, which is the name of the +symbol you wish to export, as it was defined in your source file. An +optional second parameter (separated by white space from the first) +gives the \e{external} name of the symbol: the name by which you +wish the symbol to be known to programs using the DLL. If this name +is the same as the internal name, you may leave the second parameter +off. + +Further parameters can be given to define attributes of the exported +symbol. These parameters, like the second, are separated by white +space. If further parameters are given, the external name must also +be specified, even if it is the same as the internal name. The +available attributes are: + +\b \c{resident} indicates that the exported name is to be kept +resident by the system loader. This is an optimisation for +frequently used symbols imported by name. + +\b \c{nodata} indicates that the exported symbol is a function which +does not make use of any initialized data. + +\b \c{parm=NNN}, where \c{NNN} is an integer, sets the number of +parameter words for the case in which the symbol is a call gate +between 32-bit and 16-bit segments. + +\b An attribute which is just a number indicates that the symbol +should be exported with an identifying number (ordinal), and gives +the desired number. + +For example: + +\c export myfunc +\c export myfunc TheRealMoreFormalLookingFunctionName +\c export myfunc myfunc 1234 ; export by ordinal +\c export myfunc myfunc resident parm=23 nodata + + +\S{dotdotstart} \i\c{..start}: Defining the \i{Program Entry +Point} + +\c{OMF} linkers require exactly one of the object files being linked to +define the program entry point, where execution will begin when the +program is run. If the object file that defines the entry point is +assembled using NASM, you specify the entry point by declaring the +special symbol \c{..start} at the point where you wish execution to +begin. + + +\S{objextern} \c{obj} Extensions to the \c{EXTERN} +Directive\I{EXTERN, obj extensions to} + +If you declare an external symbol with the directive + +\c extern foo + +then references such as \c{mov ax,foo} will give you the offset of +\c{foo} from its preferred segment base (as specified in whichever +module \c{foo} is actually defined in). So to access the contents of +\c{foo} you will usually need to do something like + +\c mov ax,seg foo ; get preferred segment base +\c mov es,ax ; move it into ES +\c mov ax,[es:foo] ; and use offset `foo' from it + +This is a little unwieldy, particularly if you know that an external +is going to be accessible from a given segment or group, say +\c{dgroup}. So if \c{DS} already contained \c{dgroup}, you could +simply code + +\c mov ax,[foo wrt dgroup] + +However, having to type this every time you want to access \c{foo} +can be a pain; so NASM allows you to declare \c{foo} in the +alternative form + +\c extern foo:wrt dgroup + +This form causes NASM to pretend that the preferred segment base of +\c{foo} is in fact \c{dgroup}; so the expression \c{seg foo} will +now return \c{dgroup}, and the expression \c{foo} is equivalent to +\c{foo wrt dgroup}. + +This \I{default-WRT mechanism}default-\c{WRT} mechanism can be used +to make externals appear to be relative to any group or segment in +your program. It can also be applied to common variables: see +\k{objcommon}. + + +\S{objcommon} \c{obj} Extensions to the \c{COMMON} +Directive\I{COMMON, obj extensions to} + +The \c{obj} format allows common variables to be either near\I{near +common variables} or far\I{far common variables}; NASM allows you to +specify which your variables should be by the use of the syntax + +\c common nearvar 2:near ; `nearvar' is a near common +\c common farvar 10:far ; and `farvar' is far + +Far common variables may be greater in size than 64Kb, and so the +OMF specification says that they are declared as a number of +\e{elements} of a given size. So a 10-byte far common variable could +be declared as ten one-byte elements, five two-byte elements, two +five-byte elements or one ten-byte element. + +Some \c{OMF} linkers require the \I{element size, in common +variables}\I{common variables, element size}element size, as well as +the variable size, to match when resolving common variables declared +in more than one module. Therefore NASM must allow you to specify +the element size on your far common variables. This is done by the +following syntax: + +\c common c_5by2 10:far 5 ; two five-byte elements +\c common c_2by5 10:far 2 ; five two-byte elements + +If no element size is specified, the default is 1. Also, the \c{FAR} +keyword is not required when an element size is specified, since +only far commons may have element sizes at all. So the above +declarations could equivalently be + +\c common c_5by2 10:5 ; two five-byte elements +\c common c_2by5 10:2 ; five two-byte elements + +In addition to these extensions, the \c{COMMON} directive in \c{obj} +also supports default-\c{WRT} specification like \c{EXTERN} does +(explained in \k{objextern}). So you can also declare things like + +\c common foo 10:wrt dgroup +\c common bar 16:far 2:wrt data +\c common baz 24:wrt data:6 + + +\H{win32fmt} \i\c{win32}: Microsoft Win32 Object Files + +The \c{win32} output format generates Microsoft Win32 object files, +suitable for passing to Microsoft linkers such as \i{Visual C++}. +Note that Borland Win32 compilers do not use this format, but use +\c{obj} instead (see \k{objfmt}). + +\c{win32} provides a default output file-name extension of \c{.obj}. + +Note that although Microsoft say that Win32 object files follow the +\c{COFF} (Common Object File Format) standard, the object files produced +by Microsoft Win32 compilers are not compatible with COFF linkers +such as DJGPP's, and vice versa. This is due to a difference of +opinion over the precise semantics of PC-relative relocations. To +produce COFF files suitable for DJGPP, use NASM's \c{coff} output +format; conversely, the \c{coff} format does not produce object +files that Win32 linkers can generate correct output from. + + +\S{win32sect} \c{win32} Extensions to the \c{SECTION} +Directive\I{SECTION, win32 extensions to} + +Like the \c{obj} format, \c{win32} allows you to specify additional +information on the \c{SECTION} directive line, to control the type +and properties of sections you declare. Section types and properties +are generated automatically by NASM for the \i{standard section names} +\c{.text}, \c{.data} and \c{.bss}, but may still be overridden by +these qualifiers. + +The available qualifiers are: + +\b \c{code}, or equivalently \c{text}, defines the section to be a +code section. This marks the section as readable and executable, but +not writable, and also indicates to the linker that the type of the +section is code. + +\b \c{data} and \c{bss} define the section to be a data section, +analogously to \c{code}. Data sections are marked as readable and +writable, but not executable. \c{data} declares an initialized data +section, whereas \c{bss} declares an uninitialized data section. + +\b \c{rdata} declares an initialized data section that is readable +but not writable. Microsoft compilers use this section to place +constants in it. + +\b \c{info} defines the section to be an \i{informational section}, +which is not included in the executable file by the linker, but may +(for example) pass information \e{to} the linker. For example, +declaring an \c{info}-type section called \i\c{.drectve} causes the +linker to interpret the contents of the section as command-line +options. + +\b \c{align=}, used with a trailing number as in \c{obj}, gives the +\I{section alignment, in win32}\I{alignment, in win32 +sections}alignment requirements of the section. The maximum you may +specify is 64: the Win32 object file format contains no means to +request a greater section alignment than this. If alignment is not +explicitly specified, the defaults are 16-byte alignment for code +sections, 8-byte alignment for rdata sections and 4-byte alignment +for data (and BSS) sections. +Informational sections get a default alignment of 1 byte (no +alignment), though the value does not matter. + +The defaults assumed by NASM if you do not specify the above +qualifiers are: + +\c section .text code align=16 +\c section .data data align=4 +\c section .rdata rdata align=8 +\c section .bss bss align=4 + +Any other section name is treated by default like \c{.text}. + +\S{win32safeseh} \c{win32}: Safe Structured Exception Handling + +Among other improvements in Windows XP SP2 and Windows Server 2003 +Microsoft has introduced concept of "safe structured exception +handling." General idea is to collect handlers' entry points in +designated read-only table and have alleged entry point verified +against this table prior exception control is passed to the handler. In +order for an executable module to be equipped with such "safe exception +handler table," all object modules on linker command line has to comply +with certain criteria. If one single module among them does not, then +the table in question is omitted and above mentioned run-time checks +will not be performed for application in question. Table omission is by +default silent and therefore can be easily overlooked. One can instruct +linker to refuse to produce binary without such table by passing +\c{/safeseh} command line option. + +Without regard to this run-time check merits it's natural to expect +NASM to be capable of generating modules suitable for \c{/safeseh} +linking. From developer's viewpoint the problem is two-fold: + +\b how to adapt modules not deploying exception handlers of their own; + +\b how to adapt/develop modules utilizing custom exception handling; + +Former can be easily achieved with any NASM version by adding following +line to source code: + +\c $@feat.00 equ 1 + +As of version 2.03 NASM adds this absolute symbol automatically. If +it's not already present to be precise. I.e. if for whatever reason +developer would choose to assign another value in source file, it would +still be perfectly possible. + +Registering custom exception handler on the other hand requires certain +"magic." As of version 2.03 additional directive is implemented, +\c{safeseh}, which instructs the assembler to produce appropriately +formatted input data for above mentioned "safe exception handler +table." Its typical use would be: + +\c section .text +\c extern _MessageBoxA@16 +\c %if __NASM_VERSION_ID__ >= 0x02030000 +\c safeseh handler ; register handler as "safe handler" +\c %endif +\c handler: +\c push DWORD 1 ; MB_OKCANCEL +\c push DWORD caption +\c push DWORD text +\c push DWORD 0 +\c call _MessageBoxA@16 +\c sub eax,1 ; incidentally suits as return value +\c ; for exception handler +\c ret +\c global _main +\c _main: +\c push DWORD handler +\c push DWORD [fs:0] +\c mov DWORD [fs:0],esp ; engage exception handler +\c xor eax,eax +\c mov eax,DWORD[eax] ; cause exception +\c pop DWORD [fs:0] ; disengage exception handler +\c add esp,4 +\c ret +\c text: db 'OK to rethrow, CANCEL to generate core dump',0 +\c caption:db 'SEGV',0 +\c +\c section .drectve info +\c db '/defaultlib:user32.lib /defaultlib:msvcrt.lib ' + +As you might imagine, it's perfectly possible to produce .exe binary +with "safe exception handler table" and yet engage unregistered +exception handler. Indeed, handler is engaged by simply manipulating +\c{[fs:0]} location at run-time, something linker has no power over, +run-time that is. It should be explicitly mentioned that such failure +to register handler's entry point with \c{safeseh} directive has +undesired side effect at run-time. If exception is raised and +unregistered handler is to be executed, the application is abruptly +terminated without any notification whatsoever. One can argue that +system could at least have logged some kind "non-safe exception +handler in x.exe at address n" message in event log, but no, literally +no notification is provided and user is left with no clue on what +caused application failure. + +Finally, all mentions of linker in this paragraph refer to Microsoft +linker version 7.x and later. Presence of \c{@feat.00} symbol and input +data for "safe exception handler table" causes no backward +incompatibilities and "safeseh" modules generated by NASM 2.03 and +later can still be linked by earlier versions or non-Microsoft linkers. + + +\H{win64fmt} \i\c{win64}: Microsoft Win64 Object Files + +The \c{win64} output format generates Microsoft Win64 object files, +which is nearly 100% identical to the \c{win32} object format (\k{win32fmt}) +with the exception that it is meant to target 64-bit code and the x86-64 +platform altogether. This object file is used exactly the same as the \c{win32} +object format (\k{win32fmt}), in NASM, with regard to this exception. + +\S{win64pic} \c{win64}: Writing Position-Independent Code + +While \c{REL} takes good care of RIP-relative addressing, there is one +aspect that is easy to overlook for a Win64 programmer: indirect +references. Consider a switch dispatch table: + +\c jmp QWORD[dsptch+rax*8] +\c ... +\c dsptch: dq case0 +\c dq case1 +\c ... + +Even novice Win64 assembler programmer will soon realize that the code +is not 64-bit savvy. Most notably linker will refuse to link it with +"\c{'ADDR32' relocation to '.text' invalid without +/LARGEADDRESSAWARE:NO}". So [s]he will have to split jmp instruction as +following: + +\c lea rbx,[rel dsptch] +\c jmp QWORD[rbx+rax*8] + +What happens behind the scene is that effective address in \c{lea} is +encoded relative to instruction pointer, or in perfectly +position-independent manner. But this is only part of the problem! +Trouble is that in .dll context \c{caseN} relocations will make their +way to the final module and might have to be adjusted at .dll load +time. To be specific when it can't be loaded at preferred address. And +when this occurs, pages with such relocations will be rendered private +to current process, which kind of undermines the idea of sharing .dll. +But no worry, it's trivial to fix: + +\c lea rbx,[rel dsptch] +\c add rbx,QWORD[rbx+rax*8] +\c jmp rbx +\c ... +\c dsptch: dq case0-dsptch +\c dq case1-dsptch +\c ... + +NASM version 2.03 and later provides another alternative, \c{wrt +..imagebase} operator, which returns offset from base address of the +current image, be it .exe or .dll module, therefore the name. For those +acquainted with PE-COFF format base address denotes start of +\c{IMAGE_DOS_HEADER} structure. Here is how to implement switch with +these image-relative references: + +\c lea rbx,[rel dsptch] +\c mov eax,DWORD[rbx+rax*4] +\c sub rbx,dsptch wrt ..imagebase +\c add rbx,rax +\c jmp rbx +\c ... +\c dsptch: dd case0 wrt ..imagebase +\c dd case1 wrt ..imagebase + +One can argue that the operator is redundant. Indeed, snippet before +last works just fine with any NASM version and is not even Windows +specific... The real reason for implementing \c{wrt ..imagebase} will +become apparent in next paragraph. + +It should be noted that \c{wrt ..imagebase} is defined as 32-bit +operand only: + +\c dd label wrt ..imagebase ; ok +\c dq label wrt ..imagebase ; bad +\c mov eax,label wrt ..imagebase ; ok +\c mov rax,label wrt ..imagebase ; bad + +\S{win64seh} \c{win64}: Structured Exception Handling + +Structured exception handing in Win64 is completely different matter +from Win32. Upon exception program counter value is noted, and +linker-generated table comprising start and end addresses of all the +functions [in given executable module] is traversed and compared to the +saved program counter. Thus so called \c{UNWIND_INFO} structure is +identified. If it's not found, then offending subroutine is assumed to +be "leaf" and just mentioned lookup procedure is attempted for its +caller. In Win64 leaf function is such function that does not call any +other function \e{nor} modifies any Win64 non-volatile registers, +including stack pointer. The latter ensures that it's possible to +identify leaf function's caller by simply pulling the value from the +top of the stack. + +While majority of subroutines written in assembler are not calling any +other function, requirement for non-volatile registers' immutability +leaves developer with not more than 7 registers and no stack frame, +which is not necessarily what [s]he counted with. Customarily one would +meet the requirement by saving non-volatile registers on stack and +restoring them upon return, so what can go wrong? If [and only if] an +exception is raised at run-time and no \c{UNWIND_INFO} structure is +associated with such "leaf" function, the stack unwind procedure will +expect to find caller's return address on the top of stack immediately +followed by its frame. Given that developer pushed caller's +non-volatile registers on stack, would the value on top point at some +code segment or even addressable space? Well, developer can attempt +copying caller's return address to the top of stack and this would +actually work in some very specific circumstances. But unless developer +can guarantee that these circumstances are always met, it's more +appropriate to assume worst case scenario, i.e. stack unwind procedure +going berserk. Relevant question is what happens then? Application is +abruptly terminated without any notification whatsoever. Just like in +Win32 case, one can argue that system could at least have logged +"unwind procedure went berserk in x.exe at address n" in event log, but +no, no trace of failure is left. + +Now, when we understand significance of the \c{UNWIND_INFO} structure, +let's discuss what's in it and/or how it's processed. First of all it +is checked for presence of reference to custom language-specific +exception handler. If there is one, then it's invoked. Depending on the +return value, execution flow is resumed (exception is said to be +"handled"), \e{or} rest of \c{UNWIND_INFO} structure is processed as +following. Beside optional reference to custom handler, it carries +information about current callee's stack frame and where non-volatile +registers are saved. Information is detailed enough to be able to +reconstruct contents of caller's non-volatile registers upon call to +current callee. And so caller's context is reconstructed, and then +unwind procedure is repeated, i.e. another \c{UNWIND_INFO} structure is +associated, this time, with caller's instruction pointer, which is then +checked for presence of reference to language-specific handler, etc. +The procedure is recursively repeated till exception is handled. As +last resort system "handles" it by generating memory core dump and +terminating the application. + +As for the moment of this writing NASM unfortunately does not +facilitate generation of above mentioned detailed information about +stack frame layout. But as of version 2.03 it implements building +blocks for generating structures involved in stack unwinding. As +simplest example, here is how to deploy custom exception handler for +leaf function: + +\c default rel +\c section .text +\c extern MessageBoxA +\c handler: +\c sub rsp,40 +\c mov rcx,0 +\c lea rdx,[text] +\c lea r8,[caption] +\c mov r9,1 ; MB_OKCANCEL +\c call MessageBoxA +\c sub eax,1 ; incidentally suits as return value +\c ; for exception handler +\c add rsp,40 +\c ret +\c global main +\c main: +\c xor rax,rax +\c mov rax,QWORD[rax] ; cause exception +\c ret +\c main_end: +\c text: db 'OK to rethrow, CANCEL to generate core dump',0 +\c caption:db 'SEGV',0 +\c +\c section .pdata rdata align=4 +\c dd main wrt ..imagebase +\c dd main_end wrt ..imagebase +\c dd xmain wrt ..imagebase +\c section .xdata rdata align=8 +\c xmain: db 9,0,0,0 +\c dd handler wrt ..imagebase +\c section .drectve info +\c db '/defaultlib:user32.lib /defaultlib:msvcrt.lib ' + +What you see in \c{.pdata} section is element of the "table comprising +start and end addresses of function" along with reference to associated +\c{UNWIND_INFO} structure. And what you see in \c{.xdata} section is +\c{UNWIND_INFO} structure describing function with no frame, but with +designated exception handler. References are \e{required} to be +image-relative (which is the real reason for implementing \c{wrt +..imagebase} operator). It should be noted that \c{rdata align=n}, as +well as \c{wrt ..imagebase}, are optional in these two segments' +contexts, i.e. can be omitted. Latter means that \e{all} 32-bit +references, not only above listed required ones, placed into these two +segments turn out image-relative. Why is it important to understand? +Developer is allowed to append handler-specific data to \c{UNWIND_INFO} +structure, and if [s]he adds a 32-bit reference, then [s]he will have +to remember to adjust its value to obtain the real pointer. + +As already mentioned, in Win64 terms leaf function is one that does not +call any other function \e{nor} modifies any non-volatile register, +including stack pointer. But it's not uncommon that assembler +programmer plans to utilize every single register and sometimes even +have variable stack frame. Is there anything one can do with bare +building blocks? I.e. besides manually composing fully-fledged +\c{UNWIND_INFO} structure, which would surely be considered +error-prone? Yes, there is. Recall that exception handler is called +first, before stack layout is analyzed. As it turned out, it's +perfectly possible to manipulate current callee's context in custom +handler in manner that permits further stack unwinding. General idea is +that handler would not actually "handle" the exception, but instead +restore callee's context, as it was at its entry point and thus mimic +leaf function. In other words, handler would simply undertake part of +unwinding procedure. Consider following example: + +\c function: +\c mov rax,rsp ; copy rsp to volatile register +\c push r15 ; save non-volatile registers +\c push rbx +\c push rbp +\c mov r11,rsp ; prepare variable stack frame +\c sub r11,rcx +\c and r11,-64 +\c mov QWORD[r11],rax ; check for exceptions +\c mov rsp,r11 ; allocate stack frame +\c mov QWORD[rsp],rax ; save original rsp value +\c magic_point: +\c ... +\c mov r11,QWORD[rsp] ; pull original rsp value +\c mov rbp,QWORD[r11-24] +\c mov rbx,QWORD[r11-16] +\c mov r15,QWORD[r11-8] +\c mov rsp,r11 ; destroy frame +\c ret + +The keyword is that up to \c{magic_point} original \c{rsp} value +remains in chosen volatile register and no non-volatile register, +except for \c{rsp}, is modified. While past \c{magic_point} \c{rsp} +remains constant till the very end of the \c{function}. In this case +custom language-specific exception handler would look like this: + +\c EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame, +\c CONTEXT *context,DISPATCHER_CONTEXT *disp) +\c { ULONG64 *rsp; +\c if (context->Rip<(ULONG64)magic_point) +\c rsp = (ULONG64 *)context->Rax; +\c else +\c { rsp = ((ULONG64 **)context->Rsp)[0]; +\c context->Rbp = rsp[-3]; +\c context->Rbx = rsp[-2]; +\c context->R15 = rsp[-1]; +\c } +\c context->Rsp = (ULONG64)rsp; +\c +\c memcpy (disp->ContextRecord,context,sizeof(CONTEXT)); +\c RtlVirtualUnwind(UNW_FLAG_NHANDLER,disp->ImageBase, +\c dips->ControlPc,disp->FunctionEntry,disp->ContextRecord, +\c &disp->HandlerData,&disp->EstablisherFrame,NULL); +\c return ExceptionContinueSearch; +\c } + +As custom handler mimics leaf function, corresponding \c{UNWIND_INFO} +structure does not have to contain any information about stack frame +and its layout. + +\H{cofffmt} \i\c{coff}: \i{Common Object File Format} + +The \c{coff} output type produces \c{COFF} object files suitable for +linking with the \i{DJGPP} linker. + +\c{coff} provides a default output file-name extension of \c{.o}. + +The \c{coff} format supports the same extensions to the \c{SECTION} +directive as \c{win32} does, except that the \c{align} qualifier and +the \c{info} section type are not supported. + +\H{machofmt} \I{Mach-O}\i\c{macho32} and \i\c{macho64}: \i{Mach Object File Format} + +The \c{macho32} and \c{macho64} output formts produces \c{Mach-O} +object files suitable for linking with the \i{MacOS X} linker. +\i\c{macho} is a synonym for \c{macho32}. + +\c{macho} provides a default output file-name extension of \c{.o}. + +\H{elffmt} \i\c{elf32} and \i\c{elf64}: \I{ELF}\I{linux, elf}\i{Executable and Linkable +Format} Object Files + +The \c{elf32} and \c{elf64} output formats generate \c{ELF32 and ELF64} (Executable and Linkable Format) object files, as used by Linux as well as \i{Unix System V}, +including \i{Solaris x86}, \i{UnixWare} and \i{SCO Unix}. \c{elf} +provides a default output file-name extension of \c{.o}. +\c{elf} is a synonym for \c{elf32}. + +\S{abisect} ELF specific directive \i\c{osabi} + +The ELF header specifies the application binary interface for the target operating system (OSABI). +This field can be set by using the \c{osabi} directive with the numeric value (0-255) of the target + system. If this directive is not used, the default value will be "UNIX System V ABI" (0) which will work on + most systems which support ELF. + +\S{elfsect} \c{elf} Extensions to the \c{SECTION} +Directive\I{SECTION, elf extensions to} + +Like the \c{obj} format, \c{elf} allows you to specify additional +information on the \c{SECTION} directive line, to control the type +and properties of sections you declare. Section types and properties +are generated automatically by NASM for the \i{standard section +names}, but may still be +overridden by these qualifiers. + +The available qualifiers are: + +\b \i\c{alloc} defines the section to be one which is loaded into +memory when the program is run. \i\c{noalloc} defines it to be one +which is not, such as an informational or comment section. + +\b \i\c{exec} defines the section to be one which should have execute +permission when the program is run. \i\c{noexec} defines it as one +which should not. + +\b \i\c{write} defines the section to be one which should be writable +when the program is run. \i\c{nowrite} defines it as one which should +not. + +\b \i\c{progbits} defines the section to be one with explicit contents +stored in the object file: an ordinary code or data section, for +example, \i\c{nobits} defines the section to be one with no explicit +contents given, such as a BSS section. + +\b \c{align=}, used with a trailing number as in \c{obj}, gives the +\I{section alignment, in elf}\I{alignment, in elf sections}alignment +requirements of the section. + +\b \i\c{tls} defines the section to be one which contains +thread local variables. + +The defaults assumed by NASM if you do not specify the above +qualifiers are: + +\I\c{.text} \I\c{.rodata} \I\c{.lrodata} \I\c{.data} \I\c{.ldata} +\I\c{.bss} \I\c{.lbss} \I\c{.tdata} \I\c{.tbss} \I\c\{.comment} + +\c section .text progbits alloc exec nowrite align=16 +\c section .rodata progbits alloc noexec nowrite align=4 +\c section .lrodata progbits alloc noexec nowrite align=4 +\c section .data progbits alloc noexec write align=4 +\c section .ldata progbits alloc noexec write align=4 +\c section .bss nobits alloc noexec write align=4 +\c section .lbss nobits alloc noexec write align=4 +\c section .tdata progbits alloc noexec write align=4 tls +\c section .tbss nobits alloc noexec write align=4 tls +\c section .comment progbits noalloc noexec nowrite align=1 +\c section other progbits alloc noexec nowrite align=1 + +(Any section name other than those in the above table + is treated by default like \c{other} in the above table. + Please note that section names are case sensitive.) + + +\S{elfwrt} \i{Position-Independent Code}\I{PIC}: \c{elf} Special +Symbols and \i\c{WRT} + +The \c{ELF} specification contains enough features to allow +position-independent code (PIC) to be written, which makes \i{ELF +shared libraries} very flexible. However, it also means NASM has to +be able to generate a variety of ELF specific relocation types in ELF +object files, if it is to be an assembler which can write PIC. + +Since \c{ELF} does not support segment-base references, the \c{WRT} +operator is not used for its normal purpose; therefore NASM's +\c{elf} output format makes use of \c{WRT} for a different purpose, +namely the PIC-specific \I{relocations, PIC-specific}relocation +types. + +\c{elf} defines five special symbols which you can use as the +right-hand side of the \c{WRT} operator to obtain PIC relocation +types. They are \i\c{..gotpc}, \i\c{..gotoff}, \i\c{..got}, +\i\c{..plt} and \i\c{..sym}. Their functions are summarized here: + +\b Referring to the symbol marking the global offset table base +using \c{wrt ..gotpc} will end up giving the distance from the +beginning of the current section to the global offset table. +(\i\c{_GLOBAL_OFFSET_TABLE_} is the standard symbol name used to +refer to the \i{GOT}.) So you would then need to add \i\c{$$} to the +result to get the real address of the GOT. + +\b Referring to a location in one of your own sections using \c{wrt +..gotoff} will give the distance from the beginning of the GOT to +the specified location, so that adding on the address of the GOT +would give the real address of the location you wanted. + +\b Referring to an external or global symbol using \c{wrt ..got} +causes the linker to build an entry \e{in} the GOT containing the +address of the symbol, and the reference gives the distance from the +beginning of the GOT to the entry; so you can add on the address of +the GOT, load from the resulting address, and end up with the +address of the symbol. + +\b Referring to a procedure name using \c{wrt ..plt} causes the +linker to build a \i{procedure linkage table} entry for the symbol, +and the reference gives the address of the \i{PLT} entry. You can +only use this in contexts which would generate a PC-relative +relocation normally (i.e. as the destination for \c{CALL} or +\c{JMP}), since ELF contains no relocation type to refer to PLT +entries absolutely. + +\b Referring to a symbol name using \c{wrt ..sym} causes NASM to +write an ordinary relocation, but instead of making the relocation +relative to the start of the section and then adding on the offset +to the symbol, it will write a relocation record aimed directly at +the symbol in question. The distinction is a necessary one due to a +peculiarity of the dynamic linker. + +A fuller explanation of how to use these relocation types to write +shared libraries entirely in NASM is given in \k{picdll}. + +\S{elftls} \i{Thread Local Storage}\I{TLS}: \c{elf} Special +Symbols and \i\c{WRT} + +\b In ELF32 mode, referring to an external or global symbol using +\c{wrt ..tlsie} \I\c{..tlsie} +causes the linker to build an entry \e{in} the GOT containing the +offset of the symbol within the TLS block, so you can access the value +of the symbol with code such as: + +\c mov eax,[tid wrt ..tlsie] +\c mov [gs:eax],ebx + + +\b In ELF64 mode, referring to an external or global symbol using +\c{wrt ..gottpoff} \I\c{..gottpoff} +causes the linker to build an entry \e{in} the GOT containing the +offset of the symbol within the TLS block, so you can access the value +of the symbol with code such as: + +\c mov rax,[rel tid wrt ..gottpoff] +\c mov rcx,[fs:rax] + + +\S{elfglob} \c{elf} Extensions to the \c{GLOBAL} Directive\I{GLOBAL, +elf extensions to}\I{GLOBAL, aoutb extensions to} + +\c{ELF} object files can contain more information about a global symbol +than just its address: they can contain the \I{symbol sizes, +specifying}\I{size, of symbols}size of the symbol and its \I{symbol +types, specifying}\I{type, of symbols}type as well. These are not +merely debugger conveniences, but are actually necessary when the +program being written is a \i{shared library}. NASM therefore +supports some extensions to the \c{GLOBAL} directive, allowing you +to specify these features. + +You can specify whether a global variable is a function or a data +object by suffixing the name with a colon and the word +\i\c{function} or \i\c{data}. (\i\c{object} is a synonym for +\c{data}.) For example: + +\c global hashlookup:function, hashtable:data + +exports the global symbol \c{hashlookup} as a function and +\c{hashtable} as a data object. + +Optionally, you can control the ELF visibility of the symbol. Just +add one of the visibility keywords: \i\c{default}, \i\c{internal}, +\i\c{hidden}, or \i\c{protected}. The default is \i\c{default} of +course. For example, to make \c{hashlookup} hidden: + +\c global hashlookup:function hidden + +You can also specify the size of the data associated with the +symbol, as a numeric expression (which may involve labels, and even +forward references) after the type specifier. Like this: + +\c global hashtable:data (hashtable.end - hashtable) +\c +\c hashtable: +\c db this,that,theother ; some data here +\c .end: + +This makes NASM automatically calculate the length of the table and +place that information into the \c{ELF} symbol table. + +Declaring the type and size of global symbols is necessary when +writing shared library code. For more information, see +\k{picglobal}. + + +\S{elfcomm} \c{elf} Extensions to the \c{COMMON} Directive +\I{COMMON, elf extensions to} + +\c{ELF} also allows you to specify alignment requirements \I{common +variables, alignment in elf}\I{alignment, of elf common variables}on +common variables. This is done by putting a number (which must be a +power of two) after the name and size of the common variable, +separated (as usual) by a colon. For example, an array of +doublewords would benefit from 4-byte alignment: + +\c common dwordarray 128:4 + +This declares the total size of the array to be 128 bytes, and +requires that it be aligned on a 4-byte boundary. + + +\S{elf16} 16-bit code and ELF +\I{ELF, 16-bit code and} + +The \c{ELF32} specification doesn't provide relocations for 8- and +16-bit values, but the GNU \c{ld} linker adds these as an extension. +NASM can generate GNU-compatible relocations, to allow 16-bit code to +be linked as ELF using GNU \c{ld}. If NASM is used with the +\c{-w+gnu-elf-extensions} option, a warning is issued when one of +these relocations is generated. + +\S{elfdbg} Debug formats and ELF +\I{ELF, Debug formats and} + +\c{ELF32} and \c{ELF64} provide debug information in \c{STABS} and \c{DWARF} formats. +Line number information is generated for all executable sections, but please +note that only the ".text" section is executable by default. + +\H{aoutfmt} \i\c{aout}: Linux \I{a.out, Linux version}\I{linux, a.out}\c{a.out} Object Files + +The \c{aout} format generates \c{a.out} object files, in the form used +by early Linux systems (current Linux systems use ELF, see +\k{elffmt}.) These differ from other \c{a.out} object files in that +the magic number in the first four bytes of the file is +different; also, some implementations of \c{a.out}, for example +NetBSD's, support position-independent code, which Linux's +implementation does not. + +\c{a.out} provides a default output file-name extension of \c{.o}. + +\c{a.out} is a very simple object format. It supports no special +directives, no special symbols, no use of \c{SEG} or \c{WRT}, and no +extensions to any standard directives. It supports only the three +\i{standard section names} \i\c{.text}, \i\c{.data} and \i\c{.bss}. + + +\H{aoutfmt} \i\c{aoutb}: \i{NetBSD}/\i{FreeBSD}/\i{OpenBSD} +\I{a.out, BSD version}\c{a.out} Object Files + +The \c{aoutb} format generates \c{a.out} object files, in the form +used by the various free \c{BSD Unix} clones, \c{NetBSD}, \c{FreeBSD} +and \c{OpenBSD}. For simple object files, this object format is exactly +the same as \c{aout} except for the magic number in the first four bytes +of the file. However, the \c{aoutb} format supports +\I{PIC}\i{position-independent code} in the same way as the \c{elf} +format, so you can use it to write \c{BSD} \i{shared libraries}. + +\c{aoutb} provides a default output file-name extension of \c{.o}. + +\c{aoutb} supports no special directives, no special symbols, and +only the three \i{standard section names} \i\c{.text}, \i\c{.data} +and \i\c{.bss}. However, it also supports the same use of \i\c{WRT} as +\c{elf} does, to provide position-independent code relocation types. +See \k{elfwrt} for full documentation of this feature. + +\c{aoutb} also supports the same extensions to the \c{GLOBAL} +directive as \c{elf} does: see \k{elfglob} for documentation of +this. + + +\H{as86fmt} \c{as86}: \i{Minix}/Linux\I{linux, as86} \i\c{as86} Object Files + +The Minix/Linux 16-bit assembler \c{as86} has its own non-standard +object file format. Although its companion linker \i\c{ld86} produces +something close to ordinary \c{a.out} binaries as output, the object +file format used to communicate between \c{as86} and \c{ld86} is not +itself \c{a.out}. + +NASM supports this format, just in case it is useful, as \c{as86}. +\c{as86} provides a default output file-name extension of \c{.o}. + +\c{as86} is a very simple object format (from the NASM user's point +of view). It supports no special directives, no use of \c{SEG} or \c{WRT}, +and no extensions to any standard directives. It supports only the three +\i{standard section names} \i\c{.text}, \i\c{.data} and \i\c{.bss}. The +only special symbol supported is \c{..start}. + + +\H{rdffmt} \I{RDOFF}\i\c{rdf}: \i{Relocatable Dynamic Object File +Format} + +The \c{rdf} output format produces \c{RDOFF} object files. \c{RDOFF} +(Relocatable Dynamic Object File Format) is a home-grown object-file +format, designed alongside NASM itself and reflecting in its file +format the internal structure of the assembler. + +\c{RDOFF} is not used by any well-known operating systems. Those +writing their own systems, however, may well wish to use \c{RDOFF} +as their object format, on the grounds that it is designed primarily +for simplicity and contains very little file-header bureaucracy. + +The Unix NASM archive, and the DOS archive which includes sources, +both contain an \I{rdoff subdirectory}\c{rdoff} subdirectory holding +a set of RDOFF utilities: an RDF linker, an \c{RDF} static-library +manager, an RDF file dump utility, and a program which will load and +execute an RDF executable under Linux. + +\c{rdf} supports only the \i{standard section names} \i\c{.text}, +\i\c{.data} and \i\c{.bss}. + + +\S{rdflib} Requiring a Library: The \i\c{LIBRARY} Directive + +\c{RDOFF} contains a mechanism for an object file to demand a given +library to be linked to the module, either at load time or run time. +This is done by the \c{LIBRARY} directive, which takes one argument +which is the name of the module: + +\c library mylib.rdl + + +\S{rdfmod} Specifying a Module Name: The \i\c{MODULE} Directive + +Special \c{RDOFF} header record is used to store the name of the module. +It can be used, for example, by run-time loader to perform dynamic +linking. \c{MODULE} directive takes one argument which is the name +of current module: + +\c module mymodname + +Note that when you statically link modules and tell linker to strip +the symbols from output file, all module names will be stripped too. +To avoid it, you should start module names with \I{$, prefix}\c{$}, like: + +\c module $kernel.core + + +\S{rdfglob} \c{rdf} Extensions to the \c{GLOBAL} Directive\I{GLOBAL, +rdf extensions to} + +\c{RDOFF} global symbols can contain additional information needed by +the static linker. You can mark a global symbol as exported, thus +telling the linker do not strip it from target executable or library +file. Like in \c{ELF}, you can also specify whether an exported symbol +is a procedure (function) or data object. + +Suffixing the name with a colon and the word \i\c{export} you make the +symbol exported: + +\c global sys_open:export + +To specify that exported symbol is a procedure (function), you add the +word \i\c{proc} or \i\c{function} after declaration: + +\c global sys_open:export proc + +Similarly, to specify exported data object, add the word \i\c{data} +or \i\c{object} to the directive: + +\c global kernel_ticks:export data + + +\S{rdfimpt} \c{rdf} Extensions to the \c{EXTERN} Directive\I{EXTERN, +rdf extensions to} + +By default the \c{EXTERN} directive in \c{RDOFF} declares a "pure external" +symbol (i.e. the static linker will complain if such a symbol is not resolved). +To declare an "imported" symbol, which must be resolved later during a dynamic +linking phase, \c{RDOFF} offers an additional \c{import} modifier. As in +\c{GLOBAL}, you can also specify whether an imported symbol is a procedure +(function) or data object. For example: + +\c library $libc +\c extern _open:import +\c extern _printf:import proc +\c extern _errno:import data + +Here the directive \c{LIBRARY} is also included, which gives the dynamic linker +a hint as to where to find requested symbols. + + +\H{dbgfmt} \i\c{dbg}: Debugging Format + +The \c{dbg} output format is not built into NASM in the default +configuration. If you are building your own NASM executable from the +sources, you can define \i\c{OF_DBG} in \c{output/outform.h} or on the +compiler command line, and obtain the \c{dbg} output format. + +The \c{dbg} format does not output an object file as such; instead, +it outputs a text file which contains a complete list of all the +transactions between the main body of NASM and the output-format +back end module. It is primarily intended to aid people who want to +write their own output drivers, so that they can get a clearer idea +of the various requests the main program makes of the output driver, +and in what order they happen. + +For simple files, one can easily use the \c{dbg} format like this: + +\c nasm -f dbg filename.asm + +which will generate a diagnostic file called \c{filename.dbg}. +However, this will not work well on files which were designed for a +different object format, because each object format defines its own +macros (usually user-level forms of directives), and those macros +will not be defined in the \c{dbg} format. Therefore it can be +useful to run NASM twice, in order to do the preprocessing with the +native object format selected: + +\c nasm -e -f rdf -o rdfprog.i rdfprog.asm +\c nasm -a -f dbg rdfprog.i + +This preprocesses \c{rdfprog.asm} into \c{rdfprog.i}, keeping the +\c{rdf} object format selected in order to make sure RDF special +directives are converted into primitive form correctly. Then the +preprocessed source is fed through the \c{dbg} format to generate +the final diagnostic output. + +This workaround will still typically not work for programs intended +for \c{obj} format, because the \c{obj} \c{SEGMENT} and \c{GROUP} +directives have side effects of defining the segment and group names +as symbols; \c{dbg} will not do this, so the program will not +assemble. You will have to work around that by defining the symbols +yourself (using \c{EXTERN}, for example) if you really need to get a +\c{dbg} trace of an \c{obj}-specific source file. + +\c{dbg} accepts any section name and any directives at all, and logs +them all to its output file. + + +\C{16bit} Writing 16-bit Code (DOS, Windows 3/3.1) + +This chapter attempts to cover some of the common issues encountered +when writing 16-bit code to run under \c{MS-DOS} or \c{Windows 3.x}. It +covers how to link programs to produce \c{.EXE} or \c{.COM} files, +how to write \c{.SYS} device drivers, and how to interface assembly +language code with 16-bit C compilers and with Borland Pascal. + + +\H{exefiles} Producing \i\c{.EXE} Files + +Any large program written under DOS needs to be built as a \c{.EXE} +file: only \c{.EXE} files have the necessary internal structure +required to span more than one 64K segment. \i{Windows} programs, +also, have to be built as \c{.EXE} files, since Windows does not +support the \c{.COM} format. + +In general, you generate \c{.EXE} files by using the \c{obj} output +format to produce one or more \i\c{.OBJ} files, and then linking +them together using a linker. However, NASM also supports the direct +generation of simple DOS \c{.EXE} files using the \c{bin} output +format (by using \c{DB} and \c{DW} to construct the \c{.EXE} file +header), and a macro package is supplied to do this. Thanks to +Yann Guidon for contributing the code for this. + +NASM may also support \c{.EXE} natively as another output format in +future releases. + + +\S{objexe} Using the \c{obj} Format To Generate \c{.EXE} Files + +This section describes the usual method of generating \c{.EXE} files +by linking \c{.OBJ} files together. + +Most 16-bit programming language packages come with a suitable +linker; if you have none of these, there is a free linker called +\i{VAL}\I{linker, free}, available in \c{LZH} archive format from +\W{ftp://x2ftp.oulu.fi/pub/msdos/programming/lang/}\i\c{x2ftp.oulu.fi}. +An LZH archiver can be found at +\W{ftp://ftp.simtel.net/pub/simtelnet/msdos/arcers}\i\c{ftp.simtel.net}. +There is another `free' linker (though this one doesn't come with +sources) called \i{FREELINK}, available from +\W{http://www.pcorner.com/tpc/old/3-101.html}\i\c{www.pcorner.com}. +A third, \i\c{djlink}, written by DJ Delorie, is available at +\W{http://www.delorie.com/djgpp/16bit/djlink/}\i\c{www.delorie.com}. +A fourth linker, \i\c{ALINK}, written by Anthony A.J. Williams, is +available at \W{http://alink.sourceforge.net}\i\c{alink.sourceforge.net}. + +When linking several \c{.OBJ} files into a \c{.EXE} file, you should +ensure that exactly one of them has a start point defined (using the +\I{program entry point}\i\c{..start} special symbol defined by the +\c{obj} format: see \k{dotdotstart}). If no module defines a start +point, the linker will not know what value to give the entry-point +field in the output file header; if more than one defines a start +point, the linker will not know \e{which} value to use. + +An example of a NASM source file which can be assembled to a +\c{.OBJ} file and linked on its own to a \c{.EXE} is given here. It +demonstrates the basic principles of defining a stack, initialising +the segment registers, and declaring a start point. This file is +also provided in the \I{test subdirectory}\c{test} subdirectory of +the NASM archives, under the name \c{objexe.asm}. + +\c segment code +\c +\c ..start: +\c mov ax,data +\c mov ds,ax +\c mov ax,stack +\c mov ss,ax +\c mov sp,stacktop + +This initial piece of code sets up \c{DS} to point to the data +segment, and initializes \c{SS} and \c{SP} to point to the top of +the provided stack. Notice that interrupts are implicitly disabled +for one instruction after a move into \c{SS}, precisely for this +situation, so that there's no chance of an interrupt occurring +between the loads of \c{SS} and \c{SP} and not having a stack to +execute on. + +Note also that the special symbol \c{..start} is defined at the +beginning of this code, which means that will be the entry point +into the resulting executable file. + +\c mov dx,hello +\c mov ah,9 +\c int 0x21 + +The above is the main program: load \c{DS:DX} with a pointer to the +greeting message (\c{hello} is implicitly relative to the segment +\c{data}, which was loaded into \c{DS} in the setup code, so the +full pointer is valid), and call the DOS print-string function. + +\c mov ax,0x4c00 +\c int 0x21 + +This terminates the program using another DOS system call. + +\c segment data +\c +\c hello: db 'hello, world', 13, 10, '$' + +The data segment contains the string we want to display. + +\c segment stack stack +\c resb 64 +\c stacktop: + +The above code declares a stack segment containing 64 bytes of +uninitialized stack space, and points \c{stacktop} at the top of it. +The directive \c{segment stack stack} defines a segment \e{called} +\c{stack}, and also of \e{type} \c{STACK}. The latter is not +necessary to the correct running of the program, but linkers are +likely to issue warnings or errors if your program has no segment of +type \c{STACK}. + +The above file, when assembled into a \c{.OBJ} file, will link on +its own to a valid \c{.EXE} file, which when run will print `hello, +world' and then exit. + + +\S{binexe} Using the \c{bin} Format To Generate \c{.EXE} Files + +The \c{.EXE} file format is simple enough that it's possible to +build a \c{.EXE} file by writing a pure-binary program and sticking +a 32-byte header on the front. This header is simple enough that it +can be generated using \c{DB} and \c{DW} commands by NASM itself, so +that you can use the \c{bin} output format to directly generate +\c{.EXE} files. + +Included in the NASM archives, in the \I{misc subdirectory}\c{misc} +subdirectory, is a file \i\c{exebin.mac} of macros. It defines three +macros: \i\c{EXE_begin}, \i\c{EXE_stack} and \i\c{EXE_end}. + +To produce a \c{.EXE} file using this method, you should start by +using \c{%include} to load the \c{exebin.mac} macro package into +your source file. You should then issue the \c{EXE_begin} macro call +(which takes no arguments) to generate the file header data. Then +write code as normal for the \c{bin} format - you can use all three +standard sections \c{.text}, \c{.data} and \c{.bss}. At the end of +the file you should call the \c{EXE_end} macro (again, no arguments), +which defines some symbols to mark section sizes, and these symbols +are referred to in the header code generated by \c{EXE_begin}. + +In this model, the code you end up writing starts at \c{0x100}, just +like a \c{.COM} file - in fact, if you strip off the 32-byte header +from the resulting \c{.EXE} file, you will have a valid \c{.COM} +program. All the segment bases are the same, so you are limited to a +64K program, again just like a \c{.COM} file. Note that an \c{ORG} +directive is issued by the \c{EXE_begin} macro, so you should not +explicitly issue one of your own. + +You can't directly refer to your segment base value, unfortunately, +since this would require a relocation in the header, and things +would get a lot more complicated. So you should get your segment +base by copying it out of \c{CS} instead. + +On entry to your \c{.EXE} file, \c{SS:SP} are already set up to +point to the top of a 2Kb stack. You can adjust the default stack +size of 2Kb by calling the \c{EXE_stack} macro. For example, to +change the stack size of your program to 64 bytes, you would call +\c{EXE_stack 64}. + +A sample program which generates a \c{.EXE} file in this way is +given in the \c{test} subdirectory of the NASM archive, as +\c{binexe.asm}. + + +\H{comfiles} Producing \i\c{.COM} Files + +While large DOS programs must be written as \c{.EXE} files, small +ones are often better written as \c{.COM} files. \c{.COM} files are +pure binary, and therefore most easily produced using the \c{bin} +output format. + + +\S{combinfmt} Using the \c{bin} Format To Generate \c{.COM} Files + +\c{.COM} files expect to be loaded at offset \c{100h} into their +segment (though the segment may change). Execution then begins at +\I\c{ORG}\c{100h}, i.e. right at the start of the program. So to +write a \c{.COM} program, you would create a source file looking +like + +\c org 100h +\c +\c section .text +\c +\c start: +\c ; put your code here +\c +\c section .data +\c +\c ; put data items here +\c +\c section .bss +\c +\c ; put uninitialized data here + +The \c{bin} format puts the \c{.text} section first in the file, so +you can declare data or BSS items before beginning to write code if +you want to and the code will still end up at the front of the file +where it belongs. + +The BSS (uninitialized data) section does not take up space in the +\c{.COM} file itself: instead, addresses of BSS items are resolved +to point at space beyond the end of the file, on the grounds that +this will be free memory when the program is run. Therefore you +should not rely on your BSS being initialized to all zeros when you +run. + +To assemble the above program, you should use a command line like + +\c nasm myprog.asm -fbin -o myprog.com + +The \c{bin} format would produce a file called \c{myprog} if no +explicit output file name were specified, so you have to override it +and give the desired file name. + + +\S{comobjfmt} Using the \c{obj} Format To Generate \c{.COM} Files + +If you are writing a \c{.COM} program as more than one module, you +may wish to assemble several \c{.OBJ} files and link them together +into a \c{.COM} program. You can do this, provided you have a linker +capable of outputting \c{.COM} files directly (\i{TLINK} does this), +or alternatively a converter program such as \i\c{EXE2BIN} to +transform the \c{.EXE} file output from the linker into a \c{.COM} +file. + +If you do this, you need to take care of several things: + +\b The first object file containing code should start its code +segment with a line like \c{RESB 100h}. This is to ensure that the +code begins at offset \c{100h} relative to the beginning of the code +segment, so that the linker or converter program does not have to +adjust address references within the file when generating the +\c{.COM} file. Other assemblers use an \i\c{ORG} directive for this +purpose, but \c{ORG} in NASM is a format-specific directive to the +\c{bin} output format, and does not mean the same thing as it does +in MASM-compatible assemblers. + +\b You don't need to define a stack segment. + +\b All your segments should be in the same group, so that every time +your code or data references a symbol offset, all offsets are +relative to the same segment base. This is because, when a \c{.COM} +file is loaded, all the segment registers contain the same value. + + +\H{sysfiles} Producing \i\c{.SYS} Files + +\i{MS-DOS device drivers} - \c{.SYS} files - are pure binary files, +similar to \c{.COM} files, except that they start at origin zero +rather than \c{100h}. Therefore, if you are writing a device driver +using the \c{bin} format, you do not need the \c{ORG} directive, +since the default origin for \c{bin} is zero. Similarly, if you are +using \c{obj}, you do not need the \c{RESB 100h} at the start of +your code segment. + +\c{.SYS} files start with a header structure, containing pointers to +the various routines inside the driver which do the work. This +structure should be defined at the start of the code segment, even +though it is not actually code. + +For more information on the format of \c{.SYS} files, and the data +which has to go in the header structure, a list of books is given in +the Frequently Asked Questions list for the newsgroup +\W{news:comp.os.msdos.programmer}\i\c{comp.os.msdos.programmer}. + + +\H{16c} Interfacing to 16-bit C Programs + +This section covers the basics of writing assembly routines that +call, or are called from, C programs. To do this, you would +typically write an assembly module as a \c{.OBJ} file, and link it +with your C modules to produce a \i{mixed-language program}. + + +\S{16cunder} External Symbol Names + +\I{C symbol names}\I{underscore, in C symbols}C compilers have the +convention that the names of all global symbols (functions or data) +they define are formed by prefixing an underscore to the name as it +appears in the C program. So, for example, the function a C +programmer thinks of as \c{printf} appears to an assembly language +programmer as \c{_printf}. This means that in your assembly +programs, you can define symbols without a leading underscore, and +not have to worry about name clashes with C symbols. + +If you find the underscores inconvenient, you can define macros to +replace the \c{GLOBAL} and \c{EXTERN} directives as follows: + +\c %macro cglobal 1 +\c +\c global _%1 +\c %define %1 _%1 +\c +\c %endmacro +\c +\c %macro cextern 1 +\c +\c extern _%1 +\c %define %1 _%1 +\c +\c %endmacro + +(These forms of the macros only take one argument at a time; a +\c{%rep} construct could solve this.) + +If you then declare an external like this: + +\c cextern printf + +then the macro will expand it as + +\c extern _printf +\c %define printf _printf + +Thereafter, you can reference \c{printf} as if it was a symbol, and +the preprocessor will put the leading underscore on where necessary. + +The \c{cglobal} macro works similarly. You must use \c{cglobal} +before defining the symbol in question, but you would have had to do +that anyway if you used \c{GLOBAL}. + +Also see \k{opt-pfix}. + +\S{16cmodels} \i{Memory Models} + +NASM contains no mechanism to support the various C memory models +directly; you have to keep track yourself of which one you are +writing for. This means you have to keep track of the following +things: + +\b In models using a single code segment (tiny, small and compact), +functions are near. This means that function pointers, when stored +in data segments or pushed on the stack as function arguments, are +16 bits long and contain only an offset field (the \c{CS} register +never changes its value, and always gives the segment part of the +full function address), and that functions are called using ordinary +near \c{CALL} instructions and return using \c{RETN} (which, in +NASM, is synonymous with \c{RET} anyway). This means both that you +should write your own routines to return with \c{RETN}, and that you +should call external C routines with near \c{CALL} instructions. + +\b In models using more than one code segment (medium, large and +huge), functions are far. This means that function pointers are 32 +bits long (consisting of a 16-bit offset followed by a 16-bit +segment), and that functions are called using \c{CALL FAR} (or +\c{CALL seg:offset}) and return using \c{RETF}. Again, you should +therefore write your own routines to return with \c{RETF} and use +\c{CALL FAR} to call external routines. + +\b In models using a single data segment (tiny, small and medium), +data pointers are 16 bits long, containing only an offset field (the +\c{DS} register doesn't change its value, and always gives the +segment part of the full data item address). + +\b In models using more than one data segment (compact, large and +huge), data pointers are 32 bits long, consisting of a 16-bit offset +followed by a 16-bit segment. You should still be careful not to +modify \c{DS} in your routines without restoring it afterwards, but +\c{ES} is free for you to use to access the contents of 32-bit data +pointers you are passed. + +\b The huge memory model allows single data items to exceed 64K in +size. In all other memory models, you can access the whole of a data +item just by doing arithmetic on the offset field of the pointer you +are given, whether a segment field is present or not; in huge model, +you have to be more careful of your pointer arithmetic. + +\b In most memory models, there is a \e{default} data segment, whose +segment address is kept in \c{DS} throughout the program. This data +segment is typically the same segment as the stack, kept in \c{SS}, +so that functions' local variables (which are stored on the stack) +and global data items can both be accessed easily without changing +\c{DS}. Particularly large data items are typically stored in other +segments. However, some memory models (though not the standard +ones, usually) allow the assumption that \c{SS} and \c{DS} hold the +same value to be removed. Be careful about functions' local +variables in this latter case. + +In models with a single code segment, the segment is called +\i\c{_TEXT}, so your code segment must also go by this name in order +to be linked into the same place as the main code segment. In models +with a single data segment, or with a default data segment, it is +called \i\c{_DATA}. + + +\S{16cfunc} Function Definitions and Function Calls + +\I{functions, C calling convention}The \i{C calling convention} in +16-bit programs is as follows. In the following description, the +words \e{caller} and \e{callee} are used to denote the function +doing the calling and the function which gets called. + +\b The caller pushes the function's parameters on the stack, one +after another, in reverse order (right to left, so that the first +argument specified to the function is pushed last). + +\b The caller then executes a \c{CALL} instruction to pass control +to the callee. This \c{CALL} is either near or far depending on the +memory model. + +\b The callee receives control, and typically (although this is not +actually necessary, in functions which do not need to access their +parameters) starts by saving the value of \c{SP} in \c{BP} so as to +be able to use \c{BP} as a base pointer to find its parameters on +the stack. However, the caller was probably doing this too, so part +of the calling convention states that \c{BP} must be preserved by +any C function. Hence the callee, if it is going to set up \c{BP} as +a \i\e{frame pointer}, must push the previous value first. + +\b The callee may then access its parameters relative to \c{BP}. +The word at \c{[BP]} holds the previous value of \c{BP} as it was +pushed; the next word, at \c{[BP+2]}, holds the offset part of the +return address, pushed implicitly by \c{CALL}. In a small-model +(near) function, the parameters start after that, at \c{[BP+4]}; in +a large-model (far) function, the segment part of the return address +lives at \c{[BP+4]}, and the parameters begin at \c{[BP+6]}. The +leftmost parameter of the function, since it was pushed last, is +accessible at this offset from \c{BP}; the others follow, at +successively greater offsets. Thus, in a function such as \c{printf} +which takes a variable number of parameters, the pushing of the +parameters in reverse order means that the function knows where to +find its first parameter, which tells it the number and type of the +remaining ones. + +\b The callee may also wish to decrease \c{SP} further, so as to +allocate space on the stack for local variables, which will then be +accessible at negative offsets from \c{BP}. + +\b The callee, if it wishes to return a value to the caller, should +leave the value in \c{AL}, \c{AX} or \c{DX:AX} depending on the size +of the value. Floating-point results are sometimes (depending on the +compiler) returned in \c{ST0}. + +\b Once the callee has finished processing, it restores \c{SP} from +\c{BP} if it had allocated local stack space, then pops the previous +value of \c{BP}, and returns via \c{RETN} or \c{RETF} depending on +memory model. + +\b When the caller regains control from the callee, the function +parameters are still on the stack, so it typically adds an immediate +constant to \c{SP} to remove them (instead of executing a number of +slow \c{POP} instructions). Thus, if a function is accidentally +called with the wrong number of parameters due to a prototype +mismatch, the stack will still be returned to a sensible state since +the caller, which \e{knows} how many parameters it pushed, does the +removing. + +It is instructive to compare this calling convention with that for +Pascal programs (described in \k{16bpfunc}). Pascal has a simpler +convention, since no functions have variable numbers of parameters. +Therefore the callee knows how many parameters it should have been +passed, and is able to deallocate them from the stack itself by +passing an immediate argument to the \c{RET} or \c{RETF} +instruction, so the caller does not have to do it. Also, the +parameters are pushed in left-to-right order, not right-to-left, +which means that a compiler can give better guarantees about +sequence points without performance suffering. + +Thus, you would define a function in C style in the following way. +The following example is for small model: + +\c global _myfunc +\c +\c _myfunc: +\c push bp +\c mov bp,sp +\c sub sp,0x40 ; 64 bytes of local stack space +\c mov bx,[bp+4] ; first parameter to function +\c +\c ; some more code +\c +\c mov sp,bp ; undo "sub sp,0x40" above +\c pop bp +\c ret + +For a large-model function, you would replace \c{RET} by \c{RETF}, +and look for the first parameter at \c{[BP+6]} instead of +\c{[BP+4]}. Of course, if one of the parameters is a pointer, then +the offsets of \e{subsequent} parameters will change depending on +the memory model as well: far pointers take up four bytes on the +stack when passed as a parameter, whereas near pointers take up two. + +At the other end of the process, to call a C function from your +assembly code, you would do something like this: + +\c extern _printf +\c +\c ; and then, further down... +\c +\c push word [myint] ; one of my integer variables +\c push word mystring ; pointer into my data segment +\c call _printf +\c add sp,byte 4 ; `byte' saves space +\c +\c ; then those data items... +\c +\c segment _DATA +\c +\c myint dw 1234 +\c mystring db 'This number -> %d <- should be 1234',10,0 + +This piece of code is the small-model assembly equivalent of the C +code + +\c int myint = 1234; +\c printf("This number -> %d <- should be 1234\n", myint); + +In large model, the function-call code might look more like this. In +this example, it is assumed that \c{DS} already holds the segment +base of the segment \c{_DATA}. If not, you would have to initialize +it first. + +\c push word [myint] +\c push word seg mystring ; Now push the segment, and... +\c push word mystring ; ... offset of "mystring" +\c call far _printf +\c add sp,byte 6 + +The integer value still takes up one word on the stack, since large +model does not affect the size of the \c{int} data type. The first +argument (pushed last) to \c{printf}, however, is a data pointer, +and therefore has to contain a segment and offset part. The segment +should be stored second in memory, and therefore must be pushed +first. (Of course, \c{PUSH DS} would have been a shorter instruction +than \c{PUSH WORD SEG mystring}, if \c{DS} was set up as the above +example assumed.) Then the actual call becomes a far call, since +functions expect far calls in large model; and \c{SP} has to be +increased by 6 rather than 4 afterwards to make up for the extra +word of parameters. + + +\S{16cdata} Accessing Data Items + +To get at the contents of C variables, or to declare variables which +C can access, you need only declare the names as \c{GLOBAL} or +\c{EXTERN}. (Again, the names require leading underscores, as stated +in \k{16cunder}.) Thus, a C variable declared as \c{int i} can be +accessed from assembler as + +\c extern _i +\c +\c mov ax,[_i] + +And to declare your own integer variable which C programs can access +as \c{extern int j}, you do this (making sure you are assembling in +the \c{_DATA} segment, if necessary): + +\c global _j +\c +\c _j dw 0 + +To access a C array, you need to know the size of the components of +the array. For example, \c{int} variables are two bytes long, so if +a C program declares an array as \c{int a[10]}, you can access +\c{a[3]} by coding \c{mov ax,[_a+6]}. (The byte offset 6 is obtained +by multiplying the desired array index, 3, by the size of the array +element, 2.) The sizes of the C base types in 16-bit compilers are: +1 for \c{char}, 2 for \c{short} and \c{int}, 4 for \c{long} and +\c{float}, and 8 for \c{double}. + +To access a C \i{data structure}, you need to know the offset from +the base of the structure to the field you are interested in. You +can either do this by converting the C structure definition into a +NASM structure definition (using \i\c{STRUC}), or by calculating the +one offset and using just that. + +To do either of these, you should read your C compiler's manual to +find out how it organizes data structures. NASM gives no special +alignment to structure members in its own \c{STRUC} macro, so you +have to specify alignment yourself if the C compiler generates it. +Typically, you might find that a structure like + +\c struct { +\c char c; +\c int i; +\c } foo; + +might be four bytes long rather than three, since the \c{int} field +would be aligned to a two-byte boundary. However, this sort of +feature tends to be a configurable option in the C compiler, either +using command-line options or \c{#pragma} lines, so you have to find +out how your own compiler does it. + + +\S{16cmacro} \i\c{c16.mac}: Helper Macros for the 16-bit C Interface + +Included in the NASM archives, in the \I{misc subdirectory}\c{misc} +directory, is a file \c{c16.mac} of macros. It defines three macros: +\i\c{proc}, \i\c{arg} and \i\c{endproc}. These are intended to be +used for C-style procedure definitions, and they automate a lot of +the work involved in keeping track of the calling convention. + +(An alternative, TASM compatible form of \c{arg} is also now built +into NASM's preprocessor. See \k{stackrel} for details.) + +An example of an assembly function using the macro set is given +here: + +\c proc _nearproc +\c +\c %$i arg +\c %$j arg +\c mov ax,[bp + %$i] +\c mov bx,[bp + %$j] +\c add ax,[bx] +\c +\c endproc + +This defines \c{_nearproc} to be a procedure taking two arguments, +the first (\c{i}) an integer and the second (\c{j}) a pointer to an +integer. It returns \c{i + *j}. + +Note that the \c{arg} macro has an \c{EQU} as the first line of its +expansion, and since the label before the macro call gets prepended +to the first line of the expanded macro, the \c{EQU} works, defining +\c{%$i} to be an offset from \c{BP}. A context-local variable is +used, local to the context pushed by the \c{proc} macro and popped +by the \c{endproc} macro, so that the same argument name can be used +in later procedures. Of course, you don't \e{have} to do that. + +The macro set produces code for near functions (tiny, small and +compact-model code) by default. You can have it generate far +functions (medium, large and huge-model code) by means of coding +\I\c{FARCODE}\c{%define FARCODE}. This changes the kind of return +instruction generated by \c{endproc}, and also changes the starting +point for the argument offsets. The macro set contains no intrinsic +dependency on whether data pointers are far or not. + +\c{arg} can take an optional parameter, giving the size of the +argument. If no size is given, 2 is assumed, since it is likely that +many function parameters will be of type \c{int}. + +The large-model equivalent of the above function would look like this: + +\c %define FARCODE +\c +\c proc _farproc +\c +\c %$i arg +\c %$j arg 4 +\c mov ax,[bp + %$i] +\c mov bx,[bp + %$j] +\c mov es,[bp + %$j + 2] +\c add ax,[bx] +\c +\c endproc + +This makes use of the argument to the \c{arg} macro to define a +parameter of size 4, because \c{j} is now a far pointer. When we +load from \c{j}, we must load a segment and an offset. + + +\H{16bp} Interfacing to \i{Borland Pascal} Programs + +Interfacing to Borland Pascal programs is similar in concept to +interfacing to 16-bit C programs. The differences are: + +\b The leading underscore required for interfacing to C programs is +not required for Pascal. + +\b The memory model is always large: functions are far, data +pointers are far, and no data item can be more than 64K long. +(Actually, some functions are near, but only those functions that +are local to a Pascal unit and never called from outside it. All +assembly functions that Pascal calls, and all Pascal functions that +assembly routines are able to call, are far.) However, all static +data declared in a Pascal program goes into the default data +segment, which is the one whose segment address will be in \c{DS} +when control is passed to your assembly code. The only things that +do not live in the default data segment are local variables (they +live in the stack segment) and dynamically allocated variables. All +data \e{pointers}, however, are far. + +\b The function calling convention is different - described below. + +\b Some data types, such as strings, are stored differently. + +\b There are restrictions on the segment names you are allowed to +use - Borland Pascal will ignore code or data declared in a segment +it doesn't like the name of. The restrictions are described below. + + +\S{16bpfunc} The Pascal Calling Convention + +\I{functions, Pascal calling convention}\I{Pascal calling +convention}The 16-bit Pascal calling convention is as follows. In +the following description, the words \e{caller} and \e{callee} are +used to denote the function doing the calling and the function which +gets called. + +\b The caller pushes the function's parameters on the stack, one +after another, in normal order (left to right, so that the first +argument specified to the function is pushed first). + +\b The caller then executes a far \c{CALL} instruction to pass +control to the callee. + +\b The callee receives control, and typically (although this is not +actually necessary, in functions which do not need to access their +parameters) starts by saving the value of \c{SP} in \c{BP} so as to +be able to use \c{BP} as a base pointer to find its parameters on +the stack. However, the caller was probably doing this too, so part +of the calling convention states that \c{BP} must be preserved by +any function. Hence the callee, if it is going to set up \c{BP} as a +\i{frame pointer}, must push the previous value first. + +\b The callee may then access its parameters relative to \c{BP}. +The word at \c{[BP]} holds the previous value of \c{BP} as it was +pushed. The next word, at \c{[BP+2]}, holds the offset part of the +return address, and the next one at \c{[BP+4]} the segment part. The +parameters begin at \c{[BP+6]}. The rightmost parameter of the +function, since it was pushed last, is accessible at this offset +from \c{BP}; the others follow, at successively greater offsets. + +\b The callee may also wish to decrease \c{SP} further, so as to +allocate space on the stack for local variables, which will then be +accessible at negative offsets from \c{BP}. + +\b The callee, if it wishes to return a value to the caller, should +leave the value in \c{AL}, \c{AX} or \c{DX:AX} depending on the size +of the value. Floating-point results are returned in \c{ST0}. +Results of type \c{Real} (Borland's own custom floating-point data +type, not handled directly by the FPU) are returned in \c{DX:BX:AX}. +To return a result of type \c{String}, the caller pushes a pointer +to a temporary string before pushing the parameters, and the callee +places the returned string value at that location. The pointer is +not a parameter, and should not be removed from the stack by the +\c{RETF} instruction. + +\b Once the callee has finished processing, it restores \c{SP} from +\c{BP} if it had allocated local stack space, then pops the previous +value of \c{BP}, and returns via \c{RETF}. It uses the form of +\c{RETF} with an immediate parameter, giving the number of bytes +taken up by the parameters on the stack. This causes the parameters +to be removed from the stack as a side effect of the return +instruction. + +\b When the caller regains control from the callee, the function +parameters have already been removed from the stack, so it needs to +do nothing further. + +Thus, you would define a function in Pascal style, taking two +\c{Integer}-type parameters, in the following way: + +\c global myfunc +\c +\c myfunc: push bp +\c mov bp,sp +\c sub sp,0x40 ; 64 bytes of local stack space +\c mov bx,[bp+8] ; first parameter to function +\c mov bx,[bp+6] ; second parameter to function +\c +\c ; some more code +\c +\c mov sp,bp ; undo "sub sp,0x40" above +\c pop bp +\c retf 4 ; total size of params is 4 + +At the other end of the process, to call a Pascal function from your +assembly code, you would do something like this: + +\c extern SomeFunc +\c +\c ; and then, further down... +\c +\c push word seg mystring ; Now push the segment, and... +\c push word mystring ; ... offset of "mystring" +\c push word [myint] ; one of my variables +\c call far SomeFunc + +This is equivalent to the Pascal code + +\c procedure SomeFunc(String: PChar; Int: Integer); +\c SomeFunc(@mystring, myint); + + +\S{16bpseg} Borland Pascal \I{segment names, Borland Pascal}Segment +Name Restrictions + +Since Borland Pascal's internal unit file format is completely +different from \c{OBJ}, it only makes a very sketchy job of actually +reading and understanding the various information contained in a +real \c{OBJ} file when it links that in. Therefore an object file +intended to be linked to a Pascal program must obey a number of +restrictions: + +\b Procedures and functions must be in a segment whose name is +either \c{CODE}, \c{CSEG}, or something ending in \c{_TEXT}. + +\b initialized data must be in a segment whose name is either +\c{CONST} or something ending in \c{_DATA}. + +\b Uninitialized data must be in a segment whose name is either +\c{DATA}, \c{DSEG}, or something ending in \c{_BSS}. + +\b Any other segments in the object file are completely ignored. +\c{GROUP} directives and segment attributes are also ignored. + + +\S{16bpmacro} Using \i\c{c16.mac} With Pascal Programs + +The \c{c16.mac} macro package, described in \k{16cmacro}, can also +be used to simplify writing functions to be called from Pascal +programs, if you code \I\c{PASCAL}\c{%define PASCAL}. This +definition ensures that functions are far (it implies +\i\c{FARCODE}), and also causes procedure return instructions to be +generated with an operand. + +Defining \c{PASCAL} does not change the code which calculates the +argument offsets; you must declare your function's arguments in +reverse order. For example: + +\c %define PASCAL +\c +\c proc _pascalproc +\c +\c %$j arg 4 +\c %$i arg +\c mov ax,[bp + %$i] +\c mov bx,[bp + %$j] +\c mov es,[bp + %$j + 2] +\c add ax,[bx] +\c +\c endproc + +This defines the same routine, conceptually, as the example in +\k{16cmacro}: it defines a function taking two arguments, an integer +and a pointer to an integer, which returns the sum of the integer +and the contents of the pointer. The only difference between this +code and the large-model C version is that \c{PASCAL} is defined +instead of \c{FARCODE}, and that the arguments are declared in +reverse order. + + +\C{32bit} Writing 32-bit Code (Unix, Win32, DJGPP) + +This chapter attempts to cover some of the common issues involved +when writing 32-bit code, to run under \i{Win32} or Unix, or to be +linked with C code generated by a Unix-style C compiler such as +\i{DJGPP}. It covers how to write assembly code to interface with +32-bit C routines, and how to write position-independent code for +shared libraries. + +Almost all 32-bit code, and in particular all code running under +\c{Win32}, \c{DJGPP} or any of the PC Unix variants, runs in \I{flat +memory model}\e{flat} memory model. This means that the segment registers +and paging have already been set up to give you the same 32-bit 4Gb +address space no matter what segment you work relative to, and that +you should ignore all segment registers completely. When writing +flat-model application code, you never need to use a segment +override or modify any segment register, and the code-section +addresses you pass to \c{CALL} and \c{JMP} live in the same address +space as the data-section addresses you access your variables by and +the stack-section addresses you access local variables and procedure +parameters by. Every address is 32 bits long and contains only an +offset part. + + +\H{32c} Interfacing to 32-bit C Programs + +A lot of the discussion in \k{16c}, about interfacing to 16-bit C +programs, still applies when working in 32 bits. The absence of +memory models or segmentation worries simplifies things a lot. + + +\S{32cunder} External Symbol Names + +Most 32-bit C compilers share the convention used by 16-bit +compilers, that the names of all global symbols (functions or data) +they define are formed by prefixing an underscore to the name as it +appears in the C program. However, not all of them do: the \c{ELF} +specification states that C symbols do \e{not} have a leading +underscore on their assembly-language names. + +The older Linux \c{a.out} C compiler, all \c{Win32} compilers, +\c{DJGPP}, and \c{NetBSD} and \c{FreeBSD}, all use the leading +underscore; for these compilers, the macros \c{cextern} and +\c{cglobal}, as given in \k{16cunder}, will still work. For \c{ELF}, +though, the leading underscore should not be used. + +See also \k{opt-pfix}. + +\S{32cfunc} Function Definitions and Function Calls + +\I{functions, C calling convention}The \i{C calling convention} +in 32-bit programs is as follows. In the following description, +the words \e{caller} and \e{callee} are used to denote +the function doing the calling and the function which gets called. + +\b The caller pushes the function's parameters on the stack, one +after another, in reverse order (right to left, so that the first +argument specified to the function is pushed last). + +\b The caller then executes a near \c{CALL} instruction to pass +control to the callee. + +\b The callee receives control, and typically (although this is not +actually necessary, in functions which do not need to access their +parameters) starts by saving the value of \c{ESP} in \c{EBP} so as +to be able to use \c{EBP} as a base pointer to find its parameters +on the stack. However, the caller was probably doing this too, so +part of the calling convention states that \c{EBP} must be preserved +by any C function. Hence the callee, if it is going to set up +\c{EBP} as a \i{frame pointer}, must push the previous value first. + +\b The callee may then access its parameters relative to \c{EBP}. +The doubleword at \c{[EBP]} holds the previous value of \c{EBP} as +it was pushed; the next doubleword, at \c{[EBP+4]}, holds the return +address, pushed implicitly by \c{CALL}. The parameters start after +that, at \c{[EBP+8]}. The leftmost parameter of the function, since +it was pushed last, is accessible at this offset from \c{EBP}; the +others follow, at successively greater offsets. Thus, in a function +such as \c{printf} which takes a variable number of parameters, the +pushing of the parameters in reverse order means that the function +knows where to find its first parameter, which tells it the number +and type of the remaining ones. + +\b The callee may also wish to decrease \c{ESP} further, so as to +allocate space on the stack for local variables, which will then be +accessible at negative offsets from \c{EBP}. + +\b The callee, if it wishes to return a value to the caller, should +leave the value in \c{AL}, \c{AX} or \c{EAX} depending on the size +of the value. Floating-point results are typically returned in +\c{ST0}. + +\b Once the callee has finished processing, it restores \c{ESP} from +\c{EBP} if it had allocated local stack space, then pops the previous +value of \c{EBP}, and returns via \c{RET} (equivalently, \c{RETN}). + +\b When the caller regains control from the callee, the function +parameters are still on the stack, so it typically adds an immediate +constant to \c{ESP} to remove them (instead of executing a number of +slow \c{POP} instructions). Thus, if a function is accidentally +called with the wrong number of parameters due to a prototype +mismatch, the stack will still be returned to a sensible state since +the caller, which \e{knows} how many parameters it pushed, does the +removing. + +There is an alternative calling convention used by Win32 programs +for Windows API calls, and also for functions called \e{by} the +Windows API such as window procedures: they follow what Microsoft +calls the \c{__stdcall} convention. This is slightly closer to the +Pascal convention, in that the callee clears the stack by passing a +parameter to the \c{RET} instruction. However, the parameters are +still pushed in right-to-left order. + +Thus, you would define a function in C style in the following way: + +\c global _myfunc +\c +\c _myfunc: +\c push ebp +\c mov ebp,esp +\c sub esp,0x40 ; 64 bytes of local stack space +\c mov ebx,[ebp+8] ; first parameter to function +\c +\c ; some more code +\c +\c leave ; mov esp,ebp / pop ebp +\c ret + +At the other end of the process, to call a C function from your +assembly code, you would do something like this: + +\c extern _printf +\c +\c ; and then, further down... +\c +\c push dword [myint] ; one of my integer variables +\c push dword mystring ; pointer into my data segment +\c call _printf +\c add esp,byte 8 ; `byte' saves space +\c +\c ; then those data items... +\c +\c segment _DATA +\c +\c myint dd 1234 +\c mystring db 'This number -> %d <- should be 1234',10,0 + +This piece of code is the assembly equivalent of the C code + +\c int myint = 1234; +\c printf("This number -> %d <- should be 1234\n", myint); + + +\S{32cdata} Accessing Data Items + +To get at the contents of C variables, or to declare variables which +C can access, you need only declare the names as \c{GLOBAL} or +\c{EXTERN}. (Again, the names require leading underscores, as stated +in \k{32cunder}.) Thus, a C variable declared as \c{int i} can be +accessed from assembler as + +\c extern _i +\c mov eax,[_i] + +And to declare your own integer variable which C programs can access +as \c{extern int j}, you do this (making sure you are assembling in +the \c{_DATA} segment, if necessary): + +\c global _j +\c _j dd 0 + +To access a C array, you need to know the size of the components of +the array. For example, \c{int} variables are four bytes long, so if +a C program declares an array as \c{int a[10]}, you can access +\c{a[3]} by coding \c{mov ax,[_a+12]}. (The byte offset 12 is obtained +by multiplying the desired array index, 3, by the size of the array +element, 4.) The sizes of the C base types in 32-bit compilers are: +1 for \c{char}, 2 for \c{short}, 4 for \c{int}, \c{long} and +\c{float}, and 8 for \c{double}. Pointers, being 32-bit addresses, +are also 4 bytes long. + +To access a C \i{data structure}, you need to know the offset from +the base of the structure to the field you are interested in. You +can either do this by converting the C structure definition into a +NASM structure definition (using \c{STRUC}), or by calculating the +one offset and using just that. + +To do either of these, you should read your C compiler's manual to +find out how it organizes data structures. NASM gives no special +alignment to structure members in its own \i\c{STRUC} macro, so you +have to specify alignment yourself if the C compiler generates it. +Typically, you might find that a structure like + +\c struct { +\c char c; +\c int i; +\c } foo; + +might be eight bytes long rather than five, since the \c{int} field +would be aligned to a four-byte boundary. However, this sort of +feature is sometimes a configurable option in the C compiler, either +using command-line options or \c{#pragma} lines, so you have to find +out how your own compiler does it. + + +\S{32cmacro} \i\c{c32.mac}: Helper Macros for the 32-bit C Interface + +Included in the NASM archives, in the \I{misc directory}\c{misc} +directory, is a file \c{c32.mac} of macros. It defines three macros: +\i\c{proc}, \i\c{arg} and \i\c{endproc}. These are intended to be +used for C-style procedure definitions, and they automate a lot of +the work involved in keeping track of the calling convention. + +An example of an assembly function using the macro set is given +here: + +\c proc _proc32 +\c +\c %$i arg +\c %$j arg +\c mov eax,[ebp + %$i] +\c mov ebx,[ebp + %$j] +\c add eax,[ebx] +\c +\c endproc + +This defines \c{_proc32} to be a procedure taking two arguments, the +first (\c{i}) an integer and the second (\c{j}) a pointer to an +integer. It returns \c{i + *j}. + +Note that the \c{arg} macro has an \c{EQU} as the first line of its +expansion, and since the label before the macro call gets prepended +to the first line of the expanded macro, the \c{EQU} works, defining +\c{%$i} to be an offset from \c{BP}. A context-local variable is +used, local to the context pushed by the \c{proc} macro and popped +by the \c{endproc} macro, so that the same argument name can be used +in later procedures. Of course, you don't \e{have} to do that. + +\c{arg} can take an optional parameter, giving the size of the +argument. If no size is given, 4 is assumed, since it is likely that +many function parameters will be of type \c{int} or pointers. + + +\H{picdll} Writing NetBSD/FreeBSD/OpenBSD and Linux/ELF \i{Shared +Libraries} + +\c{ELF} replaced the older \c{a.out} object file format under Linux +because it contains support for \i{position-independent code} +(\i{PIC}), which makes writing shared libraries much easier. NASM +supports the \c{ELF} position-independent code features, so you can +write Linux \c{ELF} shared libraries in NASM. + +\i{NetBSD}, and its close cousins \i{FreeBSD} and \i{OpenBSD}, take +a different approach by hacking PIC support into the \c{a.out} +format. NASM supports this as the \i\c{aoutb} output format, so you +can write \i{BSD} shared libraries in NASM too. + +The operating system loads a PIC shared library by memory-mapping +the library file at an arbitrarily chosen point in the address space +of the running process. The contents of the library's code section +must therefore not depend on where it is loaded in memory. + +Therefore, you cannot get at your variables by writing code like +this: + +\c mov eax,[myvar] ; WRONG + +Instead, the linker provides an area of memory called the +\i\e{global offset table}, or \i{GOT}; the GOT is situated at a +constant distance from your library's code, so if you can find out +where your library is loaded (which is typically done using a +\c{CALL} and \c{POP} combination), you can obtain the address of the +GOT, and you can then load the addresses of your variables out of +linker-generated entries in the GOT. + +The \e{data} section of a PIC shared library does not have these +restrictions: since the data section is writable, it has to be +copied into memory anyway rather than just paged in from the library +file, so as long as it's being copied it can be relocated too. So +you can put ordinary types of relocation in the data section without +too much worry (but see \k{picglobal} for a caveat). + + +\S{picgot} Obtaining the Address of the GOT + +Each code module in your shared library should define the GOT as an +external symbol: + +\c extern _GLOBAL_OFFSET_TABLE_ ; in ELF +\c extern __GLOBAL_OFFSET_TABLE_ ; in BSD a.out + +At the beginning of any function in your shared library which plans +to access your data or BSS sections, you must first calculate the +address of the GOT. This is typically done by writing the function +in this form: + +\c func: push ebp +\c mov ebp,esp +\c push ebx +\c call .get_GOT +\c .get_GOT: +\c pop ebx +\c add ebx,_GLOBAL_OFFSET_TABLE_+$$-.get_GOT wrt ..gotpc +\c +\c ; the function body comes here +\c +\c mov ebx,[ebp-4] +\c mov esp,ebp +\c pop ebp +\c ret + +(For BSD, again, the symbol \c{_GLOBAL_OFFSET_TABLE} requires a +second leading underscore.) + +The first two lines of this function are simply the standard C +prologue to set up a stack frame, and the last three lines are +standard C function epilogue. The third line, and the fourth to last +line, save and restore the \c{EBX} register, because PIC shared +libraries use this register to store the address of the GOT. + +The interesting bit is the \c{CALL} instruction and the following +two lines. The \c{CALL} and \c{POP} combination obtains the address +of the label \c{.get_GOT}, without having to know in advance where +the program was loaded (since the \c{CALL} instruction is encoded +relative to the current position). The \c{ADD} instruction makes use +of one of the special PIC relocation types: \i{GOTPC relocation}. +With the \i\c{WRT ..gotpc} qualifier specified, the symbol +referenced (here \c{_GLOBAL_OFFSET_TABLE_}, the special symbol +assigned to the GOT) is given as an offset from the beginning of the +section. (Actually, \c{ELF} encodes it as the offset from the operand +field of the \c{ADD} instruction, but NASM simplifies this +deliberately, so you do things the same way for both \c{ELF} and +\c{BSD}.) So the instruction then \e{adds} the beginning of the section, +to get the real address of the GOT, and subtracts the value of +\c{.get_GOT} which it knows is in \c{EBX}. Therefore, by the time +that instruction has finished, \c{EBX} contains the address of the GOT. + +If you didn't follow that, don't worry: it's never necessary to +obtain the address of the GOT by any other means, so you can put +those three instructions into a macro and safely ignore them: + +\c %macro get_GOT 0 +\c +\c call %%getgot +\c %%getgot: +\c pop ebx +\c add ebx,_GLOBAL_OFFSET_TABLE_+$$-%%getgot wrt ..gotpc +\c +\c %endmacro + +\S{piclocal} Finding Your Local Data Items + +Having got the GOT, you can then use it to obtain the addresses of +your data items. Most variables will reside in the sections you have +declared; they can be accessed using the \I{GOTOFF +relocation}\c{..gotoff} special \I\c{WRT ..gotoff}\c{WRT} type. The +way this works is like this: + +\c lea eax,[ebx+myvar wrt ..gotoff] + +The expression \c{myvar wrt ..gotoff} is calculated, when the shared +library is linked, to be the offset to the local variable \c{myvar} +from the beginning of the GOT. Therefore, adding it to \c{EBX} as +above will place the real address of \c{myvar} in \c{EAX}. + +If you declare variables as \c{GLOBAL} without specifying a size for +them, they are shared between code modules in the library, but do +not get exported from the library to the program that loaded it. +They will still be in your ordinary data and BSS sections, so you +can access them in the same way as local variables, using the above +\c{..gotoff} mechanism. + +Note that due to a peculiarity of the way BSD \c{a.out} format +handles this relocation type, there must be at least one non-local +symbol in the same section as the address you're trying to access. + + +\S{picextern} Finding External and Common Data Items + +If your library needs to get at an external variable (external to +the \e{library}, not just to one of the modules within it), you must +use the \I{GOT relocations}\I\c{WRT ..got}\c{..got} type to get at +it. The \c{..got} type, instead of giving you the offset from the +GOT base to the variable, gives you the offset from the GOT base to +a GOT \e{entry} containing the address of the variable. The linker +will set up this GOT entry when it builds the library, and the +dynamic linker will place the correct address in it at load time. So +to obtain the address of an external variable \c{extvar} in \c{EAX}, +you would code + +\c mov eax,[ebx+extvar wrt ..got] + +This loads the address of \c{extvar} out of an entry in the GOT. The +linker, when it builds the shared library, collects together every +relocation of type \c{..got}, and builds the GOT so as to ensure it +has every necessary entry present. + +Common variables must also be accessed in this way. + + +\S{picglobal} Exporting Symbols to the Library User + +If you want to export symbols to the user of the library, you have +to declare whether they are functions or data, and if they are data, +you have to give the size of the data item. This is because the +dynamic linker has to build \I{PLT}\i{procedure linkage table} +entries for any exported functions, and also moves exported data +items away from the library's data section in which they were +declared. + +So to export a function to users of the library, you must use + +\c global func:function ; declare it as a function +\c +\c func: push ebp +\c +\c ; etc. + +And to export a data item such as an array, you would have to code + +\c global array:data array.end-array ; give the size too +\c +\c array: resd 128 +\c .end: + +Be careful: If you export a variable to the library user, by +declaring it as \c{GLOBAL} and supplying a size, the variable will +end up living in the data section of the main program, rather than +in your library's data section, where you declared it. So you will +have to access your own global variable with the \c{..got} mechanism +rather than \c{..gotoff}, as if it were external (which, +effectively, it has become). + +Equally, if you need to store the address of an exported global in +one of your data sections, you can't do it by means of the standard +sort of code: + +\c dataptr: dd global_data_item ; WRONG + +NASM will interpret this code as an ordinary relocation, in which +\c{global_data_item} is merely an offset from the beginning of the +\c{.data} section (or whatever); so this reference will end up +pointing at your data section instead of at the exported global +which resides elsewhere. + +Instead of the above code, then, you must write + +\c dataptr: dd global_data_item wrt ..sym + +which makes use of the special \c{WRT} type \I\c{WRT ..sym}\c{..sym} +to instruct NASM to search the symbol table for a particular symbol +at that address, rather than just relocating by section base. + +Either method will work for functions: referring to one of your +functions by means of + +\c funcptr: dd my_function + +will give the user the address of the code you wrote, whereas + +\c funcptr: dd my_function wrt .sym + +will give the address of the procedure linkage table for the +function, which is where the calling program will \e{believe} the +function lives. Either address is a valid way to call the function. + + +\S{picproc} Calling Procedures Outside the Library + +Calling procedures outside your shared library has to be done by +means of a \i\e{procedure linkage table}, or \i{PLT}. The PLT is +placed at a known offset from where the library is loaded, so the +library code can make calls to the PLT in a position-independent +way. Within the PLT there is code to jump to offsets contained in +the GOT, so function calls to other shared libraries or to routines +in the main program can be transparently passed off to their real +destinations. + +To call an external routine, you must use another special PIC +relocation type, \I{PLT relocations}\i\c{WRT ..plt}. This is much +easier than the GOT-based ones: you simply replace calls such as +\c{CALL printf} with the PLT-relative version \c{CALL printf WRT +..plt}. + + +\S{link} Generating the Library File + +Having written some code modules and assembled them to \c{.o} files, +you then generate your shared library with a command such as + +\c ld -shared -o library.so module1.o module2.o # for ELF +\c ld -Bshareable -o library.so module1.o module2.o # for BSD + +For ELF, if your shared library is going to reside in system +directories such as \c{/usr/lib} or \c{/lib}, it is usually worth +using the \i\c{-soname} flag to the linker, to store the final +library file name, with a version number, into the library: + +\c ld -shared -soname library.so.1 -o library.so.1.2 *.o + +You would then copy \c{library.so.1.2} into the library directory, +and create \c{library.so.1} as a symbolic link to it. + + +\C{mixsize} Mixing 16 and 32 Bit Code + +This chapter tries to cover some of the issues, largely related to +unusual forms of addressing and jump instructions, encountered when +writing operating system code such as protected-mode initialisation +routines, which require code that operates in mixed segment sizes, +such as code in a 16-bit segment trying to modify data in a 32-bit +one, or jumps between different-size segments. + + +\H{mixjump} Mixed-Size Jumps\I{jumps, mixed-size} + +\I{operating system, writing}\I{writing operating systems}The most +common form of \i{mixed-size instruction} is the one used when +writing a 32-bit OS: having done your setup in 16-bit mode, such as +loading the kernel, you then have to boot it by switching into +protected mode and jumping to the 32-bit kernel start address. In a +fully 32-bit OS, this tends to be the \e{only} mixed-size +instruction you need, since everything before it can be done in pure +16-bit code, and everything after it can be pure 32-bit. + +This jump must specify a 48-bit far address, since the target +segment is a 32-bit one. However, it must be assembled in a 16-bit +segment, so just coding, for example, + +\c jmp 0x1234:0x56789ABC ; wrong! + +will not work, since the offset part of the address will be +truncated to \c{0x9ABC} and the jump will be an ordinary 16-bit far +one. + +The Linux kernel setup code gets round the inability of \c{as86} to +generate the required instruction by coding it manually, using +\c{DB} instructions. NASM can go one better than that, by actually +generating the right instruction itself. Here's how to do it right: + +\c jmp dword 0x1234:0x56789ABC ; right + +\I\c{JMP DWORD}The \c{DWORD} prefix (strictly speaking, it should +come \e{after} the colon, since it is declaring the \e{offset} field +to be a doubleword; but NASM will accept either form, since both are +unambiguous) forces the offset part to be treated as far, in the +assumption that you are deliberately writing a jump from a 16-bit +segment to a 32-bit one. + +You can do the reverse operation, jumping from a 32-bit segment to a +16-bit one, by means of the \c{WORD} prefix: + +\c jmp word 0x8765:0x4321 ; 32 to 16 bit + +If the \c{WORD} prefix is specified in 16-bit mode, or the \c{DWORD} +prefix in 32-bit mode, they will be ignored, since each is +explicitly forcing NASM into a mode it was in anyway. + + +\H{mixaddr} Addressing Between Different-Size Segments\I{addressing, +mixed-size}\I{mixed-size addressing} + +If your OS is mixed 16 and 32-bit, or if you are writing a DOS +extender, you are likely to have to deal with some 16-bit segments +and some 32-bit ones. At some point, you will probably end up +writing code in a 16-bit segment which has to access data in a +32-bit segment, or vice versa. + +If the data you are trying to access in a 32-bit segment lies within +the first 64K of the segment, you may be able to get away with using +an ordinary 16-bit addressing operation for the purpose; but sooner +or later, you will want to do 32-bit addressing from 16-bit mode. + +The easiest way to do this is to make sure you use a register for +the address, since any effective address containing a 32-bit +register is forced to be a 32-bit address. So you can do + +\c mov eax,offset_into_32_bit_segment_specified_by_fs +\c mov dword [fs:eax],0x11223344 + +This is fine, but slightly cumbersome (since it wastes an +instruction and a register) if you already know the precise offset +you are aiming at. The x86 architecture does allow 32-bit effective +addresses to specify nothing but a 4-byte offset, so why shouldn't +NASM be able to generate the best instruction for the purpose? + +It can. As in \k{mixjump}, you need only prefix the address with the +\c{DWORD} keyword, and it will be forced to be a 32-bit address: + +\c mov dword [fs:dword my_offset],0x11223344 + +Also as in \k{mixjump}, NASM is not fussy about whether the +\c{DWORD} prefix comes before or after the segment override, so +arguably a nicer-looking way to code the above instruction is + +\c mov dword [dword fs:my_offset],0x11223344 + +Don't confuse the \c{DWORD} prefix \e{outside} the square brackets, +which controls the size of the data stored at the address, with the +one \c{inside} the square brackets which controls the length of the +address itself. The two can quite easily be different: + +\c mov word [dword 0x12345678],0x9ABC + +This moves 16 bits of data to an address specified by a 32-bit +offset. + +You can also specify \c{WORD} or \c{DWORD} prefixes along with the +\c{FAR} prefix to indirect far jumps or calls. For example: + +\c call dword far [fs:word 0x4321] + +This instruction contains an address specified by a 16-bit offset; +it loads a 48-bit far pointer from that (16-bit segment and 32-bit +offset), and calls that address. + + +\H{mixother} Other Mixed-Size Instructions + +The other way you might want to access data might be using the +string instructions (\c{LODSx}, \c{STOSx} and so on) or the +\c{XLATB} instruction. These instructions, since they take no +parameters, might seem to have no easy way to make them perform +32-bit addressing when assembled in a 16-bit segment. + +This is the purpose of NASM's \i\c{a16}, \i\c{a32} and \i\c{a64} prefixes. If +you are coding \c{LODSB} in a 16-bit segment but it is supposed to +be accessing a string in a 32-bit segment, you should load the +desired address into \c{ESI} and then code + +\c a32 lodsb + +The prefix forces the addressing size to 32 bits, meaning that +\c{LODSB} loads from \c{[DS:ESI]} instead of \c{[DS:SI]}. To access +a string in a 16-bit segment when coding in a 32-bit one, the +corresponding \c{a16} prefix can be used. + +The \c{a16}, \c{a32} and \c{a64} prefixes can be applied to any instruction +in NASM's instruction table, but most of them can generate all the +useful forms without them. The prefixes are necessary only for +instructions with implicit addressing: +\# \c{CMPSx} (\k{insCMPSB}), +\# \c{SCASx} (\k{insSCASB}), \c{LODSx} (\k{insLODSB}), \c{STOSx} +\# (\k{insSTOSB}), \c{MOVSx} (\k{insMOVSB}), \c{INSx} (\k{insINSB}), +\# \c{OUTSx} (\k{insOUTSB}), and \c{XLATB} (\k{insXLATB}). +\c{CMPSx}, \c{SCASx}, \c{LODSx}, \c{STOSx}, \c{MOVSx}, \c{INSx}, +\c{OUTSx}, and \c{XLATB}. +Also, the +various push and pop instructions (\c{PUSHA} and \c{POPF} as well as +the more usual \c{PUSH} and \c{POP}) can accept \c{a16}, \c{a32} or \c{a64} +prefixes to force a particular one of \c{SP}, \c{ESP} or \c{RSP} to be used +as a stack pointer, in case the stack segment in use is a different +size from the code segment. + +\c{PUSH} and \c{POP}, when applied to segment registers in 32-bit +mode, also have the slightly odd behaviour that they push and pop 4 +bytes at a time, of which the top two are ignored and the bottom two +give the value of the segment register being manipulated. To force +the 16-bit behaviour of segment-register push and pop instructions, +you can use the operand-size prefix \i\c{o16}: + +\c o16 push ss +\c o16 push ds + +This code saves a doubleword of stack space by fitting two segment +registers into the space which would normally be consumed by pushing +one. + +(You can also use the \i\c{o32} prefix to force the 32-bit behaviour +when in 16-bit mode, but this seems less useful.) + + +\C{64bit} Writing 64-bit Code (Unix, Win64) + +This chapter attempts to cover some of the common issues involved when +writing 64-bit code, to run under \i{Win64} or Unix. It covers how to +write assembly code to interface with 64-bit C routines, and how to +write position-independent code for shared libraries. + +All 64-bit code uses a flat memory model, since segmentation is not +available in 64-bit mode. The one exception is the \c{FS} and \c{GS} +registers, which still add their bases. + +Position independence in 64-bit mode is significantly simpler, since +the processor supports \c{RIP}-relative addressing directly; see the +\c{REL} keyword (\k{effaddr}). On most 64-bit platforms, it is +probably desirable to make that the default, using the directive +\c{DEFAULT REL} (\k{default}). + +64-bit programming is relatively similar to 32-bit programming, but +of course pointers are 64 bits long; additionally, all existing +platforms pass arguments in registers rather than on the stack. +Furthermore, 64-bit platforms use SSE2 by default for floating point. +Please see the ABI documentation for your platform. + +64-bit platforms differ in the sizes of the fundamental datatypes, not +just from 32-bit platforms but from each other. If a specific size +data type is desired, it is probably best to use the types defined in +the Standard C header \c{<inttypes.h>}. + +In 64-bit mode, the default instruction size is still 32 bits. When +loading a value into a 32-bit register (but not an 8- or 16-bit +register), the upper 32 bits of the corresponding 64-bit register are +set to zero. + +\H{reg64} Register Names in 64-bit Mode + +NASM uses the following names for general-purpose registers in 64-bit +mode, for 8-, 16-, 32- and 64-bit references, respecitively: + +\c AL/AH, CL/CH, DL/DH, BL/BH, SPL, BPL, SIL, DIL, R8B-R15B +\c AX, CX, DX, BX, SP, BP, SI, DI, R8W-R15W +\c EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI, R8D-R15D +\c RAX, RCX, RDX, RBX, RSP, RBP, RSI, RDI, R8-R15 + +This is consistent with the AMD documentation and most other +assemblers. The Intel documentation, however, uses the names +\c{R8L-R15L} for 8-bit references to the higher registers. It is +possible to use those names by definiting them as macros; similarly, +if one wants to use numeric names for the low 8 registers, define them +as macros. The standard macro package \c{altreg} (see \k{pkg_altreg}) +can be used for this purpose. + +\H{id64} Immediates and Displacements in 64-bit Mode + +In 64-bit mode, immediates and displacements are generally only 32 +bits wide. NASM will therefore truncate most displacements and +immediates to 32 bits. + +The only instruction which takes a full \i{64-bit immediate} is: + +\c MOV reg64,imm64 + +NASM will produce this instruction whenever the programmer uses +\c{MOV} with an immediate into a 64-bit register. If this is not +desirable, simply specify the equivalent 32-bit register, which will +be automatically zero-extended by the processor, or specify the +immediate as \c{DWORD}: + +\c mov rax,foo ; 64-bit immediate +\c mov rax,qword foo ; (identical) +\c mov eax,foo ; 32-bit immediate, zero-extended +\c mov rax,dword foo ; 32-bit immediate, sign-extended + +The length of these instructions are 10, 5 and 7 bytes, respectively. + +The only instructions which take a full \I{64-bit displacement}64-bit +\e{displacement} is loading or storing, using \c{MOV}, \c{AL}, \c{AX}, +\c{EAX} or \c{RAX} (but no other registers) to an absolute 64-bit address. +Since this is a relatively rarely used instruction (64-bit code generally uses +relative addressing), the programmer has to explicitly declare the +displacement size as \c{QWORD}: + +\c default abs +\c +\c mov eax,[foo] ; 32-bit absolute disp, sign-extended +\c mov eax,[a32 foo] ; 32-bit absolute disp, zero-extended +\c mov eax,[qword foo] ; 64-bit absolute disp +\c +\c default rel +\c +\c mov eax,[foo] ; 32-bit relative disp +\c mov eax,[a32 foo] ; d:o, address truncated to 32 bits(!) +\c mov eax,[qword foo] ; error +\c mov eax,[abs qword foo] ; 64-bit absolute disp + +A sign-extended absolute displacement can access from -2 GB to +2 GB; +a zero-extended absolute displacement can access from 0 to 4 GB. + +\H{unix64} Interfacing to 64-bit C Programs (Unix) + +On Unix, the 64-bit ABI is defined by the document: + +\W{http://www.x86-64.org/documentation/abi.pdf}\c{http://www.x86-64.org/documentation/abi.pdf} + +Although written for AT&T-syntax assembly, the concepts apply equally +well for NASM-style assembly. What follows is a simplified summary. + +The first six integer arguments (from the left) are passed in \c{RDI}, +\c{RSI}, \c{RDX}, \c{RCX}, \c{R8}, and \c{R9}, in that order. +Additional integer arguments are passed on the stack. These +registers, plus \c{RAX}, \c{R10} and \c{R11} are destroyed by function +calls, and thus are available for use by the function without saving. + +Integer return values are passed in \c{RAX} and \c{RDX}, in that order. + +Floating point is done using SSE registers, except for \c{long +double}. Floating-point arguments are passed in \c{XMM0} to \c{XMM7}; +return is \c{XMM0} and \c{XMM1}. \c{long double} are passed on the +stack, and returned in \c{ST0} and \c{ST1}. + +All SSE and x87 registers are destroyed by function calls. + +On 64-bit Unix, \c{long} is 64 bits. + +Integer and SSE register arguments are counted separately, so for the case of + +\c void foo(long a, double b, int c) + +\c{a} is passed in \c{RDI}, \c{b} in \c{XMM0}, and \c{c} in \c{ESI}. + +\H{win64} Interfacing to 64-bit C Programs (Win64) + +The Win64 ABI is described at: + +\W{http://msdn2.microsoft.com/en-gb/library/ms794533.aspx}\c{http://msdn2.microsoft.com/en-gb/library/ms794533.aspx} + +What follows is a simplified summary. + +The first four integer arguments are passed in \c{RCX}, \c{RDX}, +\c{R8} and \c{R9}, in that order. Additional integer arguments are +passed on the stack. These registers, plus \c{RAX}, \c{R10} and +\c{R11} are destroyed by function calls, and thus are available for +use by the function without saving. + +Integer return values are passed in \c{RAX} only. + +Floating point is done using SSE registers, except for \c{long +double}. Floating-point arguments are passed in \c{XMM0} to \c{XMM3}; +return is \c{XMM0} only. + +On Win64, \c{long} is 32 bits; \c{long long} or \c{_int64} is 64 bits. + +Integer and SSE register arguments are counted together, so for the case of + +\c void foo(long long a, double b, int c) + +\c{a} is passed in \c{RCX}, \c{b} in \c{XMM1}, and \c{c} in \c{R8D}. + +\C{trouble} Troubleshooting + +This chapter describes some of the common problems that users have +been known to encounter with NASM, and answers them. It also gives +instructions for reporting bugs in NASM if you find a difficulty +that isn't listed here. + + +\H{problems} Common Problems + +\S{inefficient} NASM Generates \i{Inefficient Code} + +We sometimes get `bug' reports about NASM generating inefficient, or +even `wrong', code on instructions such as \c{ADD ESP,8}. This is a +deliberate design feature, connected to predictability of output: +NASM, on seeing \c{ADD ESP,8}, will generate the form of the +instruction which leaves room for a 32-bit offset. You need to code +\I\c{BYTE}\c{ADD ESP,BYTE 8} if you want the space-efficient form of +the instruction. This isn't a bug, it's user error: if you prefer to +have NASM produce the more efficient code automatically enable +optimization with the \c{-O} option (see \k{opt-O}). + + +\S{jmprange} My Jumps are Out of Range\I{out of range, jumps} + +Similarly, people complain that when they issue \i{conditional +jumps} (which are \c{SHORT} by default) that try to jump too far, +NASM reports `short jump out of range' instead of making the jumps +longer. + +This, again, is partly a predictability issue, but in fact has a +more practical reason as well. NASM has no means of being told what +type of processor the code it is generating will be run on; so it +cannot decide for itself that it should generate \i\c{Jcc NEAR} type +instructions, because it doesn't know that it's working for a 386 or +above. Alternatively, it could replace the out-of-range short +\c{JNE} instruction with a very short \c{JE} instruction that jumps +over a \c{JMP NEAR}; this is a sensible solution for processors +below a 386, but hardly efficient on processors which have good +branch prediction \e{and} could have used \c{JNE NEAR} instead. So, +once again, it's up to the user, not the assembler, to decide what +instructions should be generated. See \k{opt-O}. + + +\S{proborg} \i\c{ORG} Doesn't Work + +People writing \i{boot sector} programs in the \c{bin} format often +complain that \c{ORG} doesn't work the way they'd like: in order to +place the \c{0xAA55} signature word at the end of a 512-byte boot +sector, people who are used to MASM tend to code + +\c ORG 0 +\c +\c ; some boot sector code +\c +\c ORG 510 +\c DW 0xAA55 + +This is not the intended use of the \c{ORG} directive in NASM, and +will not work. The correct way to solve this problem in NASM is to +use the \i\c{TIMES} directive, like this: + +\c ORG 0 +\c +\c ; some boot sector code +\c +\c TIMES 510-($-$$) DB 0 +\c DW 0xAA55 + +The \c{TIMES} directive will insert exactly enough zero bytes into +the output to move the assembly point up to 510. This method also +has the advantage that if you accidentally fill your boot sector too +full, NASM will catch the problem at assembly time and report it, so +you won't end up with a boot sector that you have to disassemble to +find out what's wrong with it. + + +\S{probtimes} \i\c{TIMES} Doesn't Work + +The other common problem with the above code is people who write the +\c{TIMES} line as + +\c TIMES 510-$ DB 0 + +by reasoning that \c{$} should be a pure number, just like 510, so +the difference between them is also a pure number and can happily be +fed to \c{TIMES}. + +NASM is a \e{modular} assembler: the various component parts are +designed to be easily separable for re-use, so they don't exchange +information unnecessarily. In consequence, the \c{bin} output +format, even though it has been told by the \c{ORG} directive that +the \c{.text} section should start at 0, does not pass that +information back to the expression evaluator. So from the +evaluator's point of view, \c{$} isn't a pure number: it's an offset +from a section base. Therefore the difference between \c{$} and 510 +is also not a pure number, but involves a section base. Values +involving section bases cannot be passed as arguments to \c{TIMES}. + +The solution, as in the previous section, is to code the \c{TIMES} +line in the form + +\c TIMES 510-($-$$) DB 0 + +in which \c{$} and \c{$$} are offsets from the same section base, +and so their difference is a pure number. This will solve the +problem and generate sensible code. + + +\H{bugs} \i{Bugs}\I{reporting bugs} + +We have never yet released a version of NASM with any \e{known} +bugs. That doesn't usually stop there being plenty we didn't know +about, though. Any that you find should be reported firstly via the +\i\c{bugtracker} at +\W{https://sourceforge.net/projects/nasm/}\c{https://sourceforge.net/projects/nasm/} +(click on "Bugs"), or if that fails then through one of the +contacts in \k{contact}. + +Please read \k{qstart} first, and don't report the bug if it's +listed in there as a deliberate feature. (If you think the feature +is badly thought out, feel free to send us reasons why you think it +should be changed, but don't just send us mail saying `This is a +bug' if the documentation says we did it on purpose.) Then read +\k{problems}, and don't bother reporting the bug if it's listed +there. + +If you do report a bug, \e{please} give us all of the following +information: + +\b What operating system you're running NASM under. DOS, Linux, +NetBSD, Win16, Win32, VMS (I'd be impressed), whatever. + +\b If you're running NASM under DOS or Win32, tell us whether you've +compiled your own executable from the DOS source archive, or whether +you were using the standard distribution binaries out of the +archive. If you were using a locally built executable, try to +reproduce the problem using one of the standard binaries, as this +will make it easier for us to reproduce your problem prior to fixing +it. + +\b Which version of NASM you're using, and exactly how you invoked +it. Give us the precise command line, and the contents of the +\c{NASMENV} environment variable if any. + +\b Which versions of any supplementary programs you're using, and +how you invoked them. If the problem only becomes visible at link +time, tell us what linker you're using, what version of it you've +got, and the exact linker command line. If the problem involves +linking against object files generated by a compiler, tell us what +compiler, what version, and what command line or options you used. +(If you're compiling in an IDE, please try to reproduce the problem +with the command-line version of the compiler.) + +\b If at all possible, send us a NASM source file which exhibits the +problem. If this causes copyright problems (e.g. you can only +reproduce the bug in restricted-distribution code) then bear in mind +the following two points: firstly, we guarantee that any source code +sent to us for the purposes of debugging NASM will be used \e{only} +for the purposes of debugging NASM, and that we will delete all our +copies of it as soon as we have found and fixed the bug or bugs in +question; and secondly, we would prefer \e{not} to be mailed large +chunks of code anyway. The smaller the file, the better. A +three-line sample file that does nothing useful \e{except} +demonstrate the problem is much easier to work with than a +fully fledged ten-thousand-line program. (Of course, some errors +\e{do} only crop up in large files, so this may not be possible.) + +\b A description of what the problem actually \e{is}. `It doesn't +work' is \e{not} a helpful description! Please describe exactly what +is happening that shouldn't be, or what isn't happening that should. +Examples might be: `NASM generates an error message saying Line 3 +for an error that's actually on Line 5'; `NASM generates an error +message that I believe it shouldn't be generating at all'; `NASM +fails to generate an error message that I believe it \e{should} be +generating'; `the object file produced from this source code crashes +my linker'; `the ninth byte of the output file is 66 and I think it +should be 77 instead'. + +\b If you believe the output file from NASM to be faulty, send it to +us. That allows us to determine whether our own copy of NASM +generates the same file, or whether the problem is related to +portability issues between our development platforms and yours. We +can handle binary files mailed to us as MIME attachments, uuencoded, +and even BinHex. Alternatively, we may be able to provide an FTP +site you can upload the suspect files to; but mailing them is easier +for us. + +\b Any other information or data files that might be helpful. If, +for example, the problem involves NASM failing to generate an object +file while TASM can generate an equivalent file without trouble, +then send us \e{both} object files, so we can see what TASM is doing +differently from us. + + +\A{ndisasm} \i{Ndisasm} + + The Netwide Disassembler, NDISASM + +\H{ndisintro} Introduction + + +The Netwide Disassembler is a small companion program to the Netwide +Assembler, NASM. It seemed a shame to have an x86 assembler, +complete with a full instruction table, and not make as much use of +it as possible, so here's a disassembler which shares the +instruction table (and some other bits of code) with NASM. + +The Netwide Disassembler does nothing except to produce +disassemblies of \e{binary} source files. NDISASM does not have any +understanding of object file formats, like \c{objdump}, and it will +not understand \c{DOS .EXE} files like \c{debug} will. It just +disassembles. + + +\H{ndisstart} Getting Started: Installation + +See \k{install} for installation instructions. NDISASM, like NASM, +has a \c{man page} which you may want to put somewhere useful, if you +are on a Unix system. + + +\H{ndisrun} Running NDISASM + +To disassemble a file, you will typically use a command of the form + +\c ndisasm -b {16|32|64} filename + +NDISASM can disassemble 16-, 32- or 64-bit code equally easily, +provided of course that you remember to specify which it is to work +with. If no \i\c{-b} switch is present, NDISASM works in 16-bit mode +by default. The \i\c{-u} switch (for USE32) also invokes 32-bit mode. + +Two more command line options are \i\c{-r} which reports the version +number of NDISASM you are running, and \i\c{-h} which gives a short +summary of command line options. + + +\S{ndiscom} COM Files: Specifying an Origin + +To disassemble a \c{DOS .COM} file correctly, a disassembler must assume +that the first instruction in the file is loaded at address \c{0x100}, +rather than at zero. NDISASM, which assumes by default that any file +you give it is loaded at zero, will therefore need to be informed of +this. + +The \i\c{-o} option allows you to declare a different origin for the +file you are disassembling. Its argument may be expressed in any of +the NASM numeric formats: decimal by default, if it begins with `\c{$}' +or `\c{0x}' or ends in `\c{H}' it's \c{hex}, if it ends in `\c{Q}' it's +\c{octal}, and if it ends in `\c{B}' it's \c{binary}. + +Hence, to disassemble a \c{.COM} file: + +\c ndisasm -o100h filename.com + +will do the trick. + + +\S{ndissync} Code Following Data: Synchronisation + +Suppose you are disassembling a file which contains some data which +isn't machine code, and \e{then} contains some machine code. NDISASM +will faithfully plough through the data section, producing machine +instructions wherever it can (although most of them will look +bizarre, and some may have unusual prefixes, e.g. `\c{FS OR AX,0x240A}'), +and generating `DB' instructions ever so often if it's totally stumped. +Then it will reach the code section. + +Supposing NDISASM has just finished generating a strange machine +instruction from part of the data section, and its file position is +now one byte \e{before} the beginning of the code section. It's +entirely possible that another spurious instruction will get +generated, starting with the final byte of the data section, and +then the correct first instruction in the code section will not be +seen because the starting point skipped over it. This isn't really +ideal. + +To avoid this, you can specify a `\i\c{synchronisation}' point, or indeed +as many synchronisation points as you like (although NDISASM can +only handle 2147483647 sync points internally). The definition of a sync +point is this: NDISASM guarantees to hit sync points exactly during +disassembly. If it is thinking about generating an instruction which +would cause it to jump over a sync point, it will discard that +instruction and output a `\c{db}' instead. So it \e{will} start +disassembly exactly from the sync point, and so you \e{will} see all +the instructions in your code section. + +Sync points are specified using the \i\c{-s} option: they are measured +in terms of the program origin, not the file position. So if you +want to synchronize after 32 bytes of a \c{.COM} file, you would have to +do + +\c ndisasm -o100h -s120h file.com + +rather than + +\c ndisasm -o100h -s20h file.com + +As stated above, you can specify multiple sync markers if you need +to, just by repeating the \c{-s} option. + + +\S{ndisisync} Mixed Code and Data: Automatic (Intelligent) Synchronisation +\I\c{auto-sync} + +Suppose you are disassembling the boot sector of a \c{DOS} floppy (maybe +it has a virus, and you need to understand the virus so that you +know what kinds of damage it might have done you). Typically, this +will contain a \c{JMP} instruction, then some data, then the rest of the +code. So there is a very good chance of NDISASM being \e{misaligned} +when the data ends and the code begins. Hence a sync point is +needed. + +On the other hand, why should you have to specify the sync point +manually? What you'd do in order to find where the sync point would +be, surely, would be to read the \c{JMP} instruction, and then to use +its target address as a sync point. So can NDISASM do that for you? + +The answer, of course, is yes: using either of the synonymous +switches \i\c{-a} (for automatic sync) or \i\c{-i} (for intelligent +sync) will enable \c{auto-sync} mode. Auto-sync mode automatically +generates a sync point for any forward-referring PC-relative jump or +call instruction that NDISASM encounters. (Since NDISASM is one-pass, +if it encounters a PC-relative jump whose target has already been +processed, there isn't much it can do about it...) + +Only PC-relative jumps are processed, since an absolute jump is +either through a register (in which case NDISASM doesn't know what +the register contains) or involves a segment address (in which case +the target code isn't in the same segment that NDISASM is working +in, and so the sync point can't be placed anywhere useful). + +For some kinds of file, this mechanism will automatically put sync +points in all the right places, and save you from having to place +any sync points manually. However, it should be stressed that +auto-sync mode is \e{not} guaranteed to catch all the sync points, and +you may still have to place some manually. + +Auto-sync mode doesn't prevent you from declaring manual sync +points: it just adds automatically generated ones to the ones you +provide. It's perfectly feasible to specify \c{-i} \e{and} some \c{-s} +options. + +Another caveat with auto-sync mode is that if, by some unpleasant +fluke, something in your data section should disassemble to a +PC-relative call or jump instruction, NDISASM may obediently place a +sync point in a totally random place, for example in the middle of +one of the instructions in your code section. So you may end up with +a wrong disassembly even if you use auto-sync. Again, there isn't +much I can do about this. If you have problems, you'll have to use +manual sync points, or use the \c{-k} option (documented below) to +suppress disassembly of the data area. + + +\S{ndisother} Other Options + +The \i\c{-e} option skips a header on the file, by ignoring the first N +bytes. This means that the header is \e{not} counted towards the +disassembly offset: if you give \c{-e10 -o10}, disassembly will start +at byte 10 in the file, and this will be given offset 10, not 20. + +The \i\c{-k} option is provided with two comma-separated numeric +arguments, the first of which is an assembly offset and the second +is a number of bytes to skip. This \e{will} count the skipped bytes +towards the assembly offset: its use is to suppress disassembly of a +data section which wouldn't contain anything you wanted to see +anyway. + + +\H{ndisbugs} Bugs and Improvements + +There are no known bugs. However, any you find, with patches if +possible, should be sent to +\W{mailto:nasm-bugs@lists.sourceforge.net}\c{nasm-bugs@lists.sourceforge.net}, or to the +developer's site at +\W{https://sourceforge.net/projects/nasm/}\c{https://sourceforge.net/projects/nasm/} +and we'll try to fix them. Feel free to send contributions and +new features as well. + +\A{inslist} \i{Instruction List} + +\H{inslistintro} Introduction + +The following sections show the instructions which NASM currently supports. For each +instruction, there is a separate entry for each supported addressing mode. The third +column shows the processor type in which the instruction was introduced and, + when appropriate, one or more usage flags. + +\& inslist.src + +\A{changelog} \i{NASM Version History} + +\& changes.src + diff --git a/doc/nasmlogo.eps b/doc/nasmlogo.eps new file mode 100644 index 0000000..deb5a2c --- /dev/null +++ b/doc/nasmlogo.eps @@ -0,0 +1,35 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%BoundingBox: 99 45 385 111 +%%DocumentData: Clean7Bit +%%DocumentFonts: Courier-Bold +%%DocumentNeededFonts: Courier-Bold +%%Title: (NASM logo) +%%EndComments +%%Page 1 1 +%%BeginPageSetup +save +newpath +%%EndPageSetup +% x y pointsize -- +/nasmlogo { +gsave 1 dict begin +/sz exch def +/Courier-Bold findfont sz scalefont setfont +moveto +0.85 1.22 scale +[(-~~..~:#;L .-:#;L,.- .~:#:;.T -~~.~:;. .~:;. ) +( E8+U *T +U' *T# .97 *L E8+' *;T' *;, ) +( D97 `*L .97 '*L "T;E+:, D9 *L *L ) +( H7 I# T7 I# "*:. H7 I# I# ) +( U: :8 *#+ , :8 T, 79 U: :8 :8 ) +(,#B. .IE, "T;E* .IE, J *+;#:T*" ,#B. .IE, .IE,)] { +currentpoint 3 -1 roll +sz -0.10 mul 0 3 -1 roll ashow +sz 0.72 mul sub moveto +} forall +end grestore +} def +0.6 setgray 100 100 12 nasmlogo +%%PageTrailer +restore +%%EOF diff --git a/doc/opt_var.txt b/doc/opt_var.txt new file mode 100644 index 0000000..4482e5d --- /dev/null +++ b/doc/opt_var.txt @@ -0,0 +1,114 @@ + NASM Optimizer Usage of + Certain Variables to Control Assembly + + prepared by: John R Coffman + date: 07-Mar-2005 + + +GLOBAL variables: + optimizing -1 flags nasm 0.98 compatible operation; + offsets usually are explicit (short/near) + no optimization passes + 0 flags non-optimized assembly; forward + references generate long offsets; always + assembles + no optimization passes + 2 or more specifies optmization passes. 5 is + the actual recommended minimum setting + optimization passes (2 or more, plus + passes 1 and 2 will be required) + + + pass0 0 flags an optimizer pass (multiple passes) + 1 flags pass1 (define labels) + 2 flags pass2 (spit out code) + + +LOCAL variables: local to 'assemble_file' (nasm.c) + + pass_max 2 for non-optimized assembly + 4 or more for optimized assembly + + pass index of the FOR loop (1..pass_max) + with optimized assembly, this variable is + advanced to 'pass_max - 1' in the logic + at the end of the loop to terminate + an optimized assembly before all passes + are used; i.e., when convergence has + occurred + + + pass1 flag for making parts of the assembler do + pass 1 behaviors on optimizer passes + + pass2 flag for making parts of the assembler do + pass 2 behaviors on optimizer passes + + pass_cnt benign counter for counting the actual + number of passes taken. Since 'pass' + may be jerked upward early on optimized + assembly, it does not accurately reflect + the number of passes taken. + always ends at 2 for non-optimized assembly + + + + How the variables sequence: + + +NON-OPTIMIZED assembly: + + + pass0 1 2 all indicate, pass 1 and pass 2 + pass1 1 2 + pass2 1 2 + + pass 1 2 + ---------------------------------------- + + pass_max pre-set to 2 + pass_cnt ends at 2 + + +OPTIMIZED assembly: + + optimizing set to 2 or greater + + pass0 0 0 0 0 0 ... 0 0 1 2 + pass1 1 1 1 1 1 ... 1 1 1 2 + pass2 1 2 2 2 2 ... 2 2 2 2 + + pass 1 2 3 4 5 ... 7 8 9 12 + + pass_max pre-set to, say, 12 + pass_cnt ends at 10 for this assembly + +>From pass_cnt, the reported number of passes will be 1+8+1, meaning +8 optimization passes, plus pass 1, plus pass 2. + +Subroutines may check 'pass0' to see if an optimizer pass is in +progress (pass0==0). Many have arguments to tell what pass is in +progress. But these variables are passed in as 'pass1' or 'pass2'. + +>From the sequences above, 'pass' bears no relation to the desired +pass 1 or pass 2 behavior of the assembler. 'pass1' is used to tell +parts of the assembler, on multiple occasions, that pass 1 is in +progress, and only once that pass 2 is being performed. Other parts +of the assembler need to be told only once that pass 1 is being +performed, but may be told multiple times that pass 2 is being done. + +For instance, the preprocessor reset operation looks at pass1, and it +thinks many pass 1 resets are being done, but only one pass 2 reset +is done. Also, certain errors are non-fatal on pass 1, but fatal on +pass 2; hence, they are tied to the 'pass1' variable to determine the +assembler pass number. + +Further, segment definitions look at the 'pass2' variable, since they +do some initialization on pass 1, but are pretty much no-ops on pass +2. Hence, they should see pass 1 only once, but may see pass 2 +multiple times. + + + +[end] + diff --git a/doc/psfonts.ph b/doc/psfonts.ph new file mode 100644 index 0000000..8d2f4e6 --- /dev/null +++ b/doc/psfonts.ph @@ -0,0 +1,112 @@ +#!/usr/bin/perl +# +# Font metrics for the PS code generator +# + +# These files are generated from AFM files +require 'metrics/ptmr8a.ph'; # Times-Roman +require 'metrics/ptmb8a.ph'; # Times-Bold +require 'metrics/ptmri8a.ph'; # Times-Italic +require 'metrics/ptmbi8a.ph'; # Times-BoldItalic +require 'metrics/pcrr8a.ph'; # Courier +require 'metrics/pcrb8a.ph'; # Courier-Bold +require 'metrics/phvr8a.ph'; # Helvetica +require 'metrics/phvro8a.ph'; # Helvetica-Oblique +require 'metrics/phvb8a.ph'; # Helvetica-Bold +require 'metrics/phvbo8a.ph'; # Helvetica-BoldOblique + +# The fonts we want to use for various things +# The order is: <normal> <emphatic> <code> + +if ( 1 ) { + # Times family fonts + + %TitlFont = (name => 'tfont', + leading => 22, + fonts => [[20,\%PS_Times_Bold], + [20,\%PS_Times_BoldItalic], + [20,\%PS_Courier_Bold]]); + %ChapFont = (name => 'cfont', + leading => 19.2, + fonts => [[18,\%PS_Times_Bold], + [18,\%PS_Times_BoldItalic], + [18,\%PS_Courier_Bold]]); + %HeadFont = (name => 'hfont', + leading => 15.4, + fonts => [[14,\%PS_Times_Bold], + [14,\%PS_Times_BoldItalic], + [14,\%PS_Courier_Bold]]); + %SubhFont = (name => 'sfont', + leading => 13.2, + fonts => [[12,\%PS_Times_Bold], + [12,\%PS_Times_BoldItalic], + [12,\%PS_Courier_Bold]]); + %BodyFont = (name => 'bfont', + leading => 11, + fonts => [[10,\%PS_Times_Roman], + [10,\%PS_Times_Italic], + [10,\%PS_Courier]]); +} elsif ( 0 ) { + # Helvetica family fonts + + %TitlFont = (name => 'tfont', + leading => 22, + fonts => [[20,\%PS_Helvetica_Bold], + [20,\%PS_Helvetica_BoldOblique], + [20,\%PS_Courier_Bold]]); + %ChapFont = (name => 'cfont', + leading => 19.2, + fonts => [[18,\%PS_Helvetica_Bold], + [18,\%PS_Helvetica_BoldOblique], + [18,\%PS_Courier_Bold]]); + %HeadFont = (name => 'hfont', + leading => 15.4, + fonts => [[14,\%PS_Helvetica_Bold], + [14,\%PS_Helvetica_BoldOblique], + [14,\%PS_Courier_Bold]]); + %SubhFont = (name => 'sfont', + leading => 13.2, + fonts => [[12,\%PS_Helvetica_Bold], + [12,\%PS_Helvetica_BoldOblique], + [12,\%PS_Courier_Bold]]); + %BodyFont = (name => 'bfont', + leading => 11, + fonts => [[10,\%PS_Helvetica], + [10,\%PS_Helvetica_Oblique], + [10,\%PS_Courier]]); +} else { + # Body text Times; headings Helvetica + %TitlFont = (name => 'tfont', + leading => 22, + fonts => [[20,\%PS_Helvetica_Bold], + [20,\%PS_Helvetica_BoldOblique], + [20,\%PS_Courier_Bold]]); + %ChapFont = (name => 'cfont', + leading => 19.2, + fonts => [[18,\%PS_Helvetica_Bold], + [18,\%PS_Helvetica_BoldOblique], + [18,\%PS_Courier_Bold]]); + %HeadFont = (name => 'hfont', + leading => 15.4, + fonts => [[14,\%PS_Helvetica_Bold], + [14,\%PS_Helvetica_BoldOblique], + [14,\%PS_Courier_Bold]]); + %SubhFont = (name => 'sfont', + leading => 13.2, + fonts => [[12,\%PS_Helvetica_Bold], + [12,\%PS_Helvetica_BoldOblique], + [12,\%PS_Courier_Bold]]); + %BodyFont = (name => 'bfont', + leading => 11, + fonts => [[10,\%PS_Times_Roman], + [10,\%PS_Times_Italic], + [10,\%PS_Courier]]); +} + +# +# List of all fontsets; used to compute the list of fonts needed +# +@AllFonts = ( \%TitlFont, \%ChapFont, \%HeadFont, \%SubhFont, \%BodyFont ); + +# OK +1; diff --git a/doc/pswidth.ph b/doc/pswidth.ph new file mode 100644 index 0000000..36fc07a --- /dev/null +++ b/doc/pswidth.ph @@ -0,0 +1,26 @@ +#!/usr/bin/perl +# +# Get the width of a PostScript string in font units +# (1000 font units == the font point height) given a set of +# font metrics and an encoding vector. +# +sub ps_width($$$) { + my($str, $met, $encoding) = @_; + my($w) = 0; + my($i,$c,$p); + + $l = length($str); + undef $p; + for ( $i = 0 ; $i < $l ; $i++ ) { + $c = substr($str,$i,1); + $w += $$met{widths}{$encoding->[ord($c)]}; + # The standard PostScript "show" operator doesn't do kerning. + # $w += $$met{kern}{$p.$c}; + $p = $c; + } + + return $w; +} + +# OK +1; diff --git a/doc/rdsrc.pl b/doc/rdsrc.pl new file mode 100644 index 0000000..de3a862 --- /dev/null +++ b/doc/rdsrc.pl @@ -0,0 +1,1509 @@ +#!/usr/bin/perl +## -------------------------------------------------------------------------- +## +## Copyright 1996-2009 The NASM Authors - All Rights Reserved +## See the file AUTHORS included with the NASM distribution for +## the specific copyright holders. +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following +## conditions are met: +## +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above +## copyright notice, this list of conditions and the following +## disclaimer in the documentation and/or other materials provided +## with the distribution. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +## CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +## DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +## EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## +## -------------------------------------------------------------------------- + + +# Read the source-form of the NASM manual and generate the various +# output forms. + +# TODO: +# +# Ellipsis support would be nice. + +# Source-form features: +# --------------------- +# +# Bullet \b +# Bullets the paragraph. Rest of paragraph is indented to cope. In +# HTML, consecutive groups of bulleted paragraphs become unordered +# lists. +# +# Emphasis \e{foobar} +# produces `_foobar_' in text and italics in HTML, PS, RTF +# +# Inline code \c{foobar} +# produces ``foobar'' in text, and fixed-pitch font in HTML, PS, RTF +# +# Display code +# \c line one +# \c line two +# produces fixed-pitch font where appropriate, and doesn't break +# pages except sufficiently far into the middle of a display. +# +# Chapter, header and subheader +# \C{intro} Introduction +# \H{whatsnasm} What is NASM? +# \S{free} NASM Is Free +# dealt with as appropriate. Chapters begin on new sides, possibly +# even new _pages_. (Sub)?headers are good places to begin new +# pages. Just _after_ a (sub)?header isn't. +# The keywords can be substituted with \K and \k. +# +# Keyword \K{cintro} \k{cintro} +# Expands to `Chapter 1', `Section 1.1', `Section 1.1.1'. \K has an +# initial capital whereas \k doesn't. In HTML, will produce +# hyperlinks. +# +# Web link \W{http://foobar/}{text} or \W{mailto:me@here}\c{me@here} +# the \W prefix is ignored except in HTML; in HTML the last part +# becomes a hyperlink to the first part. +# +# Literals \{ \} \\ +# In case it's necessary, they expand to the real versions. +# +# Nonbreaking hyphen \- +# Need more be said? +# +# Source comment \# +# Causes everything after it on the line to be ignored by the +# source-form processor. +# +# Indexable word \i{foobar} (or \i\e{foobar} or \i\c{foobar}, equally) +# makes word appear in index, referenced to that point +# \i\c comes up in code style even in the index; \i\e doesn't come +# up in emphasised style. +# +# Indexable non-displayed word \I{foobar} or \I\c{foobar} +# just as \i{foobar} except that nothing is displayed for it +# +# Index rewrite +# \IR{foobar} \c{foobar} operator, uses of +# tidies up the appearance in the index of something the \i or \I +# operator was applied to +# +# Index alias +# \IA{foobar}{bazquux} +# aliases one index tag (as might be supplied to \i or \I) to +# another, so that \I{foobar} has the effect of \I{bazquux}, and +# \i{foobar} has the effect of \I{bazquux}foobar +# +# Metadata +# \M{key}{something} +# defines document metadata, such as authorship, title and copyright; +# different output formats use this differently. +# +# Include subfile +# \&{filename} +# Includes filename. Recursion is allowed. +# + +use IO::File; + +$diag = 1, shift @ARGV if $ARGV[0] eq "-d"; + +($out_format) = @ARGV; + +$| = 1; + +$tstruct_previtem = $node = "Top"; +$nodes = ($node); +$tstruct_level{$tstruct_previtem} = 0; +$tstruct_last[$tstruct_level{$tstruct_previtem}] = $tstruct_previtem; +$MAXLEVEL = 10; # really 3, but play safe ;-) + +# Read the file; pass a paragraph at a time to the paragraph processor. +print "Reading input..."; +$pname = "para000000"; +@pnames = @pflags = (); +$para = undef; +while (defined($_ = <STDIN>)) { + $_ = &untabify($_); + &check_include($_); +} +&got_para($para); +print "done.\n"; + +# Now we've read in the entire document and we know what all the +# heading keywords refer to. Go through and fix up the \k references. +print "Fixing up cross-references..."; +&fixup_xrefs; +print "done.\n"; + +# Sort the index tags, according to the slightly odd order I've decided on. +print "Sorting index tags..."; +&indexsort; +print "done.\n"; + +if ($diag) { + print "Writing index-diagnostic file..."; + &indexdiag; + print "done.\n"; +} + +# OK. Write out the various output files. +if ($out_format eq 'txt') { + print "Producing text output: "; + &write_txt; + print "done.\n"; +} elsif ($out_format eq 'html') { + print "Producing HTML output: "; + &write_html; + print "done.\n"; +} elsif ($out_format eq 'texi') { + print "Producing Texinfo output: "; + &write_texi; + print "done.\n"; +} elsif ($out_format eq 'hlp') { + print "Producing WinHelp output: "; + &write_hlp; + print "done.\n"; +} elsif ($out_format eq 'dip') { + print "Producing Documentation Intermediate Paragraphs: "; + &write_dip; + print "done.\n"; +} else { + die "$0: unknown output format: $out_format\n"; +} + +sub untabify($) { + my($s) = @_; + my $o = ''; + my($c, $i, $p); + + $p = 0; + for ($i = 0; $i < length($s); $i++) { + $c = substr($s, $i, 1); + if ($c eq "\t") { + do { + $o .= ' '; + $p++; + } while ($p & 7); + } else { + $o .= $c; + $p++; + } + } + return $o; +} +sub check_include { + local $_ = shift; + if (/\\& (\S+)/) { + &include($1); + } else { + &get_para($_); + } +} +sub get_para($_) { + chomp; + if (!/\S/ || /^\\(IA|IR|M)/) { # special case: \IA \IR \M imply new-paragraph + &got_para($para); + $para = undef; + } + if (/\S/) { + s/\\#.*$//; # strip comments + $para .= " " . $_; + } +} +sub include { + my $name = shift; + my $F = IO::File->new($name) + or die "Cannot open $name: $!"; + while (<$F>) { + &check_include($_); + } +} +sub got_para { + local ($_) = @_; + my $pflags = "", $i, $w, $l, $t; + return if !/\S/; + + @$pname = (); + + # Strip off _leading_ spaces, then determine type of paragraph. + s/^\s*//; + $irewrite = undef; + if (/^\\c[^{]/) { + # A code paragraph. The paragraph-array will contain the simple + # strings which form each line of the paragraph. + $pflags = "code"; + while (/^\\c (([^\\]|\\[^c])*)(.*)$/) { + $l = $1; + $_ = $3; + $l =~ s/\\{/{/g; + $l =~ s/\\}/}/g; + $l =~ s/\\\\/\\/g; + push @$pname, $l; + } + $_ = ''; # suppress word-by-word code + } elsif (/^\\C/) { + # A chapter heading. Define the keyword and allocate a chapter + # number. + $cnum++; + $hnum = 0; + $snum = 0; + $xref = "chapter-$cnum"; + $pflags = "chap $cnum :$xref"; + die "badly formatted chapter heading: $_\n" if !/^\\C{([^}]*)}\s*(.*)$/; + $refs{$1} = "chapter $cnum"; + $node = "Chapter $cnum"; + &add_item($node, 1); + $xrefnodes{$node} = $xref; $nodexrefs{$xref} = $node; + $xrefs{$1} = $xref; + $_ = $2; + # the standard word-by-word code will happen next + } elsif (/^\\A/) { + # An appendix heading. Define the keyword and allocate an appendix + # letter. + $cnum++; + $cnum = 'A' if $cnum =~ /[0-9]+/; + $hnum = 0; + $snum = 0; + $xref = "appendix-$cnum"; + $pflags = "appn $cnum :$xref"; + die "badly formatted appendix heading: $_\n" if !/^\\A{([^}]*)}\s*(.*)$/; + $refs{$1} = "appendix $cnum"; + $node = "Appendix $cnum"; + &add_item($node, 1); + $xrefnodes{$node} = $xref; $nodexrefs{$xref} = $node; + $xrefs{$1} = $xref; + $_ = $2; + # the standard word-by-word code will happen next + } elsif (/^\\H/) { + # A major heading. Define the keyword and allocate a section number. + $hnum++; + $snum = 0; + $xref = "section-$cnum.$hnum"; + $pflags = "head $cnum.$hnum :$xref"; + die "badly formatted heading: $_\n" if !/^\\[HP]{([^}]*)}\s*(.*)$/; + $refs{$1} = "section $cnum.$hnum"; + $node = "Section $cnum.$hnum"; + &add_item($node, 2); + $xrefnodes{$node} = $xref; $nodexrefs{$xref} = $node; + $xrefs{$1} = $xref; + $_ = $2; + # the standard word-by-word code will happen next + } elsif (/^\\S/) { + # A sub-heading. Define the keyword and allocate a section number. + $snum++; + $xref = "section-$cnum.$hnum.$snum"; + $pflags = "subh $cnum.$hnum.$snum :$xref"; + die "badly formatted subheading: $_\n" if !/^\\S{([^}]*)}\s*(.*)$/; + $refs{$1} = "section $cnum.$hnum.$snum"; + $node = "Section $cnum.$hnum.$snum"; + &add_item($node, 3); + $xrefnodes{$node} = $xref; $nodexrefs{$xref} = $node; + $xrefs{$1} = $xref; + $_ = $2; + # the standard word-by-word code will happen next + } elsif (/^\\IR/) { + # An index-rewrite. + die "badly formatted index rewrite: $_\n" if !/^\\IR{([^}]*)}\s*(.*)$/; + $irewrite = $1; + $_ = $2; + # the standard word-by-word code will happen next + } elsif (/^\\IA/) { + # An index-alias. + die "badly formatted index alias: $_\n" if !/^\\IA{([^}]*)}{([^}]*)}\s*$/; + $idxalias{$1} = $2; + return; # avoid word-by-word code + } elsif (/^\\M/) { + # Metadata + die "badly formed metadata: $_\n" if !/^\\M{([^}]*)}{([^}]*)}\s*$/; + $metadata{$1} = $2; + return; # avoid word-by-word code + } elsif (/^\\b/) { + # A bulleted paragraph. Strip off the initial \b and let the + # word-by-word code take care of the rest. + $pflags = "bull"; + s/^\\b\s*//; + } else { + # A normal paragraph. Just set $pflags: the word-by-word code does + # the rest. + $pflags = "norm"; + } + + # The word-by-word code: unless @$pname is already defined (which it + # will be in the case of a code paragraph), split the paragraph up + # into words and push each on @$pname. + # + # Each thing pushed on @$pname should have a two-character type + # code followed by the text. + # + # Type codes are: + # "n " for normal + # "da" for a dash + # "es" for first emphasised word in emphasised bit + # "e " for emphasised in mid-emphasised-bit + # "ee" for last emphasised word in emphasised bit + # "eo" for single (only) emphasised word + # "c " for code + # "k " for cross-ref + # "kK" for capitalised cross-ref + # "w " for Web link + # "wc" for code-type Web link + # "x " for beginning of resolved cross-ref; generates no visible output, + # and the text is the cross-reference code + # "xe" for end of resolved cross-ref; text is same as for "x ". + # "i " for point to be indexed: the text is the internal index into the + # index-items arrays + # "sp" for space + while (/\S/) { + s/^\s*//, push @$pname, "sp" if /^\s/; + $indexing = $qindex = 0; + if (/^(\\[iI])?\\c/) { + $qindex = 1 if $1 eq "\\I"; + $indexing = 1, s/^\\[iI]// if $1; + s/^\\c//; + die "badly formatted \\c: \\c$_\n" if !/{(([^\\}]|\\.)*)}(.*)$/; + $w = $1; + $_ = $3; + $w =~ s/\\{/{/g; + $w =~ s/\\}/}/g; + $w =~ s/\\-/-/g; + $w =~ s/\\\\/\\/g; + (push @$pname,"i"),$lastp = $#$pname if $indexing; + push @$pname,"c $w" if !$qindex; + $$pname[$lastp] = &addidx($node, $w, "c $w") if $indexing; + } elsif (/^\\[iIe]/) { + /^(\\[iI])?(\\e)?/; + $emph = 0; + $qindex = 1 if $1 eq "\\I"; + $indexing = 1, $type = "\\i" if $1; + $emph = 1, $type = "\\e" if $2; + s/^(\\[iI])?(\\e?)//; + die "badly formatted $type: $type$_\n" if !/{(([^\\}]|\\.)*)}(.*)$/; + $w = $1; + $_ = $3; + $w =~ s/\\{/{/g; + $w =~ s/\\}/}/g; + $w =~ s/\\-/-/g; + $w =~ s/\\\\/\\/g; + $t = $emph ? "es" : "n "; + @ientry = (); + (push @$pname,"i"),$lastp = $#$pname if $indexing; + foreach $i (split /\s+/,$w) { # \e and \i can be multiple words + push @$pname,"$t$i","sp" if !$qindex; + ($ii=$i) =~ tr/A-Z/a-z/, push @ientry,"n $ii","sp" if $indexing; + $t = $emph ? "e " : "n "; + } + $w =~ tr/A-Z/a-z/, pop @ientry if $indexing; + $$pname[$lastp] = &addidx($node, $w, @ientry) if $indexing; + pop @$pname if !$qindex; # remove final space + if (substr($$pname[$#$pname],0,2) eq "es" && !$qindex) { + substr($$pname[$#$pname],0,2) = "eo"; + } elsif ($emph && !$qindex) { + substr($$pname[$#$pname],0,2) = "ee"; + } + } elsif (/^\\[kK]/) { + $t = "k "; + $t = "kK" if /^\\K/; + s/^\\[kK]//; + die "badly formatted \\k: \\c$_\n" if !/{([^}]*)}(.*)$/; + $_ = $2; + push @$pname,"$t$1"; + } elsif (/^\\W/) { + s/^\\W//; + die "badly formatted \\W: \\W$_\n" + if !/{([^}]*)}(\\i)?(\\c)?{(([^\\}]|\\.)*)}(.*)$/; + $l = $1; + $w = $4; + $_ = $6; + $t = "w "; + $t = "wc" if $3 eq "\\c"; + $indexing = 1 if $2; + $w =~ s/\\{/{/g; + $w =~ s/\\}/}/g; + $w =~ s/\\-/-/g; + $w =~ s/\\\\/\\/g; + (push @$pname,"i"),$lastp = $#$pname if $indexing; + push @$pname,"$t<$l>$w"; + $$pname[$lastp] = &addidx($node, $w, "c $w") if $indexing; + } else { + die "what the hell? $_\n" if !/^(([^\s\\\-]|\\[\\{}\-])*-?)(.*)$/; + die "painful death! $_\n" if !length $1; + $w = $1; + $_ = $3; + $w =~ s/\\{/{/g; + $w =~ s/\\}/}/g; + $w =~ s/\\-/-/g; + $w =~ s/\\\\/\\/g; + if ($w eq "-") { + push @$pname,"da"; + } else { + push @$pname,"n $w"; + } + } + } + if ($irewrite ne undef) { + &addidx(undef, $irewrite, @$pname); + @$pname = (); + } else { + push @pnames, $pname; + push @pflags, $pflags; + $pname++; + } +} + +sub addidx { + my ($node, $text, @ientry) = @_; + $text = $idxalias{$text} || $text; + if ($node eq undef || !$idxmap{$text}) { + @$ientry = @ientry; + $idxmap{$text} = $ientry; + $ientry++; + } + if ($node) { + $idxnodes{$node,$text} = 1; + return "i $text"; + } +} + +sub indexsort { + my $iitem, $ientry, $i, $piitem, $pcval, $cval, $clrcval; + + @itags = map { # get back the original data as the 1st elt of each list + $_->[0] + } sort { # compare auxiliary (non-first) elements of lists + $a->[1] cmp $b->[1] || + $a->[2] cmp $b->[2] || + $a->[0] cmp $b->[0] + } map { # transform array into list of 3-element lists + my $ientry = $idxmap{$_}; + my $a = substr($$ientry[0],2); + $a =~ tr/A-Za-z0-9//cd; + [$_, uc($a), substr($$ientry[0],0,2)] + } keys %idxmap; + + # Having done that, check for comma-hood. + $cval = 0; + foreach $iitem (@itags) { + $ientry = $idxmap{$iitem}; + $clrcval = 1; + $pcval = $cval; + FL:for ($i=0; $i <= $#$ientry; $i++) { + if ($$ientry[$i] =~ /^(n .*,)(.*)/) { + $$ientry[$i] = $1; + splice @$ientry,$i+1,0,"n $2" if length $2; + $commapos{$iitem} = $i+1; + $cval = join("\002", @$ientry[0..$i]); + $clrcval = 0; + last FL; + } + } + $cval = undef if $clrcval; + $commanext{$iitem} = $commaafter{$piitem} = 1 + if $cval and ($cval eq $pcval); + $piitem = $iitem; + } +} + +sub indexdiag { + my $iitem,$ientry,$w,$ww,$foo,$node; + open INDEXDIAG,">index.diag"; + foreach $iitem (@itags) { + $ientry = $idxmap{$iitem}; + print INDEXDIAG "<$iitem> "; + foreach $w (@$ientry) { + $ww = &word_txt($w); + print INDEXDIAG $ww unless $ww eq "\001"; + } + print INDEXDIAG ":"; + $foo = " "; + foreach $node (@nodes) { + (print INDEXDIAG $foo,$node), $foo = ", " if $idxnodes{$node,$iitem}; + } + print INDEXDIAG "\n"; + } + close INDEXDIAG; +} + +sub fixup_xrefs { + my $pname, $p, $i, $j, $k, $caps, @repl; + + for ($p=0; $p<=$#pnames; $p++) { + next if $pflags[$p] eq "code"; + $pname = $pnames[$p]; + for ($i=$#$pname; $i >= 0; $i--) { + if ($$pname[$i] =~ /^k/) { + $k = $$pname[$i]; + $caps = ($k =~ /^kK/); + $k = substr($k,2); + $repl = $refs{$k}; + die "undefined keyword `$k'\n" unless $repl; + substr($repl,0,1) =~ tr/a-z/A-Z/ if $caps; + @repl = (); + push @repl,"x $xrefs{$k}"; + foreach $j (split /\s+/,$repl) { + push @repl,"n $j"; + push @repl,"sp"; + } + pop @repl; # remove final space + push @repl,"xe$xrefs{$k}"; + splice @$pname,$i,1,@repl; + } + } + } +} + +sub write_txt { + # This is called from the top level, so I won't bother using + # my or local. + + # Open file. + print "writing file..."; + open TEXT,">nasmdoc.txt"; + select TEXT; + + # Preamble. + $title = "The Netwide Assembler: NASM"; + $spaces = ' ' x ((75-(length $title))/2); + ($underscore = $title) =~ s/./=/g; + print "$spaces$title\n$spaces$underscore\n"; + + for ($para = 0; $para <= $#pnames; $para++) { + $pname = $pnames[$para]; + $pflags = $pflags[$para]; + $ptype = substr($pflags,0,4); + + print "\n"; # always one of these before a new paragraph + + if ($ptype eq "chap") { + # Chapter heading. "Chapter N: Title" followed by a line of + # minus signs. + $pflags =~ /chap (.*) :(.*)/; + $title = "Chapter $1: "; + foreach $i (@$pname) { + $ww = &word_txt($i); + $title .= $ww unless $ww eq "\001"; + } + print "$title\n"; + $title =~ s/./-/g; + print "$title\n"; + } elsif ($ptype eq "appn") { + # Appendix heading. "Appendix N: Title" followed by a line of + # minus signs. + $pflags =~ /appn (.*) :(.*)/; + $title = "Appendix $1: "; + foreach $i (@$pname) { + $ww = &word_txt($i); + $title .= $ww unless $ww eq "\001"; + } + print "$title\n"; + $title =~ s/./-/g; + print "$title\n"; + } elsif ($ptype eq "head" || $ptype eq "subh") { + # Heading or subheading. Just a number and some text. + $pflags =~ /.... (.*) :(.*)/; + $title = sprintf "%6s ", $1; + foreach $i (@$pname) { + $ww = &word_txt($i); + $title .= $ww unless $ww eq "\001"; + } + print "$title\n"; + } elsif ($ptype eq "code") { + # Code paragraph. Emit each line with a seven character indent. + foreach $i (@$pname) { + warn "code line longer than 68 chars: $i\n" if length $i > 68; + print ' 'x7, $i, "\n"; + } + } elsif ($ptype eq "bull" || $ptype eq "norm") { + # Ordinary paragraph, optionally bulleted. We wrap, with ragged + # 75-char right margin and either 7 or 11 char left margin + # depending on bullets. + if ($ptype eq "bull") { + $line = ' 'x7 . '(*) '; + $next = ' 'x11; + } else { + $line = $next = ' 'x7; + } + @a = @$pname; + $wd = $wprev = ''; + do { + do { $w = &word_txt(shift @a) } while $w eq "\001"; # nasty hack + $wd .= $wprev; + if ($wprev =~ /-$/ || $w eq ' ' || $w eq '' || $w eq undef) { + if (length ($line . $wd) > 75) { + $line =~ s/\s*$//; # trim trailing spaces + print "$line\n"; + $line = $next; + $wd =~ s/^\s*//; # trim leading spaces + } + $line .= $wd; + $wd = ''; + } + $wprev = $w; + } while ($w ne '' && $w ne undef); + if ($line =~ /\S/) { + $line =~ s/\s*$//; # trim trailing spaces + print "$line\n"; + } + } + } + + # Close file. + select STDOUT; + close TEXT; +} + +sub word_txt { + my ($w) = @_; + my $wtype, $wmajt; + + return undef if $w eq '' || $w eq undef; + $wtype = substr($w,0,2); + $wmajt = substr($wtype,0,1); + $w = substr($w,2); + $w =~ s/<.*>// if $wmajt eq "w"; # remove web links + if ($wmajt eq "n" || $wtype eq "e " || $wtype eq "w ") { + return $w; + } elsif ($wtype eq "sp") { + return ' '; + } elsif ($wtype eq "da") { + return '-'; + } elsif ($wmajt eq "c" || $wtype eq "wc") { + return "`${w}'"; + } elsif ($wtype eq "es") { + return "_${w}"; + } elsif ($wtype eq "ee") { + return "${w}_"; + } elsif ($wtype eq "eo") { + return "_${w}_"; + } elsif ($wmajt eq "x" || $wmajt eq "i") { + return "\001"; + } else { + die "panic in word_txt: $wtype$w\n"; + } +} + +sub write_html { + # This is called from the top level, so I won't bother using + # my or local. + + # Write contents file. Just the preamble, then a menu of links to the + # separate chapter files and the nodes therein. + print "writing contents file..."; + open TEXT,">nasmdoc0.html"; + select TEXT; + &html_preamble(0); + print "<p>This manual documents NASM, the Netwide Assembler: an assembler\n"; + print "targetting the Intel x86 series of processors, with portable source.\n"; + print "<p>"; + for ($node = $tstruct_next{'Top'}; $node; $node = $tstruct_next{$node}) { + if ($tstruct_level{$node} == 1) { + # Invent a file name. + ($number = lc($xrefnodes{$node})) =~ s/.*-//; + $fname="nasmdocx.html"; + substr($fname,8 - length $number, length $number) = $number; + $html_fnames{$node} = $fname; + $link = $fname; + print "<p>"; + } else { + # Use the preceding filename plus a marker point. + $link = $fname . "#$xrefnodes{$node}"; + } + $title = "$node: "; + $pname = $tstruct_pname{$node}; + foreach $i (@$pname) { + $ww = &word_html($i); + $title .= $ww unless $ww eq "\001"; + } + print "<a href=\"$link\">$title</a><br>\n"; + } + print "<p><a href=\"nasmdoci.html\">Index</a>\n"; + print "</body></html>\n"; + select STDOUT; + close TEXT; + + # Open a null file, to ensure output (eg random &html_jumppoints calls) + # goes _somewhere_. + print "writing chapter files..."; + open TEXT,">/dev/null"; + select TEXT; + $html_lastf = ''; + + $in_list = 0; + + for ($para = 0; $para <= $#pnames; $para++) { + $pname = $pnames[$para]; + $pflags = $pflags[$para]; + $ptype = substr($pflags,0,4); + + $in_list = 0, print "</ul>\n" if $in_list && $ptype ne "bull"; + if ($ptype eq "chap") { + # Chapter heading. Begin a new file. + $pflags =~ /chap (.*) :(.*)/; + $title = "Chapter $1: "; + $xref = $2; + &html_jumppoints; print "</body></html>\n"; select STDOUT; close TEXT; + $html_lastf = $html_fnames{$chapternode}; + $chapternode = $nodexrefs{$xref}; + $html_nextf = $html_fnames{$tstruct_mnext{$chapternode}}; + open TEXT,">$html_fnames{$chapternode}"; select TEXT; &html_preamble(1); + foreach $i (@$pname) { + $ww = &word_html($i); + $title .= $ww unless $ww eq "\001"; + } + $h = "<h2><a name=\"$xref\">$title</a></h2>\n"; + print $h; print FULL $h; + } elsif ($ptype eq "appn") { + # Appendix heading. Begin a new file. + $pflags =~ /appn (.*) :(.*)/; + $title = "Appendix $1: "; + $xref = $2; + &html_jumppoints; print "</body></html>\n"; select STDOUT; close TEXT; + $html_lastf = $html_fnames{$chapternode}; + $chapternode = $nodexrefs{$xref}; + $html_nextf = $html_fnames{$tstruct_mnext{$chapternode}}; + open TEXT,">$html_fnames{$chapternode}"; select TEXT; &html_preamble(1); + foreach $i (@$pname) { + $ww = &word_html($i); + $title .= $ww unless $ww eq "\001"; + } + print "<h2><a name=\"$xref\">$title</a></h2>\n"; + } elsif ($ptype eq "head" || $ptype eq "subh") { + # Heading or subheading. + $pflags =~ /.... (.*) :(.*)/; + $hdr = ($ptype eq "subh" ? "h4" : "h3"); + $title = $1 . " "; + $xref = $2; + foreach $i (@$pname) { + $ww = &word_html($i); + $title .= $ww unless $ww eq "\001"; + } + print "<$hdr><a name=\"$xref\">$title</a></$hdr>\n"; + } elsif ($ptype eq "code") { + # Code paragraph. + print "<p><pre>\n"; + foreach $i (@$pname) { + $w = $i; + $w =~ s/&/&/g; + $w =~ s/</</g; + $w =~ s/>/>/g; + print $w, "\n"; + } + print "</pre>\n"; + } elsif ($ptype eq "bull" || $ptype eq "norm") { + # Ordinary paragraph, optionally bulleted. We wrap, with ragged + # 75-char right margin and either 7 or 11 char left margin + # depending on bullets. + if ($ptype eq "bull") { + $in_list = 1, print "<ul>\n" unless $in_list; + $line = '<li>'; + } else { + $line = '<p>'; + } + @a = @$pname; + $wd = $wprev = ''; + do { + do { $w = &word_html(shift @a) } while $w eq "\001"; # nasty hack + $wd .= $wprev; + if ($w eq ' ' || $w eq '' || $w eq undef) { + if (length ($line . $wd) > 75) { + $line =~ s/\s*$//; # trim trailing spaces + print "$line\n"; + $line = ''; + $wd =~ s/^\s*//; # trim leading spaces + } + $line .= $wd; + $wd = ''; + } + $wprev = $w; + } while ($w ne '' && $w ne undef); + if ($line =~ /\S/) { + $line =~ s/\s*$//; # trim trailing spaces + print "$line\n"; + } + } + } + + # Close whichever file was open. + &html_jumppoints; + print "</body></html>\n"; + select STDOUT; + close TEXT; + + print "\n writing index file..."; + open TEXT,">nasmdoci.html"; + select TEXT; + &html_preamble(0); + print "<p align=center><a href=\"nasmdoc0.html\">Contents</a>\n"; + print "<p>"; + &html_index; + print "<p align=center><a href=\"nasmdoc0.html\">Contents</a>\n"; + print "</body></html>\n"; + select STDOUT; + close TEXT; +} + +sub html_preamble { + print "<html><head><title>NASM Manual</title></head>\n"; + print "<body><h1 align=center>The Netwide Assembler: NASM</h1>\n\n"; + &html_jumppoints if $_[0]; +} + +sub html_jumppoints { + print "<p align=center>"; + print "<a href=\"$html_nextf\">Next Chapter</a> |\n" if $html_nextf; + print "<a href=\"$html_lastf\">Previous Chapter</a> |\n" if $html_lastf; + print "<a href=\"nasmdoc0.html\">Contents</a> |\n"; + print "<a href=\"nasmdoci.html\">Index</a>\n"; +} + +sub html_index { + my $itag, $a, @ientry, $sep, $w, $wd, $wprev, $line; + + $chapternode = ''; + foreach $itag (@itags) { + $ientry = $idxmap{$itag}; + @a = @$ientry; + push @a, "n :"; + $sep = 0; + foreach $node (@nodes) { + next if !$idxnodes{$node,$itag}; + push @a, "n ," if $sep; + push @a, "sp", "x $xrefnodes{$node}", "n $node", "xe$xrefnodes{$node}"; + $sep = 1; + } + $line = ''; + do { + do { $w = &word_html(shift @a) } while $w eq "\001"; # nasty hack + $wd .= $wprev; + if ($w eq ' ' || $w eq '' || $w eq undef) { + if (length ($line . $wd) > 75) { + $line =~ s/\s*$//; # trim trailing spaces + print "$line\n"; + $line = ''; + $wd =~ s/^\s*//; # trim leading spaces + } + $line .= $wd; + $wd = ''; + } + $wprev = $w; + } while ($w ne '' && $w ne undef); + if ($line =~ /\S/) { + $line =~ s/\s*$//; # trim trailing spaces + print "$line\n"; + } + print "<br>\n"; + } +} + +sub word_html { + my ($w) = @_; + my $wtype, $wmajt, $pfx, $sfx; + + return undef if $w eq '' || $w eq undef; + + $wtype = substr($w,0,2); + $wmajt = substr($wtype,0,1); + $w = substr($w,2); + $pfx = $sfx = ''; + $pfx = "<a href=\"$1\">", $sfx = "</a>", $w = $2 + if $wmajt eq "w" && $w =~ /^<(.*)>(.*)$/; + $w =~ s/&/&/g; + $w =~ s/</</g; + $w =~ s/>/>/g; + if ($wmajt eq "n" || $wtype eq "e " || $wtype eq "w ") { + return $pfx . $w . $sfx; + } elsif ($wtype eq "sp") { + return ' '; + } elsif ($wtype eq "da") { + return '-'; # sadly, en-dashes are non-standard in HTML + } elsif ($wmajt eq "c" || $wtype eq "wc") { + return $pfx . "<code><nobr>${w}</nobr></code>" . $sfx; + } elsif ($wtype eq "es") { + return "<em>${w}"; + } elsif ($wtype eq "ee") { + return "${w}</em>"; + } elsif ($wtype eq "eo") { + return "<em>${w}</em>"; + } elsif ($wtype eq "x ") { + # Magic: we must resolve the cross reference into file and marker + # parts, then dispose of the file part if it's us, and dispose of + # the marker part if the cross reference describes the top node of + # another file. + my $node = $nodexrefs{$w}; # find the node we're aiming at + my $level = $tstruct_level{$node}; # and its level + my $up = $node, $uplev = $level-1; + $up = $tstruct_up{$up} while $uplev--; # get top node of containing file + my $file = ($up ne $chapternode) ? $html_fnames{$up} : ""; + my $marker = ($level == 1 and $file) ? "" : "#$w"; + return "<a href=\"$file$marker\">"; + } elsif ($wtype eq "xe") { + return "</a>"; + } elsif ($wmajt eq "i") { + return "\001"; + } else { + die "panic in word_html: $wtype$w\n"; + } +} + +sub write_texi { + # This is called from the top level, so I won't bother using + # my or local. + + # Open file. + print "writing file..."; + open TEXT,">nasmdoc.texi"; + select TEXT; + + # Preamble. + print "\\input texinfo \@c -*-texinfo-*-\n"; + print "\@c \%**start of header\n"; + print "\@setfilename ",$metadata{'infofile'},".info\n"; + print "\@dircategory ",$metadata{'category'},"\n"; + print "\@direntry\n"; + printf "* %-28s %s.\n", + sprintf('%s: (%s).', $metadata{'infoname'}, $metadata{'infofile'}), + $metadata{'infotitle'}; + print "\@end direntry\n"; + print "\@settitle ", $metadata{'title'},"\n"; + print "\@setchapternewpage odd\n"; + print "\@c \%**end of header\n"; + print "\n"; + print "\@ifinfo\n"; + print $metadata{'summary'}, "\n"; + print "\n"; + print "Copyright ",$metadata{'year'}," ",$metadata{'author'},"\n"; + print "\n"; + print $metadata{'license'}, "\n"; + print "\@end ifinfo\n"; + print "\n"; + print "\@titlepage\n"; + $title = $metadata{'title'}; + $title =~ s/ - / --- /g; + print "\@title ${title}\n"; + print "\@author ",$metadata{'author'},"\n"; + print "\n"; + print "\@page\n"; + print "\@vskip 0pt plus 1filll\n"; + print "Copyright \@copyright{} ",$metadata{'year'},' ',$metadata{'author'},"\n"; + print "\n"; + print $metadata{'license'}, "\n"; + print "\@end titlepage\n"; + print "\n"; + print "\@node Top, $tstruct_next{'Top'}, (dir), (dir)\n"; + print "\@top ",$metadata{'infotitle'},"\n"; + print "\n"; + print "\@ifinfo\n"; + print $metadata{'summary'}, "\n"; + print "\@end ifinfo\n"; + + $node = "Top"; + + $bulleting = 0; + for ($para = 0; $para <= $#pnames; $para++) { + $pname = $pnames[$para]; + $pflags = $pflags[$para]; + $ptype = substr($pflags,0,4); + + $bulleting = 0, print "\@end itemize\n" if $bulleting && $ptype ne "bull"; + print "\n"; # always one of these before a new paragraph + + if ($ptype eq "chap") { + # Chapter heading. Begin a new node. + &texi_menu($node) + if $tstruct_level{$tstruct_next{$node}} > $tstruct_level{$node}; + $pflags =~ /chap (.*) :(.*)/; + $node = "Chapter $1"; + $title = "Chapter $1: "; + foreach $i (@$pname) { + $ww = &word_texi($i); + $title .= $ww unless $ww eq "\001"; + } + print "\@node $node, $tstruct_next{$node}, $tstruct_prev{$node},"; + print " $tstruct_up{$node}\n\@unnumbered $title\n"; + } elsif ($ptype eq "appn") { + # Appendix heading. Begin a new node. + &texi_menu($node) + if $tstruct_level{$tstruct_next{$node}} > $tstruct_level{$node}; + $pflags =~ /appn (.*) :(.*)/; + $node = "Appendix $1"; + $title = "Appendix $1: "; + foreach $i (@$pname) { + $ww = &word_texi($i); + $title .= $ww unless $ww eq "\001"; + } + print "\@node $node, $tstruct_next{$node}, $tstruct_prev{$node},"; + print " $tstruct_up{$node}\n\@unnumbered $title\n"; + } elsif ($ptype eq "head" || $ptype eq "subh") { + # Heading or subheading. Begin a new node. + &texi_menu($node) + if $tstruct_level{$tstruct_next{$node}} > $tstruct_level{$node}; + $pflags =~ /.... (.*) :(.*)/; + $node = "Section $1"; + $title = "$1. "; + foreach $i (@$pname) { + $ww = &word_texi($i); + $title .= $ww unless $ww eq "\001"; + } + print "\@node $node, $tstruct_next{$node}, $tstruct_prev{$node},"; + print " $tstruct_up{$node}\n"; + $hdr = ($ptype eq "subh" ? "\@unnumberedsubsec" : "\@unnumberedsec"); + print "$hdr $title\n"; + } elsif ($ptype eq "code") { + # Code paragraph. Surround with @example / @end example. + print "\@example\n"; + foreach $i (@$pname) { + warn "code line longer than 68 chars: $i\n" if length $i > 68; + $i =~ s/\@/\@\@/g; + $i =~ s/\{/\@\{/g; + $i =~ s/\}/\@\}/g; + print "$i\n"; + } + print "\@end example\n"; + } elsif ($ptype eq "bull" || $ptype eq "norm") { + # Ordinary paragraph, optionally bulleted. We wrap, FWIW. + if ($ptype eq "bull") { + $bulleting = 1, print "\@itemize \@bullet\n" if !$bulleting; + print "\@item\n"; + } + $line = ''; + @a = @$pname; + $wd = $wprev = ''; + do { + do { $w = &word_texi(shift @a); } while $w eq "\001"; # hack + $wd .= $wprev; + if ($wprev =~ /-$/ || $w eq ' ' || $w eq '' || $w eq undef) { + if (length ($line . $wd) > 75) { + $line =~ s/\s*$//; # trim trailing spaces + print "$line\n"; + $line = ''; + $wd =~ s/^\s*//; # trim leading spaces + } + $line .= $wd; + $wd = ''; + } + $wprev = $w; + } while ($w ne '' && $w ne undef); + if ($line =~ /\S/) { + $line =~ s/\s*$//; # trim trailing spaces + print "$line\n"; + } + } + } + + # Write index. + &texi_index; + + # Close file. + print "\n\@contents\n\@bye\n"; + select STDOUT; + close TEXT; +} + +# Side effect of this procedure: update global `texiwdlen' to be the length +# in chars of the formatted version of the word. +sub word_texi { + my ($w) = @_; + my $wtype, $wmajt; + + return undef if $w eq '' || $w eq undef; + $wtype = substr($w,0,2); + $wmajt = substr($wtype,0,1); + $w = substr($w,2); + $wlen = length $w; + $w =~ s/\@/\@\@/g; + $w =~ s/\{/\@\{/g; + $w =~ s/\}/\@\}/g; + $w =~ s/<.*>// if $wmajt eq "w"; # remove web links + substr($w,0,1) =~ tr/a-z/A-Z/, $capital = 0 if $capital; + if ($wmajt eq "n" || $wtype eq "e " || $wtype eq "w ") { + $texiwdlen = $wlen; + return $w; + } elsif ($wtype eq "sp") { + $texiwdlen = 1; + return ' '; + } elsif ($wtype eq "da") { + $texiwdlen = 2; + return '--'; + } elsif ($wmajt eq "c" || $wtype eq "wc") { + $texiwdlen = 2 + $wlen; + return "\@code\{$w\}"; + } elsif ($wtype eq "es") { + $texiwdlen = 1 + $wlen; + return "\@emph\{${w}"; + } elsif ($wtype eq "ee") { + $texiwdlen = 1 + $wlen; + return "${w}\}"; + } elsif ($wtype eq "eo") { + $texiwdlen = 2 + $wlen; + return "\@emph\{${w}\}"; + } elsif ($wtype eq "x ") { + $texiwdlen = 0; # we don't need it in this case + $capital = 1; # hack + return "\@ref\{"; + } elsif ($wtype eq "xe") { + $texiwdlen = 0; # we don't need it in this case + return "\}"; + } elsif ($wmajt eq "i") { + $texiwdlen = 0; # we don't need it in this case + return "\001"; + } else { + die "panic in word_texi: $wtype$w\n"; + } +} + +sub texi_menu { + my ($topitem) = @_; + my $item, $i, $mpname, $title, $wd; + + $item = $tstruct_next{$topitem}; + print "\@menu\n"; + while ($item) { + $title = ""; + $mpname = $tstruct_pname{$item}; + foreach $i (@$mpname) { + $wd = &word_texi($i); + $title .= $wd unless $wd eq "\001"; + } + print "* ${item}:: $title\n"; + $item = $tstruct_mnext{$item}; + } + print "* Index::\n" if $topitem eq "Top"; + print "\@end menu\n"; +} + +sub texi_index { + my $itag, $ientry, @a, $wd, $item, $len; + my $subnums = "123456789ABCDEFGHIJKLMNOPQRSTU" . + "VWXYZabcdefghijklmnopqrstuvwxyz"; + + print "\@ifinfo\n\@node Index, , $FIXMElastnode, Top\n"; + print "\@unnumbered Index\n\n\@menu\n"; + + foreach $itag (@itags) { + $ientry = $idxmap{$itag}; + @a = @$ientry; + $item = ''; + $len = 0; + foreach $i (@a) { + $wd = &word_texi($i); + $item .= $wd, $len += $texiwdlen unless $wd eq "\001"; + } + $i = 0; + foreach $node (@nodes) { + next if !$idxnodes{$node,$itag}; + printf "* %s%s (%s): %s.\n", + $item, " " x (40-$len), substr($subnums,$i++,1), $node; + } + } + print "\@end menu\n\@end ifinfo\n"; +} + +sub write_hlp { + # This is called from the top level, so I won't bother using + # my or local. + + # Build the index-tag text forms. + print "building index entries..."; + @hlp_index = map { + my $i,$ww; + my $ientry = $idxmap{$_}; + my $title = ""; + foreach $i (@$ientry) { + $ww = &word_hlp($i,0); + $title .= $ww unless $ww eq "\001"; + } + $title; + } @itags; + + # Write the HPJ project-description file. + print "writing .hpj file..."; + open HPJ,">nasmdoc.hpj"; + print HPJ "[OPTIONS]\ncompress=true\n"; + print HPJ "title=NASM: The Netwide Assembler\noldkeyphrase=no\n\n"; + print HPJ "[FILES]\nnasmdoc.rtf\n\n"; + print HPJ "[CONFIG]\n"; + print HPJ 'CreateButton("btn_up", "&Up",'. + ' "JumpContents(`nasmdoc.hlp'."'".')")'; + print HPJ "\nBrowseButtons()\n"; + close HPJ; + + # Open file. + print "\n writing .rtf file..."; + open TEXT,">nasmdoc.rtf"; + select TEXT; + + # Preamble. + print "{\\rtf1\\ansi{\\fonttbl\n"; + print "\\f0\\froman Times New Roman;\\f1\\fmodern Courier New;\n"; + print "\\f2\\fswiss Arial;\\f3\\ftech Wingdings}\\deff0\n"; + print "#{\\footnote Top}\n"; + print "\${\\footnote Contents}\n"; + print "+{\\footnote browse:00000}\n"; + print "!{\\footnote DisableButton(\"btn_up\")}\n"; + print "\\keepn\\f2\\b\\fs30\\sb0\n"; + print "NASM: The Netwide Assembler\n"; + print "\\par\\pard\\plain\\sb120\n"; + print "This file documents NASM, the Netwide Assembler: an assembler \n"; + print "targetting the Intel x86 series of processors, with portable source.\n"; + + $node = "Top"; + $browse = 0; + + $newpar = "\\par\\sb120\n"; + for ($para = 0; $para <= $#pnames; $para++) { + $pname = $pnames[$para]; + $pflags = $pflags[$para]; + $ptype = substr($pflags,0,4); + + print $newpar; + $newpar = "\\par\\sb120\n"; + + if ($ptype eq "chap") { + # Chapter heading. Begin a new node. + &hlp_menu($node) + if $tstruct_level{$tstruct_next{$node}} > $tstruct_level{$node}; + $pflags =~ /chap (.*) :(.*)/; + $node = "Chapter $1"; + $title = $footnotetitle = "Chapter $1: "; + foreach $i (@$pname) { + $ww = &word_hlp($i,1); + $title .= $ww, $footnotetitle .= &word_hlp($i,0) unless $ww eq "\001"; + } + print "\\page\n"; + printf "#{\\footnote %s}\n", &hlp_sectkw($node); + print "\${\\footnote $footnotetitle}\n"; + printf "+{\\footnote browse:%05d}\n", ++$browse; + printf "!{\\footnote ChangeButtonBinding(\"btn_up\"," . + "\"JumpId(\`nasmdoc.hlp',\`%s')\");\n", + &hlp_sectkw($tstruct_up{$node}); + print "EnableButton(\"btn_up\")}\n"; + &hlp_keywords($node); + print "\\keepn\\f2\\b\\fs30\\sb60\\sa60\n"; + print "$title\n"; + $newpar = "\\par\\pard\\plain\\sb120\n"; + } elsif ($ptype eq "appn") { + # Appendix heading. Begin a new node. + &hlp_menu($node) + if $tstruct_level{$tstruct_next{$node}} > $tstruct_level{$node}; + $pflags =~ /appn (.*) :(.*)/; + $node = "Appendix $1"; + $title = $footnotetitle = "Appendix $1: "; + foreach $i (@$pname) { + $ww = &word_hlp($i,1); + $title .= $ww, $footnotetitle .= &word_hlp($i,0) unless $ww eq "\001"; + } + print "\\page\n"; + printf "#{\\footnote %s}\n", &hlp_sectkw($node); + print "\${\\footnote $footnotetitle}\n"; + printf "+{\\footnote browse:%05d}\n", ++$browse; + printf "!{\\footnote ChangeButtonBinding(\"btn_up\"," . + "\"JumpId(\`nasmdoc.hlp',\`%s')\");\n", + &hlp_sectkw($tstruct_up{$node}); + print "EnableButton(\"btn_up\")}\n"; + &hlp_keywords($node); + print "\\keepn\\f2\\b\\fs30\\sb60\\sa60\n"; + print "$title\n"; + $newpar = "\\par\\pard\\plain\\sb120\n"; + } elsif ($ptype eq "head" || $ptype eq "subh") { + # Heading or subheading. Begin a new node. + &hlp_menu($node) + if $tstruct_level{$tstruct_next{$node}} > $tstruct_level{$node}; + $pflags =~ /.... (.*) :(.*)/; + $node = "Section $1"; + $title = $footnotetitle = "$1. "; + foreach $i (@$pname) { + $ww = &word_hlp($i,1); + $title .= $ww, $footnotetitle .= &word_hlp($i,0) unless $ww eq "\001"; + } + print "\\page\n"; + printf "#{\\footnote %s}\n", &hlp_sectkw($node); + print "\${\\footnote $footnotetitle}\n"; + printf "+{\\footnote browse:%05d}\n", ++$browse; + printf "!{\\footnote ChangeButtonBinding(\"btn_up\"," . + "\"JumpId(\`nasmdoc.hlp',\`%s')\");\n", + &hlp_sectkw($tstruct_up{$node}); + print "EnableButton(\"btn_up\")}\n"; + &hlp_keywords($node); + print "\\keepn\\f2\\b\\fs30\\sb60\\sa60\n"; + print "$title\n"; + $newpar = "\\par\\pard\\plain\\sb120\n"; + } elsif ($ptype eq "code") { + # Code paragraph. + print "\\keep\\f1\\sb120\n"; + foreach $i (@$pname) { + my $x = $i; + warn "code line longer than 68 chars: $i\n" if length $i > 68; + $x =~ s/\\/\\\\/g; + $x =~ s/\{/\\\{/g; + $x =~ s/\}/\\\}/g; + print "$x\\par\\sb0\n"; + } + $newpar = "\\pard\\f0\\sb120\n"; + } elsif ($ptype eq "bull" || $ptype eq "norm") { + # Ordinary paragraph, optionally bulleted. We wrap, FWIW. + if ($ptype eq "bull") { + print "\\tx360\\li360\\fi-360{\\f3\\'9F}\\tab\n"; + $newpar = "\\par\\pard\\sb120\n"; + } else { + $newpar = "\\par\\sb120\n"; + } + $line = ''; + @a = @$pname; + $wd = $wprev = ''; + do { + do { $w = &word_hlp((shift @a),1); } while $w eq "\001"; # hack + $wd .= $wprev; + if ($w eq ' ' || $w eq '' || $w eq undef) { + if (length ($line . $wd) > 75) { + $line =~ s/\s*$//; # trim trailing spaces + print "$line \n"; # and put one back + $line = ''; + $wd =~ s/^\s*//; # trim leading spaces + } + $line .= $wd; + $wd = ''; + } + $wprev = $w; + } while ($w ne '' && $w ne undef); + if ($line =~ /\S/) { + $line =~ s/\s*$//; # trim trailing spaces + print "$line\n"; + } + } + } + + # Close file. + print "\\page}\n"; + select STDOUT; + close TEXT; +} + +sub word_hlp { + my ($w, $docode) = @_; + my $wtype, $wmajt; + + return undef if $w eq '' || $w eq undef; + $wtype = substr($w,0,2); + $wmajt = substr($wtype,0,1); + $w = substr($w,2); + $w =~ s/\\/\\\\/g; + $w =~ s/\{/\\\{/g; + $w =~ s/\}/\\\}/g; + $w =~ s/<.*>// if $wmajt eq "w"; # remove web links + substr($w,0,length($w)-1) =~ s/-/\\\'AD/g if $wmajt ne "x"; #nonbreakhyphens + if ($wmajt eq "n" || $wtype eq "e " || $wtype eq "w ") { + return $w; + } elsif ($wtype eq "sp") { + return ' '; + } elsif ($wtype eq "da") { + return "\\'96"; + } elsif ($wmajt eq "c" || $wtype eq "wc") { + $w =~ s/ /\\\'A0/g; # make spaces non-breaking + return $docode ? "{\\f1 ${w}}" : $w; + } elsif ($wtype eq "es") { + return "{\\i ${w}"; + } elsif ($wtype eq "ee") { + return "${w}}"; + } elsif ($wtype eq "eo") { + return "{\\i ${w}}"; + } elsif ($wtype eq "x ") { + return "{\\uldb "; + } elsif ($wtype eq "xe") { + $w = &hlp_sectkw($w); + return "}{\\v ${w}}"; + } elsif ($wmajt eq "i") { + return "\001"; + } else { + die "panic in word_hlp: $wtype$w\n"; + } +} + +sub hlp_menu { + my ($topitem) = @_; + my $item, $kword, $i, $mpname, $title; + + $item = $tstruct_next{$topitem}; + print "\\li360\\fi-360\n"; + while ($item) { + $title = ""; + $mpname = $tstruct_pname{$item}; + foreach $i (@$mpname) { + $ww = &word_hlp($i, 0); + $title .= $ww unless $ww eq "\001"; + } + $kword = &hlp_sectkw($item); + print "{\\uldb ${item}: $title}{\\v $kword}\\par\\sb0\n"; + $item = $tstruct_mnext{$item}; + } + print "\\pard\\sb120\n"; +} + +sub hlp_sectkw { + my ($node) = @_; + $node =~ tr/A-Z/a-z/; + $node =~ tr/- ./___/; + $node; +} + +sub hlp_keywords { + my ($node) = @_; + my $pfx = "K{\\footnote "; + my $done = 0; + foreach $i (0..$#itags) { + (print $pfx,$hlp_index[$i]), $pfx = ";\n", $done++ + if $idxnodes{$node,$itags[$i]}; + } + print "}\n" if $done; +} + +# Make tree structures. $tstruct_* is top-level and global. +sub add_item { + my ($item, $level) = @_; + my $i; + + $tstruct_pname{$item} = $pname; + $tstruct_next{$tstruct_previtem} = $item; + $tstruct_prev{$item} = $tstruct_previtem; + $tstruct_level{$item} = $level; + $tstruct_up{$item} = $tstruct_last[$level-1]; + $tstruct_mnext{$tstruct_last[$level]} = $item; + $tstruct_last[$level] = $item; + for ($i=$level+1; $i<$MAXLEVEL; $i++) { $tstruct_last[$i] = undef; } + $tstruct_previtem = $item; + push @nodes, $item; +} + +# +# This produces documentation intermediate paragraph format; this is +# basically the digested output of the front end. Intended for use +# by future backends, instead of putting it all in the same script. +# +sub write_dip { + open(PARAS, "> nasmdoc.dip"); + foreach $k (keys(%metadata)) { + print PARAS 'meta :', $k, "\n"; + print PARAS $metadata{$k},"\n"; + } + for ($para = 0; $para <= $#pnames; $para++) { + print PARAS $pflags[$para], "\n"; + print PARAS join("\037", @{$pnames[$para]}, "\n"); + } + foreach $k (@itags) { + print PARAS 'indx :', $k, "\n"; + print PARAS join("\037", @{$idxmap{$k}}), "\n"; + } + close(PARAS); +} |