提交 605b404d 创建 作者: 赵鹏翀's avatar 赵鹏翀

init template

上级
/Debug
/Release
\ No newline at end of file
<?xml version="1.0" encoding="gb2312"?>
<ASMProject Version="1.00" Name="Demo018" TemplatePath="Lab004\Project" ProjectID="b78064ed-7120-4cca-b645-4fd9bcdb14b1" IsSubmitWork="0">
<Configurations>
<Configuration Name="Debug" DebuggerFlavor="0">
<Tool Name="PreBuildEventTool"/>
<Tool Name="CustomBuildTool"/>
<Tool Name="GCCCompilerTool" PreprocessorDefinitions="_DEBUG" GenerateDebugInformation="-1" LanguageStandard="c99" AssemblerOutput="-1"/>
<Tool Name="PreLinkEventTool"/>
<Tool Name="GCCLinkerTool"/>
<Tool Name="PostBuildEventTool"/>
</Configuration>
<Configuration Name="Release" DebuggerFlavor="0">
<Tool Name="PreBuildEventTool"/>
<Tool Name="CustomBuildTool"/>
<Tool Name="GCCCompilerTool" PreprocessorDefinitions="NDEBUG" LanguageStandard="c99"/>
<Tool Name="PreLinkEventTool"/>
<Tool Name="GCCLinkerTool" StripDebugInfo="-1"/>
<Tool Name="PostBuildEventTool"/>
</Configuration>
</Configurations>
<Files>
<Filter Name="ͷļ" Filter="h;hpp;hxx">
<File RelativePath=".\console.h">
</File>
</Filter>
<Filter Name="Դļ" Filter="cpp;c;cc;cxx">
<File RelativePath=".\asmfun.s">
</File>
<File RelativePath=".\console.c">
</File>
</Filter>
</Files>
</ASMProject>
添加文件
.globl _asmfun
_asmfun:
mov _x, %eax #将保存的x的值传入寄存器eax
mov _y, %ebx #将保存的y的值传入寄存器ebx
add %ebx, %eax #使用add指令将两个寄存器中的数据相加,结果保存到eax中
mov %eax, _result #将eax中的结果给到全局变量
ret #程序返回
\ No newline at end of file
#include "console.h"
int x, y; // 指数
int result; // 计算结果
unsigned long asmfun(); // 声明函数asmfun()
int main()
{
printf("输入两个数据求和\n");
scanf("%d %d", &x, &y);
asmfun(); // 调用函数asmfun()
printf("两个数的和为:%d\n", result);
}
#ifndef _CONSOLE_H_
#define _CONSOLE_H_
#include <stdio.h>
/* TODO: 在此处引用程序需要的其他头文件 */
#endif /* _CONSOLE_H_ */
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论