flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > eqtype bug?

Author
Thread Post new topic Reply to topic
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Hi Smile

just wanted to mention maybe it's not a bug, but I use:

Code:
if ~ p1 eqtype 0
  err
end if    


p1 is a macro parameter. It works okay if I call it with 'eax'.. it gives error, which is good.. but it doesn't give error when I use a name, like 'Something'.. it's like it is a number?? Obviously it's a name.. another funny thing is:

Code:
if xxxx eqtype 0
  display 'xxxx'
end if    


xxxx is, of course, not defined anywhere, so it's not a numeric constant.. Why does it display 'xxxx'? It this a bug?

PS: How can I be assured and preserve the FASM directives, numbers, etc.. like:

Code:
macro xxx p1, p2
{
  if ~ p1 eqtype 0
    err
  end if
  ; do somethin'
}


; some code
define 0 somethin'

; or
define eqtype ...

xxx 5, 10  ; this will not be generated properly, because
           ; '0' and 'eqtype' are replaced, even though
           ; in my code it isn't even obvious I use them    


Is there a way I can be assured that some Fasm directives or numbers are preserved and local to a macro?

PS2: is err a good choice for stopping compilation errors? because it will give a 'invalid instruction' error, even though I use it for various purposes. Is
Code:
err "Parameter must be a numeric constant"    

valid? Or what directive can I use to accomplish same thing? thank you


Regards Very Happy
Post 13 Jan 2006, 18:25
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
Each unknown name for assembler is a label, it doesn't matter whether it actually gets defined or not - you can put a label inside the "if 0" block so it never gets defined actually, but it doesn't change a fact that for assembler it is a label - thus part of numerical expression.

So "xxx" is of the same type as "+xxx" and "xxx+0" - they are all numerical expressions (and "+xxx" is in fact equivalent to "xxx" for the assembler, so "xxx eq +xxx" is true condition).


Last edited by Tomasz Grysztar on 13 Jan 2006, 19:03; edited 2 times in total
Post 13 Jan 2006, 18:55
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
As for the second problem you can do it like:
Code:
macro xxx p1, p2
{
  define eqtype eqtype
  define 0 0
  if ~ p1 eqtype 0
    err
  end if
  restore eqtype,0
}


define 0 somethin'

define eqtype ...

xxx 5, 10    
Post 13 Jan 2006, 18:59
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
And for the third one: the "err" is something like "ud2" opcode - you can be sure it will always cause an error and is fully backward-compatible, since there always wasn't any instruction of such name (except, of course, when you define such macro etc.)
Post 13 Jan 2006, 19:05
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Tomasz Grysztar wrote:
Each unknown name for assembler is a label, it doesn't matter whether it actually gets defined or not - you can put a label inside the "if 0" block so it never gets defined actually, but it doesn't change a fact that for assembler it is a label - thus part of numerical expression.

So "xxx" is of the same type as "+xxx" and "xxx+0" - they are all numerical expressions (and "+xxx" is in fact equivalent to "xxx" for the assembler, so "xxx eq +xxx" is true condition).


how to check if it is a number or is it impossible?
thanks for other replies. Very Happy
Post 13 Jan 2006, 19:07
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
"eqtype" doesn't distinguish numerical expression, so any solution would be a tricky one.
Post 13 Jan 2006, 19:16
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Crying or Very sad

just kidding Very Happy i'm not sad Smile
thx

EDIT: what's ud2? It compiled ok.. I thought it was just an arbitrary name?
Post 13 Jan 2006, 19:25
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
For UD2 see the Intel manuals. Wink
Post 13 Jan 2006, 20: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.