flat assembler
Message board for the users of flat assembler.

Index > Main > Stop assembling ("assert" vs "err")

Author
Thread Post new topic Reply to topic
Bargest



Joined: 09 Feb 2012
Posts: 79
Location: Russia
Bargest
I have a configuration file, where I can set many parameters of program. But some values or value combinations are invalid. So I use several tests like this:
Code:
if (ObjectHashTableSize < 2)
  display 'Error: Object hash table size is less than 2', 13  
end if
    

After it I want to stop compilation, because there is no point in compiling program with this value. Is there a way to stop compilation without generating an output file?

_________________
jmp $ ; Happy end!
Post 11 Nov 2012, 10:55
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
You can stop assembly using the err keyword:
Code:
if (ObjectHashTableSize < 2) 
  display 'Error: Object hash table size is less than 2', 13   
  err
end if    
There is also an assert keyword:
Code:
assert ObjectHashTableSize < 2    
Post 11 Nov 2012, 11:07
View user's profile Send private message Reply with quote
Bargest



Joined: 09 Feb 2012
Posts: 79
Location: Russia
Bargest
Thank you. First code stopped compilation even if ObjectHashTableSize > 2, but
Code:
assert ObjectHashTableSize >= 2
    

works fine.
Post 11 Nov 2012, 11:30
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Bargest wrote:
...First code stopped compilation even if ObjectHashTableSize > 2, but
Code:
assert ObjectHashTableSize >= 2    
works fine.
err directive is kinda too hard error (i.e. if your ObjectHashTableSize is forward-referenced, compilation will abort). Compare
Code:
ObjectHashTableSize = 3

if (ObjectHashTableSize < 2)
  display 'Error: Object hash table size is less than 2', 13   
  err
end if    
and
Code:
if (ObjectHashTableSize < 2)
  display 'Error: Object hash table size is less than 2', 13   
  err
end if

ObjectHashTableSize = 3    
There were several threads about that, e.g. this one.
Post 21 Nov 2012, 16:24
View user's profile Send private message Reply with quote
Bargest



Joined: 09 Feb 2012
Posts: 79
Location: Russia
Bargest
baldr, thanks. First variant works good. In my source config file was included at the end.
Post 21 Nov 2012, 16:33
View user's profile Send private message 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.