flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > multiple array-like statements

Author
Thread Post new topic Reply to topic
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 20 Feb 2004, 17:56
I would like to define, say, 5 symbols:
Code:
pos1 = 2
pos2 = 4
pos3 = 6
pos4 = 8
pos5 = 10    


Can I do something like:
Code:
repeat 5
    pos#%# = % * 2
end repeat    


I looked up ` and # symbols in fasm manual, but could not understand the correct combination to work this out.

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 20 Feb 2004, 17:56
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 20 Feb 2004, 18:00
For some reason that repeat block causes "illegal instruction" error, but does not when is inside a macro block.

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 20 Feb 2004, 18:00
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy 20 Feb 2004, 18:09
If I'm not wrong, concating of symbols as this are only allowed inside macros...
Post 20 Feb 2004, 18:09
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 20 Feb 2004, 18:11
Well, it still does not work even inside macro.

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 20 Feb 2004, 18:11
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo 20 Feb 2004, 18:14
Same with symbol < and >. I find it useful to use them outside macros sometimes.
Post 20 Feb 2004, 18:14
View user's profile Send private message Yahoo Messenger Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 20 Feb 2004, 18:20
Code:
macro foobar name,value {
    pos#name = value
}
repeat 5
    param = %
    foobar param,%
end repeat
display posparam+30h,13,10    


This define posparam 5 times, finally making it equal to 5. Looks like FASM just pass by reference in macro, not value?

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 20 Feb 2004, 18:20
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
pas



Joined: 16 Aug 2003
Posts: 17
Location: Russia
pas 21 Feb 2004, 05:20
macro IdNum strt,[equat]
{
common
local count
count = strt
forward
equat = count
count = count + 1
}
IdNum 1,\
IDM_NEW,\
IDM_OPEN,\
IDM_SAVE,\
IDM_EXIT,\
IDM_ADD_TO,\
IDM_CLOSE,\
IDM_DIALOG
It creates 7 macro variable. You wanted it to achieve?
Post 21 Feb 2004, 05:20
View user's profile Send private message Reply with quote
S.T.A.S.



Joined: 09 Jan 2004
Posts: 173
Location: Ru#27
S.T.A.S. 21 Feb 2004, 11:11
Here's my try

Code:
macro foo name,first,[list]
{       common  local counter
                counter =  first
        forward name#list = counter
                counter = counter + 1}

nums    fix .1,.2,.3,.4,.5,.6,.7,.8
foo pos,1,nums

;or
;foo pos,1,.1,.2,.3,.4,.5

display pos.2+30h,13,10
display pos.5+30h,13,10 
    


------
BTW, # directive outside maros would be really handy sometimes
Post 21 Feb 2004, 11:11
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 21 Feb 2004, 17:15
Spasibo!
That is almost it, because num has to be variable though.

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 21 Feb 2004, 17:15
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo 23 Feb 2004, 16:32
S.T.A.S. wrote:

BTW, # directive outside macros would be really handy sometimes


Yes, it will. Also this outside macros:
Fasm Manual wrote:

When it's needed to provide macroinstruction with argument that contains some commas, such argument should be enclosed between < and > characters. If it contains more than one < character, the same number of > should be used to tell that the value of argument ends.


i.e.
Code:
mov eax,<'a',09h,'1'>
cmp dx,<'b',0>    
Post 23 Feb 2004, 16:32
View user's profile Send private message Yahoo Messenger 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.