Mac 上的 x86 程序集 [英] x86 Assembly on a Mac

查看:26
本文介绍了Mac 上的 x86 程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道在 Mac 上编写程序集的任何好工具(我正在寻找 IDE).Xcode 对我来说有点麻烦.

Does anyone know of any good tools (I'm looking for IDEs) to write assembly on the Mac. Xcode is a little cumbersome to me.

此外,在 Intel Mac 上,我可以使用通用的 x86 asm 吗?或者是否有修改后的指令集?任何有关后英特尔的信息.

Also, on the Intel Macs, can I use generic x86 asm? Or is there a modified instruction set? Any information about post Intel.

另外:我知道在 Windows 上,asm 可以在操作系统创建的模拟环境中运行,让代码认为它是在自己的专用机器上运行的.OS X 是否提供相同的功能?

Also: I know that on windows, asm can run in an emulated environment created by the OS to let the code think it's running on its own dedicated machine. Does OS X provide the same thing?

推荐答案

在安装了针对基于 Intel 的 Mac 的任何版本的 Xcode 后,您应该能够编写汇编代码.Xcode 是一套工具,其中只有一个是 IDE,因此如果您不想使用它,则不必使用它.(也就是说,如果您发现某些特定的东西很笨拙,请在 Apple 的错误报告者处提交错误报告 - 每个错误都归于工程.)此外,安装 Xcode 将同时安装 Netwide Assembler (NASM) 和 GNU Assembler (GAS);这将让您使用任何您最熟悉的汇编语法.

After installing any version of Xcode targeting Intel-based Macs, you should be able to write assembly code. Xcode is a suite of tools, only one of which is the IDE, so you don't have to use it if you don't want to. (That said, if there are specific things you find clunky, please file a bug at Apple's bug reporter - every bug goes to engineering.) Furthermore, installing Xcode will install both the Netwide Assembler (NASM) and the GNU Assembler (GAS); that will let you use whatever assembly syntax you're most comfortable with.

您还需要查看 编译与调试指南调试指南,因为它们记录了用于运行 Mac OS X 的各种体系结构的调用约定,以及二进制格式和加载程序的工作方式.特别是 IA-32 (x86-32) 调用约定可能与您习惯的略有不同.

You'll also want to take a look at the Compiler & Debugging Guides, because those document the calling conventions used for the various architectures that Mac OS X runs on, as well as how the binary format and the loader work. The IA-32 (x86-32) calling conventions in particular may be slightly different from what you're used to.

要记住的另一件事是,Mac OS X 上的系统调用接口与您在 DOS/Windows、Linux 或其他 BSD 风格上可能习惯的不同.系统调用在 Mac OS X 上不被视为稳定的 API;相反,你总是通过 libSystem.这将确保您编写的代码可从操作系统的一个版本移植到下一个版本.

Another thing to keep in mind is that the system call interface on Mac OS X is different from what you might be used to on DOS/Windows, Linux, or the other BSD flavors. System calls aren't considered a stable API on Mac OS X; instead, you always go through libSystem. That will ensure you're writing code that's portable from one release of the OS to the next.

最后,请记住,Mac OS X 运行在相当广泛的硬件上——从 32 位 Core Single 到高端四核 Xeon.通过在汇编中编码,您可能不会像您想象的那样优化;在一台机器上最佳的在另一台机器上可能是悲观的.Apple 定期测量其编译器并使用-Os"优化标志调整其输出以使其在整个生产线中都不错,并且您可以使用广泛的向量/矩阵处理库通过手动调整的 CPU 特定实现来获得高性能.

Finally, keep in mind that Mac OS X runs across a pretty wide array of hardware - everything from the 32-bit Core Single through the high-end quad-core Xeon. By coding in assembly you might not be optimizing as much as you think; what's optimal on one machine may be pessimal on another. Apple regularly measures its compilers and tunes their output with the "-Os" optimization flag to be decent across its line, and there are extensive vector/matrix-processing libraries that you can use to get high performance with hand-tuned CPU-specific implementations.

去参加集会很有趣.如今,为了速度而去组装并不适合胆小的人.

Going to assembly for fun is great. Going to assembly for speed is not for the faint of heart these days.

这篇关于Mac 上的 x86 程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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