如何将C转换为汇编[dev C ++]? [英] How do I convert C into assembly [dev C++]?

查看:1015
本文介绍了如何将C转换为汇编[dev C ++]?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,如何将此代码转换为开发组件中的汇编



Hey, how do I convert this code into assembly in dev c++

#include <stdio.h>

#define CALORIES_PER_GRAM 9.0   /* there are 9 calories per gram of fat */

int main (void)
{
        int     grams_of_fat,   /* number of grams of fat in one serving */
                total_calories; /* number of calories in one serving */
        float   fat_fraction,   /* fraction of calories due to fat */
                percent;        /* percentage of total calories from fat */

        printf("This program will tell you how much of the calories in\n");
        printf("a food are from the food's fat content.\n\n");

        printf("How many grams of fat are in one serving?  ");
        scanf("%d",&grams_of_fat);
        printf("How many total calories are in one serving?  ");
        scanf("%d",&total_calories);

        fat_fraction = (grams_of_fat * CALORIES_PER_GRAM) / total_calories;
        percent = fat_fraction * 100;

        if (grams_of_fat == 1) {
                printf("\nA food with 1 gram of fat ");
        } else {
                printf("\nA food with %d grams of fat ",grams_of_fat);
        }

        if (total_calories == 1) {
                printf("and 1 calorie per serving\n");
        } else {
                printf("and %d calories per serving\n",total_calories);
        }

        printf("has %.2f%% of those calories from fat.\n\n",percent);

        return 0;
}





我的尝试:



试图将c转换为汇编



What I have tried:

Tried to convert c into assembly

推荐答案

通常你可以使用编译器本身,并请求它以汇编语言提供输出,这样就可以了在安装了GCC的Linux机器上工作,
Typically you can use the compiler itself, and request it to provide the output in Assembly language, this would work on a Linux machine with GCC installed,


gcc program.c -S --masm = intel -o program.asm
gcc program.c -S --masm=intel -o program.asm



这当然不在我的脑海中,但它会起作用。此外,这将编译并呈现英特尔版本的程序集而不是AT& T,这很难阅读。 :-)



哦,如果这是为这个C创建汇编程序的任务,那么也许你真的需要做一些功课。阅读手册, gcc(1):GNU项目C / C ++编译器 - Linux手册页 [ ^ ]。


这篇关于如何将C转换为汇编[dev C ++]?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆