We are migrating the bug tracker to github Issues. This is now the preferred way to report NASM bugs.

Self-registration is disabled due to spam issue (mail gorcunov@gmail.com or hpa@zytor.com to create an account)

Bug 3392915 - [Feature request] Directive to emit text into the listing file only
Summary: [Feature request] Directive to emit text into the listing file only
Status: CLOSED FIXED
Alias: None
Product: NASM
Classification: Unclassified
Component: Assembler (show other bugs)
Version: new feature request
Hardware: All All
: Medium new functionality request
Assignee: nobody
URL:
Depends on:
Blocks:
 
Reported: 2024-07-10 08:15 PDT by E. C. Masloch
Modified: 2025-09-04 14:52 PDT (History)
5 users (show)

Obtained from: Built from git using configure
Generated by: Human
Bug category:
Observed for: Invalid input
Regression: No
Regression since:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description E. C. Masloch 2024-07-10 08:15:28 PDT
I'd like to have a directive like %warning but for the output to *only* be written to the listing file.

My use case is to add annotations to the listing file such as for changing sections. My TracList conversion scripts want to know which section code is being emitted to. It is trivial to detect the usual "section" or "segment" directives or the "addsection" and "usesection" macros that I use, but sometimes these simpler directives are used in macros where the expansion will show up like "section %1" without the actual section name listed.

Example: https://hg.pushbx.org/ecm/ldebug/file/a25db784fd80/source/debug.asm#l3409

(To be fair in this case the expansion is always one of two section names so I can work around this by explicitly using "usesection" with a literal section name. OTOH, false %if legs are still listed so it may not be easy to solve. Probably have to indirect into another mmacro that expands to just a literal "usesection lDEBUG_CODE".)

If this feature request is fulfilled I could add annotations into the listing file to show which section is being written to.

Alternatively the listing format could be extended to note when sections are switched. However, I think a %warning-but-to-the-listing-file is a more useful and more generic solution.

As a workaround, %warning can be used as is, but this will spam the output to the terminal that NASM is running from as well. Disabling the user warning class also seems to disable writing the warning text to the listing file so doesn't help.
Comment 1 H. Peter Anvin 2024-09-19 04:27:34 PDT
This makes a lot of sense.

I have added this as %note.

Checkin: 8d62e99e140f20dcab6d1568fe9b3734b5f3b61d

It should be in tomorrow's nightly build.
Comment 2 E. C. Masloch 2025-09-04 14:52:26 PDT
I made use of this, gated using a check for NASM v2.17, in three repos:

Emit usesection notes for dynamically expanded section names: https://hg.pushbx.org/ecm/ldebug/rev/8304e68ec140

Detect the above to find most section changes of the lDebug listing file: https://hg.pushbx.org/ecm/tractest/rev/fc5bf64b4745

Emit notes on what listing files should be included for an incbin: https://hg.pushbx.org/ecm/instsect/rev/b780f030905d

Detect the above to include nested listing files: https://hg.pushbx.org/ecm/tractest/rev/02afad5ca42c