flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Eqtype does not recognize <"Hello"," World

Author
Thread Post new topic Reply to topic
rCX



Joined: 29 Jul 2007
Posts: 166
Location: Maryland, USA
rCX
I was using revolution's method to concat strings and I found that eqtype does not recognize angled brackets.

Code:
org 100h
use16

macro   type_test       A*
{ 
  if A eqtype "a" 
    display "String",0Ah 
  else if A eqtype <>
    display "Concated String",0Ah 
  end if 
} 

type_test "Hello World"          ;Prints "String"
type_test <"Hello World"> ;Prints "String"
type_test <"Hello"," World">    ;Doesn't print anything Sad
    


EDIT: Probably not a bug...


Last edited by rCX on 29 May 2009, 01:03; edited 1 time in total
Post 28 May 2009, 18:54
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Well, can't check now if eqtype should support angle brackets (it doesn't support '<"a", "a">' neither), but this way you will make the "Concated String" to be displayed:
Code:
macro   type_test       A*
{ 
  if A eqtype "a" 
    display "String",13, 10
  else if A eqtype "a"," a"
    display "Concated String", 13, 10
  end if 
}    
Post 28 May 2009, 19:10
View user's profile Send private message Reply with quote
rCX



Joined: 29 Jul 2007
Posts: 166
Location: Maryland, USA
rCX
hmm... Is there any way to consistently identify something as a string regardless of how many substrings there are?

Code:
type_test <"Hello"," World">   ;Gives "Concated String"
type_test <"Hello","Wor","ld">;Gives nothing... Sad
    


I used fasmpre and its output is below. Apparently the preprocessor does not convert 'Hello',' Wor','ld' to 'Hello World' before performing eqtype

Code:
;macro type_test A*
;{
; if A eqtype 'a'
; display 'String',0Ah
; else if A eqtype 'a','a'
; display 'Concated String',0Ah
; end if
;}

;type_test 'Hello World'

if 'Hello World' eqtype 'a'
display 'String',0Ah
else if 'Hello World' eqtype 'a','a'
display 'Concated String',0Ah
end if

;type_test<'Hello World'>

if 'Hello World' eqtype 'a'
display 'String',0Ah
else if 'Hello World' eqtype 'a','a'
display 'Concated String',0Ah
end if

;type_test<'Hello',' Wor','ld'>

if 'Hello',' Wor','ld' eqtype 'a'
display 'String',0Ah
else if 'Hello',' Wor','ld' eqtype 'a','a'
display 'Concated String',0Ah
end if
    
Post 28 May 2009, 19:28
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
From FASM.PDF (2.3. PREPROCESSOR DIRECTIVES) modified example:
Code:
macro append item
{
  list equ
  match any, list \{ list equ list,item \}
  match , list \{ list equ item \}
  display list
}

append <"Hi", ",",32,"Hello World",13,10,"Smile">
    
Post 28 May 2009, 19:54
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
rCX



Joined: 29 Jul 2007
Posts: 166
Location: Maryland, USA
rCX
Sad but the code...
Code:
macro   type_test       A*
{ 
  if A eqtype "a" 
    display "String",13, 10
  else if A eqtype <"a"," a">
    display "Concated String", 13, 10
  end if  
}
    

...won't identify list as a "string" or "concated string"
Post 28 May 2009, 20:49
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2917
Location: [RSP+8*5]
bitRAKE
Code:
type_test <<"Hello","World">>    
The MACRO invocation strips the outer <> - by design.

It is important to note: EQTYPE is assemble-time whereas MATCH is done by the pre-processor. All macros have finished by the time EQTYPE is being resolved. rCX, I am certain you are already aware of this - I'm just stating the obvious for completeness of the discussion.

EQTYPE counts items. So, a general test is not possible with EQTYPE. <<"Hello","Cruel","World">> would require another IF, etc...
Post 29 May 2009, 00:15
View user's profile Send private message Visit poster's website Reply with quote
rCX



Joined: 29 Jul 2007
Posts: 166
Location: Maryland, USA
rCX
Another question... Is there a way to use escape sequences in strings? e.g...
Quote:
" I said \"hi\". "

...or...
Quote:
"bye\0"
Post 10 Jun 2009, 06:16
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. Also on YouTube, Twitter.

Website powered by rwasa.