flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > How macro understood . or .. ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1847
Roman 09 Mar 2023, 13:36
Fasmw 1.73
My question how macro know is . or .. name from struc POINT ?
I want my macro (Update) put integer to .x and put float to ..x

Code:

struc POINT xdata=?, ydata=? {
  .x  dd xdata ;as integer
  .y  dd ydata
..x dd 1.0 ;as float for macro 
..y dd 1.0 ;as float for macro
}
pp POINT 1,1
Update pp.x,5  ;macro put 5
Update pp..x,5 ;macro put 5f
        
Post 09 Mar 2023, 13:36
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 09 Mar 2023, 19:27
You can separate locations for different types of data then check it in your macro
Code:
struc point
{
        .x dd ?
        .y dd ?
}

struc pointFloat
{
    if 0
    .:
    end if
        ..x dd ?
        ..y dd ?
}

macro Update source,data
{
   if source >= Float
      ;use float variant
   else
      ;use integer variant
   end if
}

Mytest point
Float = $       ;your float area next to this point
Mytest pointFloat
    

Anyway, don't you want to name it more intuitive? )) UpdateFloat pp.x.float ...
Post 09 Mar 2023, 19:27
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1847
Roman 09 Mar 2023, 19:41
Thanks.
Very cool.
Post 09 Mar 2023, 19:41
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1042
Location: Russia
macomics 09 Mar 2023, 19:57
Why divide it into two structures?
Code:
struc POINT xdata=?, ydata=? {
  .x  dd xdata ;as integer
  .y  dd ydata
..x dd 1.0 ;as float for macro 
..y dd 1.0 ;as float for macro
}

macro Update base*,source*,data=0 {
  if base#source >= base#..x
    mov [base#source], data#f
  else
    mov [base#source], data
  end if
}

pp POINT 1,1

Update pp,.x,5  ;macro put 5
Update pp,..x,5 ;macro put 5f     


Last edited by macomics on 09 Mar 2023, 20:10; edited 1 time in total
Post 09 Mar 2023, 19:57
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 09 Mar 2023, 20:01
macomics, your variant works for one structure only. It's ok but if there some more structures/points like that it will not.
Did you check it? match a=.b, source


Last edited by Overclick on 09 Mar 2023, 20:03; edited 2 times in total
Post 09 Mar 2023, 20:01
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1847
Roman 09 Mar 2023, 20:02
I do this. Like c++ class Smile
Code:
macro Update source,data
{
   if source >= Initz
      mov eax,data
      call source
   end if
   if source = Float &  source < Initz
      mov [source],data#f ;use float variant
   end if   
   if source < Float  
      mov [source],data   ;use integer variant
   end if

}
struc POINT xdata=?, ydata=? {
  .x  dd xdata ;as integer
  .y  dd ydata
}
struc POINTfl xdata=?, ydata=? {
Float = $
if 0
    .:
    end if
..x dd xdata
..y dd ydata
}
struc POINTintz  {
Initz = $
if 0
    .:
    end if
.i:
    ;proc xdata
     add eax,eax
     ret
    ;endp
}                      
;data
pp      POINT 1,1
pp      POINTfl 2,3
pp      POINTintz 
;code
Update pp.i,32   ;do call ahhh1 i check in IDA Pro 
Update pp.x,5    ;put [pp.x],5
Update pp..x,1   ;put [pp..x],1f
    


Last edited by Roman on 09 Mar 2023, 20:12; edited 1 time in total
Post 09 Mar 2023, 20:02
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1042
Location: Russia
macomics 09 Mar 2023, 20:11
Overclick wrote:
Did you check it? match a=.b, source
Yes. I just checked it out. The corrected version works.

Roman, only when using relative access to the fields of the structure, this will not work.

Code:
virtual at rbx
  pp POINT 1,1
end virtual

Update pp.x, 5
Update pp..x, 5    
Post 09 Mar 2023, 20:11
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 669
Location: Ukraine
Overclick 09 Mar 2023, 20:23
Roman you put separators at wrong places
Code:
.data
pp      POINT 1,1
Float =$
pp      POINTfl 2,3
.code
Initz =$
pp      POINTintz 
Update pp.i,32   ;do call ahhh1 i check in IDA Pro 
Update pp.x,5    ;put [pp.x],5
Update pp..x,1   ;put [pp..x],1f
    
Post 09 Mar 2023, 20:23
View user's profile Send private message Visit poster's website 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 09 Mar 2023, 21:34
Very confusing!
Roman wrote:
Code:
Update pp.x,5  ;macro put 5
Update pp..x,5 ;macro put 5f    
This is better:
Very clear, no confusion, obvious what is intended.
Code:
Update_integer pp.x,5  ;macro put 5
Update_float   pp..x,5 ;macro put 5f    
But this is best:
Code:
mov [pp.x],5
mov [pp..x],5f    
Smile
Post 09 Mar 2023, 21:34
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.