Re: Mixed assembler and C++



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






.



Relevant Pages

  • Re: Help! The problem about armasm.exe
    ... Microsoft Windows CE Compiler Team ... SDK ... Can you tell me why your assembler can't assemble the .asm files generated ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Assembling Visual Studio generated listing files
    ... I wonder how the compiler itself works internally. ... compatible assembler file that can output ... days an application developer was in-the-loop as part of the ... produced, one can write .asm files and assemble them with MASM, then ...
    (microsoft.public.vc.mfc)
  • Re: Structures in Assembly Language
    ... "Alex McDonald" écrivait ... such a level of intellectual dishonnesty pushes you ... the Members of the "instances" of the STRUCT, ... Assembler, because it would no longuer be an Assembler, ...
    (alt.lang.asm)
  • Re: Mixed assembler and C++
    ... studied how the compiler make the assembler code - and it seems to be bit ... Does anyone know how to pass a structure back from assembler? ... struct Y var1; ...
    (microsoft.public.vc.language)
  • Re: struct stat
    ... assembler declarations, using sizeof and offsetof. ... importance of version-to-version binary compatibility. ... redefining a "public" interface like `struct stat' seems like ... executables, it changes the magic in the executable file (or ...
    (comp.unix.programmer)

Quantcast