flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > a problem with "common" directive

Author
Thread Post new topic Reply to topic
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
hi, i am starting to learn some basic fasm macroinstruction and met with one problem

Code:
macro m_message [param1] {
        common
      mov eax,param1
      forward
     mov eax,param1
}
m_message 0x11111,0x22222,0x33333
    


and resulted the following output
Code:
flat assembler  version 1.56
macro.txt [52]:
m_message 0x11111,0x22222,0x33333
macro.txt [48] m_message [2]:
        mov eax,param1
error: extra characters on line.
    


and i really wonder WHY?
coz i guess it should be assembled and the result should be four mov eax,param1?
with the common eax value "0x11111"

Code:
macro m_message [param1] {
 common
      mov eax,param1
      forward
     mov eax,param1
}
m_message 0x11111
    

this could be assembled without problem, so does this mean, parameter is limitted to one
when we want to use it inside common directive?

thanks.
Post 26 Dec 2004, 04:48
View user's profile Send private message Visit poster's website Reply with quote
zjlcc



Joined: 23 Jul 2003
Posts: 32
Location: china
zjlcc
Code:
include '%fasminc%\win32ax.inc' 
.code
start:
macro m_message [param1] { 
;        common 
;        mov eax,param1 
        forward 
        mov eax,param1 
} 
m_message 11111h,22222h,33333h 

invoke ExitProcess,0
.end start  
    

Code:
00401000 >/$  B8 11110100   MOV     EAX,11111
00401005  |.  B8 22220200   MOV     EAX,22222
0040100A  |.  B8 33330300   MOV     EAX,33333
0040100F  |.  6A 00         PUSH    0                                ; /ExitCode = 0
00401011  \.  FF15 35204000 CALL    [402035]                         ; \ExitProcess

    
Post 26 Dec 2004, 07:27
View user's profile Send private message Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
well zjlcc, did u try to understand the problem?

Code:
macro m_message [param1] {  
;        common  
;        mov eax,param1  
;        forward                ;<- don't need to write this too coz it is default directive
        mov eax,param1  
} 
    
Post 26 Dec 2004, 13:13
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
vb: when you use group argument in common section, then it is replaced by all arguments:
Code:
macro def [a]
{
common
 db a
}
def 1,2,3,4
    

gets assembled to
Code:
db 1,2,3,4
    

check my preprocessor tutorial
Post 26 Dec 2004, 14:55
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
hi vid, i don't know if i get u correctly,
Code:
macro m_message [param1] { 
        common 
        mov eax,param1 
} 
m_message 0x11,0x22,0x33 
    

does this mean, this can't be assembled is because of the "comma (,)" coz when processed it would be translated into
mov eax,0x11,0x22,0x33?

so, unless we have a macro that let mov support the "comma (,)" for more parameters.
Code:
macro mov2 op1,op2,op3,op4 {
      mov  op1,op2
        mov  op1,op3
        mov  op1,op4
}

macro m_message [param1] {
       common
      mov2 eax,param1
     reverse
     mov  eax,param1
}
m_message 0xFFFFF,0xFEEEE,0xFDDDD

004020AF  |. B8 FFFF0F00    MOV EAX,0FFFFF   ;mov2
004020B4  |. B8 EEEE0F00    MOV EAX,0FEEEE   ;mov2
004020B9  |. B8 DDDD0F00    MOV EAX,0FDDDD   ;mov2
004020BE  |. B8 DDDD0F00    MOV EAX,0FDDDD   ;reverse
004020C3  |. B8 EEEE0F00    MOV EAX,0FEEEE   ;reverse
004020C8  |. B8 FFFF0F00    MOV EAX,0FFFFF   ;reverse
    
Post 26 Dec 2004, 20:03
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Quote:
does this mean, this can't be assembled is because of the "comma (,)" coz when processed it would be translated into
mov eax,0x11,0x22,0x33?

yes (if i understood your english right). Really try reading that tutorial, there can be many things you won't find out by yourself so soon.
Post 26 Dec 2004, 22:25
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
yup, i guess u understood my english :[o],

well, i am reading the fasm manual too

Quote:

there can be many things you won't find out by yourself so soon.

sounds like they masked those secrets with simple words :p

anyway, thanks for confirming my understanding Smile
Post 27 Dec 2004, 04:57
View user's profile Send private message Visit poster's website 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.

Powered by rwasa.