flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > converting this complex masm macro argument

Author
Thread Post new topic Reply to topic
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
What in the hell is that arugment do????? Anyone?


Code:
lea edi,offset ImportStruct
        assume edi: PL_IMPORTS_INFO

        mov edi,[edi].plImportDir
        assume edi: IMAGE_IMPORT_DESCRIPTOR
        
   .while !([edi].OriginalFirstThunk,e,0 && [edi].TimeDateStamp,e,0 && [edi].ForwarderChain,e,0 && [edi].Name1,e,0 && [edi].FirstThunk,e,0) <----
        
        .if [edi].OriginalFirstThunk,e,0
                mov esi,[edi].FirstThunk
        .else
                mov esi,[edi].OriginalFirstThunk
        .endif    
Post 05 Mar 2006, 04:16
View user's profile Send private message Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost
Code:
assume edi: IMAGE_IMPORT_DESCRIPTOR 
    


compiler assumes edi points to an IMAGE_IMPORT_DESCRIPTOR structure, so [edi].StructMember will generate edi+that many bytes etc

_________________
redghost.ca
Post 05 Mar 2006, 08:25
View user's profile Send private message AIM Address MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
With the "match-improved" version of the classic assume-emulating macro:
Code:
macro assume param
 { local _reg
   match reg:struc, param
   \{ virtual at reg
      reg equ _reg
      reg struc
      end virtual
      restore reg \} }    

and with the fasm's official HLL macros it can be written like:
Code:
assume edi:IMAGE_IMPORT_DESCRIPTOR

.while ~([edi.OriginalFirstThunk]=0 & [edi.TimeDateStamp]=0 & [edi.ForwarderChain]=0 & [edi.Name1]=0 & [edi.FirstThunk]=0)    
Post 05 Mar 2006, 12:50
View user's profile Send private message Visit poster's website Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
I knew the assume part but I just put everything else just incase you needed to see the surrounding code

What does ~ do?
Post 05 Mar 2006, 14:05
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
It's the standard fasm's operator for logical negation. See fasm's manual, section 2.2.2.
Post 05 Mar 2006, 14:12
View user's profile Send private message Visit poster's website Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
Is there anyway you can make a table with all of them?
Post 05 Mar 2006, 14:24
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
You mean, all three of them?
Post 05 Mar 2006, 14:47
View user's profile Send private message Visit poster's website Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
Like ~ means not
= means equal
~= means not equal
somethng like that
Post 05 Mar 2006, 17:07
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
Why "assume" is not included in standard package? If you add it please add the possibility to define "reg:nothing", it can be achieved with a structure named "nothing", no?
Post 05 Mar 2006, 18:08
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
Be careful not to mix the different kinds of operators. The ~, & and | are operators applied to logical values to calculate more complex logical value, while =, <, >, <> etc. are operators applied to numerical expressions etc. in order to create single logical value.
Post 05 Mar 2006, 19:28
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
locodelassembly wrote:
Why "assume" is not included in standard package? If you add it please add the possibility to define "reg:nothing", it can be achieved with a structure named "nothing", no?

Because this simple trick doesn't support "undefining" the previous assume on the next one. This can be done using the similar mechanism to "local", but it would be much more complex macro, which I have not written yet.
Post 05 Mar 2006, 19:29
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
OK, something like this should work like I wanted:
Code:
macro assume params
 { match assumed, all@assumed
   \{ irp name, assumed
      \\{ restore name \\} \}
   match reg:struct, params
   \{ macro label . \\{ \\}
      struc db [val] \\{ \common def@assumed .,db val \\}
      struc dw [val] \\{ \common def@assumed .,dw val \\}
      struc dp [val] \\{ \common def@assumed .,dp val \\}
      struc dd [val] \\{ \common def@assumed .,dd val \\}
      struc dt [val] \\{ \common def@assumed .,dt val \\}
      struc dq [val] \\{ \common def@assumed .,dq val \\}
      struc rb cnt \\{ def@assumed .,rb cnt \\}
      struc rw cnt \\{ def@assumed .,rw cnt \\}
      struc rp cnt \\{ def@assumed .,rp cnt \\}
      struc rd cnt \\{ def@assumed .,rd cnt \\}
      struc rt cnt \\{ def@assumed .,rt cnt \\}
      struc rq cnt \\{ def@assumed .,rq cnt \\}
      all@assumed equ
      virtual at reg
       reg struct
      end virtual
      purge label
      restruc db,dw,dp,dd,dt,dq
      restruc rb,rw,rp,rd,rt,rq \} }

macro def@assumed name,def
 { match vars, all@assumed \{ all@assumed equ all@assumed, \}
   all@assumed equ all@assumed name
   local ..label
   name equ ..label
   ..label def }

all@assumed equ

struc none { label . }    

I will include it in official MASM.INC
Post 05 Mar 2006, 20:00
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Thank you Very HappyVery HappyVery HappyVery Happy
Post 05 Mar 2006, 20:55
View user's profile Send private message Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi
there should be no official masm.inc in first place Evil or Very Mad



Laughing

_________________
When We Ride On Our Enemies
support reverse smileys |:
Post 05 Mar 2006, 21:16
View user's profile Send private message MSN Messenger 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.