flat assembler
Message board for the users of flat assembler.

Index > Main > The question about if and include directives

Author
Thread Post new topic Reply to topic
kiselevd2002



Joined: 06 May 2021
Posts: 4
kiselevd2002
Hi,
I cannot get the subject of if statement. The question is about why I always get the file included whether I set up USE_NO_PAYLOAD to 0 or 1?
Code:
USE_NO_PAYLOAD equ 1
USE_RESOURCE_SEGMENT_FOR_PAYLOAD equ 0
USE_DATA_SEGMENT_FOR_PAYLOAD equ 0

include 'win32ax.inc'
include 'w32_payload_constants.inc'
include 'useful_macros32.inc'

.data
include 'data_segment32.inc'

if USE_NO_PAYLOAD = 0
if USE_RESOURCE_SEGMENT_FOR_PAYLOAD = 0
if USE_DATA_SEGMENT_FOR_PAYLOAD = 0
if FILE_IS_DIFFERENT_SEGMENTS = 1
include 'w32_payload_data.inc'
end if
end if

if defined USE_DATA_SEGMENT_FOR_PAYLOAD = 1
include 'w32_payload_text.inc'
include 'w32_payload_data.inc'
include 'w32_payload_idata.inc'
end if
end if
end if
    
Post 06 May 2021, 11:24
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7935
Location: Kraków, Poland
Tomasz Grysztar
In fasm INCLUDE is a preprocessor's directive, while IF is directive of the assembler. At the time when the source text is assembled, all preprocessing has already been done, so by the time the assembler sees the IF construct, INCLUDE statements have already been unrolled.

If you tried the same with fasmg, which has preprocessor and assembler combined into one, you'd get what you expected here.
Post 06 May 2021, 11:34
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: 18198
Location: In your JS exploiting you and your system
revolution
kiselevd2002: You can use match instead of if to make conditional includes.
Code:
match 0, USE_NO_PAYLOAD {
  include '...'
}    
Post 06 May 2021, 13:34
View user's profile Send private message Visit poster's website Reply with quote
kiselevd2002



Joined: 06 May 2021
Posts: 4
kiselevd2002
revolution wrote:
kiselevd2002: You can use match instead of if to make conditional includes.
Code:
match 0, USE_NO_PAYLOAD {
  include '...'
}    


This does not work either... I tried.
Post 10 May 2021, 06:17
View user's profile Send private message Reply with quote
kiselevd2002



Joined: 06 May 2021
Posts: 4
kiselevd2002
Tomasz Grysztar wrote:
In fasm INCLUDE is a preprocessor's directive, while IF is directive of the assembler. At the time when the source text is assembled, all preprocessing has already been done, so by the time the assembler sees the IF construct, INCLUDE statements have already been unrolled.

If you tried the same with fasmg, which has preprocessor and assembler combined into one, you'd get what you expected here.


Please, advise then how should I do in my case? Should I use -d flag in command line? Or what?
Post 10 May 2021, 06:19
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7935
Location: Kraków, Poland
Tomasz Grysztar
kiselevd2002 wrote:
revolution wrote:
kiselevd2002: You can use match instead of if to make conditional includes.
Code:
match 0, USE_NO_PAYLOAD {
  include '...'
}    


This does not work either... I tried.
It's missing "=" to match the literal. It should be:
Code:
match =0, USE_NO_PAYLOAD {
  include '...'
}    
Post 10 May 2021, 08:17
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.