本文介绍了汇编语言有多不可移植,/真的/?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在汇编中编写任何内容或将汇编添加到任何程序都会损害其可移植性.但是,有多糟糕?我的意思是,现在基本上所有的 PC 都是 x86 或 x64,对吧?那么,如果我将汇编嵌入到一个 C 程序中,为什么它不管走到哪里都不能编译?

I understand that writing anything in assembly, or adding assembly to any program harms its portability. But, how bad? I mean, basically all PC's are x86 or x64 these days, right? So, if I embed assembly into a C program, why wouldn't it still compile no matter where it went?

这种不可移植性的概念是否只是指当您真的深入研究特定处理器的特定怪癖,以从一段代码中榨取每一滴性能?

Does this notion of un-portability just refer to when you really dig in to the specific quirks of a specific processor, to squeeze out every drop of performance from a piece of code?

如果我没记错的话,PC 游戏Roller Coaster Tycoon"几乎完全是用汇编语言编写的.那么......它真的有多不可移植?

The PC game "Roller Coaster Tycoon" was written almost entirely in assembly language if I remember correctly. So... How un-portably could it really be?

推荐答案

除了处理器本身之外,当然还有其他考虑因素:您的目标平台上的调用约定是什么?struct 值如何传递给其他(比如:API)函数?哪些寄存器可能会被被调用者破坏?哪些可以保证为调用者保留?如何进行系统调用?进程启动时操作系统为您准备的内存布局是什么?

Besides the processor itself, there are, of course, always other considerations: what are the calling conventions on your target platform? How are struct values passed to other (say: API) functions? Which registers may be clobbered by the callee? Which are guaranteed to be preserved for the caller? How to do a system call? What's the memory layout prepared for you by the OS upon process start?

这篇关于汇编语言有多不可移植,/真的/?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 08:42