Author Topic: %assign bug  (Read 2531 times)

Klod

  • Guest
%assign bug
« on: October 11, 2010, 01:44:40 AM »
 The following code snippet worked fine up to NASM NASM 2.09.02
Code: [Select]
%macro smac 1
    %defstr temp %$
        %rep %{1}
            %strcat temp ,temp ,'$'
        %endrep
    %deftok  %$index temp
    %warning %$index
%endm

%push __FIRST__
    %push __SECOND__
        %push __THIRD__
            smac 2
            %assign %{$index}first 3    ;create a local in context __FIRST__
            %defstr %$temp %{$index}first
            %warning %{$index}first %$temp
        %pop
            smac 1
            %assign %{$index}first  %{$index}first -1
            %warning %{$index}first
    %pop
   
        smac 0
        %assign %{$index}first  %{$index}first -1
        %warning %{$index}first
%pop

When compiling with produces errors assign expects macro

Code: [Select]
    ;NASM 2.10rc1-20101008
%push __FIRST__
    %push __SECOND__
        %push __THIRD__
            smac 2
            %assign %{$index}first 3    ;create a local in context __FIRST__ %$$$first
            %assign %$$$first 4
            ;%assign %{$index}first 5    ;error: `%assign' expects a macro identifier
            ;%undef %{$index}first        ;error: `%undef' expects a macro identifier
            ;%undef %$$$first       
            %warning %{$index}first  %{$index} %[%{$index}]
        %pop
            smac 1
            ;%assign %{$index}first  2
            %warning %{$index}first   %[$index]first
    %pop
   
        smac 0
        ;%assign %{$index}first  %{$index}first -1
        %warning %{$index}first
%pop   

It appears that the identifier %{$index}first can only be  used once in an %assignment, %define or %xdefine. Subsequent %undef of the identifier will also throw an  error.

in the bug tracker I found:
concatenating context variables with identifiers in %define

I wonder if this may be related??

Regards
Klod

Offline Cyrill Gorcunov

  • NASM Developer
  • Full Member
  • *****
  • Posts: 176
  • Country: 00
Re: %assign bug
« Reply #1 on: October 11, 2010, 07:48:35 PM »
thanks Klod, I'll take a look as only i can. Actually there was a bug in 2.09.02 which is fixed now and pushed in main repo, still your issues fires on nasm snapshot so I presume there is something else involved (probably deftok related).

Some simple code looked semi-same works fine
Code: [Select]
%macro smac 1
%defstr temp %$
%rep %{1}
%strcat temp ,temp ,'$'
%endrep
%deftok  %$index temp
%warning %$index
%endm

%macro s 1
%push __FIRST__
%push __SECOND__
%push __THIRD__
smac 2
%warning %$index

%assign %{%$index}%{%1}first 1
%warning %{%$index}%{%1}first
%pop

smac 1
%assign %{%$index}%{%1}first 2
%warning %{%$index}%{%1}first
%pop
%pop
%endm

s 1