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

Ticket #17 (new defect)

Opened 5 years ago

Last modified 2 years 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 5 years ago by jlawson-yasm@…

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

comment:2 Changed 5 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 5 years ago by jlawson-yasm@…

  • target_milestone changed from 0.2.0 to 0.3.0

comment:4 Changed 4 years ago by peter@…

  • description modified (diff)
  • milestone changed from 0.3.0 to 1.0.0

Add/Change #17 (%assign does not support $)

Author



Action
as new
 
Note: See TracTickets for help on using tickets.