在 iphone 上编写 ARM 汇编代码的工作流程 [英] Workflow for writing ARM assembly code on the iphone

查看:24
本文介绍了在 iphone 上编写 ARM 汇编代码的工作流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开始编写 ARM 汇编程序并在 iPhone 上运行它.

I would like to begin writing ARM assembler and running it on the iPhone.

这不是为了在应用程序中使用以发布到应用程序商店 - 基本上我想解决 ProjectEuler 上的问题 使用 ARM 和 iPhone,仅用于业余爱好和教育目的.

This is not with the intent of using in an app to be released to the app store - Basically I would like to solve problems on ProjectEuler using ARM and the iPhone, just for hobby and educational purposes.

我该怎么做?我一直无法想出一种方法来使用任何手写的手臂来运行项目.

How can I go about doing this? I have not been able to come up with a way get a project running using any hand written arm.

推荐答案

我找不到任何关于如何专门为 iPhone 编写汇编代码的信息,但就像这里其他人所说的那样,您可以:

I haven't been able to find any information about how to write assembly code specifically for the iPhone, but like the other people said here, you can either:

1) 在 C/C++/ObjC 代码中编写内联 asm 语句,或2) 在.s"文件中编写独立的程序集函数,然后简单地将其添加到您的 XCode 源中,或3) 为外部汇编器(如 NASM)编写独立的汇编函数.您在.s"文件中编写汇编代码并使用 NASM 生成.o"目标文件,并将目标文件与 XCode 中的项目链接.

1) write inline asm statements in C/C++/ObjC code, or 2) write standalone assembly functions in a '.s' file and simply add it in your XCode sources, or 3) write standalone assembly functions for an external assembler such as NASM. You write assembly code in a '.s' file and generate a '.o' object file using NASM and link the object file with your project in XCode.

因此,如果您只是尝试编写一些汇编指令,那么内联汇编程序将是最简单的方法,但是如果您打算编写多个汇编函数,那么我建议您使用独立的汇编文件.如果你打算用宏编写许多汇编函数并想要跨平台兼容性等,那么我建议使用 NASM 将你的汇编代码编译成目标文件.因为我使用的是 XCode gcc 汇编器,与 NASM 相比它非常缺乏.您可以在 http://www.nasm.us/

So if you are just trying to write a few assembly instructions then inline assembler would be the easiest way, but if you plan on writing several assembly functions then I'd recommend a standalone assembly file. And if you plan on writing many assembly functions with macros and want cross-platform compatibility, etc, then I'd recommend using NASM to compile your assembly code into an object file. Because I am using the XCode gcc assembler and it is quite lacking compared to NASM. You can get NASM for free at http://www.nasm.us/

设置好汇编环境后,您需要学习如何编写 ARM 汇编代码!因为 iPhone(以及许多其他便携式设备和智能手机)使用 ARM 指令集.在 http://www.coranac.com 上有一个很好但很老的 ARM 程序集介绍/tonc/text/asm.htm.

Once you have setup your assembler environment, you need to learn how to write ARM Assembly code! Because the iPhone (and many other portable devices and smartphones) use the ARM instruction set. There is a very good but old intro to ARM assembly at http://www.coranac.com/tonc/text/asm.htm.

说到汇编编程,官方指令集参考手册通常是您编写的所有内容的主要信息来源,因此您应该到 ARM 网站下载ARM 和 Thumb-2 快速参考卡(6 页长)如以及适用于您的确切 CPU 的 2 个完整文档.

When it comes to assembly programming, the official instruction set reference manual is usually the main source of information for everything you will write, so you should go to the ARM website and download the ARM and Thumb-2 Quick Reference Card (6 pages long) as well as the 2 full documents for your exact CPU.

例如,iPhone 3GS 和 iPhone 4 都具有 ARMv7-A Cortex-A8 CPU,因此您可以下载 ARM 体系结构参考手册 ARMv7-A 和 ARMv7-R 版(2000 页),它准确地告诉您哪些指令可用以及它们究竟是如何工作的,以及 Cortex™-A8 技术参考手册,解释了特定 CPU 的指令时序等.

For example, the iPhone 3GS and iPhone 4 both have an ARMv7-A Cortex-A8 CPU, so you can download the ARM Architecture Reference Manual ARMv7-A and ARMv7-R Edition (2000 pages long) that tells you exactly which instructions are available and exactly how they work, and the Cortex™-A8 Technical Reference Manual that explains the instruction timing, etc for your specific CPU.

这篇关于在 iphone 上编写 ARM 汇编代码的工作流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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