flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > New powerfull invoke

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
dead_body



Joined: 21 Sep 2005
Posts: 187
Location: Ukraine,Kharkov
dead_body 17 Aug 2007, 15:49
Blid
Many people doesn't uses macroses. Some people don't need macroses at all.
Many of them use win32a.inc instead of win32ax.inc. So what do you want. Sad

If someone make a package of macroses. That will be good. But it is a hard work, and I think that a few of people would use it.
Post 17 Aug 2007, 15:49
View user's profile Send private message Reply with quote
Blid



Joined: 19 Apr 2007
Posts: 31
Location: Russia, Novorossysk
Blid 17 Aug 2007, 17:16
I do not understand them! Macro do hard work: repeat, pick up
optimal variant, optimization .....
Thanks for reply Ukraine comrade Smile
Post 17 Aug 2007, 17:16
View user's profile Send private message Reply with quote
Blid



Joined: 19 Apr 2007
Posts: 31
Location: Russia, Novorossysk
Blid 21 Sep 2007, 20:02
;----------=#COMMENTS about INVOKE#=--------------------------
added :
+ invoke Something,myLabel "not work properly at all !!!"
now strings(labels), defined with label are avaible
in any place of code.
+ invoke Something,hash "not work properly at all !!!"
the hash of string will bee pushed as dword 0XXXXXXXXh
for this you should define hash macro before my invoke
defined. Hash macro you can take my or youself, writen
by some rules.
+ invoke Something,dw mm0,dw mm7
the low dword of mmx register will be pushed as:
movd edx,mm0
push edx
all properties of old version(push byte, word..) are saved.
;------------------------------------------------------------
Code:
macro hash function_name,dw_to_store
{
;--------------parametrs----------------------
;function_name string for hash as "my string"
;dw_to_store into this var hash will placed and pushed
;-----------------------------------------------
;--------------X86 emulation-----------------
;input esi = pointer to string. out eax = hash
;metka:
;xor eax,eax
;ror eax,7
;xor [esp], eax
;lodsb
;test al,al
;jnz metka
;pop eax
  local ..b_hash,..dw_cyclcont,..dw_help,..dw_to_ror,..dw_hash,..dw_hash_l
     ;xor eax,eax
     ..dw_cyclcont = dword 0
     ..b_hash      = byte 0
     ..dw_help     = dword 0
     ..dw_to_ror   = dword 0
     ..dw_hash     = dword 0
   virtual at 0
     db function_name,0
   while 1      ;cycl
     ;ror eax,7
     ..dw_to_ror = ..dw_help
     ..dw_to_ror = ..dw_to_ror and 0FFh   ;to avoid out of range
     ..dw_help   = ..dw_help shr 7
     ..dw_to_ror = ..dw_to_ror shl 25     ;restore 7 bit''s
     ..dw_help   = ..dw_help or ..dw_to_ror
     ;xor     [esp+0], eax
     ..dw_hash   = ..dw_hash xor ..dw_help

     ;LODSB
     load ..b_hash byte from ..dw_cyclcont

     ..dw_cyclcont = ..dw_cyclcont + 1
     ..dw_help = ..dw_help and 0FFFFFF00h
     ..dw_help = ..dw_help + ..b_hash
     ;TEST    AL,AL
     if ..b_hash = 0
       break
     end if
     ;JNZ     SHORT if ..b_hash = 0
   end while
   end virtual
     dw_to_store = ..dw_hash
}
;------------------------------------------------------------ 
macro invoke function*,[arg]
{
;warning: not allowed: ByTe,WoRd
common 
local parsed_var,edx_status,argument_edx,\   ;local var's ' 
      argument_number,argument_with_edx

      argument_with_edx=0   ;we do not know  number, it is set to 0 
      edx_status = 0            ;edx_status flag, edx is no zero, it is set to 0
                      ;edx contain smth == 0
                      ;edx is clean, but dx is not == 1
                      ;edx and dx is clean, but dl is not == 2
                      ;edx is clear == 3
      argument_edx=0        ;before parsing we do not now it 
  
;find arg edx
reverse 
argument_with_edx = argument_with_edx + 1 
;if last argument->disable: any manipulation cannot 
;change this argument 
   if (arg in <edx,dx,dh,dl,EDX,DX,DH,DL,Edx,Dx,Dh,Dl>)&(argument_with_edx<>1) 
      argument_edx=1        
   end if 
    
common 

reverse 

if ~arg eq
      parsed_var = 0        ;parsed_var flag, if begin parsing = 0
;case string

  if arg eqtype ''            ;if arg string 
   parsed_var = 1         ;arg parsed as string 
   local ..to_jmp,..metka ;labels for label and jmp 
   jmp ..to_jmp           ;jmp over string 
   ..metka db arg,0       ;define string 
   ..to_jmp:
   push ..metka   ;pushing pointer to string 
  end if

;case register based

  if arg eqtype [ebp+0]     ;if argument is smth: [ebp+12] 
     parsed_var = 1         ;arg is parsed 
     push dword arg         ;push dword  [ebp+12] 
  else

match type some,arg     ;type contain type of argum., some have not meanig 
\{ 
   parsed_var = 1       ;if we here arg is parsed -> set flag 
;case type sig number
  if arg eqtype 1     ;if argument is smth: [ebp+12]
     push  arg         ;push dword  [ebp+12]
  end if
;case hash

   if type eq hash
     local hash
     arg,hash
     push hash
   end if

;case string with label

   if (some eqtype '')&(~(type eq hash))   ;if arg string
   local ..to_jmp,..metka ;as above
    jmp ..to_jmp
    type = ..metka;type equ  ..metka
    ..metka: 
     db some,0      ;string with label 
    ..to_jmp: 
    invoke.create_sizeof type 
    push ..metka   ;pushing pointer to string   

   end if
           
;case type byte

   if type in <b,B,byte,BYTE,Byte> ;if byte load it to edx and push 
    if argument_edx=1        ;if argument cont. edx -> warning 
           err you should not use EDX for argument 
          end if 
          if edx_status < 2     ;is need to clear edx? 
           xor edx,edx    ;clear edx 
          end if 
          mov dl,ByTe some
          edx_status = 2   ;the part of register is not clean,set flag 
          push edx
          restore b,B,byte,BYTE,Byte 
   end if
;case type addr 

if type in <Addr,addr,ADDR>   ;if arg: 'Addr ebp+12' (LocalVar1) 
    if argument_edx=1              ;if argument cont. edx -> warning 
               err you should not use EDX for argument 
          end if 
           lea edx,[some]                              ;loading adress 
           push edx
           edx_status =0                                 ;now edx is no zero, flag to 0
           restore Addr,addr,ADDR 
   end if 
   
;case type word

   if type in <word,Word,WORD,w,W>   ;such as for byte
    if argument_edx=1       ;if argument cont. edx -> warning 
           err you should not use EDX for argument 
          end if
          if edx_status = 0 
           xor edx,edx 
          end if 
           mov dx,WoRd some
           edx_status = 1 
           push edx 
           restore word,Word,WORD,w,W
   end if 
   
;case type dword

   if type in <dword,Dword,DWORD,dw,d,D,DW,Dw>  ;such as for byte, but not using edx
          if some in <mm0,mm1,mm2,mm3,mm4,mm5,mm6,mm7>
           if argument_edx=1              ;if argument cont. edx -> warning
            err you should not use EDX for argument
           end if
           movd edx,some
           push edx
           edx_status =0                                 ;now edx is no zero, flag to 0
           parsed_var = 1
          else
           push  arg
          end if
   end if

;case type invoke

   if type eq invoke  ;is this nested invoke -> parse 
    if argument_edx=1       ;if argument cont. edx -> warning 
            err you should not use EDX for argument 
          end if 
             arg 
             push eax    ;push return value 
             edx_status =0 ;after invoke edx is not clean -> set flag 
      end if 
\} 
;case type none
  if  parsed_var = 0  ;if var is not parsed -> push it 
   push arg 
  end if
end if
end if 
common

  call [function] ;at last direct call

}
;------------------------------------------------------------
    
Post 21 Sep 2007, 20:02
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.