将 C 源代码转换为 ARM 程序集 [英] Converting C source to ARM assembly

查看:31
本文介绍了将 C 源代码转换为 ARM 程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 ARM(用于 Raspberry Pi2 的 ARMv7l)转换 .c 文件,但我找不到任何在线转换器或了解它是如何工作的.以前这些 .c 文件在 Windows 平台上是可执行的,因此无法在 Pi 的 arm 架构上执行.有人可以帮助我吗?

I am trying to convert .c files for ARM (ARMv7l for Raspberry Pi2) but I could not find any online converter or understand how it works. Previously these .c files were executable in Windows platform and thus unable to execute on Pi's arm architecture. Does anybody can assist me in this?

推荐答案

任何 c 编译器都可以从 C 代码生成汇编代码,如果您的目标是专门为 arm 生成汇编代码,那么您将需要一个交叉编译器,例如GNU arm 嵌入式工具链.

Any c compiler can generate assembly code from C code, if your objective is specifically to generate assembly code for arm then you'll need a cross compiler such as the GNU arm embedded toolchain.

对于特定的 gcc,你只需要在编译时使用 -S 选项,所以该行看起来像:

For gcc on particular you just need to use the -S option when compiling, so the line looks something like:

gcc -S -source.c -o output.s

当然,您需要包含任何标头并包含要编译的目录.

Of course you'll need to include any headers and include directories for it to compile.

如果你只是想交叉编译它,那么只需进行完整的编译组装和链接过程.取决于 c 代码的级别有多低,它实际上可能无法在 pi 2 上运行(但它会编译)

if you simply want to cross compile it, then simply do the full compilation assemblage and linking process. Depending on how low level the c code is it's actually possible for it not to work on the pi 2 (but it will compile)

这篇关于将 C 源代码转换为 ARM 程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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