flat assembler
Message board for the users of flat assembler.

Index > Windows > invokeif macro...

Author
Thread Post new topic Reply to topic
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
Hi

I'm trying to get my invokeif macro to work:
Code:
jnne equ je
jnna equ ja
jnnb equ jb
jnnz equ jz
jnbe equ ja
jnae equ jb 

macro invokeif v1,cond,v2,proc,[args]
 {
 common
        cmp v1,v2
        jn#cond @f

        if ~ args eq
                stdcall proc,args
        else
                call [proc]
        end if

    @@:
 }  

;Example Usage:
invokeif [hWnd],ne,0,ShowWindow,[hWnd],SW_SHOW

    
Can anyone see what I'm doing wrong?

Thanks in advance,

cod3b453
Post 29 Jun 2005, 16:35
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
I can't see any error there, are you sure it doesn't work?

But:
1. use macro-local labels instead of @@. Also sart all their names with "..".
2. I believe you don't need to define jnbe and jnae.
3. Seems you forgot about signed local jumps - jl, jng...

PS: why not "c0d3b453", if you want to look hacky?
Post 29 Jun 2005, 20:58
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
1. When you say "local label instead of @@", do you mean:

Code:
macro invokeif v1,cond,v2,proc,[args] 
 { 
 local _jmp ; <<<
 common 
        cmp v1,v2 
        jn#cond _jmp ; <<<

        if ~ args eq 
                stdcall proc,args 
        else 
                call [proc] 
        end if 

    _jmp: ; <<<
 }   


    


2. Your probably right but it's there just in case

3. I never use jl jng etc (what do they do that the others don't anyway? lol)

PS: Because the "0" on most fonts looks rubbish so i stick with "o" - if I really thought the number of non alpha numeric characters on my tag were related to my computer ability I would have had : ©ØÐ3ß@$€
Post 30 Jun 2005, 17:18
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
OK i just realised something - it's not the jump, but the call: when I use invoke it disassembles to:

call dword ptr [????????]

whereas invokeif disassembles to:

call ????????

so I have now got:

Code:
macro invokeif v1,cond,v2,proc,[args]
 {
 common
        cmp v1,v2
        jn#cond @f

        if ~ args eq

 reverse
     pushd args

 common
        call dword ptr proc

        else
                call dword ptr proc
        end if

    @@:
 }
    
which seems to work
Post 30 Jun 2005, 17:44
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
of course, but it should be
Code:
macro invokeif v1,cond,v2,proc,[args]  
 {  
 local ..jmp ; <<<  note two dots
 common  
        cmp v1,v2  
        jn#cond ..jmp ; <<< 

        if ~ args eq  
                stdcall [proc],args  ;<- this was the problem
        else  
                call [proc]  
        end if  

    ..jmp: ; <<< 
 }
    

otherwise code like
Code:
MyProcedure:
  ...
  invokeif ...
  .a:
    

will define "_jmp.a" instead of "MyProcedure.a". But label with two dots doesn't change namespace.

PS: "call ptr a" is same as "call [a]", and "call dword ptr a" is same as "call dword [a]"
Post 30 Jun 2005, 20:13
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number 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 YouTube, Twitter.

Website powered by rwasa.