flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > AX=2 instead of mov AX,2 ?

Author
Thread Post new topic Reply to topic
Slai



Joined: 11 Jan 2006
Posts: 40
Location: NY/Bulgaria
Slai 29 Jan 2006, 06:05
is there any way to use a macro for replasing the mov register, value with register=value ?
Post 29 Jan 2006, 06:05
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 29 Jan 2006, 09:39
Look here for some hints: http://board.flatassembler.net/topic.php?t=4638

Or check out this ready solution:
Code:
macro addxsyntax [reg]
{
  macro reg param
  \{
     define status 0
     match =0 ++ , status param
     \\{
        inc reg
        define status 1
     \\}
     match =0 -- , status param
     \\{
        dec reg
        define status 1
     \\}
     match =0 +==src , status param
     \\{
        add reg,src
        define status 1
     \\}
     match =0 -==src , status param
     \\{
        sub reg,src
        define status 1
     \\}
     match =0 ==src , status param
     \\{
        mov reg,src
        define status 1
     \\}
     match =0 any , status param
     \\{
        unknown syntax
     \\}
  \}
}    

Code:
addxsyntax ax,bx,cx,dx

ax = 2
bx += 7
cx--
dx++    
Post 29 Jan 2006, 09:39
View user's profile Send private message Visit poster's website Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 29 Jan 2006, 09:45
Tomasz Grysztar wrote:
Look here for some hints: http://board.flatassembler.net/topic.php?t=4638

Or check out this ready solution:
Code:
macro addxsyntax [reg]
{
  macro reg param
  \{
     define status 0
     match =0 ++ , status param
     \\{
        inc reg
        define status 1
     \\}
     match =0 -- , status param
     \\{
        dec reg
        define status 1
     \\}
     match =0 +==src , status param
     \\{
        add reg,src
        define status 1
     \\}
     match =0 -==src , status param
     \\{
        sub reg,src
        define status 1
     \\}
     match =0 ==src , status param
     \\{
        mov reg,src
        define status 1
     \\}
     match =0 any , status param
     \\{
        unknown syntax
     \\}
  \}
}    

Code:
addxsyntax ax,bx,cx,dx

ax = 2
bx += 7
cx--
dx++    


just fasm macro's code make a pretty damn powerful script language i think Shocked

_________________
redghost.ca
Post 29 Jan 2006, 09:45
View user's profile Send private message AIM Address MSN Messenger Reply with quote
Slai



Joined: 11 Jan 2006
Posts: 40
Location: NY/Bulgaria
Slai 29 Jan 2006, 23:18
Great ! Smile Thanks
Post 29 Jan 2006, 23:18
View user's profile Send private message Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY 05 Feb 2006, 04:17
Wow! FASM is more than an assembler! With the macros it can be used to build new languages, scripting languages, packers with EXE self-extractor using "file" directive, and other cool stuff...

After messing so much with C/C++, I think I'll come back to FASM again and study/use it exclusivelly for some time... I'll try to write some small utilities and post at "project and ideas" forum.
Post 05 Feb 2006, 04:17
View user's profile Send private message Reply with quote
llaurrentt



Joined: 02 Nov 2006
Posts: 13
Location: Liège / Belgium
llaurrentt 04 Nov 2006, 10:00
One of these days we'll end up having a set of macro that enable preprocessing of C or C++ code with FASM to produce assembly !!!

Just kidding Twisted Evil but I really wonder why are these people trying to make assembly code like basic! Anyway it shows the power of FASM preprocessor Very Happy
Post 04 Nov 2006, 10:00
View user's profile Send private message MSN Messenger Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica 06 Nov 2006, 11:21
Quote:
One of these days we'll end up having a set of macro that enable preprocessing of C or C++ code with FASM to produce assembly !!!

Just kidding Twisted Evil

Just wait, sooner or later someone will do it... Smile
(and it will do optimizations too Wink)
Post 06 Nov 2006, 11:21
View user's profile Send private message Visit poster's website Reply with quote
tantrikwizard



Joined: 13 Dec 2006
Posts: 142
tantrikwizard 22 Jan 2008, 00:59
Tomasz Grysztar wrote:
Look here for some hints: http://board.flatassembler.net/topic.php?t=4638

Or check out this ready solution:
Code:
macro addxsyntax [reg]
<SNIP>.. }    

Code:
addxsyntax ax,bx,cx,dx

ax = 2
bx += 7
cx--
dx++    

Thomasz, Thank you for this post, I like the HLA type syntax at times.
I must be having a major brain fart because I cannot figure out the syntax of some of these more complex macros. I'm well familiar with the macro syntax of other assemblers (TASM, MASM, etc) but cannot, for the life of me, get my head around the FASM syntax. I've scoured through the documentation, examples, posts and tutorials but cannot figure out how these macros work. Would someone be so kind to detail in a step-by-step manner how these macros expand and are interpreted at assemble/process/preprocess time? Please no links! I've read them all and while many posts are very helpful, these are confusing to me.

Thanks in advance.
Post 22 Jan 2008, 00:59
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
chris



Joined: 05 Jan 2006
Posts: 62
Location: China->US->China->?
chris 22 Jan 2008, 07:16
there is a fasm preprocessor which expands macros and dump the results to file. I often find it useful in understanding marcos. check it out here http://board.flatassembler.net/topic.php?t=4490
Post 22 Jan 2008, 07:16
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.