Advertisement

__asm { }

Started by October 01, 2000 05:18 AM
7 comments, last by davepermen 24 years, 3 months ago
how could I use the __asm { } statement in visual c++?! i'm interested in optimize my source with assembler, and now(today i ve found this statement in the msdn-library) i just wanna know how (when you know some assembler-tutorials, i'm interested, to) Edited by - davepermen on 10/1/00 7:50:51 AM
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

Yes...that's the way to use ASM-code, but if you only need one line of code then
_asm code
would work as well..
There are some good tutorials on the net written by Iczelion, but i don't know the URL..I've got the zipped tut's so if you're interested mail me at Wixner@Hotmail.com

//Patrik Wixner


Edited by - Metus on October 1, 2000 6:43:19 AM
Ethereal
Advertisement
the problem is, it doesnt work, and I don''t know why.. (I dont understand anything in asm, but I used the examples from msdn, so ?! what should i do,that the compiler understand my code?!)

we wanna play, not watch the pictures
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

i''m just playing around with my links and images

we wanna play, not watch the pictures

If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

ok, i was just to stupid, i let the compiler create the exe in a folder, and execute it in another
ok know it runs.. (i dont say that it has a complete shut down), im just at the beginning of asm..

we wanna play, not watch the pictures

If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

ok this stupid little source-snipple is working:

#pragma warning( disable : 4035)
int power2( int num, int power )
{
__asm
{
mov eax, num ; Get first argument
mov ecx, power ; Get second argument
shl eax, cl ; EAX = EAX * ( 2 to the power of CL )
}
}
#pragma warning( default : 4035 )


(the pragmas are for disableing the warning, that i havent a return value, because i have one, vc++ just couldnt see it

we wanna play, not watch the pictures

If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

Advertisement
ya know (num<<) (think thats what it is) would proberbly be just as fast if not faster then that
and why not make power a byte...just move to cl then less shit to move around
better yet do 2 powers at a time might need to move back to vaibles in asm (think vc++ uses eax for return values...all of the windows functions do) but it should all work in 3 clocks on a pentium
I agree with the AP.

int power2( int num, int power ){  __asm  {    mov eax, num ; Get first argument    mov ecx, power ; Get second argument    shl eax, cl ; EAX = EAX * ( 2 to the power of CL )  }} 


could be rewritten as such:
    int __inline power2( int num, int power ){  return (num << power);}    



That''s my opinion anyway.

Regards,
Jumpster





Semper Fi
Regards,JumpsterSemper Fi
could be.. yes

the example was just a demo from the MSDN Library, and it has shown, that it works and that was all I wanted

we wanna play, not watch the pictures

If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

This topic is closed to new replies.

Advertisement