#17 (%assign does not support $) – The Yasm Modular Assembler Project
Modify

Ticket #17 (new defect)

Opened 7 years ago

Last modified 9 months ago

%assign does not support $

Reported by: jlawson-yasm@… Owned by: peter@…
Priority: P2 Milestone: 1.0.0
Component: Preprocessor: 'real' NASM Version: other
Severity: normal Keywords: rthml tab space editor js
Cc:

Description (last modified by peter@…) (diff)

The "$" operator (current assembly position) cannot be used in expressions for 
the %assign directive.

This was seen in YASM version 0.3.0
(Note that your Bugzilla version table dropdown does not list 0.3.0 yet)

For example this fails with "`$' not supported":

   %assign ual ($-startseg)
   mov eax,ual

But this succeeds:

   mov eax,($-startseg)

I've tried this in "-p nasm -r nasm" and also without any -p or -r options.

Attachments

Change History

comment:1 Changed 7 years ago by jlawson-yasm@…

  • Cc peter@… added
Note that in the above example, "startseg:" is a label defined previously.

comment:2 Changed 7 years ago by peter@…

  • Owner changed from mu@… to peter@…
  • Component changed from preprocessor: nasm-compatible to preprocessor: 'real' nasm
0.3.0 uses the real NASM preprocessor... and this bug was a crash workaround
until I figured out a better way to handle this.  As a workaround, use EQU for
the test case given.

The major difficulty here is for the %assign .... %if situation (e.g. you
%assign with a $ expression and then test that asssignment).  Because YASM only
preprocesses and parses a file once before passing the parsed result onto the
later assembly stages, whereas NASM parsed a file once, ran it all the way
through the assembler to determine offsets of jump targets, then re-parsed (and
re-preprocessed) the file to generate the output, the YASM preprocessor cannot
know the output addresses (e.g. $) whereas the NASM preprocessor can.

Thus, while it may be not too hard to support this particular testcases' usage,
not all usages of $ in %assign will be able to be supported without significant
impact to the overall design of YASM: multiple parses, or the slightly more
preferable (but still difficult to implement) option of pushing back %if
decisions to the output stage.

comment:3 Changed 7 years ago by jlawson-yasm@…

  • target_milestone changed from 0.2.0 to 0.3.0

comment:4 Changed 6 years ago by peter@…

  • Description modified (diff)
  • Milestone changed from 0.3.0 to 1.0.0
View

Add a comment

Modify Ticket

Action
as new
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.