flat assembler
Message board for the users of flat assembler.

Index > Main > Is it possible this on "stdcall" macro?

Author
Thread Post new topic Reply to topic
alorent



Joined: 05 Dec 2005
Posts: 201
alorent
Hi guys,

Is it possible in the "stdcall" macro to call it as:

Code:
stdcall  ebx, addr [ebp + 11223344]    


I have tried under FASM but it produces error (due to the "addr [ebp + 11223344]")

Under MASM, we can call it as:

Code:
invoke ebx, ADDR [ebp + 11223344]    


and it generates:

Code:
lea     eax, [ebp + 11223344]
push   eax
call    ebx    


Thanks in advance!
Post 22 Oct 2009, 13:29
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
Yes, and it is very simple:
Code:
stdcall  ebx, addr ebp + 11223344    
Post 22 Oct 2009, 13:58
View user's profile Send private message Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 201
alorent
Woww, LocoDelAssembly, thanks!!! Very Happy

By the way, I see that the generated code is:

Code:
lea  edx, [ebp + 11223344]
push edx
call   ebx
    


Is it possible to control that code generation and use EAX instead of EDX? That is, like:

Code:
lea  eax, [ebp + 11223344]
push eax
call   ebx
    


I have been looking at the PROC32.INC file, but don't see that code being generate at all.

Thanks!!!
Post 22 Oct 2009, 14:26
View user's profile Send private message Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22
@alorent
Try the WIN32AX.INC and WIN32AXP.INC files.

The ADDR is part of the PUSHD macro. So replace
Code:
lea edx,[..address]    
with
Code:
lea eax,[..address]    


But if you start editing the includes you'll need to take note when you use a newer/upgraded version of FASM to re-implement your changes.
Post 22 Oct 2009, 15:02
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
You have to look in WIN32?X*.inc instead:
Code:
  match pushd =addr var,pushd value \{ \local ..opcode,..address
   virtual at 0
    label ..address at var
    mov eax,dword [..address]
    load ..opcode from 0
   end virtual
   if ..opcode = 0A1h
    push var
   else
    lea edx,[..address]
    push edx
   end if
   pushd equ \}     


You can't change the register unfortunately (I mean, without changing the includes). However, if you need such control, besides doing LEA and then using EAX as argument (which only works you need a single argument with the ADDR loaded into EAX), I suggest you not using stdcall at all and doing plain PUSH/CALL yourself. IMHO, macros should only be used when (1) you perform the same task several times, and (2) when you would perform the task in the very same way each time without macros.

PS: Well, r22 replied first but I think it is still somewhat important what I've said above Razz
Post 22 Oct 2009, 15:04
View user's profile Send private message Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 201
alorent
Thanks a lot guys!!! Very Happy
Post 22 Oct 2009, 18:28
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-2020, Tomasz Grysztar.

Powered by rwasa.