flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > ERR directive - useful ??? Conditional ERR

Author
Thread Post new topic Reply to topic
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
Code:
  macro mov op1,op2 {
    if op1 eq cs
      err "CS is not a valid destination"
    end if
    if op1 in <ds,es,fs,gs,ss> & op2 in <cs,ds,es,fs,gs,ss>
      push  op2
      pop   op1
    else
      mov   op1,op2
    end if
  } ; endmacro

  mov es,ax
  mov ds,cs
  mov cs,ds ; BUG !!!
    


When compiling this in the commandline, I get 2 offending lines listed:

Code:
  mov cs,ds ; BUG !!!
      err "CS is not a valid destination"
    


telling me what's wrong ... but this not really the effect of err - if I place anything other like abortcompilationhere , the effect will be pretty same.

OTOH in the IDE, only

Code:
  mov cs,ds ; BUG !!!
    


gets listed and no clue what's wrong, and no benefit from err again. Shouldn't err pass the string to become useful ?

Other possibility of improvement:

Code:
  if ($>$FFFF)
    err "You ran out of UNreal CS limit"
  end if
    


could become:

Code:
  err ($>$FFFF)
    


would crash only if the expression is true and report the offending expression. Idea
Post 07 Apr 2009, 01:54
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17664
Location: In your JS exploiting you and your system
revolution
The idea of err is that it is always guaranteed to give an error. Kind of like Intel making UD2 as an encoding to never be used by a valid instruction.


Last edited by revolution on 07 Apr 2009, 02:06; edited 1 time in total
Post 07 Apr 2009, 02:01
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
revolution wrote:
The idea of err is that is it always guaranteed to give an error. Kind of like Intel making UD2 as an encoding to never be used by a valid instruction.


while abortcompilationhere could become valid one day Laughing

Code:
  conderr ($>$FFFF) 
    
Post 07 Apr 2009, 02:04
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17664
Location: In your JS exploiting you and your system
revolution
abortcompilationhere is too long to be friendly to use.
Post 07 Apr 2009, 02:09
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
And "abortcompilationhere" gives you a different error message, while ERR tells you that breaking the compilation was intended in that place.
Post 07 Apr 2009, 05:10
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.