1. How can the function get the "this" pointer?
2. What's the name of the CSomeClass::SomeFunc() in asm?
Posted on 2003-01-22 07:40:27 by alphasun
xxxSomeFunc( CSomeClass *_this){
;
}

_this is always the first argument.
Posted on 2003-01-22 08:28:08 by Ultrano
What kind of classes? Classes in just asm? Linked to C++ (which compiler?)?

Thomas
Posted on 2003-01-22 10:11:02 by Thomas
I have a C++ class, the compiler is Visual Studio's compiler, I want to write
some of the member functions of that class in asm.
Thanks for any reply.
Posted on 2003-01-23 22:32:42 by alphasun
well,
long CClass::Func(long param1){
long var1;
__asm{
mov eax,param1
mov ecx,4343
xor eax,ecx
ror eax,5
mov var1,eax
}
return var1;
}
Posted on 2003-01-24 02:24:53 by Ultrano
You are right, but if we use inline asm, we can't use macro assembly. Macro assembly is so useful, further more, too many inline asm codes are not easy to maintain.

any reply is welcome
Posted on 2003-01-24 03:02:49 by alphasun
alphasun,

first create your member as C++ dummy. Create a linker MAP file and find the name of the member how the C++ compiler has generated it. Now code this is ASM using that name (dont use the "@xx" suffix of the name) and delete the dummy member in your C++ source.
Posted on 2003-01-24 03:19:13 by japheth
:alright:
Good idea!
But when I wrote as following, I will get a function in .obj file named _?XXXXX@XXX@XXXqi,
pay attention to that prefix, an underline!! Which language shall I choose to generate a correct name?


.model flat, c; which language shall I choose?
.code

?XXXXX@XXX@XXXqi proc a:DWORD, b:DWORD
ret
?XXXXX@XXX@XXXqi endp

end

I tried that map file, I got this 0001:0000e970 ?SomeFunc@CWaveView@@QAEXK@Z 0040f970 f WaveView.obj
Posted on 2003-01-24 07:53:40 by alphasun
dont use the "@xx" suffix of the name

I am :stupid: !@$!%#$%^$%^
Why do not use that suffix?
please
Posted on 2003-01-24 07:58:50 by alphasun
alphasun

that suffix (and a "_" prefix) is from "stdcall" convention and will be added by MASM itself.
Posted on 2003-01-24 11:31:18 by japheth