简体   繁体   English

Dosbox 是模拟 32 位环境还是 16 位环境?

[英]Does Dosbox emulate a 32bit enviroment or a 16bit environment?

Wiki says it's an x86 emulator. Wiki 说它是一个 x86 模拟器。 So, if DosBox is indeed an emulator for 32 bit applications, inorder for it to support 16 bit apps it must have another emulator in it right?那么,如果 DosBox 确实是 32 位应用程序的模拟器,为了支持 16 位应用程序,它必须有另一个模拟器,对吗? for it to run in 16 bit mode?(isn't that how regular Operating Systems(not emulators) work?) So basically I had this argument with someone, he said that when turbo cpp compiles it generates 16 bit code, but when you run it on dosbox it behaves like a 32 bit application, is that true?让它在 16 位模式下运行?(这不是常规操作系统(不是模拟器)的工作方式吗?)所以基本上我和某人有过这个争论,他说当 turbo cpp 编译时它会生成 16 位代码,但是当你在 dosbox 上运行它就像一个 32 位应用程序,是真的吗? and how does the size of an int variable change?以及 int 变量的大小如何变化? is it fixed?是固定的吗? like 2 bytes for 16 bit and 4 bytes for 32bit?像 16 位的 2 个字节和 32 位的 4 个字节?

So, if DosBox is indeed an emulator for 32 bit applications因此,如果 DosBox 确实是 32 位应用程序的模拟器

That's quite imprecise.那是相当不精确的。 It's DOS emulator, and DOS (its interface part and services (implementation in dosbox is often on the host side, not running in the emulated HW at all)) are on the 16-bit real mode side.它是 DOS 模拟器,而 DOS(它的接口部分和服务(在 dosbox 中的实现通常在主机端,根本不在模拟硬件中运行))在 16 位实模式端。 But it emulates 80386 HW (actually it does emulate also some parts of 80486 and 80586, but the 80386 is as close to "complete" as it's practical).但它模拟 80386 硬件(实际上它也模拟了 80486 和 80586 的某些部分,但 80386 尽可能接近“完整”,因为它很实用)。 So any DOS application (starting in the real-mode) can switch the CPU into protected mode, and that's what many DOS application did, often using some kind of common extender like DOS4GW, etc... dosbox does emulate enough of the machine to make most of the classic SW work, but if you are mean, you can easily create DOS application which would work on real HW but fail in dosbox, due to some missing feature in emulation.所以任何 DOS 应用程序(以实模式启动)都可以将 CPU 切换到保护模式,这就是许多 DOS 应用程序所做的,通常使用某种常见的扩展器,如 DOS4GW 等...... dosbox 确实模拟了足够的机器以使大部分经典软件工作,但如果你是刻薄的,你可以轻松地创建 DOS 应用程序,该应用程序可以在真实硬件上运行但在 dosbox 中失败,因为在仿真中缺少一些功能。

So it emulates both real-mode and protected mode of 80386 (and by the way how you switch the 80386 between modes you may get less common configurations, sometimes called "unreal mode"/etc... and I can't tell from my head, if those are accurately emulated in dosbox, but I think most of it works "good enough" to run old DOS SW).所以它模拟了 80386 的实模式和保护模式(顺便说一下,你如何在模式之间切换 80386,你可能会得到不太常见的配置,有时被称为“非真实模式”/等......我无法从我的头,如果这些在 dosbox 中被准确地模拟,但我认为它的大部分工作“足够好”以运行旧的 DOS SW)。

So basically I had this argument with someone, he said that when turbo cpp compiles it generates 16 bit code, but when you run it on dosbox it behaves like a 32 bit application, is that true?所以基本上我和某人有过这个争论,他说当 turbo cpp 编译时它会生成 16 位代码,但是当你在 dosbox 上运行它时,它的行为就像一个 32 位应用程序,是真的吗?

No, the Borland's Turbo C did produce only 16bit real-mode machine code, and executables produced by it were running in real-mode (unless somebody went great lengths by implementing switch into protected mode and use that for parts of their app code, but such code would have to be compiled by different compiler, or written in assembly, as Turbo C didn't have native support for 32bit protected mode - at least not in the versions I am aware of).不,Borland 的 Turbo C 确实只生成 16 位实模式机器代码,并且由它生成的可执行文件在实模式下运行(除非有人通过实现切换到保护模式并将其用于部分应用程序代码而竭尽全力,但是此类代码必须由不同的编译器编译,或用汇编语言编写,因为 Turbo C 没有对 32 位保护模式的本机支持 - 至少在我知道的版本中没有)。

and how does the size of an int variable change?以及 int 变量的大小如何变化?

That's compile time thing and depends on the compiler.那是编译时的事情,取决于编译器。

Although, if you run by accident 16b real-mode machine code in 32b protected mode, the most trivial pieces of code like xor ax,ax will actually work in 32b mode as xor eax,eax , and vice versa ( xor eax,eax compiled for real mode, if accidentally run in protected mode, will end operating as xor ax,ax ).虽然,如果您在 32b 保护模式下意外运行 16b 实模式机器代码,那么像xor ax,ax这样最琐碎的代码片段实际上将在 32b 模式下作为xor eax,eax ,反之亦然( xor eax,eax编译对于实模式,如果意外地在保护模式下运行,将结束作为xor ax,ax )。 So in this regard the code may due to confusion do some 16b operations instead of 32b operation, but for any non-trivial code it will very likely in few instructions hit some more major difference, which will probably make it crash it lot more hilarious way.所以在这方面,代码可能会因为混淆而做一些 16b 操作而不是 32b 操作,但是对于任何非平凡的代码,它很可能在很少的指令中遇到一些更大的差异,这可能会使它以更有趣的方式崩溃.

The bonus about dosbox: the dosbox author did multiple times refuse to make the emulation more accurate, stating his goal was to make dosbox perfect for the SW from the era, ie his focus was to make sure the old SW works as indented, even going intentionally for small imperfections or gaps in the emulation.关于 dosbox 的好处:dosbox 作者多次拒绝让模拟更准确,并表示他的目标是让 dosbox 完美适用于那个时代的软件,即他的重点是确保旧软件能够像缩进一样工作,甚至可以故意针对仿真中的小缺陷或差距。 That's the reason why it is "easy" to create new DOS SW which will not work in dosbox correctly.这就是为什么创建新的 DOS SW 很“容易”的原因,该软件在 dosbox 中无法正常工作。 There are multiple forks of original dosbox projects, which care rather about HW emulation accuracy than about old SW being usable (sometimes improving the emulation accuracy may break old SW, if the emulation is still not fully perfect, but now it has different flaws...).原来的dosbox项目有多个fork,更关心硬件仿真的准确性,而不是旧软件的可用性(有时提高仿真精度可能会破坏旧软件,如果仿真还没有完全完善,但现在它有不同的缺陷.. .)

(from comments) So basically if I were to execute a 16 bit exe file in DosBox, it would run as though it were on a 16 bit environment and a 32 bit exe as though it were on a 32 bit environment right? (来自评论)所以基本上,如果我要在 DosBox 中执行一个 16 位 exe 文件,它会像在 16 位环境中一样运行,而在 32 位 exe 中就像在 32 位环境中一样运行,对吗?

There is no such thing as 32 bit DOS exe.没有 32 位 DOS exe 这样的东西。 Games like for example DOOM did indeed run in 32b mode, but the exe starts in 16bit mode, and then it does handle the switch itself (for example DOOM did use the DOS4GW extender, as many other games of that era, which usually signaled that the main code of app was written in C, and compiled with Watcom compiler).像 DOOM 这样的游戏确实在 32b 模式下运行,但 exe 以 16 位模式启动,然后它自己处理开关(例如 DOOM 确实使用了 DOS4GW 扩展器,就像那个时代的许多其他游戏一样,这通常表明app 的主要代码是用 C 编写的,并用 Watcom 编译器编译)。 I can understand why somebody would call such executables "32 bit", if you know they are switching to protected mode and using it, but technically the first instructions of the executable are starting in 16 bit real mode, as every DOS executable.我可以理解为什么有人会称此类可执行文件为“32 位”,如果您知道他们正在切换到保护模式并使用它,但从技术上讲,可执行文件的第一条指令以 16 位实模式开始,就像每个 DOS 可执行文件一样。

Dosbox emulates a 32-bit x86 CPU. Dosbox 模拟 32 位 x86 CPU。 That CPU, both the real kind and the emulated one, is capable of running 16-bit code, for backward compatibility with earlier 16-bit CPUs in the same family.该 CPU,无论是真实的还是模拟的,都能够运行 16 位代码,以便向后兼容同一系列中较早的 16 位 CPU。 Running a 16-bit game in Dosbox is essentially the same as running it on a real 80386 PC (which is also a 32-bit machine).在 Dosbox 中运行 16 位游戏与在真正的 80386 PC(也是 32 位机器)上运行它本质上是一样的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM