Re: Mixed assembler and C++
- From: "Alan Carre" <alan@xxxxxxxxxxxxxxxxx>
- Date: Wed, 27 Sep 2006 13:33:52 +0700
Not really, at least with inline assembly. You should get a copy of MASM and
compile your C-exports in actual asm files. It goes something like:
FuncName PROC C var1:DWORD, var2:DWORD
etc... in ASM.
But I forget how the assembler sets up the stack frame even for simple
variables like this. Long time ago... wish I could be of more assistance.
- Alan
"Søren Skovgaard" <soren.skovgaard@xxxxxxxxxxxxxx> wrote in message
news:%23HYWCia4GHA.4352@xxxxxxxxxxxxxxxxxxxxxxx
Hi Alan !
First of all I pass the parameter by value, and return by value. And I
have studied how the compiler make the assembler code - and it seems to be
bit complexed when the size of the structure exceeds 4 dwords. What the
compiler does then is to make a global variable, put the values in that
variable, and then pass a pointer in eax back to the C++ program. But I
have great difficulties how this is done in practice. Do you know how ?
Thanks Alan for your reply ;-)
Regards
Søren
"Alan Carre" <alan@xxxxxxxxxxxxxxxxx> skrev i en meddelelse
news:%23%23fXcaQ4GHA.3604@xxxxxxxxxxxxxxxxxxxxxxx
"Søren Skovgaard" <soren.skovgaard@xxxxxxxxxxxxxx> wrote in message
news:eNyXFDP4GHA.1200@xxxxxxxxxxxxxxxxxxxxxxx
Hi all !
Does anyone know how to pass a structure back from assembler ?
Example:
C++ :
struct Y {
int a;
int b;
int c;
}
extern "C" struct Y __stdcall Varadd(struct Y var);
struct Y var1;
struct Y var2;
var1.a = 2;
var1.b = 3;
var1.c = 4;
var2 = Varadd(var1);
Can anyone tell me how to pass the argument to a assembler routine
called Varadd, and how to pass the returnvalue ?
I'm sure there are many implementations, and it will depend on whether or
not the struct is passed by value or by reference. But why even ask the
question when the answer is readily available: Simply create a functiom
in C/C++ and pass it a 'var' and let the function return a 'var'. Then
just look at the disassembly.
- Alan Carre
.
- References:
- Mixed assembler and C++
- From: Søren Skovgaard
- Re: Mixed assembler and C++
- From: Alan Carre
- Re: Mixed assembler and C++
- From: Søren Skovgaard
- Mixed assembler and C++
- Prev by Date: Re: Hooking Keyboard
- Next by Date: saving a word document in a runtime path and in a special path
- Previous by thread: Re: Mixed assembler and C++
- Next by thread: Re: Mixed assembler and C++
- Index(es):
Relevant Pages
|