flat assembler
Message board for the users of flat assembler.

Index > Windows > fasm "defined" directive

Author
Thread Post new topic Reply to topic
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP
I'm trying to incorporate user-included functions in my source, like this:

Code:
define food

; and later...

if defined food
  ;function
end if
    

but when I compile, it says that the instruction "if defined" is an error. win32ax is included, it seemed like it was working before, but I don't think I'm using the defined very right. I read the FASM doc that comes with the latest version, just a short mention that defined returns true for constants. I just assumed "define" worked also because of this, what's wrong?
Post 29 Jan 2008, 02:17
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
define is a preprocessor directive and has similar (but not equal) behaviour than equ.

For example this works
Code:
define food "Hello World!", 13, 10
display food    


But what you did however was defining an empty define so the assembler recieves "if defined" instead of "if defined food" as you would expect.

"defined" can work only with expressions and expression can have numbers, symbols and operations and it returns true only when the expression can be resolved (it is valid things like "if defined 5", and that will always be defined since the expression has just a constant result). Things like this are possible
Code:
if defined alpha + beta
  display "The sum can be done!", 13, 10
else
  if ~(defined alpha | defined beta)
    display "Both symbols are undefined!", 13, 10
  else if ~defined alpha
    display "Alpha is undefined!"
  else
    display "Beta is undefined!"
  end if
end if

alpha = 3
rb 9
beta:
    
Post 29 Jan 2008, 03:00
View user's profile Send private message Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP
Thanks, it works! (thought "defined" returned true even if it was only defined)
Post 29 Jan 2008, 21:08
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Perhaps you confused it with "if eq" that returns true? Even "if food eq food" would worked since the assembler would recieved "if eq" and returns true because both parts are empty Smile
Post 29 Jan 2008, 21:20
View user's profile Send private message Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP
Everything's working, but (tryin' to judge it's speed), can anyone find a link to cycle counts?? I've searched google for everything possible but I can't find one... I thought I saw one in these forums, but I don't know where
Post 29 Jan 2008, 22:18
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.

Powered by rwasa.