flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Macro only in the last pass

Author
Thread Post new topic Reply to topic
f2065



Joined: 01 Jan 2012
Posts: 11
Location: Russia,Moscow
f2065
Is it possible to make the macro run only in the last compiler pass?
Post 11 Aug 2022, 18:03
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8016
Location: Kraków, Poland
Tomasz Grysztar
fasmg has it as a "postpone ?" feature.
Post 11 Aug 2022, 18:18
View user's profile Send private message Visit poster's website Reply with quote
f2065



Joined: 01 Jan 2012
Posts: 11
Location: Russia,Moscow
f2065
Is there no solution for fasm1?
Post 11 Aug 2022, 18:21
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8016
Location: Kraków, Poland
Tomasz Grysztar
You could try some tricks based on specific optimizations done in current versions of fasm. For example, if you look at "reserve_bytes:" handler in ASSEMBLE.INC you can find this piece:
Code:
        cmp     [next_pass_needed],0
        je      zero_bytes
        add     edi,ecx
        jmp     reserved_data    
This means that RB does not actually zero the data unless the assembler believes it is the final pass. This allows to make this kind of test:
Code:
; Warning: tricky stuff relying on quirks of fasm 1 implementation
postpone {
        rb 1
        load a byte from $-1
        if a = 0
                ; dummy code for testing, if it is assembled more than once,
                ; the time difference should be noticeable
                repeat 10000000
                        a = a + 1
                end repeat
        end if
}    
Note that the code needs to be at the end of source, here ensured by POSTPONE, so that the decision to take the next pass has been already taken if necessary.
Post 11 Aug 2022, 18:49
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. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.