flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > How to check definition

Author
Thread Post new topic Reply to topic
Jin X



Joined: 06 Mar 2004
Posts: 133
Location: Russia
Jin X 16 Dec 2020, 09:44
How can I check if 'i' is defined?
Code:
define i mov    


I can't use
Code:
if defined i    

Maybe match? But how to use it in this case?
Post 16 Dec 2020, 09:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20343
Location: In your JS exploiting you and your system
revolution 16 Dec 2020, 09:46
Code:
define i mov
match =i,i { display 'i is not defined'}    
Post 16 Dec 2020, 09:46
View user's profile Send private message Visit poster's website Reply with quote
Jin X



Joined: 06 Mar 2004
Posts: 133
Location: Russia
Jin X 16 Dec 2020, 09:53
Thanks! But I want to do something if 'i' is defined, not undefined.

Of course, I can write
Code:
define i mov
i_defined equ 1
match =i,i { i_defined equ 0 }
if i_defined
  ;
end if    

But it's too large code...
Post 16 Dec 2020, 09:53
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 16 Dec 2020, 11:28
Code:
match =i , i { rept 0 \{ }
match ,
{
  display 'i is defined.'
}    
Post 16 Dec 2020, 11:28
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: 20343
Location: In your JS exploiting you and your system
revolution 16 Dec 2020, 11:39
Code:
define i mov
match=i,i{rept 0{}match,{display 'i is defined'}    


Edit: DimonSoft already posted similar.
Post 16 Dec 2020, 11:39
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 16 Dec 2020, 22:41
In fact, if the case where something is not defined means an error, one might not need to care about making proper “else” “branch”:
Code:
match =i , i { 'Error!' }
display 'i is defined.'    
Post 16 Dec 2020, 22:41
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: 20343
Location: In your JS exploiting you and your system
revolution 17 Dec 2020, 04:49
Using irpv might suit better. It can also know of something is defined as itself. But it suffers from a problem of running multiple times if it is defined more than once.
Code:
define mov mov
irpv x,mov{display 'mov is defined'}    
Post 17 Dec 2020, 04: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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.