Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

saisoft

Visual C++ with Assembler

This topic is 6508 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
I know that there is some assembler MASM win32 application example at www.grc.com - site is worth checking out anyway - but I don''t think it deals with VC++ !?!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
it''s really easy.
just load the .asm files into your project,
and go to Project->settings->custom build step
and configure it.
that''s all

Share this post


Link to post
Share on other sites
The inline assembler should be able to take care of your assembly needs. Pretty much all MASM (Microsoft Assembler) commands, directives, etc. are valid within a block of inlined assembly. Using it is very simple.

Start the block like this:
__asm

Then you have the opening curly brace, your assembly code, then a closing curly brace. I'll give an example C/C++ function that uses the inline assembler to calculate an absolute value. (A slightly outdated version of this function is in the MSDN library, I updated it to work for long integers.)

long asmAbs(long abNum)
{
__asm
{
// you can use normal C++ comments
// or assembly-style comments
// that start with the semicolon like the following
; assembly style comment

mov ebx, abNum
cwd ; replicate the high bit into DX
xor eax, edx ; take 1's complement if negative
; no change if positive
sub eax, edx ; AX is 2's complement if it was negative or ebx, ebx ; see if number is negative
jge notneg ; if it is negative...
neg ebx ; ...make it positive
notneg: ; jump to here if positive
mov eax, ebx
}
// Note that there is no return value. You will probably
// receive a warning when you compile the program, but you can
// ignore it. A value is being returned by placing the result
// of the assembly operation into eax. The compiler doesn't
// know that however
}

Notice that you can reference your C++ variables in the assembly code.

Hope this helps!

Edited by - GHoST on November 30, 2000 11:25:15 AM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
listen kids, there is no such thing as an "assembler" language, it''s called an "assembly" language. to simplify things, the assembler just assembles the assembly code. get it? just so you know....later

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!