我是靠谱客的博主 结实路人,最近开发中收集的这篇文章主要介绍ARMv8的两种执行状态: AArch64/AArch32,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Copied from ARM® Compiler User Guide
When compiling code, you must first decide which target the executable is to run on. An ARMv8-A target can run in different states:
• AArch64 state targets execute A64 instructions using 64-bit wide general-purpose registers.
• AArch32 state targets execute A32 or T32 instructions using 32-bit wide general-purpose registers.
The –target option determines which target state to compile for. This option is a mandatory option.
To create an executable for an AArch64 target in a single step:
armclang –target=aarch64-arm-none-eabi hello.c
This command creates an executable, a.out.
The –target option selects the target that you want to compile for. This example compiles for an AArch64 state target. Because only –target is specified, the compiler defaults to generating code that runs on any ARMv8-A target. You can also use -mcpu to target a specific processor.
To create an executable for an AArch32 target in a single step:
armclang –target=arm-arm-none-eabi -mcpu=cortex-a53 hello.c
In this example, there is no default target for AArch32 state, so you must specify either -march to target an architecture or -mcpu to target a processor. This example uses -mcpu to target the Cortex®-A53 processor. The compiler generates code that is optimized specifically for the Cortex-A53, but might not run on other processors.
Use -mcpu=list or -march=list to see all available options.

• The –target option is an armclang option. For all of the other tools, such as armasm and armlink,
use the –cpu and –fpu options to specify target processors and architectures.

ARMv8-A有两种执行状态: AArch64和AArch32(后者是为了兼容以前的32bit的程序)。
AArch64执行A64指令,使用64bit的通用寄存器;
AArch32执行A32/T32指令,使用32bit的通用寄存器;
arm compiler使用 –target=aarch64-arm-none-eabi 来产生 AArch64的可执行程序。默认使用ARMv8-A target,也可使用 -mcpu 指定特定的ARMv8处理器。
使用 –target=arm-arm-none-eabi 来产生 AArch32的可执行程序。对AArch32而言,没有默认target(处理器),所以需要使用 -march 或者 -mcpu 来指定处理器:
–target=arm-arm-none-eabi -mcpu=cortex-a53

可使用 -mcpu=list 或者 -march=list 查看可选的架构和处理器选项。

–target是armclang用的参数,别的工具,例如armasm/armlink,使用 –cpu 和 -fpu 参数来指定处理器和架构。

最后

以上就是结实路人为你收集整理的ARMv8的两种执行状态: AArch64/AArch32的全部内容,希望文章能够帮你解决ARMv8的两种执行状态: AArch64/AArch32所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(43)

评论列表共有 0 条评论

立即
投稿
返回
顶部