diff options
author | H. Peter Anvin <hpa@zytor.com> | 2002-04-30 20:57:38 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2002-04-30 20:57:38 +0000 |
commit | 620515ab4e66b45f9440cf04a1fa61869275170f (patch) | |
tree | 4acce4f19447ce789254e3ba213d894481a76adc | |
parent | cd08b15c28d27843722fc26cdf6f77f9082efe62 (diff) | |
download | nasm-620515ab4e66b45f9440cf04a1fa61869275170f.tar.gz nasm-620515ab4e66b45f9440cf04a1fa61869275170f.tar.bz2 nasm-620515ab4e66b45f9440cf04a1fa61869275170f.zip |
NASM 0.98p6
-rw-r--r-- | COPYING | 340 | ||||
-rw-r--r-- | Licence | 10 | ||||
-rw-r--r-- | MODIFIED | 30 | ||||
-rw-r--r-- | Makefile.in | 9 | ||||
-rw-r--r-- | Mkfiles/Makefile.b32 | 138 | ||||
-rw-r--r-- | Mkfiles/Makefile.os2 | 207 | ||||
-rw-r--r-- | Wishlist | 21 | ||||
-rw-r--r-- | changed.asm | 15 | ||||
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | doc/Makefile | 28 | ||||
-rw-r--r-- | insns.dat | 11 | ||||
-rw-r--r-- | nasm.1 | 14 | ||||
-rw-r--r-- | nasm.c | 222 | ||||
-rw-r--r-- | nasm.h | 2 | ||||
-rw-r--r-- | ndisasm.c | 3 | ||||
-rw-r--r-- | preproc.c | 93 | ||||
-rw-r--r-- | preproc.h | 1 |
17 files changed, 1044 insertions, 104 deletions
@@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) 19yy <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. @@ -95,4 +95,14 @@ inaccurate or a failure of the Software to operate with any other programs, even if you have been advised of the possibility of such damages. +X. In addition to what this Licence provides, the Software may be +distributed in such a way as to be compliant with the GNU General +Public Licence, as published by the Free Software Foundation, +Cambridge, MA, USA; version 2, or, at your option, any later version; +incorporated herein by reference. You must include a copy of this +Licence with such distribution. Furthermore, patches sent to the +authors for the purpose of inclusion in the official release version +are considered cleared for release under the full terms of this +Licence. + END OF LICENCE AGREEMENT @@ -1,6 +1,34 @@ This is a modified version of NASM, modified and released by H. Peter Anvin <hpa@zytor.com>; it is not the original form released by the -NASM authors. +NASM authors. However, as of 0.98p6 I have agreed to release the +official 0.98 version, so this is now an "official pre-release". + +For release 0.98p6: + +* 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. +* 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. +* Recognize "idt" or "centaur" for the -p option to ndisasm. +* Changed error messages back to stderr where they belong, but add an + -E option to redirect them elsewhere (the DOS shell cannot redirect + stderr.) +* -M option to generate Makefile dependencies (based on code from Alex + Verstak.) +* %undef preprocessor directive, and -u option, that undefines a + single-line macro. +* OS/2 Makefile (Mkfiles/Makefile.os2) for Borland under OS/2; from + Chuck Crayne. +* Various minor bugfixes (reported by): + - Dangling %s in preproc.c (Martin Junker) +* 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. +* Updated the License file per agreement with Simon and Jules to + include a GPL distribution clause. For release 0.98p3.7: diff --git a/Makefile.in b/Makefile.in index 35bf95c..b991991 100644 --- a/Makefile.in +++ b/Makefile.in @@ -20,6 +20,8 @@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ +NROFF = @NROFF@ + .c.o: $(CC) -c $(CFLAGS) $< @@ -30,7 +32,7 @@ NASM = nasm.o nasmlib.o float.o insnsa.o assemble.o labels.o \ NDISASM = ndisasm.o disasm.o sync.o nasmlib.o insnsd.o -all: nasm ndisasm +all: nasm ndisasm nasm.man nasm: $(NASM) $(CC) -o nasm $(NASM) @@ -80,6 +82,9 @@ insnsa.c insnsd.c insnsi.h insnsn.c: insns.dat insns.pl macros.c: standard.mac macros.pl perl $(srcdir)/macros.pl $(srcdir)/standard.mac +nasm.man: nasm.1 + $(NROFF) -man nasm.1 > nasm.man + install: nasm ndisasm $(INSTALL_PROGRAM) nasm $(bindir)/nasm $(INSTALL_PROGRAM) ndisasm $(bindir)/ndisasm @@ -95,7 +100,7 @@ distclean: clean cd rdoff; $(MAKE) distclean cleaner: clean - rm -f insnsa.c insnsd.c insnsi.h insnsn.c macros.c + rm -f insnsa.c insnsd.c insnsi.h insnsn.c macros.c nasm.man spotless: distclean cleaner diff --git a/Mkfiles/Makefile.b32 b/Mkfiles/Makefile.b32 new file mode 100644 index 0000000..d442238 --- /dev/null +++ b/Mkfiles/Makefile.b32 @@ -0,0 +1,138 @@ +# Makefile for the Netwide Assembler under 32 bit NT console
+#
+# The Netwide Assembler is copyright (C) 1996 Simon Tatham and
+# Julian Hall. All rights reserved. The software is
+# redistributable under the licence given in the file "Licence"
+# distributed in the NASM archive.
+#
+# This Makefile is designed to build NASM with the latest
+# version of Borland C++Builder and has been tested with
+# Borland C++ 5.3 (Borland C++Builder 3.0) and Borland C++ 5.4
+# (Borland C++Builder 4.0) in combination with
+# Borland MAKE versions 5.1 and 5.2
+#
+# MAKEFILE is maintained by Stefan.Hoffmeister@Econos.de
+#
+
+
+# If "BINDIR=C:\...." has not been defined on the command line
+# assume that the binary files are in the same directory as the
+# MAKE utility
+!message ****************************************************
+!message Note:
+!message -----
+!if $d(BINDIR)
+ !message Path to tools set to $(BINDIR)
+!else
+ BINDIR=$(MAKEDIR)
+ !message Assuming path to tools to be $(BINDIR)
+ !message
+ !message You can change this assumption by specifying
+ !message -DBINDIR=C:\my_path
+ !message as a command line paramter for MAKE
+!endif
+!message ****************************************************
+
+
+CC=$(BINDIR)\bcc32
+CCFLAGS=-tWC -c -O2 -A
+ # /-tWC: Windows console mode application
+ # /c: Compile, do not link
+ # /O2: Optimize for speed
+ # /A: ANSI compatible code only
+
+LINK=$(BINDIR)\ilink32
+LINKFLAGS=/V4.0 /x /c /ap /L$(BINDIR)\..\LIB # /L -> default LIB directory
+ # /V4.0: marked as Win95 / NT application in PE header
+ # /x: no map file
+ # /c: case sensitive link
+ # /ap: link for 32-bit console application
+ # /L...: path to .lib directory
+
+
+# default libraries for Win32 console applications
+LIBRARIES=cw32.lib import32.lib
+# default startup code for Win32 console applications
+STARTUP=c0x32.obj
+
+# default extension for our EXE
+EXE=.exe
+# default extension for OBJ files
+OBJ=obj
+
+
+SUFFIX= w# # by default, this makefile produces nasmw.exe and ndisasmw.exe
+
+
+# Builds C files to OBJ
+.c.$(OBJ):
+ $(CC) $(CCFLAGS) $*.c
+
+
+NASMOBJS = nasm.$(OBJ) nasmlib.$(OBJ) float.$(OBJ) insnsa.$(OBJ) \
+ assemble.$(OBJ) labels.$(OBJ) parser.$(OBJ) outform.$(OBJ) \
+ outbin.$(OBJ) outaout.$(OBJ) outcoff.$(OBJ) outelf.$(OBJ) \
+ outobj.$(OBJ) outas86.$(OBJ) outrdf.$(OBJ) outdbg.$(OBJ) \
+ outrdf2.$(OBJ) zoutieee.$(OBJ) \
+ preproc.$(OBJ) listing.$(OBJ) eval.$(OBJ)
+
+NDISASMOBJS = ndisasm.$(OBJ) disasm.$(OBJ) sync.$(OBJ) nasmlib.$(OBJ) \
+ insnsd.$(OBJ)
+
+
+BuildAll: nasm$(SUFFIX)$(EXE) ndisasm$(SUFFIX)$(EXE)
+
+
+# NASM
+nasm$(SUFFIX)$(EXE): $(NASMOBJS)
+ $(LINK) $(LINKFLAGS) @&&| #open temp response file
+ $(STARTUP) $**
+ nasm$(SUFFIX)$(EXE)
+ # default MAP file name for EXE
+ $(LIBRARIES)
+| # close temp file, first column!
+
+
+# NDISASM
+ndisasm$(SUFFIX)$(EXE): $(NDISASMOBJS)
+ $(LINK) $(LINKFLAGS) @&&| #open temp response file
+ $(STARTUP) $**
+ ndisasm$(SUFFIX)$(EXE)
+ # default MAP file name for EXE
+ $(LIBRARIES)
+| # close temp file, first column!
+
+
+# OBJs with dependencies
+assemble.$(OBJ): assemble.c nasm.h insnsi.h assemble.h insns.h
+disasm.$(OBJ): disasm.c nasm.h insnsi.h disasm.h sync.h insns.h names.c insnsn.c
+eval.$(OBJ): eval.c nasm.h insnsi.h nasmlib.h eval.h
+float.$(OBJ): float.c nasm.h insnsi.h
+insnsa.$(OBJ): insnsa.c nasm.h insnsi.h insns.h
+insnsd.$(OBJ): insnsd.c nasm.h insnsi.h insns.h
+labels.$(OBJ): labels.c nasm.h insnsi.h nasmlib.h
+listing.$(OBJ): listing.c nasm.h insnsi.h nasmlib.h listing.h
+nasm.$(OBJ): nasm.c nasm.h insnsi.h nasmlib.h parser.h assemble.h labels.h \
+ listing.h outform.h
+nasmlib.$(OBJ): nasmlib.c nasm.h insnsi.h nasmlib.h
+ndisasm.$(OBJ): ndisasm.c nasm.h insnsi.h sync.h disasm.h
+outas86.$(OBJ): outas86.c nasm.h insnsi.h nasmlib.h
+outaout.$(OBJ): outaout.c nasm.h insnsi.h nasmlib.h
+outbin.$(OBJ): outbin.c nasm.h insnsi.h nasmlib.h
+outcoff.$(OBJ): outcoff.c nasm.h insnsi.h nasmlib.h
+outdbg.$(OBJ): outdbg.c nasm.h insnsi.h nasmlib.h
+outelf.$(OBJ): outelf.c nasm.h insnsi.h nasmlib.h
+outobj.$(OBJ): outobj.c nasm.h insnsi.h nasmlib.h
+outrdf.$(OBJ): outrdf.c nasm.h insnsi.h nasmlib.h
+outrdf2.$(OBJ): outrdf2.c nasm.h insnsi.h nasmlib.h
+zoutieee.$(OBJ): zoutieee.c nasm.h insnsi.h nasmlib.h
+outform.$(OBJ): outform.c outform.h nasm.h insnsi.h
+parser.$(OBJ): parser.c nasm.h insnsi.h nasmlib.h parser.h float.h names.c insnsn.c
+preproc.$(OBJ): preproc.c macros.c preproc.h nasm.h insnsi.h nasmlib.h
+sync.$(OBJ): sync.c sync.h
+
+clean:
+ del *.obj
+ del nasm$(SUFFIX)$(EXE)
+ del ndisasm$(SUFFIX)$(EXE)
+
diff --git a/Mkfiles/Makefile.os2 b/Mkfiles/Makefile.os2 new file mode 100644 index 0000000..3ebbac1 --- /dev/null +++ b/Mkfiles/Makefile.os2 @@ -0,0 +1,207 @@ +# Makefile for the Netwide Assembler under OS/2 (aimed at Borland C++ for OS/2) +# +# The Netwide Assembler is copyright (C) 1996 Simon Tatham and +# Julian Hall. All rights reserved. The software is +# redistributable under the licence given in the file "Licence" +# distributed in the NASM archive. +# +# This makefile is made to compile NASMOS2 and NDISASM2 +# using Borland C++ for OS/2. +# +#------------------------------------------------------------------- +# Make Directives +#------------------------------------------------------------------- +.AUTODEPEND : +.SUFFIXES : .rc .res .obj .c .cpp .asm .hlp .itl .ipf + +#------------------------------------------------------------------- +# Make Macros +#------------------------------------------------------------------- + +LIBS = c2 + os2 + +# -------------------------------------------------------------------------- +# +# c compile only +# v include full sybolic debugging information +# b force enums to be of type int +# +# -------------------------------------------------------------------------- + +CCFLAGS = /c /v /b + +CC = bcc #compiler +LINK = tlink #linker + +DCCFLAGS = /d /c /O /A #compiler flags for NDISASM + #/d=merge dupicate strings + #/c=compile only + #/O=Optimise jumps + #/A=ANSI standard C + +LINKFLAGS = /c /x #linker flags + #/c=case sIgnificance on symbols + #/x=No map file at all + +LIBRARIES = #any libaries to add, out side of the standard libary +EXE = .exe #executable file extention (keep the . as the start) +OBJ = obj #OBJ file extention + +NASM_ASM=$(CC) $(CCFLAGS) $&.c #Command line for NASM +DASM_ASM=$(CC) $(DCCFLAGS) $&.c #command line for NDISASM + +# NOTE: $& is used to create the file name, as it only gives the name it's +# self, where as using $* would have give the full path of the file it +# want's done. This becomes a problem if the OBJ files are in a seperate +# directory, becuse it will then try to find the source file in the OBJ +# dir. + +################################################################ +#The OBJ files that NASM is dependent on + +NASMOBJS = $(OBJD)nasm.$(OBJ) $(OBJD)nasmlib.$(OBJ) $(OBJD)float.$(OBJ) \ + $(OBJD)insnsa.$(OBJ) $(OBJD)assemble.$(OBJ) $(OBJD)labels.$(OBJ) \ + $(OBJD)parser.$(OBJ) $(OBJD)outform.$(OBJ) $(OBJD)preproc.$(OBJ) \ + $(OBJD)listing.$(OBJ) $(OBJD)eval.$(OBJ) $(OBJD)outrdf2.$(OBJ) $(OBJD)zoutieee.$(OBJ) + +################################################################ +#The OBJ files that NDISASM is dependent on + +NDISASMOBJS = $(OBJD)ndisasm.$(OBJ) $(OBJD)disasm.$(OBJ) $(OBJD)sync.$(OBJ) \ + $(OBJD)nasmlibd.$(OBJ) $(OBJD)insnsd.$(OBJ) + +################################################################ +#The OBJ file for the output formats. + +OUTOBJ= $(OBJD)outbin.$(OBJ) $(OBJD)outaout.$(OBJ) $(OBJD)outcoff.$(OBJ) \ + $(OBJD)outelf.$(OBJ) $(OBJD)outobj.$(OBJ) $(OBJD)outas86.$(OBJ) \ + $(OBJD)outrdf.$(OBJ) $(OBJD)outdbg.$(OBJ) + + +################################################################ +# Build everything + +all : nasmos2$(EXE) ndisasm2$(EXE) + +################################################################ +#NASM, NDISASM compile, I hope it's self explanitory + +nasmos2$(EXE): $(NASMOBJS) $(OUTOBJ) + $(LINK) $(LINKFLAGS) @&&! #command for the linker + C02 $(NASMOBJS) $(OUTOBJ) #OBJ file list + $(EXED)nasmos2$(EXE) #EXE file name + NASMOS2.MAP + $(LIBS) #Libaries needed + NASMOS2.DEF #Link Definition file +! + +ndisasm2$(EXE): $(NDISASMOBJS) + $(LINK) $(LINKFLAGS) @&&! #command for the linker + c02.obj $(NDISASMOBJS) #OBJ file list + $(EXED)ndisasm2$(EXE) #EXE file name + NDISAMS2.MAP + $(LIBS) $(LIBRARIES) #Libaries needed +! + +################################################################ +# Dependencies for all of NASM's obj files + +$(OBJD)assemble.$(OBJ): assemble.c nasm.h assemble.h insns.h + $(NASM_ASM) + +$(OBJD)float.$(OBJ): float.c nasm.h + $(NASM_ASM) + +$(OBJD)labels.$(OBJ): labels.c nasm.h nasmlib.h + $(NASM_ASM) + +$(OBJD)listing.$(OBJ): listing.c nasm.h nasmlib.h listing.h + $(NASM_ASM) + +$(OBJD)eval.$(OBJ): eval.c nasm.h nasmlib.h eval.h + $(NASM_ASM) + +$(OBJD)nasm.$(OBJ): nasm.c nasm.h nasmlib.h parser.h assemble.h labels.h \ + listing.h outform.h + $(NASM_ASM) + +$(OBJD)nasmlib.$(OBJ): nasmlib.c nasm.h nasmlib.h + $(NASM_ASM) + +$(OBJD)parser.$(OBJ): parser.c nasm.h nasmlib.h parser.h float.h names.c + $(NASM_ASM) + +$(OBJD)preproc.$(OBJ): preproc.c macros.c preproc.h nasm.h nasmlib.h + $(NASM_ASM) + +$(OBJD)insnsa.$(OBJ): insnsa.c nasm.h insns.h + $(NASM_ASM) + +################################################################ +# Dependencies for all of NDISASM's obj files + +$(OBJD)disasm.$(OBJ): disasm.c nasm.h disasm.h sync.h insns.h names.c + $(DASM_ASM) + +$(OBJD)ndisasm.$(OBJ): ndisasm.c nasm.h sync.h disasm.h + $(DASM_ASM) + +$(OBJD)sync.$(OBJ): sync.c sync.h + $(DASM_ASM) + +$(OBJD)insnsd.$(OBJ): insnsd.c nasm.h insns.h + $(DASM_ASM) + +# This is a kludge from the word go, as we can't use the nasmlib.obj compiled +# for NASM, as it's could be the wrong model size, so we have to compile it +# again as huge to make sure. +# +# So as not to overwrite the nasmlib.obj for NASM (if it did, that +# could cause all kinds of problems) it compiles it into nasmlibd.obj. +# +# the -o... switch tells it the name to compile the obj file to, right here +# $(OBJD)nasmlibd.obj + +$(OBJD)nasmlibd.$(OBJ): nasmlib.c nasm.h nasmlib.h + $(CC) $(DCCFLAGS) -o$(OBJD)nasmlibd.obj nasmlib.c + +################################################################ +# Dependencies for all of the output format's OBJ files + +$(OBJD)outas86.$(OBJ): outas86.c nasm.h nasmlib.h + $(NASM_ASM) + +$(OBJD)outaout.$(OBJ): outaout.c nasm.h nasmlib.h + $(NASM_ASM) + +$(OBJD)outbin.$(OBJ): outbin.c nasm.h nasmlib.h + $(NASM_ASM) + +$(OBJD)outcoff.$(OBJ): outcoff.c nasm.h nasmlib.h + $(NASM_ASM) + +$(OBJD)outdbg.$(OBJ): outdbg.c nasm.h nasmlib.h + $(NASM_ASM) + +$(OBJD)outelf.$(OBJ): outelf.c nasm.h nasmlib.h + $(NASM_ASM) + +$(OBJD)outobj.$(OBJ): outobj.c nasm.h nasmlib.h + $(NASM_ASM) + +$(OBJD)outrdf.$(OBJ): outrdf.c nasm.h nasmlib.h + $(NASM_ASM) + +$(OBJD)outform.$(OBJ): outform.c outform.h nasm.h + $(NASM_ASM) + +################################################################ +# A quick way to delete the OBJ files as well as the binaries. + +clean : + del $(OBJD)*.obj + del nasmos2$(EXE) + del ndisasm2$(EXE) + +# Makefile created by Chuck Crayne <ccrayne@pacific.net> --05/4/99 +# Based on Makefile.bc2 by Fox Cutter <lmb@comtch.iea.com> --01/27/97 @@ -12,13 +12,17 @@ have this done by. ? means I haven't looked at it yet. - Package the Linux Assembler HOWTO. 0.98 -- AMD 3dNow extensions need documenting. 0.98 +- 3DNow!, SSE and other extensions need documenting. 0.98 + hpa: Does it really make sense to have a whole instruction set + reference packaged with the assembler? - prototypes of lrotate don't match in test/*. Fix. 0.98 - Build djgpp binaries for 0.98 onwards. Look into PMODE/W as a stub 0.98 - it might be a lot better than CWSDPMI. It's in PMW133.ZIP. +- %undef operator that goes along with %define DONE + - Fix `%error' giving error messages twice. 0.99 Not especially important, as changes planned for 1.1x below will make the preprocessor be only called once. @@ -105,9 +109,9 @@ have this done by. ? means I haven't looked at it yet. set to be written that allows the same source files to be assembled with NASM and TASM. -- Add the UD2 instruction. ? +- Add the UD2 instruction. DONE -- Add the four instructions documented in 24368901.pdf (Intel's own ? +- Add the four instructions documented in 24368901.pdf (Intel's own DONE document). - Some means of avoiding MOV memoffs,EAX which apparently the 1.10? @@ -177,6 +181,8 @@ have this done by. ? means I haven't looked at it yet. - Arbitrary section names in `bin'. ? Is this necessary? Is it even desirable? + hpa: Desirable, yes. Necessary? Probably not, but there are + definitely cases where it becomes quite useful. - Ability to read from a pipe. Obviously not useful under dos, so 1.10 memory problems with storing entire input file aren't a problem @@ -240,8 +246,10 @@ have this done by. ? means I haven't looked at it yet. undocumented flags in the instruction table. When this happens, consider allowing PMULHRW to map to either of the Cyrix or AMD versions? + hpa: The -p option to ndisasm now uses this to some extent. - Maybe NEC V20/V30 instructions? ? + hpa: What are they? Should be trivial to implement. - Yet more object formats. * Possibly direct support for .EXE files? 1.10 @@ -262,7 +270,10 @@ have this done by. ? means I haven't looked at it yet. byte code; probably ARM/StrongARM; maybe Sparc; maybe Mips; maybe Vax. Perhaps Z80 and 6502, just for a laugh? -- Consider a 'verbose' option that prints information about the resulting ? - object file onto stdout. +- Consider a 'verbose' option that prints information about the ? + resulting object file onto stdout. +- Line numbers in the .lst file don't match the line numbers in the ? + input. They probably should, rather than the current matching + of the post-preprocessor line numbers. diff --git a/changed.asm b/changed.asm index 88255f0..b0fd424 100644 --- a/changed.asm +++ b/changed.asm @@ -307,8 +307,23 @@ arg_example2 arg2 sqrtps xmm0,[ebx+10] ; SSE opcode paddsiw mm0,[ebx+10] ; Cyrix opcode with the same byte seq. +;----------------------------------------------------------------------------- +; Enhancement by hpa in preproc.c +; +; Support %undef to remoce a single-line macro +; +%define TEST_ME 42 +%ifndef TEST_ME +%error "TEST_ME not defined after %define" +%endif + +%undef TEST_ME +%ifdef TEST_ME +%error "TEST_ME defined after %undef" %endif +%endif ; oldmsg + %ifdef oldcrash ;************************************************************* This_label_is_256_characters_long__There_used_to_be_a_bug_in_stdscan_which_made_it_crash_when_it_did_a_keyword_search_on_any_label_longer_than_255_characters__Now_anything_longer_than_MAX_KEYWORD_is_always_a_symbol__It_will_not_even_try_a_keyword_search___ diff --git a/configure.in b/configure.in index b5fb0e1..80e9b38 100644 --- a/configure.in +++ b/configure.in @@ -62,6 +62,10 @@ else fi AC_SUBST(GCCFLAGS) +dnl Look for "nroff" or "groff" +AC_CHECK_PROGS(NROFF, groff nroff, echo) +AC_SUBST(NROFF) + dnl Checks for header files. AC_HEADER_STDC if test $ac_cv_header_stdc = no; then diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..572ca57 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,28 @@ +# +# Makefile for NASM documentation + +SRCS = nasmdoc.src +OUT = nasm.info + +all: $(OUT) + +.SUFFIXES: .src .texi .info .ps .rtf .hpj .ps .txt .pl + +# Consider html, txt and src output a side effect +.src.texi: + -mkdir html + perl ./rdsrc.pl < $< + mv -f *.html html + +nasm.info: nasmdoc.texi + -mkdir info + makeinfo $< + mv -f *.info *.info-* info + +clean: + -rm -f *.rtf *.hpj *.texi + +spotless: clean + -rm -rf html info *.hlp *.txt *.ps + + @@ -9,7 +9,11 @@ ; line. Hence `void' for no-operand instructions, and `\0' for such ; as EQU. If the last three fields are all `ignore', no action is ; taken except to register the opcode as being present. - +; +; For a detailed description of the code string (third field), please +; see the comment at the top of assemble.c. For a detailed description +; of the flags (fourth field), please see insns.h. +; AAA void \1\x37 8086 AAD void \2\xD5\x0A 8086 AAD imm \1\xD5\24 8086,SB @@ -1271,10 +1275,11 @@ PAVGB mmxreg,mem \301\2\x0F\xE0\110 KATMAI,MMX,SM PAVGW mmxreg,mmxreg \2\x0F\xE3\110 KATMAI,MMX PAVGW mmxreg,mem \301\2\x0F\xE3\110 KATMAI,MMX,SM PEXTRW reg32,mmxreg,imm8 \2\x0F\xC5\110\22 KATMAI,MMX -; This is documented as using a reg32, but it's really using only 16 bits -- accept either +; PINSRW is documented as using a reg32, but it's really using only 16 bit +; -- accept either PINSRW mmxreg,reg16,imm8 \2\x0F\xC4\110\22 KATMAI,MMX PINSRW mmxreg,reg32,imm8 \2\x0F\xC4\110\22 KATMAI,MMX -PINSRW mmxreg,mem16,imm8 \301\2\x0F\xC4\110\22 KATMAI,MMX,SM +PINSRW mmxreg,mem16,imm8 \301\2\x0F\xC4\110\22 KATMAI,MMX PMAXSW mmxreg,mmxreg \2\x0F\xEE\110 KATMAI,MMX PMAXSW mmxreg,mem \301\2\x0F\xEE\110 KATMAI,MMX,SM PMAXUB mmxreg,mmxreg \2\x0F\xDE\110 KATMAI,MMX @@ -53,6 +53,20 @@ to preprocess the given input file, and write the output to (or the specified output file name), and not actually assemble anything. .TP +.B \-M +Causes +.B nasm +to output Makefile-style dependencies to stdout; normal output is +suppressed. +.TP +.BI \-E " filename" +Causes +.B nasm +to redirect error messages to +.IR filename . +This option exists to support operating systems on which stderr is not +easily redirected. +.TP .BI \-r Causes .B nasm @@ -43,6 +43,8 @@ static int globallineno; /* for forward-reference tracking */ static int pass; static struct ofmt *ofmt = NULL; +static FILE *error_file = stderr; /* Where to write error messages */ + static FILE *ofile = NULL; static int sb = 16; /* by default */ @@ -57,7 +59,12 @@ static struct SAA *forwrefs; /* keep track of forward references */ static struct forwrefinfo *forwref; static Preproc *preproc; -static int preprocess_only; +enum op_type { + op_normal, /* Preprocess and assemble */ + op_preprocess, /* Preprocess only */ + op_depend /* Generate dependencies */ +}; +static enum op_type operating_mode; /* used by error function to report location */ @@ -131,7 +138,8 @@ int main(int argc, char **argv) forwrefs = saa_init ((long)sizeof(struct forwrefinfo)); preproc = &nasmpp; - preprocess_only = FALSE; + operating_mode = op_normal; + seg_init(); @@ -151,52 +159,70 @@ int main(int argc, char **argv) parser_global_info (ofmt, &location); eval_global_info (ofmt, lookup_label, &location); - if (preprocess_only) - { + switch ( operating_mode ) { + case op_depend: + { char *line; - char *file_name = NULL; - long prior_linnum=0; - int lineinc=0; - - if (*outname) { - ofile = fopen(outname, "w"); - if (!ofile) - report_error (ERR_FATAL | ERR_NOFILE, - "unable to open output file `%s'", outname); - } else - ofile = NULL; - - location.known = FALSE; - - preproc->reset (inname, 2, report_error, evaluate, &nasmlist); - while ( (line = preproc->getline()) ) { - /* - * We generate %line directives if needed for later programs - */ - long linnum = prior_linnum += lineinc; - int altline = src_get(&linnum, &file_name); - if (altline) { - if (altline==1 && lineinc==1) - nasm_fputs("", ofile); - else { - lineinc = (altline != -1 || lineinc!=1); - fprintf(ofile ? ofile : stdout, "%%line %ld+%d %s\n", - linnum, lineinc, file_name); - } - prior_linnum = linnum; - } - nasm_fputs(line, ofile); - nasm_free (line); - } - nasm_free(file_name); + preproc->reset (inname, 0, report_error, evaluate, &nasmlist); + if (outname[0] == '\0') + ofmt->filename (inname, outname, report_error); + ofile = NULL; + printf("%s: %s", outname, inname); + while ( (line = preproc->getline()) ) + nasm_free (line); preproc->cleanup(); - if (ofile) - fclose(ofile); - if (ofile && terminate_after_phase) - remove(outname); - } - else /* NOT preprocess only */ + putc('\n', stdout); + } + break; + + case op_preprocess: { + char *line; + char *file_name = NULL; + long prior_linnum=0; + int lineinc=0; + + if (*outname) { + ofile = fopen(outname, "w"); + if (!ofile) + report_error (ERR_FATAL | ERR_NOFILE, + "unable to open output file `%s'", outname); + } else + ofile = NULL; + + location.known = FALSE; + + preproc->reset (inname, 2, report_error, evaluate, &nasmlist); + while ( (line = preproc->getline()) ) { + /* + * We generate %line directives if needed for later programs + */ + long linnum = prior_linnum += lineinc; + int altline = src_get(&linnum, &file_name); + if (altline) { + if (altline==1 && lineinc==1) + nasm_fputs("", ofile); + else { + lineinc = (altline != -1 || lineinc!=1); + fprintf(ofile ? ofile : stdout, "%%line %ld+%d %s\n", + linnum, lineinc, file_name); + } + prior_linnum = linnum; + } + nasm_fputs(line, ofile); + nasm_free (line); + } + nasm_free(file_name); + preproc->cleanup(); + if (ofile) + fclose(ofile); + if (ofile && terminate_after_phase) + remove(outname); + } + break; + + case op_normal: + { /* * We must call ofmt->filename _anyway_, even if the user * has specified their own output file, because some @@ -205,46 +231,48 @@ int main(int argc, char **argv) * file. */ ofmt->filename (inname, outname, report_error); - + ofile = fopen(outname, "wb"); if (!ofile) { - report_error (ERR_FATAL | ERR_NOFILE, - "unable to open output file `%s'", outname); + report_error (ERR_FATAL | ERR_NOFILE, + "unable to open output file `%s'", outname); } - + /* * We must call init_labels() before ofmt->init() since * some object formats will want to define labels in their * init routines. (eg OS/2 defines the FLAT group) */ init_labels (); - + ofmt->init (ofile, report_error, define_label, evaluate); - + assemble_file (inname); - + if (!terminate_after_phase) { - ofmt->cleanup (using_debug_info); - cleanup_labels (); + ofmt->cleanup (using_debug_info); + cleanup_labels (); } else { - - /* - * We had an fclose on the output file here, but we - * actually do that in all the object file drivers as well, - * so we're leaving out the one here. - * fclose (ofile); - */ - - remove(outname); - if (listname[0]) - remove(listname); + + /* + * We had an fclose on the output file here, but we + * actually do that in all the object file drivers as well, + * so we're leaving out the one here. + * fclose (ofile); + */ + + remove(outname); + if (listname[0]) + remove(listname); } + } + break; } - + if (want_usage) - usage(); - + usage(); + raa_free (offsets); saa_free (forwrefs); eval_cleanup (); @@ -303,8 +331,10 @@ static int process_arg (char *p, char *q) case 'f': case 'p': case 'd': + case 'D': case 'i': case 'l': + case 'E': case 'F': if ( !(param = get_param (p, q, &advance)) ) break; @@ -322,12 +352,22 @@ static int process_arg (char *p, char *q) ofmt->current_dfmt = ofmt->debug_formats[0]; } else if (p[1]=='p') { /* pre-include */ pp_pre_include (param); - } else if (p[1]=='d') { /* pre-define */ + } else if (p[1]=='D' || p[1]=='d') { /* pre-define */ pp_pre_define (param); + } else if (p[1]=='U' || p[1]=='u') { /* un-define */ + pp_pre_undefine (param); } else if (p[1]=='i') { /* include search path */ pp_include_path (param); } else if (p[1]=='l') { /* listing file */ strcpy (listname, param); + } else if (p[1]=='E') { /* error messages file */ + error_file = fopen(param, "wt"); + if ( !error_file ) { + error_file = stderr; /* Revert to default! */ + report_error (ERR_FATAL | ERR_NOFILE | ERR_USAGE, + "cannot open file `%s' for error messages", + param); + } } else if (p[1] == 'F') { /* specify debug format */ ofmt->current_dfmt = dfmt_find(ofmt, param); if (!ofmt->current_dfmt) { @@ -344,18 +384,20 @@ static int process_arg (char *p, char *q) case 'h': printf("usage: nasm [-@ response file] [-o outfile] [-f format] " "[-l listfile]\n" - " [options...] [--] filename\n"); - printf(" or nasm -r for version info\n\n"); - printf(" -e preprocess only (writes output to " - "stdout by default)\n" - " -a don't preprocess\n\n"); - printf(" -g enable debug info\n" - " -F format select a debugging format\n\n"); - printf(" -i<path> adds a pathname to the include file path\n" + " [options...] [--] filename\n" + " or nasm -r for version info\n\n" + " -e preprocess only (writes output to stdout by default)\n" + " -a don't preprocess (assemble only)\n" + " -M generate Makefile dependencies on stdout\n\n" + " -E<file> redirect error messages to file\n\n" + " -g enable debug info\n" + " -F format select a debugging format\n\n" + " -i<path> adds a pathname to the include file path\n" " -p<file> pre-includes a file\n" - " -d<macro>[=<value>] pre-defines a macro\n"); - printf(" -w+foo enables warnings about foo; " - "-w-foo disables them\n where foo can be:\n"); + " -d<macro>[=<value>] pre-defines a macro\n" + " -u<macro> undefines a macro\n" + " -w+foo enables warnings about foo; -w-foo disables them\n" + "where foo can be:\n"); for (i=1; i<=ERR_WARN_MAX; i++) printf(" %-16s%s (default %s)\n", suppressed_names[i], suppressed_what[i], @@ -388,7 +430,7 @@ static int process_arg (char *p, char *q) exit (0); /* never need usage message here */ break; case 'e': /* preprocess only */ - preprocess_only = TRUE; + operating_mode = op_preprocess; break; case 'a': /* assemble only - don't preprocess */ preproc = &no_pp; @@ -408,6 +450,9 @@ static int process_arg (char *p, char *q) "invalid option to `-w'"); } break; + case 'M': + operating_mode = op_depend; + break; default: if (!ofmt->setinfo(GI_SWITCH,&p)) report_error (ERR_NONFATAL | ERR_NOFILE | ERR_USAGE, @@ -1165,23 +1210,23 @@ static void report_error (int severity, char *fmt, ...) return; if (severity & ERR_NOFILE) - fputs ("nasm: ", stdout); + fputs ("nasm: ", error_file); else { char * currentfile = NULL; long lineno = 0; src_get (&lineno, ¤tfile); - fprintf (stdout, "%s:%ld: ", currentfile, lineno); + fprintf (error_file, "%s:%ld: ", currentfile, lineno); nasm_free (currentfile); } if ( (severity & ERR_MASK) == ERR_WARNING) - fputs ("warning: ", stdout); + fputs ("warning: ", error_file); else if ( (severity & ERR_MASK) == ERR_PANIC) - fputs ("panic: ", stdout); + fputs ("panic: ", error_file); va_start (ap, fmt); - vfprintf (stdout, fmt, ap); - fputc ('\n', stdout); + vfprintf (error_file, fmt, ap); + fputc ('\n', error_file); if (severity & ERR_USAGE) want_usage = TRUE; @@ -1203,6 +1248,7 @@ static void report_error (int severity, char *fmt, ...) exit(1); /* instantly die */ break; /* placate silly compilers */ case ERR_PANIC: + fflush(NULL); abort(); /* halt, catch fire, and dump core */ break; } @@ -1210,7 +1256,7 @@ static void report_error (int severity, char *fmt, ...) static void usage(void) { - fputs("type `nasm -h' for help\n", stdout); + fputs("type `nasm -h' for help\n", error_file); } static void register_output_formats(void) @@ -13,7 +13,7 @@ #define NASM_MAJOR_VER 0 #define NASM_MINOR_VER 98 -#define NASM_VER "0.98 pre-release 3.7 (hpa)" +#define NASM_VER "0.98 pre-release 6" #ifndef NULL #define NULL 0 @@ -172,6 +172,9 @@ int main(int argc, char **argv) prefer = IF_AMD|IF_3DNOW; } else if ( !strcmp(v, "cyrix") ) { prefer = IF_CYRIX|IF_3DNOW; + } else if ( !strcmp(v, "idt") || !strcmp(v, "centaur") || + !strcmp(v, "winchip") ) { + prefer = IF_3DNOW; } else { fprintf(stderr, "%s: unknown vendor `%s' specified with `-p'\n", pname, v); return 1; @@ -268,7 +268,7 @@ static char *directives[] = { "%ifctx", "%ifdef", "%ifid", "%ifidn", "%ifidni", "%ifnctx", "%ifndef", "%ifnid", "%ifnidn", "%ifnidni", "%ifnnum", "%ifnstr", "%ifnum", "%ifstr", "%imacro", "%include", "%line", - "%macro", "%pop", "%push", "%rep", "%repl", "%rotate" + "%macro", "%pop", "%push", "%rep", "%repl", "%rotate", "%undef" }; enum { PP_ASSIGN, PP_CLEAR, PP_DEFINE, PP_ELIF, PP_ELIFCTX, PP_ELIFDEF, @@ -279,7 +279,7 @@ enum { PP_IFCTX, PP_IFDEF, PP_IFID, PP_IFIDN, PP_IFIDNI, PP_IFNCTX, PP_IFNDEF, PP_IFNID, PP_IFNIDN, PP_IFNIDNI, PP_IFNNUM, PP_IFNSTR, PP_IFNUM, PP_IFSTR, PP_IMACRO, PP_INCLUDE, PP_LINE, - PP_MACRO, PP_POP, PP_PUSH, PP_REP, PP_REPL, PP_ROTATE + PP_MACRO, PP_POP, PP_PUSH, PP_REP, PP_REPL, PP_ROTATE, PP_UNDEF }; @@ -290,7 +290,7 @@ static IncPath *ipath = NULL; static efunc error; static evalfunc evaluate; -static int pass; +static int pass; /* HACK: pass 0 = generate dependencies only */ static unsigned long unique; /* unique identifier numbers */ @@ -878,10 +878,21 @@ static FILE *inc_fopen(char *file) FILE *fp; char *prefix = "", *combine; IncPath *ip = ipath; + static int namelen = 0; while (1) { combine = nasm_strcat(prefix,file); fp = fopen(combine, "r"); + if (pass == 0 && fp) + { + namelen += strlen(combine) + 1; + if (namelen > 62) + { + printf(" \\\n "); + namelen = 2; + } + printf(" %s", combine); + } nasm_free (combine); if (fp) return fp; @@ -1060,7 +1071,8 @@ static int if_condition (Token *tline, int i) while (tok_isnt_(tt, ",")) tt = tt->next; if (!tt) { - error(ERR_NONFATAL, "`%s' expects two comma-separated arguments"); + error(ERR_NONFATAL, "`%s' expects two comma-separated arguments", + directives[i]); free_tlist (tline); return -1; } @@ -1829,6 +1841,56 @@ static int do_directive (Token *tline) free_tlist (origline); return 3; + case PP_UNDEF: + tline = tline->next; + skip_white_(tline); + if (!tline || (tline->type != TOK_ID && + (tline->type != TOK_PREPROC_ID || + tline->text[1] != '$'))) { + error (ERR_NONFATAL, + "`%%undef' expects a macro identifier"); + free_tlist (origline); + return 3; + } + mname = tline->text; + if (tline->type == TOK_ID) { + p = tline->text; + smhead = &smacros[hash(mname)]; + } else { + ctx = get_ctx (tline->text); + if (ctx == NULL) { + free_tlist (origline); + return 3; + } else { + p = tline->text+1; + p += strspn(p, "$"); + smhead = &ctx->localmac; + } + } + last = tline; + tline = tline->next; + last->next = NULL; + + if (tline) + error(ERR_WARNING, + "trailing garbage after macro name ignored"); + + /* + * We now have a macro name... go hunt for it. + */ + if (smacro_defined (mname, 0, &smac, 1) && smac) { + /* Defined, so we need to find its predecessor and nuke it */ + SMacro **s; + for ( s = smhead ; *s && *s != smac ; s = &(*s)->next ); + if ( *s ) { + *s = smac->next; + nasm_free(smac->name); + free_tlist(smac->expansion); + nasm_free(smac); + } + } + return 3; + case PP_ASSIGN: case PP_IASSIGN: tline = tline->next; @@ -3046,6 +3108,29 @@ void pp_pre_define (char *definition) predef = l; } +void pp_pre_undefine (char *definition) +{ + Token *def, *space; + Line *l; + + def = nasm_malloc(sizeof(Token)); + def->next = space = nasm_malloc(sizeof(Token)); + space->next = tokenise(definition); + + def->type = TOK_PREPROC_ID; + def->text = nasm_strdup("%undef"); + space->type = TOK_WHITESPACE; + space->text = nasm_strdup(" "); + + def->mac = space->mac = NULL; + + l = nasm_malloc(sizeof(Line)); + l->next = predef; + l->first = def; + l->finishes = FALSE; + predef = l; +} + void pp_extra_stdmac (char **macros) { extrastdmac = macros; @@ -12,6 +12,7 @@ void pp_include_path (char *); void pp_pre_include (char *); void pp_pre_define (char *); +void pp_pre_undefine (char *); void pp_extra_stdmac (char **); extern Preproc nasmpp; |