操作系统是一个抽象吗?

发布于 2024-10-16 19:02:02 字数 157 浏览 3 评论 0原文

在DOS环境或Windows环境下汇编、链接和加载汇编语言代码或C代码有什么关系?结果不应该是一样的吗?毕竟执行是由微处理器而不是操作系统完成的。我正在从 MS-DOS 时代的一本旧书中学习汇编语言。这是一个挫折吗?汇编语言及其代码执行不是与操作系统无关的吗?或者就此而言,任何用其他语言编写的代码?

How does it matter if you assemble, link and load an assembly language code or C code in DOS environment or Windows environment? shouldn't result be the same? after all execution is done by microprocessor, not operating system. I am learning assembly language from an old book of MS-DOS era. Is it a setback? isn't assembly language and its code execution, O/S independent? or for that matter any code written in other languages?

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

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

发布评论

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

评论(2

万人眼中万个我 2024-10-23 19:02:02

汇编语言及其代码执行不是独立于操作系统的吗?或者就此而言,任何用其他语言编写的代码?

是和不是。

是的。机器的语言独立于操作系统。无论您自己编写还是 C 编译器为您编写,都没有关系。

不可以。您必须使用操作系统才能实际运行该软件。如果您希望它做一些有用的事情,您需要调用操作系统 API。这完全取决于操作系统。

isn't assembly language and its code execution, O/S independent? or for that matter any code written in other languages?

Yes and no.

Yes. The machine's language is independent of OS. Doesn't matter if you wrote it yourself or the C compiler wrote it for you.

No. You have to use an OS to actually run the software. If you want it to do something useful, you'll need to call OS API's. That is entirely OS dependent.

旧时模样 2024-10-23 19:02:02

是的,操作系统“标准化”了我们的程序和处理器之间的通信,以便 printf() 在 Linux 和 Windows(以及其他)、这些操作系统的许多不同版本以及不同的硬件配置上都能按预期运行。 br>
而且,理论上,可以在具有不同操作系统的同一处理器上运行相同的程序,因为操作码显然是相同的,但由于金钱问题,这种情况不会发生(猜猜会发生什么如果有一天 Linux 可以运行 Windows 的应用程序......)。
因此,尽管运行或不运行二进制文件的可能性仅取决于处理器,但它也取决于操作系统。

Yes, the operating system "standardizes" the communications between our programs and the processor, so that printf() will behave as expected on both linux and windows (and others), on many different versions of those OS and on different hardware configuration.
And, theoretically, is possible to run the same program on the same processor with differents OSs, since opcodes are obviously the same, but this doesn't happen due to a matter of money (guess what would happen if one day linux could run windows's applications..).
So, although the possibility to run or not a binary should depend only to the processors, it depends on OSs too.

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