typically, emulators use their own BIOS and simulate all the HW as well,
so this is nothing new.
> And in case it wasn't obvious, a 64-bit host is not a panacea for
> speedy software emulation by any stretch. Painful and buggy (though
> unavoidable with all the dark corners, I guess, esp. unpopular 16-bit
> pmode).
>
yes, but it can be done.
one option for emulating 16-bit pmode (besides running it directly, or
using a pure software emulator) would be essentially compiling
instruction traces into the native ISA (x86 or x86-64).
>> thus real-mode will run slower in this case.
>
> It was really slow 16-bit real mode stuff last I tried (DOSEMU x64).
> But at least DJGPP was native speed. Too bad Win64 can't do it as
> well.
>
DOSBox isn't native speed, but seems to be not that drastically worse.
the main big issue is likely how the emulator is implemented, like
whether it is closer to being a plain interpreter, or closer to being a JIT.
>>> Win64 has no NTVDM nor DOSX (the pmode part). Win16 binaries, e.g. Win
>>> 3.0, were almost all pmode, and I think the Win16 API internally used
>>> DPMI 16-bit, hence if there is no DOS, there's no DPMI, and thus no
>>> Win16. I could be wrong, but that's my impression. It doesn't mean MS
>>> doesn't (and hasn't) used software emulation before, but I guess it
>>> wasn't a big priority considered how few rely on it these days. (And
>>> they do obviously want us to migrate to newer technologies.) I don't
>>> know, NTVDM is ancient to them and barely works since after WinXP.
>>
>> actually, both Win3.x and Win9x were built on DOS.
>
> Yes, but they did other (weirder) things too. ;-)
>
possibly.
>> this shouldn't matter though for running apps, since the apps did not
>> themselves generally access DOS (and most of what could be accessed via
>> 16-bit pmode is things which could be faked, such as "int 0x21" calls or
>> similar).
>
> Dunno, I'm not versed in all the gory details of 32-bit pmode.
>
well, 16-bit and 32-bit pmode are a bit different.
typically on Windows, the only "valid" way to access the OS is via API
calls (into OS DLLs). this is not the only way possible though.
IIRC, on Win9x it was still possible to use DOS interrupts (in pmode),
which would trap into DOS (in v86 mode). however, such code will (AFAIK)
no longer work on XP or newer (and did not work on WinNT).
note that in neither case is there any direct access to raw HW, rather
the application runs in a virtual address space (IIRC, there were some
differences between the Win9x and WinNT lines here, where on Win9x it
was possible to see a lot of memory shared across process/task
boundaries, including the low 1MB/DOS space, whereas the NT line ran
every process in its own fully-disjoint address space).
so, Win9x:
low 4MB: shared (read/write in Ring3), identity mapped to low 4MB of
system RAM (low 1MB was DOS space);
4MB-2GB: local space for each process;
2GB-3GB: shared memory (R/W to Ring3);
3GB-4GB: kernel memory (not accessible to Ring3).
and, WinNT/XP:
0MB-4MB: stack for main thread (low 64KB is an inaccessible NULL page);
4MB-2/3GB: local space for each process;
2GB/3GB-4GB: kernel memory.
it is possible to explicitly create shared memory in NT/XP+, but it has
no fixed location in the memory map;
for the most part, the basic idea is that one has a 2GB (9x/NT) or 3GB
(XP+) chunk of usable address space, which was unique to the process,
the only things directly existing within this space being the contents
mapped in from EXEs or DLLs, and things like allocated heap memory.
in the case of 32-bit Windows, system calls would generally be made
directly via "int 0x2e" instructions to call into the kernel.
in 64-bit Windows, the process differs some:
32-bit code will go through a thunk/trampoline, which will execute a far
jump to get into 64-bit mode, which will then call into the kernel via a
"syscall" instruction (and then use a far jump back into 32-bit code).
>> unless it were something more like MS was just using a hacked up Windows
>> 3.x, DOS crud and all, as their backwards-compatibility mechanism in
>> later Windows versions (rather than, say, giving DLLs which give the
>> same interface and behavior as the originals, but infact redirect to
>> 32-bit calls or similar).
>
> Yes, I think their NTVDM was indeed a lot of hacked pieces from older
> software. It wasn't 100% homebrewed, so perhaps they didn't know how
> to fix it.
>
dunno.
I guess if they really wanted, they could have re-implemented it.
>> otherwise, I would have just assumed moving both DOS and Win16 into an
>> emulator, just one considerably lighter weight and better integrated
>> than their XPMode beast (personally, XPMode itself is a big sign that
>> "MS just didn't really give a crap"),
>
> Yes, I feel that XP Mode was a marketing gimmick to drive sales. It
> really shouldn't be necessary. Anything (esp. Win32 apps!!) that
> doesn't run any longer on modern Windows proves that something is
> broken, and regressions for MS are very bad for business.
>
nevermind that XPMode kind of sucks...
>> since what they could have done
>> would be to make an emulator which maps the emulated windows more
>> directly into the host OS window manager (and not via an overlay), and
>> silently traps all "compatibility" apps into said emulator (which would
>> likely share the same file-systems as the host OS, maybe with or without
>> its own local OS drive, say if the VM-OS booted from 'Q' or similar, ...).
>>
>> it wouldn't likely be beyond MS's powers to have done so.
>
> Dunno. They do have 90000 employees, but they seem to be focused on a
> billion other goofy things.
>
> Anyways, we do have DOSBox, which (mostly) fulfills the need (except
> for compiling stuff).
>
possibly, but people like old stuff to keep working without issue.
breaking 16-bit apps forced me into going and finding more modern
alternatives for some apps (some of which aren't as good).
>>> VT-X first appeared circa 2006, right? AMD (supposedly) had "paged
>>> real mode" support since then, and some things (Xen, VirtualBox) may?
>>> support it. I don't have a working AMD machine anymore, so I haven't
>>> tried. I do know that my Intel Core i5 has VT-X (though unlike lower-
>>> end models, etc.), and it adds nested paging and other things like
>>> "unrestricted guest mode execution" (real mode, big real mode). So
>>> yes, I can run FreeDOS at seemingly native speeds under Win64 with
>>> VirtualBox. Without VT-X, it's much much slower (10x or worse)!!
>>
>> I have not personally messed with VT-X, as I was well out of the OS
>> space by then.
>
> I don't mean I've coded any hypervisors either, I'm just saying that
> VT-X is something fairly new that may or may not be a successor to the
> whole V86 mode idea.
>
possibly.
if observations are to be believed, hypervisors have their own costs.
although the code itself runs fast, a drawback appears to be that HW
still needs to be emulated in software, and switches in-to/out-of the
hypervisor appear to be fairly costly (and on-average, everything still
runs considerably slower than on raw HW).
this and other costs make me doubt whether they are ideal for
lightweight emulators, and whether a strategy such as trace-translation
would give considerably better overall performance for a lightweight VM,
since in many cases the emulated code will not be CPU-bound (and even
then, trace-translation should probably be able to get within 3x-5x of
native anyways).
>> performance will depend greatly on the emulator.
>> some, such as DOSBox, essentially JIT the emulated code into code
>> running on the current HW.
>
> I have no idea what DOSBox does, but it's very slow. Perhaps you mean
> "core=auto"? That doesn't always work. It's only "fast 486" speeds, at
> best. It's a great piece of software, but you can't rely on it for
> anything time intensive.
>
I was running Quake on it at fairly high resolutions (1280x1024 and
similar) and getting considerably better performance than in XPMode.
so, this is a good deal faster than any 486 I know of...
so, at least my experience with DOSBox has been fairly good here.
now, vs native, I have little idea...
>> oddly, I observed Quake running notably faster in DOSBox than I got it
>> running in VirtualPC, which is funny since VirtualPC uses virtualization.
>
> Yeah, I dunno, perhaps they heavily tuned it for Quake, Doom, etc.
> That would make sense as they always say "only for games!". It's
> really NOT faster for anything else, so maybe their VBIOS is heavily
> optimized, who knows. (And their DOS is fake, BTW, it's not real like
> FreeDOS, similarly the BIOS, etc.)
>
well, for Quake it worked pretty well...
meanwhile, Quake on XPMode was kind of laggy, as was XPMode in general.
I wasn't very impressed with what is supposed to be native-speed
execution lagging with an old game. granted, it could maybe be due to
scheduling, like native Windows limits the VirtualPC time-slice, and
then the contained WinXP limits Quake's time-slice.
VMware seems to work considerably better though.
running WinXP or Linux in VMware seems to be fairly responsive, so I
don't really know.
>> it could be either the cost of the virtualization itself, or maybe the
>> cost of running a virtualized Windows environment and then running Quake
>> in it.
>
> Dunno. Maybe SDL achieves most of that speedup. I think?? I heard that
> SDL has some partial multi-threading nowadays, maybe for audio, can't
> remember. Or maybe it uses a different speedier gfx backend nowadays
> (DirectX?), dunno.
>
I think it is still SDL.
graphics shouldn't matter so much, since in this case they are mostly
just drawing into a virtual framebuffer and then displaying the contents
of said framebuffer using GL. this isn't really a task which itself
demands high-performance.
although, DOSBox does have options to throttle back the simulated
clock-rate such that some very old DOS games don't break due to running
too fast, which could be making an issue here.
> I was running Doom 1.9 shareware under various environments yesterday.
> Indeed, it's "mostly" native speed under VBox + VT-X, but it still had
> minor issues (and wasn't fastest, ironically). I'm not sure, a naive
> guess makes me think polling to emulate SB ports for sound was slowing
> it down, but I could be wrong. (Anyways, VBox devs really don't test
> 16-bit nor DOS that much, they focus much more heavily on other OSes.)
>
yeah.
>> I since switched mostly to VMware (for Windows and Linux emulation),
>> given that, IMHO, it actually does a somewhat better job (higher
>> performance and more reliable).
>
> Dunno, I've never tried it, but I've heard good things. It may be
> better, and some people I see online swear by it.
>
well, WinXP seems less laggy in VMware, and I can install whatever OS's
in it without them breaking (VirtualPC was prone to instead cause OS
installers to break).
not compared with VirtualBox though...
>>> Supposedly with VT-X you can even run a 64-bit guest OS atop a 32-bit
>>> one, but I've not tried (should I ??).
>>
>> dunno.
>>
>> very likely, it will be limited to however much RAM can be used by the
>> host OS, which means that on a 32-bit system using much more than 256MB
>> or 512MB ram is not a good idea (otherwise severe swapping is likely).
>
> True, but I'm just curious. At least, I know QEMU used (?) to have a
> software-only 64-bit emulation version, but here I mostly meant "as if
> native" speed. So it would be cool to know for sure I can run a 64-bit
> OS atop a 32-bit one. Heck, who knows, perhaps one day a 64-bit DOS
> (extender) will piggyback atop VT-X (but I'm not getting my hopes up).
>
QEMU seems able to emulate all sorts of stuff, and I was using it to
emulate Linux/ARM on x86 a while back.
its downside though is that it is not exactly high-performance IME (or,
at least, the QEMU versions for Windows).
>> I actually have a computer at the moment, which has 6GB of RAM but can
>> only use 3GB due to using 32-bit WinXP, but I can't install anything
>> else without another HDD, but I don't have one with me at the moment.
>>
>> grr...
>
> Sorry. MS refuses to support PAE APIs there, so you're limited to
> about 3.1 GB, from what I've heard. It should be enough (and besides,
> XP inherently uses lots less RAM than Vista or 7). Vista on up let you
> resize the NTFS, but for XP you might have to use GParted. Probably
> safe, but caveat emptor.
>
I was previously running XP64 on the thing, but XP64 was on a secondary
drive which I ended up taking out. I would need to install a secondary
HDD in order to have a drive on which to install XP64 again (there are
no suitable partitions remaining on this drive, and at the moment I am
not so much inclined to install over the currently-still-working WinXP
install).
it is mostly a matter of needing another SATA HDD, but all I have
on-hand are older IDE drives.
>>> Anyways, VMs are only for convenience, more or less, since you can
>>> (for now) always dual boot multiple OSes (since no emulation is
>>> perfect, but native booting has its own bugs and drawbacks). At least
>>> that will continue to work until UEFI becomes ubiquitous or somebody
>>> decides to save a few transistors by killing off legacy mode (ugh).
>>
>> yep.
>
> If software emulation was 100% accurate and "fast enough", then who
> could complain? But it never is, sadly. It feels like we're on a
> constant upgrade treadmill. It really shouldn't be this hard to have
> working software running stable across so many years (sigh).
>
> Meh, I need to try BOCHS again, Darek M. claims to have done a lot of
> good stuff over the past few years. ;-)
"fast enough" should work for most older software...
even if it runs 100x slower than native, it is probably still running
faster than on the hardware it was originally designed for.
most 16-bit software was written for 386 and 486 systems, so even if the
emulator is slow, who really needs to care all that much?...
it is partly for these reasons I had considered the idea of trying to
port Quake to the BGBScript VM: yes, the VM isn't very fast, but would
still likely be able to run Quake faster than on the original HW.
the much bigger issue though is the part about having to write all of
the stuff to compile the C front-end's ASTs to the VM's bytecode, which
looks like a big PITA and I haven't invested much effort into this.
the other major option being a language-port (rewriting Quake from C to
BGBScript), but this also looks like a big PITA (but, is not impossible,
as the Quake codebase isn't terribly large either). a drawback though is
even if I did the port this way, Quake would still be GPL'ed, so I can't
really make much practical use of its code in an otherwise non-GPL project.
or such...