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++:


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


Then tap the right of mouse, select Add


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


Tap right of mouse, choose Properties:


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


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

In this example, include directory isc:\Irvine.


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:


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:


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):


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


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


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 ,调试状态图(注意看断点当前位置和变量与寄存器的状态):

:

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值