summaryrefslogtreecommitdiff
path: root/asm/listing.c
Commit message (Collapse)AuthorAgeFilesLines
* Make debug info and error messages correctly reflect macros and repsH. Peter Anvin (Intel)2020-07-051-48/+2
| | | | | | | | | | | | | | | 1. Error messages would issue with the line number of %endrep. 2. Debug line information would ignore both macros and reps. This is doubly wrong; macros are semantically equivalent to inline functions, and it is expected that debuggers trace into these functions. These changes finishes the last parts of moving all responsibility for the listing enable/disable into the preprocessor, so remove the way over-complicated macro inhibit facility from the listing module entirely. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* listing: list short reserved blocks as ?? instead of <res ...>H. Peter Anvin (Intel)2020-06-271-2/+7
| | | | | | | | | | | <res ...> can get rather annoying when mixed in with data, as can happen with the MASM-like db syntax. List shorter blocks (8 bytes or less) as ?? instead; 8 bytes avoids line breaks for a single statement. This is probably more readable anyway... Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* listing: make it possible to flush the listing output after every lineH. Peter Anvin (Intel)2019-10-231-1/+6
| | | | | | | Add the -Lw option to flush the list file after every line output. This is handy for debugging if nasm hangs. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* listing: encapsulate the list_options encoding, make more comprehensiveH. Peter Anvin2019-08-101-4/+1
| | | | | | | | | | Encapsulate the list_options() encoding in an inline function. We only ever compute a mask with a non-constant input in two places (command line and pragma parsing), so a slightly more complex mapping is of no consequence; thus map a-z, A-Z and 0-9 as being the most likely characters we may want to use as options. Space is left for two more :) Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Add %pragma list optionsH. Peter Anvin2019-08-101-1/+43
| | | | | | | Add a %pragma to set (or clear) listing options. It only takes effect on the next assembly pass, however! Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* listing: clean up before a restartH. Peter Anvin2019-08-101-23/+24
| | | | | | | | | With the -Lp option, the listing generator gets invoked multiple times in the same session. If we already have a list file open, call list_cleanup() before reinitializing; otherwise we get stray output in the updated file. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* listing: coalesce TIMES in non-final passes, print <len>, clarify hexH. Peter Anvin2019-08-101-1/+1
| | | | | | | | | | | | | | | Merge TIMES in the nonfinal passes, there is no point in getting <len ...> an arbitrary number of times. Actually print <len> (OUT_RAWDATA without a data pointer), not <res> (OUT_RESERVE). Dropping the zero-fill for the hex format made the listing more manageable, but it also doesn't immediately look like hex, plus there is now the -Ld option. Put an h after hex (shorter than leading 0x) to make it obvious. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Additional listing options, improve help output, fix macro limitsH. Peter Anvin2019-08-101-17/+32
| | | | | | | | | | | | | | | | | | Additional listing options: -Ld to display counts in decimal -Lp to output a list file in every pass (to make sure one exists) Clean up the help output and make it comprehensive. The -hf and -y options are no longer necessary, although they are supported for backwards compatiblity. Fix macro-levels so it actually count descent levels; a new macro-tokens limit introduced for the actual token limit. Slightly simplify the limits code. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* listing: when listing lines in macros and rep blocks, show the actual lineH. Peter Anvin2019-08-091-3/+4
| | | | | | | When printing lines coming from %rep blocks and macros, show the line number corresponding to the line actually being printed. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* listing: add -L option for additional listing infoH. Peter Anvin (Intel)2019-08-091-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | Add an -L option for additional listing information. Currently supported is -Le, which emits each line after processing through the preprocessor, and -Lm, which displays each single-line macro defined or undefined. NASM doesn't preserve the names of unused arguments, nor does it have any technical reason to do so. Instead of adding complexity to save them, make unnamed parameters official by specifying an empty string in the argument list. This has the additional advantage that () is now simply considered a single empty argument, which means that NASM should now properly handle things like: %define myreg() eax mov edx,myreg() ... similar to how the C preprocessor allows an empty macro argument list which is distinct from a macro with no arguments whatsoever. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* Merge empty reservations from TIMES; add counts in listingsH. Peter Anvin2019-08-071-34/+60
| | | | | | | | | | | | For constructs like TIMES xx RESB yy merge the TIMES and RESB and feed a single reservation to the backend; this can (obviously) be dramatically faster. Add byte count in listings for <incbin> and repeat count to <rept>; to make them more reasonable in length shorten to <bin ...> and <rep ...> respectively, and don't require leading zeroes in bin/rep/res count. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Remove #includes already provided by "compiler.h"H. Peter Anvin2018-12-271-3/+0
| | | | | | | | "compiler.h" already includes a bunch of common include files. There is absolutely no reason to duplicate them in individual files, and in fact it robs us of central control of how these files are used. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Replace <ctype.h> includes with "nctype.h"H. Peter Anvin2018-12-271-1/+1
| | | | | | | For almost everything we should use "nctype.h". Right now we don't have a nasm_toupper() to use <ctype.h> for things that need toupper(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Move <string.h> inclusion to compiler.hH. Peter Anvin2018-12-261-1/+0
| | | | | | | There is absolutely no reason not to include <string.h> globally, and with the inline function for mempcpy() we need it there anyway. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* strlist, warnings: improve strlist, buffer warnings until errorH. Peter Anvin (Intel)2018-12-141-2/+1
| | | | | | | | | | | | | | Make strlist_free() take a pointer to a pointer, so we can set it to NULL. Buffer warnings on a strlist until we either get an error or we are in pass 2. Hopefully this should let us get rid of a lot of the ERR_PASS* bullshit, which far too often causes messages to get lost. asm/labels.c contains one example of a warning that cannot be made correct with a specific pass number. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* listing: use a non-uniqizing strlist to buffer error messagesH. Peter Anvin (Intel)2018-12-131-33/+22
| | | | | | Generic code is a wonderful thing... Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* errors: change the severity parameter from "int" to "errflags"H. Peter Anvin (Intel)2018-12-131-1/+1
| | | | | | | Change the severity parameter to the error function from "int" to an unsigned typedef, currently uint32_t. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* Merge remote-tracking branch 'origin/nasm-2.14.xx'H. Peter Anvin (Intel)2018-12-121-26/+45
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resolved Conflicts: asm/assemble.c asm/directiv.c asm/error.c asm/float.c asm/labels.c asm/listing.c asm/nasm.c asm/parser.c asm/preproc.c asm/stdscan.c include/error.h output/outelf.c version Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
| * error: new flag ERR_HEREH. Peter Anvin2018-12-121-11/+11
| | | | | | | | | | | | | | | | | | | | | | ERR_HERE is used to mark messages of the form "... here" so that we can emit sane output to the list file with filename and line number, instead of a nonsensical "here" which could point almost anywhere. This patch contains some changes from the one in the master branch to make the code cleaner. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| * listing.c: handle multiple error messages on a single lineH. Peter Anvin (Intel)2018-12-121-26/+49
| | | | | | | | | | | | | | We may produce an arbitrary number of error messages on a single line; include all of them in the list file. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | error: new flag ERR_HEREH. Peter Anvin2018-12-111-2/+6
| | | | | | | | | | | | | | | | ERR_HERE is used to mark messages of the form "... here" so that we can emit sane output to the list file with filename and line number, instead of a nonsensical "here" which could point almost anywhere. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | listing: Use nasm_error helpersCyrill Gorcunov2018-12-011-2/+1
|/ | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* gcc: fix mistakes discovered by recent gccH. Peter Anvin2018-06-021-1/+1
| | | | | | | Recent versions of gcc issue a couple of warnings, which may be real bugs. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Fix implicit fallthrough that trips -WerrorH. Peter Anvin2018-05-081-2/+3
| | | | | | | -Werror now trips on implicit fallthroughs. There is also at least one that probably should not be, although it appears to be harmless. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* Revert "Use fallthrough() to placate compiler"Cyrill Gorcunov2018-02-251-1/+1
| | | | This reverts commit 8a7c6009fbddd7084fdfaebd9e3e3fd0baa39bc2.
* Use fallthrough() to placate compilerCyrill Gorcunov2018-02-251-1/+1
| | | | | | | https://bugzilla.nasm.us/show_bug.cgi?id=3392465 Reported-by: Ozkan Sezer <sezeroz@gmail.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* Sanitize the handling of segments a bitH. Peter Anvin2017-05-031-5/+13
| | | | | | | | | | | Make the internal handling of segment numbers just a little more sane. The whole use of when we have done ofmt->segbase or not is crazy, though... In the meantime, add a few more hacks to the dbg output format to make it more useful. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* listing.c: show [ssss] for a segment instead of a bogus addressH. Peter Anvin2017-05-011-2/+9
| | | | | | | | There is no point in showing a number of a relative segment, so just show [ssss]; even if there is a possible segment offset it is linker-dependent and output format dependent. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* asm/*: Move directive processing to its own file, refactor error handlingH. Peter Anvin2017-03-071-0/+1
| | | | | | | | Move directive processing to its own file, and move nasmlib/error.c to asm/error.c (it was not used by the disassembler); remove some extern declarations from .c files, and do some general code cleanups. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* New backend interface - assembler internals #1H. Peter Anvin2016-09-201-20/+20
| | | | | | | | | | | | | | | | | | | | | This provides the first pass of assembler internals for a new, richer, backend interface. It also reduces the amount of data carried in function parameters inside the assembler. The new interface is in the form of a structure, which will contain substantially more information that the previous interface. This will allow things like ELF GOT32X and Mach-O X86_64_RELOC_BRANCH relocations to be reliably emitted. This provides the initial set of structures. Future additions should include: 1. Pass down the base symbol, if any. 2. Segments should be a structure rather than a number, and the horrible hack of adding one for a segment reference should be removed (OUT_SEGMENT replaces it.) Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* Reorganize the source code into subdirectoriesH. Peter Anvin2016-05-251-0/+338
Make the source code easier to understand and keep track of by organizing it into subdirectories depending on the function. Signed-off-by: H. Peter Anvin <hpa@zytor.com>