On Saturday, 21 October 2023 17:38:29 CDT Fabian Maurer wrote:
Hello Zeb,
I'd love to see Win16 tests in upstream Wine, so thanks for working on this! This would make picking changes from winevdm (the fork) into Wine a lot easier I think.
OpenWatcom is sometimes mentioned, but that only has win32 builds (as far as I'm aware), which makes it hard if not impossible to integrate into Wine.
You can compile OpenWatcom on Linux, or did I misunderstand that? I always thought the problem with OpenWatcom was that it's not as easily available as gcc and to avoid the dependency.
Ah, perhaps. Either way I had understood that it was a blocker to adding real tests.
The compiler is called Rosé, and it lives here:
https://gitlab.winehq.org/zfigura/rose
It is not fully featured; it's still missing a few notable pieces (in particular: unions, multiple code segments) but it is reasonably complete, and I was able to use it to compile a modified version of winetest.exe, and produce working executables for Windows 98.
Could you provide a minimal example of a working program that uses MessageBoxA or printf?
I had to fix a regression, and actually add MessageBox() to the headers, but yes. I've attached a test.c (though it really is very simple).
Compiling is a bit tricky, because rose doesn't automatically call a preprocessor (I *think* this is legal by the GPL, but it also would take extra effort to implement) nor automatically find its CRT and libraries. Here is the command I use:
cpp test.c -o test.i -I../rose/include -D_WIN16 -U__GNUC__ && ./rosecc test.i crt/start.i crt/stdlib.i crt/string.i -l../rose/lib/kernel.def -l../rose/lib/user.def -o test.exe
- NE executables, unlike both their predecessor (MZ) and successor (PE),
cannot output to a controlling console, and in general have no concept of a stdin/stdout/stderr. This does not fit well with wine tests, which are built to run with a console. There is also not much in the way of IPC available to a win16 process. They can, on the other hand, open a file and output to it.
Maybe a stupid question, but won't dos console interrupts works for console?
Certainly not a stupid question :-)
In fact I tried this for some time. It turns out that the answer is no. You can make the exact same interrupts as work in a DOS program, using the predefined standard handle values, but they just don't work. They return success, but write to a hole in the ground.
I eventually had to go back and find manuals that say that Windows programs "should not" use standard I/O.
- In order to properly test Win16 we need a contemporaneous test VM, I think
ideally 98. A modern 32-bit Windows machine (of which I think we still have some) will *run* 16-bit code, and may be usable to test *some* functionality, but I do not think the results can be trusted.
Hm, I always thought XP would be a good win16 test-target. But then again, there is no XP VM either.
It's probably better than Windows 10, but still not ideal. As far as I'm aware there are applications out there that just stopped working with NT, although this is a vague idea of mine.
[2] The idea of introducing compiler support into GCC has obvious advantages: not just the reuse of frontend and optimization code, but the dialect is something that will already be perfectly familiar to a Wine developer. However, it also has disadvantages: it would take a lot of time to become familiar with gcc, and I expect that segmented address spaces will be very hard to fit into the GCC code and probably not accepted upstream.
Since gcc is capable of generating "fake" 16bit code using -m16, is this something that could be reused? Although I don't think one could get segmentation to work without way too much effort.
I don't know if -m16 is hooked up to the compiler or just the assembler, but the short answer is no. It does not handle segmented address spaces, the only difference is it generates code that can execute in a 16-bit segment as opposed to a 32-bit one, by toggling 66 and 67 overrides everywhere. My understanding is that the hard part of adding 16-bit support to gcc is the segmented address space.
--Zeb