flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Is it possible to concat EQU const with label?

Author
Thread Post new topic Reply to topic
Devel99



Joined: 26 Oct 2015
Posts: 30
Devel99 26 Oct 2015, 02:51
Hi guys

is it possible to to concat EQU const with label? I have the code where I define _struct_name_internal_ as EQU and then I try to concatenate it to make a label. Here it is:
Code:
macro BEGIN_STRUCT struc_name  
{
  _struct_name_internal_ EQU struc_name   
  _struct_name_internal_#_begin:
  db 1, 1, 1
}

macro END_STRUCT  
{
  db 2, 2, 2
  _struct_name_internal_#_end:
  restore _struct_name_internal_
}

BEGIN_STRUCT my1
END_STRUCT
    


The problem is that compiler does not treat _struct_name_internal_ as my1, it leaves it as is (_struct_name_internal_)

comliped to:
Code:
_struct_name_internal__begin:
db 1, 1, 1, 2, 2, 2
_struct_name_internal__end:
    


instead of expected
Code:
my1_begin:
db 1, 1, 1, 2, 2, 2
my1_end:
    

cause I don't want to pass struct name twice into closing section Rolling Eyes Cool

so if I define two structures, I get an error "ERR already defined _struct_name_internal__begin:"
Code:
BEGIN_STRUCT my1 
END_STRUCT

BEGIN_STRUCT my2
END_STRUCT
    



thanks in advance


Last edited by Devel99 on 26 Oct 2015, 03:12; edited 3 times in total
Post 26 Oct 2015, 02:51
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 26 Oct 2015, 03:05
You need to use match to translate EUQs in the preprocessor:
Code:
match x,equated_symbol { x#_stuff:}    
Post 26 Oct 2015, 03:05
View user's profile Send private message Visit poster's website Reply with quote
Devel99



Joined: 26 Oct 2015
Posts: 30
Devel99 26 Oct 2015, 03:10
revolution oh thanks dude, checking that
Post 26 Oct 2015, 03:10
View user's profile Send private message Reply with quote
Devel99



Joined: 26 Oct 2015
Posts: 30
Devel99 26 Oct 2015, 04:12
*deleted*


Last edited by Devel99 on 26 Oct 2015, 10:56; edited 1 time in total
Post 26 Oct 2015, 04:12
View user's profile Send private message Reply with quote
Devel99



Joined: 26 Oct 2015
Posts: 30
Devel99 26 Oct 2015, 05:45
*SOLVED* I'm happy =)) corrected code looks like this, thanks for help Wink
Code:
macro BEGIN_STRUCT structname
{
  structnameinternal EQU structname
  match x, structname  \{  x\#_begin:  \}
  db 1
} 

macro END_STRUCT   
{ 
  db 2
  match x, structnameinternal  \{  x\#_end:  \}
  restore structnameinternal
} 

    
Post 26 Oct 2015, 05:45
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.