c - 我需要将我用 C(.c) 编写的代码转换为汇编(.asm)。我对用 C 编写非常陌生,现在我需要学习如何用汇编编写
问题描述
我需要将我的 C 代码转换为程序集
这是我需要转换为汇编(.asm)的C代码
int main()
{
//Variables that stores the numbers
int num1, num2, num3;
// Variable that stores the result
int result;
// Asking the user to input the value of num1
printf("Enter the first number:");
scanf("%d",&num1);
// Asking the user to input the value of num2
printf("Enter the second number:");
scanf("%d",&num2);
// Asking the user to input the value of num3
printf("Enter the third number: ");
scanf("%d",&num3);
//Performing the operation
result = num3 - (num1 + num2);
//Printing the result
printf("The value of result is: %d",result);
return 0;
}
解决方案
那么理论上你可以使用 gcc 编译它并命令它生成 asm 列表(这将是汇编程序),所以你可以将它的扩展名更改为 .asm (https://www.systutorials.com/240/generate-a-混合源和程序集列表使用 gcc/ )
不过一般来说,在汇编中包含 scanf 和 printf 或任何库函数是个坏主意(因为它们在 asm 中可能非常长,特别是系统调用,例如读/写/打开,printf)。
万一你在大学里有人要求你用 ASM 写一些东西,他们会知道这不是你写的。
同样从标题来看,盯着 C 列表学习 ASM 是不可能的(例如由于过程调用上的堆栈操作)。
推荐阅读
- angular - 在 Angular 服务中使用静态变量时的循环依赖
- excel - 为什么更改 Slicercache.TimelineState.SetFilterDateRange 的开始和结束日期会导致“1004”应用程序或对象定义错误?
- microsoft-graph-api - 借助 Microsoft Graph API 检测退回邮件
- java - 在 Windows 中使用命令提示符编译具有 Jar 依赖项的 Java 文件
- python - 你如何预处理健身房 Dict 离散/连续动作空间?
- laravel - Laravel Socialite Facebook 登录不起作用(AuthController 不存在)
- c# - Twitchlib 预测
- list - 按输入编号轮换列表
- firebase - Firebase:云功能更改 Firestore 中的数据 - 资源项目的权限被拒绝 [X:YYYYYYYYYY:web:KKKKKKKKKKKK]
- java - LWJGL 示例代码不起作用(窗口未聚焦/显示)MacBook Air 2020