|
From: Cyrill G. <gor...@gm...> - 2010-10-04 16:51:09
|
On Mon, Oct 04, 2010 at 03:09:21PM +0200, anonymous coward wrote:
...
> >
> > We still have to support it since people use it
> >
> > %assign %$_uses 0
> > %rep 4
> > %assign %$_ur%$_uses %$_uses
> > mov eax, %$_ur%$_uses
> > %assign %$_uses %$_uses+1
> > %endrep
> >
> > and friends, we just can't drop it.
>
> Even if I wrap your sample code in %PUSH and %POP
> it does not seem to work:
>
> # ./nasm 0.asm
> 0.asm:8: error: `%assign' expects a macro identifier
> 0.asm:8: error: `%assign' expects a macro identifier
> 0.asm:8: error: `%assign' expects a macro identifier
>
Hmm, which version of nasm you were testing?
2.10rc1 handles it fine.
%macro pp_local 0
%push
%assign %$_uses 0
%rep 4
%assign %$_ur%$_uses %$_uses
mov ecx, %$_ur%$_uses
%assign %$_uses %$_uses+1
%endrep
%pop
%endmacro
pp_local
> >> In your second set of rules you cannot have TOK_NUMBER plus
> >> TOK_ID, let alone xxx plus any TOK_OTHER, for the same basic
> >> reason as above.
> >
> > Well, as far as I see there can't be a combination of TOK_NUM+TOK_ID
> > as a single term to be concat'ed, it's written this way in mask
> > due to simplicity of handling.
> >
> > So at moment I fail to see what exactly may produce wrong concat'ed
> > terms. Please, if you have a real example with code -- poke me, thanks.
>
> # cat 0.asm
> ; a number and an identifier
>
> %define TOK_NUM 1
> %define TOK_ID @
>
> ; prove it
>
First of all -- really thanks for pointing this case!
Well, in this case tokenizer (which is called exactly right
after tokens get concat'ed) split this "1@" term back into two
tokens TOK_NUM and TOK_ID. If I forbid this rule I would not be
able to handle case like
%define sup1@ 10
%macro sup 2
mov ecx, sup%1%2
%endmacro
%define TOK_NUM 1
%define TOK_ID @
sup TOK_NUM, TOK_ID
Don't get me wrong, I understand it's kinda fishy and probably I'm
missing something (definitely I'm not an preproc code expert) but at
least the old code can compile. If you have some patch which could
make the situation cleaner -- don't hesitate to post it for review.
Cyrill
|