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 3392808 - [Support request] absolute with label/dollar sign to change from progbits section to a nobits section
Summary: [Support request] absolute with label/dollar sign to change from progbits sec...
Status: OPEN
Alias: None
Product: NASM
Classification: Unclassified
Component: Assembler (show other bugs)
Version: 2.16.xx
Hardware: All All
: Medium new functionality request
Assignee: nobody
URL:
Depends on:
Blocks:
 
Reported: 2022-09-11 09:46 PDT by E. C. Masloch
Modified: 2024-11-25 07:58 PST (History)
5 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description E. C. Masloch 2022-09-11 09:46:32 PDT
I wanted to note this down here just in case it isn't known yet. Perhaps the developers could add a test case for this to the repo?

I discovered this use in the Insight debugger application, at https://hg.pushbx.org/ecm/insight/file/73e1b07abd73/src/insight.asm#l103 to quote:

udata_start:

absolute	udata_start

		resb	WINDOW_BUF_SIZE - SHARED_DATA_SIZE
code_mark_buff	resw	10 * 4


What they do is to feed the "absolute" directive a label (equivalently, could use the dollar sign '$' here-position-indicator) so that they can then continue with nobits space reservation directives (resb and friends) at the exact address that the progbits section ended at. This is the easiest way I've seen of doing that.

The second-easiest, equally-or-more powerful way is to utilise NASM's bin format multi-section support, to make an explicit nobits section that follows the progbits section(s). However, this is more complex for users to understand and prepare. (My own debugger application, lDebug, employs this. However, its sectioning is very complex all in all anyway, featuring 9 different sections in the same assembly source.)

The remaining ways would involve labels and equates after the end of the progbits data, which becomes unwieldy very quickly if there's more than two or three variables (so to say).

Here's a small test case. The construct appears to work on at least two different NASM versions:

$ cat test2.asm
        org 256
        mov ax, buffer
        retn

absolute $
buffer: resb 100
$ nasm -v
NASM version 2.16rc0 compiled on Sep  6 2022
$ nasm test2.asm -l /dev/stderr -o /dev/null
     1                                          org 256
     2 00000000 B8[0400]                        mov ax, buffer
     3 00000003 C3                              retn
     4
     5                                  absolute $
     6 00000004 <res 64h>               buffer: resb 100
$ oldnasm -v
NASM version 2.14.03rc2 compiled on Aug 31 2019
$ oldnasm test2.asm -l /dev/stderr -o /dev/null
     1                                          org 256
     2 00000000 B8[0400]                        mov ax, buffer
     3 00000003 C3                              retn
     4
     5                                  absolute $
     6 00000004 <res 00000064>          buffer: resb 100
$


Additionally, here is a use case in the wild that reminded me of how this feature is used in Insight:

https://stackoverflow.com/questions/73618421/replace-one-character-with-string-in-assembly-language-8086#comment130109622_73679742
Comment 1 E. C. Masloch 2023-08-13 08:19:51 PDT
I made use of the ''absolute $'' feature in a different program: https://hg.pushbx.org/ecm/ldosmbr/rev/0bf55528bbac
Comment 2 E. C. Masloch 2024-03-17 14:35:06 PDT
I also make use of absolute with a progbits label in some of my Extensions for lDebug (ELDs), for example in aformat.asm: https://hg.pushbx.org/ecm/ldebug/file/ab4b2313e537/source/eld/aformat.asm#l487
Comment 3 E. C. Masloch 2024-11-25 07:58:24 PST
Used absolute $ in x2b2 as well: https://hg.pushbx.org/ecm/x2b2/rev/6467945b362c