VS2010嵌入汇编模块前基本配置以及一个小例子程序

转自:http://www.cppblog.com/jxtgddlt/archive/2011/11/02/159497.html#Post

MASM in VisualStudio 2010

First step:

Create an empty project in Visual C++:

VS2010嵌入汇编模块前基本配置以及一个小例子程序_第1张图片

Second, right-click project in solutionexplorer, Build customizations, tick "masm",

VS2010嵌入汇编模块前基本配置以及一个小例子程序_第2张图片

VS2010嵌入汇编模块前基本配置以及一个小例子程序_第3张图片

Then tap the right of mouse, select Add

VS2010嵌入汇编模块前基本配置以及一个小例子程序_第4张图片

Now, select C++ File(.cpp), enter the sourcefile name with .asm as extend file name.

VS2010嵌入汇编模块前基本配置以及一个小例子程序_第5张图片
Tap right of mouse, choose Properties:

VS2010嵌入汇编模块前基本配置以及一个小例子程序_第6张图片

Expand the entry under ConfigurationProperties. Then expand the entry named Microsoft Macro Assembler.

VS2010嵌入汇编模块前基本配置以及一个小例子程序_第7张图片

Notice that the Include Paths option hasbeen set to the x:\file directory\include directory.

In this example, include directory isc:\Irvine.

VS2010嵌入汇编模块前基本配置以及一个小例子程序_第8张图片

Next, select the Listing File entry, also in theMicrosoft Macro Assembler group. Notice that the Assembled Code Listing Fileentry (shown below) has been assigned a macro name (starting with $) thatidentifies the name of the source input file, with a file extension of .lst.So, if your program were named main.asm, the listing file would be namedmain.lst:

VS2010嵌入汇编模块前基本配置以及一个小例子程序_第9张图片

Find the Linker entry under ConfigurationProperties. Select theInput entry, and notice that two filenameshave been added to theAdditional Dependencies entry. The user32.libfile is a standard MS-Windows file. Theirvine32.lib file is the linklibrary file supplied with this book. There must be at least one spaceseparating the file names:

VS2010嵌入汇编模块前基本配置以及一个小例子程序_第10张图片

Next, select Linker underConfiguration Properties, and then selectGeneral. The AdditionalLibrary Directories option equalsc:\Irvine, so the linker can findthe Irvine32.lib library file(you also can copy irvine32.lib to .../VC/LIB direcotry, so this would needn't to be done):

VS2010嵌入汇编模块前基本配置以及一个小例子程序_第11张图片

Select Linker under the ConfigurationProperties and selectDebugging. Notice that the Generate DebugInfo option is set toYes:

VS2010嵌入汇编模块前基本配置以及一个小例子程序_第12张图片

Select System under the Linkerentry. Notice that the SubSystem option has been set toConsole:

VS2010嵌入汇编模块前基本配置以及一个小例子程序_第13张图片

We use the Console settingbecause it is easy for assembly language programs to write output to a textconsole (Command) window. This is the window you see when running cmd.exe fromthe Start > Run menu in Windows.

Click the OK button to close theProject Property Pages window.

==============================一个例子===============================

转自:http://www.cnblogs.com/cyberarmy/archive/2012/05/18/2508305.html

C内嵌汇编实现大写字母转成小写字母

/********************     Compiled by VS2010        *************/
/********************  Code by 猎鹰   2012.05.18    ************/

#include <stdlib.h>
#include <stdio.h>
int fun(int x)  
{                
  int z;
  _asm
  {
      mov eax,x
      or eax,0x20
      mov z,eax

  }
  return z;
}

int main()
{
    char x;
    printf("Please input a capital letter : ");
    scanf_s("%c",&x);                
    if(((int)x>=65)&&((int)x<=90))   
    {
        printf("\nIts lowercase  letter is:  %c\n\n",fun(x));
    }
    else
        printf("\n%c is not a capital letter.\n\n",x);
    system("pause");
    return 0;
}
/**************************************************************/


 

输入大写字母 A ,调试状态图(注意看断点当前位置和变量与寄存器的状态):

:

VS2010嵌入汇编模块前基本配置以及一个小例子程序_第14张图片

VS2010嵌入汇编模块前基本配置以及一个小例子程序_第15张图片

VS2010嵌入汇编模块前基本配置以及一个小例子程序_第16张图片

 

你可能感兴趣的:(VS2010嵌入汇编模块前基本配置以及一个小例子程序)