.com 可执行文件可以在 Windows 之外的其他操作系统上运行吗?

发布于 2024-11-08 14:30:57 字数 126 浏览 5 评论 0原文

据我所知,可执行文件的扩展名 .com .exe 等适用于操作系统。它与底层 ISA(无论是 x86 还是 SPARC)无关。我说得对吗? .com 可执行文件只能在 Windows 操作系统上运行吗? .com 可执行文件是遗留文件吗?

I understand that the extension of the executables .com .exe etc is meant for the operating system. It has got nothing to do with the underlying ISA (be it x86 or SPARC). Am I correct?
does .com executable run only on windows OS ?
Are .com executables legacy?

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

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

发布评论

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

评论(3

孤千羽 2024-11-15 14:30:57

.com、.exe 扩展名告诉 DOS 或 Windows 操作系统该文件是可执行文件。文件扩展名(.com、.exe)本身并不能告诉操作系统底层指令集是什么。对于具有 .exe 扩展名的 Windows 可执行文件,指令集在文件的前几个字节(PE 标头)中指定。

最初,DOS .com 文件仅包含一组指令,操作系统(即 DOS)将在固定地址加载这些指令并从第一条指令开始执行。这些类型的 .com 文件是“遗留”文件。如果没有模拟,它们就无法在现代操作系统上运行。这种类型的 .com 文件可以在 CP/M 和更高版本(更常见)的 DOS 上找到,但只能在它们最初设计的操作系统和指令体系结构上运行。您可以通过模拟在其他操作系统上运行它们。例如,dosbox 在Linux 上运行DOS .com 文件。更高版本的 DOS 和 Windows 会查看 .com 文件,看看它们是否真的是 LE/PE 可执行文件。如果是,则执行它们就像它们具有 .exe 扩展名一样。 Visual Studio 附带了一些带有 .com 扩展名的文件。请参阅 https://devblogs.microsoft.com/oldnewthing/20080324-00/ ?p=23033 了解更多信息。

The .com, .exe extension tells the DOS or Windows operating systems that the file is an executable. The file extension (.com, .exe) alone doesn't tell the operating system what the underlying instruction set is. For Windows executables with a .exe extension the instruction set is specified in the first few bytes of the file (the PE header).

Originally DOS .com files simply contained a set of instructions that the operating system (i.e. DOS) would load at a fixed address and execute from the first instruction. These type of .com files are 'legacy'. They cannot be run on modern operating systems without emulation. This type of .com files can be found on CP/M and later (and more commonly) DOS but only run on the operating system and instruction architecture they were originally designed for. You can run them on other operating systems through emulation. e.g. dosbox runs DOS .com files on Linux. Later versions of DOS and then Windows look inside .com files to see if they are really LE/PE executables. If they are it executes them as if they had a .exe extension instead. Visual Studio ships some files with the .com extension. See https://devblogs.microsoft.com/oldnewthing/20080324-00/?p=23033 for more on this.

陌路黄昏 2024-11-15 14:30:57

从技术上讲,可执行文件只是一个二进制文件。只有在 Windows 操作系统上才需要可执行文件的文件扩展名。否则你是对的。我不确定旧版 com 究竟如何,它可能已被正式弃用,但仍然在现代版本的 Windows 上运行。

Technically, an executable is simply a binary file. It's only on the windows os that you need a file extension for executables. Otherwise you are correct. I'm not sure exactly how legacy com is, it may be officially deprecated, but have bits still running around modern versions of windows.

如若梦似彩虹 2024-11-15 14:30:57

.com 和 .exe 通常是 x86 代码。尽管维基百科文章 http://en.wikipedia.org/wiki/COM_file 提到了 .com扩展出现在较旧的 cp/m 中。

它们并不是“故意移植的”,尽管现在 DOS 和 Windows 模拟器存在于可以运行它们的其他平台上。

像 .py (python) 和 .jar (编译的 java) 这样的文件类型被设计为可以在任何 CPU 和任何操作系统上运行,只要它们安装了它们的“平台”(分别是 Python 或 JRE)。

.com and .exe's are usually x86 code. Though the wikipedia article http://en.wikipedia.org/wiki/COM_file mentions the .com extension came up in cp/m which is older.

They are NOT "intentionally portable", though nowadays DOS and Windows emulators exist on other platforms that could run these.

Filetypes like .py (python) and .jar (compiled java) are designed to be run on any CPU and any OS, as long as they have their "platform" installed (Python or JRE, respectively).

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