flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > about use macro in struc

Author
Thread Post new topic Reply to topic
zjlcc



Joined: 23 Jul 2003
Posts: 32
Location: china
zjlcc 18 May 2004, 07:18
hi,good day everyone
can you help me? thank you!
Code:
struc TPoint {
  .x  dw     0
  .y  dw     0
}
struc TRect {
  .x dw    0
  .y dw    0

  virtual at .x
    .TPoint TPoint
  end virtual                                            
}
======>is OK

but, if Use macro:

macro mv base,type
{
  virtual at .#base
    .#type type
  end virtual                                            
}
struc TRect {
  .x dw    0
  .y dw    0
  mv x,TPoint
}
    

=======>is error and message: " .#type type" illegal instruction Question


Last edited by zjlcc on 19 May 2004, 07:19; edited 1 time in total
Post 18 May 2004, 07:18
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 18 May 2004, 18:11
i quess it is because macro contents are preprocessed before preprocessing '#' operator, so it won't take ".#type type" as usage of structure (it is not symbol followed by structure name, but it is symbol followed by "#" followed by symbol followed by structure name).

i am not sure if this is really the matter.
Post 18 May 2004, 18:11
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 18 May 2004, 18:23
It wouldn't matter if it was inside the structure, because it would anyway be processed as "StrucName.#type" and then concatenated into "StrucName.type". The problem is that dot is used inside the macroinstruction, where it has no special meaning. The structure-specific substitutions are done before doing anything else (if you use "mv .x,.TPoint" macro inside the structure, it will be processed as "mv StrucName.x,StrucName.TPoint"). But in this case, "mv x,TPoint" macro makes just ".x" and ".TPoint" symbols.
Post 18 May 2004, 18:23
View user's profile Send private message Visit poster's website Reply with quote
zjlcc



Joined: 23 Jul 2003
Posts: 32
Location: china
zjlcc 19 May 2004, 07:16
thanks reply
(if you use "mv .x,.TPoint" macro inside the structure, it will be processed as "mv StrucName.x,StrucName.TPoint"). But in this case, "mv x,TPoint" macro makes just ".x" and ".TPoint" symbols.
Code:
format PE GUI 4.0

entry start

macro vv main,base,type{   ;vv TRect,TRect.x0,TPoint
  virtual at base          ;virtual at TRect.x0
    main#.#type type       ;  TRect.TPoint TPoint
  end virtual              ;end virtual
}
struc TPoint {
  .x  dw     0
  .y  dw     0
}
virtual at 0
  TPoint TPoint
end virtual

struc TRect {
  .x0 dw    0
  .y0 dw    0
  vv TRect , .x0 , TPoint ;<== OK!!
}
virtual at 0
  TRect TRect
end virtual

;RR  TRect  ;<==if use it then report error Else OK!!!!!
 
start:
;  mov  [RR.x0],10h 
;  mov  ax,[RR.TPoint.x] 
  ret
    

err msg:
main#.#type type
error:symbol already defined Crying or Very sad
Post 19 May 2004, 07:16
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 19 May 2004, 08:40
Your struc macro defines "TRect.TPoint" structure each time it is invoked, so that's why when you use it for the second time you get "symbol already defined" error.
Post 19 May 2004, 08:40
View user's profile Send private message Visit poster's website Reply with quote
zjlcc



Joined: 23 Jul 2003
Posts: 32
Location: china
zjlcc 19 May 2004, 11:36
oh,yes!you right
Post 19 May 2004, 11:36
View user's profile Send private message Reply with quote
aaro



Joined: 21 Jun 2003
Posts: 107
Location: hel.fi
aaro 19 May 2004, 11:42
Are you trying to do union macro? Here's how i did it:
Code:
macro _union_declare_data [arg] { 
forward 
  arg 
} 

macro union [arg] { 
common 
  local ..union_addr, peak 
  ..union_addr: 
  peak = $ 

forward 
  virtual at ..union_addr 
    _union_declare_data arg 
    if $ > peak 
      peak = $ 
    end if 
  end virtual 

common 
  rb peak - $ 
} 
    

Usage:
Code:
struc TVINSERTSTRUCTA {
    .hParent dd ?
       .hInsertAfter dd ?
  union \
            .itemex TVITEMEXA,\
                .item TVITEMA
}
struct TVINSERTSTRUCTA
    
Post 19 May 2004, 11:42
View user's profile Send private message Reply with quote
zjlcc



Joined: 23 Jul 2003
Posts: 32
Location: china
zjlcc 22 May 2004, 10:44
thank aaro!

have some like my idea
can you see my topic: ?
http://board.flatassembler.net/topic.php?t=1607
Post 22 May 2004, 10:44
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.