Author Topic: Problem with macros to simplify %local using  (Read 14714 times)

Offline rdtsc

  • Jr. Member
  • *
  • Posts: 6
Problem with macros to simplify %local using
« on: January 23, 2011, 01:57:44 PM »
I wrote 2 macroses to simplify using %args and %locals in my procs.
For example,for %local:

Code: [Select]
%macro LOCALS 1+
%push mycontext
%stacksize flat
   %assign %$localsize 0
%local %1
enter   %$localsize,0
%endmacro

Proc1:
    LOCALS v:dword
...

Proc2:
    LOCALS v:dword
...


The PROBLEM is that it dose not allow to make local vars with the same names in 2 (for example) procedures.
In the above code will be compile error((LOCALS:4) `%local' missing argument parameter) at line LOCALS in Proc2

BUT, when i use above code itself (without macro LOCALS) - ALL WORKS good.
Code: [Select]
Proc1:
%push mycontext
%stacksize flat
   %assign %$localsize 0
%local v:dword
enter   %$localsize,0
...
Proc2:
%push mycontext
%stacksize flat
   %assign %$localsize 0
%local v:dword
enter   %$localsize,0
...


Please, help, how should i modify LOCALS macro in order to use vars with identical (the same) names ?
« Last Edit: January 23, 2011, 02:00:21 PM by rdtsc »

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: Problem with macros to simplify %local using
« Reply #1 on: January 23, 2011, 08:13:00 PM »
NASMX solves this by using the nasm "dot" notation as offsets from ebp.  If you're feeling "very" adventurous you can download the package http://sourceforge.net/projects/nasmx/ and see how it is handled there.  You may want to look at the demos to see it in action first.  A word of caution though, NASMX hides a huge amount of complexity with regards to parameters, local variables, procedure definitions, etc.  In other words, the source for the macros is not for the feint of heart ;)


Offline rdtsc

  • Jr. Member
  • *
  • Posts: 6
Re: Problem with macros to simplify %local using
« Reply #2 on: January 24, 2011, 06:26:45 PM »
NASMX solves this by using the nasm "dot" notation as offsets from ebp.  If you're feeling "very" adventurous you can download the package http://sourceforge.net/projects/nasmx/ and see how it is handled there.  You may want to look at the demos to see it in action first.  A word of caution though, NASMX hides a huge amount of complexity with regards to parameters, local variables, procedure definitions, etc.  In other words, the source for the macros is not for the feint of heart ;)


I am nop english-man, and dont understand what is "is not for the feint of heart" ? Very interesting sentence..
I think you mean that source is hard for understanding..

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: Problem with macros to simplify %local using
« Reply #3 on: January 25, 2011, 12:35:49 AM »
Yes, it is if you're not fluent in Nasm preprocessing.  However, the demos show how easy it is to use and will give you an idea of how you can solve your problem.

Offline rdtsc

  • Jr. Member
  • *
  • Posts: 6
Re: Problem with macros to simplify %local using
« Reply #4 on: January 25, 2011, 06:14:40 PM »
Yes, it is if you're not fluent in Nasm preprocessing.  However, the demos show how easy it is to use and will give you an idea of how you can solve your problem.
Thanks! It 's realy powerfull thing..Stucttures,types,..Masm is knocked down)

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: Problem with macros to simplify %local using
« Reply #5 on: January 26, 2011, 01:26:16 AM »
Thanks! It 's realy powerfull thing..Stucttures,types,..Masm is knocked down)

Well, we're not quite there yet in stealing masm's thunder but it's a start. ;)