Click to See Complete Forum and Search --> : Inline assembly
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.
Vlatko
Oct 16th, 2000, 11:57 AM
Could you post your assembly code so we can see what isn't working.
parksie
Oct 16th, 2000, 01:47 PM
Hmm...don't use the inline keyword...
long myfunc(long in) {
__asm {
mov eax, in
}
}
That just returns the supplied value.
This line would create an error...
_asm mov hAppInstance, hInstance
parksie
Oct 16th, 2000, 02:57 PM
Try:
push ebx
mov ebx, hInstance
mov hAppInstance, ebx
pop ebx
There probably isn't a direct path from memory->memory like that (I don't know).
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.
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++
Colors = GetPixel(Hdc, Mouse.x, Mouse.y);
MASM
call GetPixel, Hdc, Mouse.x, Mouse.y
mov Colors, eax
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.
Anyone? Just a paragraph or two on how to call an API?
V(ery) Basic
Oct 17th, 2000, 01:26 PM
I'm not really sure, but I think you have to push the parameters in reverse order:
push Mouse.y
push Mouse.x
push Hdc
call GetPixel
mov Colors, eax
I hope this works,
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?
parksie
Oct 18th, 2000, 07:39 PM
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.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.