flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > PROC more like MASM

Author
Thread Post new topic Reply to topic
alorent



Joined: 05 Dec 2005
Posts: 201
alorent
Hello guys!

I know that many of you might disagree with MASM syntax and move 100% to FASM...but for an old MASM guy like me that's not quite easy Smile

I have 2 questions for the PROC macro in FASM and check if it's possible:

1) It is possible to create a macro where *all* "labels" and "jumps to labels" are treated like if it had a dot '.' before the name? That is, we can forget about putting the initial '.' to all label names inside our PROC. Example:

Code:

myproc proc 

   jmp  Exit

Exit:
   ret 

myproc  endp

; the above should generate:

myproc proc 

   jmp  .Exit

.Exit:
   ret 

myproc  endp

    



2) Each param and local variable in PROC can be referenced by its name without adding the '[' ']'. Example:

Code:

myproc proc Param1

   local  local1 

   mov  eax, local1
   mov  ebx, Param1

   ret 

myproc  endp

; the above should generate:

myproc proc Param1

   local  local1 

   mov  eax, [local1]
   mov  ebx, [Param1]

   ret 

myproc  endp

    


Thanks!
Post 24 Feb 2010, 06:13
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
1) No. You can't overload : operator
2) Yes. Just change the macro to create the symbolic aliases with [] surrounding.
Post 24 Feb 2010, 07:10
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
revolution wrote:
2) Yes. Just change the macro to create the symbolic aliases with [] surrounding.
This will create problem with extended headers (addr feature of invoke macro).
Post 27 Feb 2010, 20:14
View user's profile Send private message Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 201
alorent
Hello,

I have come back to this topic.

revolution, could you let me know how I can modify the macro to be able to access to the local variable content withouth the brackets? Or maybe to define something like "local2" which allow those variables to be access without brackets. Example:

Code:
Myproc proc 

 local  i1:DWORD, i2:DWORD
 local2  j1:DWORD, j2:DWORD

...    




baldr, you say that there are problems with invoke. What if I don't use invoke?

What about global variables that are defined as:

Code:
MyVar dd 0    


Is it possible to create a macro or something to access to that global variable withouth the brackets?. Example:

Code:
mov   eax, MyVar      ; it would do "mov eax, [MyVar]"    


Thanks!
Post 25 May 2010, 13:26
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
alorent: Doing what you suggest above creates many problems, not just with invoke.

If we do this:
Code:
AVar equ [ebp+8] ;first parameter    
And then this:
Code:
mov eax,AVar    
Then you get what you want.

But what happens for arrays (or any indexing or offsets)?
Code:
mov eax,AVar+ecx*4    
It compiles to:
Code:
mov eax,[ebp+8]+ecx*4 ;error    
Post 25 May 2010, 13:53
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
revolution wrote:
alorent: Doing what you suggest above creates many problems, not just with invoke.

If we do this:
Code:
AVar equ [ebp+8] ;first parameter    
And then this:
Code:
mov eax,AVar    
Then you get what you want.

But what happens for arrays (or any indexing or offsets)?
Code:
mov eax,AVar+ecx*4    
It compiles to:
Code:
mov eax,[ebp+8]+ecx*4 ;error    
You can overcome this problem with definition like:
Code:
AVar equ ptr ebp+8    

Then
Code:
mov eax,AVar+ecx*4    
would compile to:
Code:
mov eax,ptr ebp+8+ecx*4    
and this would compile correctly.
Post 25 May 2010, 15:01
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
Oh, ptr is new to me. I've not seen that in fasm before.
Post 25 May 2010, 15:08
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
It was introduced in version 1.36 (released in May 2002). Documented in section 1.2.1 since the release of the new documentation with 1.41. Wink
Post 25 May 2010, 15:13
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
Tomasz Grysztar wrote:
It was introduced in version 1.36 (released in May 2002). Documented in section 1.2.1 since the release of the new documentation with 1.41. Wink
Embarassed
Post 25 May 2010, 18:43
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji
I didn't know that either ! Shocked
but I prefer "[x]", it's more explicit than "ptr x" !

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 25 May 2010, 19:08
View user's profile Send private message Send e-mail Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 201
alorent
Thanks again guys!

Well, I better stay with the FASM basics and use the brackets even if MASM has been on my bones for such a long time Smile
Post 26 May 2010, 15:53
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.