flat assembler
Message board for the users of flat assembler.

Index > Main > macro duplicated args no error message,

Author
Thread Post new topic Reply to topic
lazer1



Joined: 24 Jan 2006
Posts: 185
lazer1
fasm doesnt give any error messages if a macro
has 2 args with the same name,

eg

Code:
macro  xyz a,a
  {
  mov a, a
  }

xyz eax, eax
    


no error message,

I think that is an error codition,
Post 17 Jun 2007, 01:02
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
[edit]Save your time skipping this senseless post and continue reading from the post below this one.[/edit]

Why do you think it is wrong?? "mov eax, eax" is perfectly valid (even though it just do nothing). However are other instructions where using the same operand has effect, for example sub and xor which has the effect of clearing the operand and add which has the effect of multiply the operand by two. Obviously there are others but I think that those are enough examples Wink

If you want to trap when both operands are the same check http://flatassembler.net/docs.php?article=manual#2.2.2 (the "eq" operator)


Last edited by LocoDelAssembly on 17 Jun 2007, 15:38; edited 1 time in total
Post 17 Jun 2007, 01:39
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17284
Location: In your JS exploiting you and your system
revolution
What happens if you do this:?
Code:
macro  xyz a,a
  {
  mov a, a
  }

xyz eax, ebx    
Post 17 Jun 2007, 12:37
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
I never realized that he means that the formal parameters names are the same Embarassed

With that code it produces "mov ebx, ebx" so it uses the rightmost value. If you only supply one actual parameter then it tries to assemble "mov ," because the last value of a was void.

Sorry for my very silly post above
Post 17 Jun 2007, 15:36
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
i think i even mentioned this in my old preprocessor tutorial Wink
Post 17 Jun 2007, 17:48
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
lazer1



Joined: 24 Jan 2006
Posts: 185
lazer1
revolution wrote:
What happens if you do this:?
Code:
macro  xyz a,a
  {
  mov a, a
  }

xyz eax, ebx    


that is a better example of the problem,

I had a header file with many macros, and my code kept
echoing 0 when it was supposed to echo nonzero,

after much debugging I realised the problem must be in
the macro, careful scrutiny revealed that
arg 3 and arg 6 of a 6 arg macro had the same name,

if you arent thinking about this specific problem then
you might not notice it in a macro with many args.

so I think fasm needs to regard this as an error,

duplicated arg names serves no purpose: no point
having an arg you cannot reference eg in your
example above the "ebx" cannot be referenced to

so it must be an error condition,
Post 17 Jun 2007, 20:02
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.