For some reason the assembly i learned wont work as inline in Visual C++. Could someone post a link to a tutorial or an example or a reason why it wont work. Thanks.
Printable View
For some reason the assembly i learned wont work as inline in Visual C++. Could someone post a link to a tutorial or an example or a reason why it wont work. Thanks.
Anyone?
Could you post your assembly code so we can see what isn't working.
Hmm...don't use the inline keyword...
That just returns the supplied value.Code:long myfunc(long in) {
__asm {
mov eax, in
}
}
This line would create an error...
Code:_asm mov hAppInstance, hInstance
Try:
There probably isn't a direct path from memory->memory like that (I don't know).Code:push ebx
mov ebx, hInstance
mov hAppInstance, ebx
pop ebx
That worked, so apparently everything i learned in ASM for Windows, is crap. So as an example for me could someone turn this piece of code into ASM for me? Thanks.
Code:while(GetMessage(&Msg, NULL, 0, 0))
{
if(doit == 1)
{
GetCursorPos(&Mouse2);
if(Mouse2.x != Mouse.x || Mouse2.y != Mouse.y)
{
GetCursorPos(&Mouse);
Window = WindowFromPoint(Mouse);
Window = ChildWindowFromPoint(Window, Mouse);
Hdc = GetWindowDC(Window);
Colors = GetPixel(Hdc, Mouse.x, Mouse.y);
Red = GetRValue(Colors);
Green = GetGValue(Colors);
Blue = GetBValue(Colors);
SetDlgItemInt(hMainDialog, ID_EDIT_RED, Red, FALSE);
SetDlgItemInt(hMainDialog, ID_EDIT_GREEN, Green, FALSE);
SetDlgItemInt(hMainDialog, ID_EDIT_BLUE, Blue, FALSE);
SetDlgItemInt(hMainDialog, ID_EDIT_HEX, Colors, FALSE);
}
}
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
If i made an ass out of myself by asking all that, then could someone do a paragraph on calling an API function. In MASM i learned to do it this way...
VC++
MASMCode:Colors = GetPixel(Hdc, Mouse.x, Mouse.y);
Or something like that. But when i do that in VC++, i get errors everytime. So could ya just explain how to call API. Thanks.Code:call GetPixel, Hdc, Mouse.x, Mouse.y
mov Colors, eax
Anyone? Just a paragraph or two on how to call an API?
Is that to much to ask?
I'm not really sure, but I think you have to push the parameters in reverse order:
I hope this works,Code:push Mouse.y
push Mouse.x
push Hdc
call GetPixel
mov Colors, eax
Me.
I looked around some tutorials for TASM, just to see if i could find an answer. Well thats what i found, and for some reason that wont work either. I think VC++ has its own way of doing ASM. But thanks for trying though. And i know im whining in this thread, but because the code is in the message loop, its really slow. So i want to replace the whole message loop so it will go faster. But thanks though...
Anyone else?
Hey parksie, any suggestions?
Not really...
VC++ uses normal ASM. The thing about MASM (or possibly TASM), is that it uses different non-standard syntax to make it easier to call functions, rather than V(ery)'s utterly correct method of pushing them onto the stack. By the way, that's what __stdcall means - doing that. The other conventions have different methods, but that is the easiest to implement in nearly all cases.