flat assembler
Message board for the users of flat assembler.

Index > Main > Count Enumeration

Author
Thread Post new topic Reply to topic
jInuQ



Joined: 26 Jun 2003
Posts: 48
Location: USA - NV
jInuQ 07 Jan 2004, 08:32
Not being able to think well enough tonight. I was interested in knowing if there was anyway to implement a macro that you could do the following. I know it is in C.

Code:
enum RETS { RET_OK, RET_ERROR }
    

_________________
jInuQ

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away."
- Antoine de Saint Exupery
Post 07 Jan 2004, 08:32
View user's profile Send private message Visit poster's website AIM Address Reply with quote
aaro



Joined: 21 Jun 2003
Posts: 107
Location: hel.fi
aaro 07 Jan 2004, 09:22
Code:
macro enum [rets] {
common
   count = 1
forward
   rets = count
   count = count + 1
}

enum RET_OK, RET_ERROR ; After this RET_OK = 1 and RET_ERROR = 2

macro enum lab, [rets] {
common
   count = 1
forward
   lab#.#rets = count
   count = count + 1
}

enum RETS, RET_OK, RET_ERROR ; After this RETS.RET_OK = 1 and RETS.RET_ERROR = 2
    

Don't know C so there's two versions, hope they'll do.
Post 07 Jan 2004, 09:22
View user's profile Send private message Reply with quote
jInuQ



Joined: 26 Jun 2003
Posts: 48
Location: USA - NV
jInuQ 07 Jan 2004, 10:05
Thank you sir. They look okay ,but it is bed time. In C you never know what you enums are going to be unless you specify that starting point.

_________________
jInuQ

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away."
- Antoine de Saint Exupery
Post 07 Jan 2004, 10:05
View user's profile Send private message Visit poster's website AIM Address Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 07 Jan 2004, 12:05
Here I can see that macros can be of fun too. They seem to be very helpful. But where on Earth can I find the "syntax" on macros. Again new macro that worked, but it again has some commands that I don't understand:(

Is there any possibility to "read" out of fASM's source, what is the possible syntax of macros in fASM

Hey....anyone... Rolling Eyes
Post 07 Jan 2004, 12:05
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica 07 Jan 2004, 14:01
Madis731 wrote:
But where on Earth can I find the "syntax" on macros

Have you read fasm.txt (or fasm.pdf in the windows package)?

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 07 Jan 2004, 14:01
View user's profile Send private message Visit poster's website Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo 08 Jan 2004, 04:27
Or better the CHM help file prepared by IceStudent, look here:

http://board.flatassembler.net/topic.php?t=822
Post 08 Jan 2004, 04:27
View user's profile Send private message Yahoo Messenger Reply with quote
aaro



Joined: 21 Jun 2003
Posts: 107
Location: hel.fi
aaro 08 Jan 2004, 05:38
Code:
macro _enum [arg, arg2] {
forward
    if ~ arg2 eq 
               arg = arg2
          count = arg2
        else
                arg = count
 end if
}

macro enum start, step, [arg] {
common
      count = start
       
forward
 _enum arg
   count = count + step
}

enum 1, 2, foo, <bar, 7>, foobar ; foo=1 bar=7 foobar=9
    

Here's extended version of the enum macro
Post 08 Jan 2004, 05:38
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.