|
-
Oct 15th, 2000, 08:54 PM
#1
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.
-
Oct 16th, 2000, 10:23 AM
#2
-
Oct 16th, 2000, 11:57 AM
#3
Frenzied Member
Could you post your assembly code so we can see what isn't working.
-
Oct 16th, 2000, 01:47 PM
#4
Monday Morning Lunatic
Hmm...don't use the inline keyword...
Code:
long myfunc(long in) {
__asm {
mov eax, in
}
}
That just returns the supplied value.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 16th, 2000, 02:52 PM
#5
This line would create an error...
Code:
_asm mov hAppInstance, hInstance
-
Oct 16th, 2000, 02:57 PM
#6
Monday Morning Lunatic
Try:
Code:
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).
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 16th, 2000, 05:24 PM
#7
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);
}
-
Oct 16th, 2000, 08:05 PM
#8
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++
Code:
Colors = GetPixel(Hdc, Mouse.x, Mouse.y);
MASM
Code:
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.
-
Oct 16th, 2000, 11:51 PM
#9
Anyone? Just a paragraph or two on how to call an API?
-
Oct 17th, 2000, 12:19 PM
#10
-
Oct 17th, 2000, 01:26 PM
#11
Fanatic Member
I'm not really sure, but I think you have to push the parameters in reverse order:
Code:
push Mouse.y
push Mouse.x
push Hdc
call GetPixel
mov Colors, eax
I hope this works,
Me.
-
Oct 17th, 2000, 02:17 PM
#12
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?
-
Oct 17th, 2000, 03:32 PM
#13
Hey parksie, any suggestions?
-
Oct 18th, 2000, 07:39 PM
#14
Monday Morning Lunatic
(slurs words)
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|