flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Programming Language Design > Simple listing macro for fasmg

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6633
Location: Kraków, Poland
With the new VIRTUAL features it becomes very easy to alter the macros so that they write the listing into a separate file:

Code:

Listing? = 1

namespace Listing  
        base = $$  
        offset = $
        virtual at 0
                HexDigits:: db '0123456789ABCDEF'
        end virtual
        virtual as 'lst'
                Text::
        end virtual
end namespace

macro ? line&
        line
        rmatch =nolist?line
                Listing? =: 0
        else rmatch =list?line
                restore Listing?
        else
                if Listing
                        namespace Listing
                                if ~ $$ eq base  
                                        base = $$  
                                        offset = $$  
                                end if  
                                bytes = $ - offset  
                                if $ - bytes < $$  
                                        bytes = $ - $$  
                                end if  
                                offset = $
                                address = (offset scale 0)-bytes
                                virtual Text
                                repeat 8
                                        load digit:byte from HexDigits:((addressshr ((%%-%shl 2)) and 0Fh
                                        db digit
                                end repeat
                                db ': '
                                end virtual
                                if bytes < 0
                                        bytes = 0
                                end if
                                while bytes > 0
                                        if bytes > 8
                                                load data:8 from $ - bytes
                                                virtual Text
                                                repeat 8
                                                        load digit:byte from HexDigits:(data shr ((%-1shl 3 + 4)) and 0Fh
                                                        db digit
                                                        load digit:byte from HexDigits:(data shr ((%-1shl 3)) and 0Fh
                                                        db digit,' '
                                                end repeat
                                                bytes = bytes - 8
                                                db 13,10,'          '
                                                end virtual
                                        else
                                                load data:bytes from $ - bytes
                                                virtual Text
                                                repeat bytes
                                                        load digit:byte from HexDigits:(data shr ((%-1shl 3 + 4)) and 0Fh
                                                        db digit
                                                        load digit:byte from HexDigits:(data shr ((%-1shl 3)) and 0Fh
                                                        db digit,' '
                                                end repeat
                                                end virtual
                                                break
                                        end if
                                end while
                                virtual Text
                                repeat 8-bytes
                                        db '   '
                                end repeat
                                db `line,13,10
                                end virtual
                        end namespace  
                end if
        end rmatch
end macro

macro nolist?
end macro

macro list?
end macro

postpone
        nolist 
end postpone

Post 15 Oct 2017, 15:08
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:  
Goto page Previous  1, 2

< 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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.