统一汇编语言

发布于 2024-11-02 02:22:15 字数 302 浏览 1 评论 0原文

我想知道是否存在某种通用且易于编码的操作码(或汇编)语言,它提供了当今大多数 CPU 中可用的基本指令集(不是一些奇特的 CISC、仅寄存器计算机,只是常见的)。是否可以在任何提到的 CPU 上“编译”、微优化和“解释”?

我正在考虑像 MARS MIPS 模拟器(相当简单且易于阅读的代码)之类的东西,可以制作真正的程序。不需要库(但如果可能的话,这很好),只是为了以统一的方式使事情(库或类似 UNIX 的工具)更快。

抱歉,如果这是个愚蠢的问题,我是汇编程序新手。我只是觉得 NASM 或 UNIX 汇编语言既不具有极强的跨平台性,也不易于阅读和编码。

I wonder if there exists some kind of universal and easy-to-code opcode (or assembly) language which provides basic set of instructions available in most of today's CPUs (not some fancy CISC, register-only computer, just common one). With possibility to "compile", micro-optimize and "interpret" on any mentioned CPUs?

I'm thinking about something like MARS MIPS simulator (rather simple and easy to read code), with possibility to make real programs. No libraries necessary (but nice thing if that possible), just to make things (libraries or UNIX-like tools) faster in uniform way.

Sorry if that's silly question, I'm new to assembler. I just don't find NASM or UNIX assembly language neither extremely cross-platform nor easy to read and code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

一个人练习一个人 2024-11-09 02:22:15

JVM 字节码有点像汇编语言,但没有指针运算。然而,它是非常面向对象的。从积极的一面来看,它是完全跨平台的。

您可能想查看 LLVM 字节码 - 但请记住以下警告:http://llvm.org/docs/FAQ.html#can-i-compile-c-or-c-code-to-platform-independent-llvm -位码

The JVM bytecode is sort of like assembly language, but without pointer arithmetic. However, it's quite object-oriented. On the positive side, it's totally cross-platform.

You might want to look at LLVM bytecode - but bear in mind this warning: http://llvm.org/docs/FAQ.html#can-i-compile-c-or-c-code-to-platform-independent-llvm-bitcode

甜妞爱困 2024-11-09 02:22:15

首先:用汇编语言编写并不能保证速度的提高。对手头的工作使用正确的算法对速度影响最大。当您需要进行组装以挤出最后几个残差时,您只能通过使算法适应相关硬件的特定架构来真正做到这一点。通用的 HLA(高级汇编器)几乎违背了用汇编语言编写代码的目的。请注意,我并不是敲兰德尔·海德的 HLA,这是一个很棒的产品,我只是说以编译器生成机器代码的方式编写汇编并不会获得任何好处。大多数 C 和 C++ 编译器都有非常好的优化器,并且可以生成优于 ASM 中几乎任何简单实现的机器代码。

看看你是否能找到 Michael Abrash 写的这些书(第二手,它们已经绝版):“Zen of Assembly Language”和“Zen of Code Optimization”。或者看看在 DDJ 上是否可以找到他的文章。他们将为您提供首屈一指的优化见解,

First thing: writing in Assembly does not guarantee a speed increase. Using the correct algorithm for the job at hand has the greatest impact on speed. By the time you need to go down to Assembly to squeeze the last few drops out you can only really do that by adapting the algorithm to the specific architecture of the hardware in question. A generic HLA (High Level Assembler) pretty much defeats the purpose of writing your code in Assembly. Note that I am not knocking Randall Hyde’s HLA, which is a great product, I’m just saying that you don’t gain anything from writing Assembly the way a compiler generates machine code. Most C and C++ compilers have very good optimizers, and can produce machine code superior to almost any naïve implementation in ASM.

See if you can find these books (2nd hand, they are out of print) by Michael Abrash: "Zen of Assembly Language", and "Zen of Code Optimization". Or look if you can find his articles on DDJ. They will give you an insight into optimization second to none,

故事灯 2024-11-09 02:22:15

相关的东西,所以我希望可能有用:

具有一种便携式汇编器的方法。

有趣的操作系统项目,具有用汇编程序编写的图形用户界面和出色的汇编 API:

Related stuff, so I hope might be useful :

There is

with an approach of a kind of portable assembler.

Interesting project of operating system with graphical user interface written in assembler, and great assembly API :

睡美人的小仙女 2024-11-09 02:22:15

LLVM IR 提供了相当可移植的程序集,并以强大的 编译器,支持包括 Clang 在内的许多项目

LLVM IR provides quite portable assembly, backed with powerful compiler, backing many projects including Clang

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文