<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>gcc &#8211; Virtually Fun</title>
	<atom:link href="https://virtuallyfun.com/category/gcc/feed/" rel="self" type="application/rss+xml" />
	<link>https://virtuallyfun.com</link>
	<description>Fun with Virtualization</description>
	<lastBuildDate>Mon, 20 Apr 2026 19:36:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
	<item>
		<title>Fun with POSX subsystem on NT</title>
		<link>https://virtuallyfun.com/2026/04/19/fun-with-posx-subsystem-on-nt/</link>
					<comments>https://virtuallyfun.com/2026/04/19/fun-with-posx-subsystem-on-nt/#respond</comments>
		
		<dc:creator><![CDATA[neozeed]]></dc:creator>
		<pubDate>Sun, 19 Apr 2026 08:45:33 +0000</pubDate>
				<category><![CDATA[cross compiler]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[gnu]]></category>
		<category><![CDATA[Windows NT 3.1]]></category>
		<guid isPermaLink="false">https://virtuallyfun.com/?p=15686</guid>

					<description><![CDATA[Well this is going to be a seemingly pointless post but you know I love stuff like this. I&#8217;d already gotten GCC 1.40 to run on the Windows NT 1991December Pre-Release, but that&#8217;s all Win32, what about the much vaunted &#8230; <a href="https://virtuallyfun.com/2026/04/19/fun-with-posx-subsystem-on-nt/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Well this is going to be a seemingly pointless post but you know I love stuff like this.  I&#8217;d already gotten GCC 1.40 to run on the Windows NT 1991December Pre-Release, but that&#8217;s all Win32, what about the much vaunted POSIX subsystem?</p>



<p class="wp-block-paragraph">Well what is it?  Basically it&#8217;s just enough of the UNIX/POSIX standard to check a box that gave Windows NT an in for US Government contracts that required a POSIX checkbox.  And nothing else more.  It&#8217;s basically agreed that it&#8217;s just enough to run &#8216;vi&#8217; and that&#8217;s basically it.</p>



<p class="wp-block-paragraph">But surely we can probably do more with this?</p>



<p class="wp-block-paragraph">The first fun part is that setting up the environment is basically <strong>UNDOCUMENTED</strong>. It was a nightmare back. then, as you need to setup a termcap environment that again is not mentioned.  The only hint is is an old KB article <a href="https://jeffpar.github.io/kbarchive/kb/108/Q108581/">Q108581</a>, which sets out the vauge guide.  I do know that back in the day I did have vi running, but I can&#8217;t remember how I did it exactly but wow.</p>


<div class="wp-block-image">
<figure class="alignleft size-full"><a href="https://archive.org/details/win32-sdk-final-release-nt-31" target="_blank" rel=" noreferrer noopener"><img decoding="async" width="180" height="180" src="https://virtuallyfun.com/wp-content/uploads/2026/04/image-10.png" alt="" class="wp-image-15687" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/image-10.png 180w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-10-150x150.png 150w" sizes="(max-width: 180px) 100vw, 180px" /></a></figure>
</div>


<p class="wp-block-paragraph">The first thing you need to do, naturally is install Windows NT 3.1. I did have access to this fun CD back in the day, it&#8217;s a combination <a href="https://archive.org/details/win32-sdk-final-release-nt-31" target="_blank" rel="noreferrer noopener">Windows NT 3.1 Workstation +SDK CD-ROM</a>.  This way you not only get the operating system, but you also now have the C compiler, libraries and headers.  Once setup, there is even a POSIX sample program.  Great?  Well, no.  Because this doesn&#8217;t include the OS environment, there is no previous &#8216;vi&#8217; either. Very sad.  Naturally you need another CD to install, which of course back in the day if you were going to use or support Windows NT, you&#8217;d naturally run out or order the <a href="https://archive.org/details/mswinntrskt310_20190128" target="_blank" rel="noreferrer noopener">Windows NT Resource Kit</a>.  These were absolutely required back in the day as the &#8216;task manager&#8217; only at best would show you named windows, it doesn&#8217;t show you the actual processes, making managing NT a nightmare without pviewer. (process viewer), among others.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img fetchpriority="high" decoding="async" width="408" height="308" src="https://virtuallyfun.com/wp-content/uploads/2026/04/image-11.png" alt="" class="wp-image-15688" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/image-11.png 408w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-11-300x226.png 300w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-11-397x300.png 397w" sizes="(max-width: 408px) 100vw, 408px" /><figcaption class="wp-element-caption">Windows NT Task List</figcaption></figure>
</div>


<p class="wp-block-paragraph">On the Resource Kit is not only a tiny &#8216;userland&#8217; but also it includes Elvis a vi clone, along with a much needed &#8216;cc&#8217; wrapper that will let you invoke the SDK C compiler as if it&#8217;s the Unix cc C compiler command.</p>



<p class="wp-block-paragraph">Elvis was written by Steve Kirkendall, back in the day, and even on Linux back in the day, I was using Elvis as well.  Remember &#8216;real&#8217; vi was tied to needing a 32v / BSD source license so it wasn&#8217;t free. </p>



<pre class="wp-block-code"><code>/* Author:
 *      Steve Kirkendall
 *      14407 SW Teal Blvd. #C
 *      Beaverton, OR 97005
 *      kirkenda@cs.pdx.edu
 */</code></pre>



<p class="wp-block-paragraph">It&#8217;s just how things were back then.</p>



<p class="wp-block-paragraph">To make things weird, I installed Windows NT onto a HPFS partition, because I wanted long file names, but I didn&#8217;t want to have a case preserving filesystem, as these old things have so much UPPERCASE/lowercase naming conflicts, because YES as a feature of NTFS &amp; POSIX it really does support Mixed case naming.  And I don&#8217;t feel like dealing with it, and it&#8217;s 1993, and HPFS is still a popular filesystem for us OS/2 users.</p>



<p class="wp-block-paragraph">Okay, so you&#8217;ve installed both the SDK &amp; the resource kit, surely you can just run vi?</p>



<figure class="wp-block-image size-full"><img decoding="async" width="452" height="174" src="https://virtuallyfun.com/wp-content/uploads/2026/04/image-13.png" alt="" class="wp-image-15690" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/image-13.png 452w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-13-300x115.png 300w" sizes="(max-width: 452px) 100vw, 452px" /></figure>



<p class="wp-block-paragraph">No. No you cannot. Remember you need that TERM variable and termcap library!</p>



<p class="wp-block-paragraph">Now to save you the hassle you&#8217;ll go back and check Q108581 and you&#8217;ll see this example:</p>



<pre class="wp-block-code"><code>li|ansi|psx_ansi|:\ 

            :co#80:li#25:\ 
            :am:pt:ms:bw:\ 
            :cl=\E&#91;2J:cm=\E&#91;%i%d;%dH:ce=\E&#91;K:cd=\E&#91;J:\ 
            :sf=\E&#91;S:sr=\E&#91;T:\ 
             :ho=\E&#91;H:sc=\E&#91;s:rc=\E&#91;u:up=\E&#91;A:d=^J:nd=\E&#91;C:le=^H:\ 
             :ku=\E&#91;A:kd=\E&#91;V:kr=\E&#91;C:kl=\E&#91;D:kb=^H:\ 
             :so=\E&#91;7m:se=\E&#91;m:mr=\E&#91;7m:me=\E&#91;0m:\ </code></pre>



<p class="wp-block-paragraph">copy paste and and, yeah IT DOESNT WORK.  Like something being passed endlessly through a photocopier, it got mangled in usenet (maybe where I found it?) , and yeah you need to &#8216;fix&#8217; it up as it should look more like this.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="553" height="284" src="https://virtuallyfun.com/wp-content/uploads/2026/04/Screenshot-2026-04-19-at-8.21.16-AM.png" alt="" class="wp-image-15691" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/Screenshot-2026-04-19-at-8.21.16-AM.png 553w, https://virtuallyfun.com/wp-content/uploads/2026/04/Screenshot-2026-04-19-at-8.21.16-AM-300x154.png 300w, https://virtuallyfun.com/wp-content/uploads/2026/04/Screenshot-2026-04-19-at-8.21.16-AM-500x257.png 500w" sizes="auto, (max-width: 553px) 100vw, 553px" /></figure>
</div>


<p class="wp-block-paragraph">Or for anyone hoping to copy/paste:</p>



<pre class="wp-block-code"><code>li|ansi|psx_ansi|:\
	:co#80:li#25:\
	:am:pt:ms:bw:\
	:cl=\E&#91;2J:cm=\E&#91;%i%d;%dH:ce=\E&#91;K:cd=\E&#91;J:\
	:sf=\E&#91;S:sr=\E&#91;T:\
	:ho=\E&#91;H:sc=\E&#91;s:rc=\E&#91;u:up=\E&#91;A:d=^J:nd=\E&#91;C:le=^H:\
	:ku=\E&#91;A:kd=\E&#91;V:kr=\E&#91;C:kl=\E&#91;D:kb=^H:bc=^H:\
	:so=\E&#91;7m:se=\E&#91;m:mr=\E&#91;7m:me=\E&#91;0m:\</code></pre>



<p class="wp-block-paragraph">Note that the leading &#8216;tab&#8217; actually matters and there should be NO empty spaces at the tail backslash!  If that tab or ending \ is padded or wrong it just plain will not work.  I wasted so much time before realizing the craziness of this setup.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">Thinking that&#8217;s enough you have to keep reading, as the POSIX environment has no idea what c: is, or how to set variables, so you need to specify the full NT path, not the Win32 path</p>



<p class="wp-block-paragraph">To save the adventure some time this is what I end up just putting into a CMD file so I can just click and go!</p>



<pre class="wp-block-code"><code>@stitle posix
@set PATH=c:\bin;%PATH%
@set Lib=c:\mstools\posix\lib;%lib%
@set Include=c:\mstools\posix\h;%include%
@set TERM=ansi
@set TERMCAP=//C/etc/termcap
@set _POSIX_TERM=on
@set TEMP=
@set tmp=
@set INCLUDE=
@set include=
@set lib=/usr/lib
@set tmp=//C/tmp
@set temp=//C/temp
@set MAKEPATH=//C/posix/src/MK-RULES
@cls
@sh</code></pre>



<p class="wp-block-paragraph">Now with a corrected environment for POSIX and a termcap file, now we can actually run VI/Elvis!</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="633" height="327" src="https://virtuallyfun.com/wp-content/uploads/2026/04/image-14.png" alt="" class="wp-image-15692" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/image-14.png 633w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-14-300x155.png 300w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-14-500x258.png 500w" sizes="auto, (max-width: 633px) 100vw, 633px" /><figcaption class="wp-element-caption">Elvis running correctly on the POSIX subsystem</figcaption></figure>



<p class="wp-block-paragraph">This is what success looks like!</p>



<p class="wp-block-paragraph">Now I know what you&#8217;re thinking okay, were setup now, we can just build something simple like say a hello world style program right?  I made a simple Makefile, and let&#8217;s go ahead and try to invoke the &#8216;cc&#8217; compiler wrapper:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="634" height="331" src="https://virtuallyfun.com/wp-content/uploads/2026/04/image-15.png" alt="" class="wp-image-15693" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/image-15.png 634w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-15-300x157.png 300w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-15-500x261.png 500w" sizes="auto, (max-width: 634px) 100vw, 634px" /></figure>



<p class="wp-block-paragraph">And it just hangs, doing nothing.  As it turns out that the &#8216;cc&#8217; wrapper uses a file for IPC to talk between POSIX &amp; WIN32.  Remember they are separate personalities on the NTOKS kernel, and they cannot directly communicate with eachother.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="474" height="355" src="https://virtuallyfun.com/wp-content/uploads/2026/04/image-16.png" alt="" class="wp-image-15694" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/image-16.png 474w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-16-300x225.png 300w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-16-401x300.png 401w" sizes="auto, (max-width: 474px) 100vw, 474px" /></figure>
</div>


<p class="wp-block-paragraph">I don&#8217;t know why they didn&#8217;t use a named pipe, maybe POSIX cannot write to them?  Maybe when they were writing the POSIX subsystem, named pipes weren&#8217;t working yet?  It&#8217;s hard to say, and the early NT 3.1 pre-releases don&#8217;t included the POSIX, or OS/2 subsystem.  Actually they don&#8217;t even have the NTVDM/MS-DOS/WoW either.</p>



<p class="wp-block-paragraph">So you need to run something called &#8216;devsrv&#8217; which is a Win32 program that looks for c:\tmp\ for devsem.ini file telling it what Win32 program to run and how.  For example, in this case it looks like this:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="585" height="327" src="https://virtuallyfun.com/wp-content/uploads/2026/04/Screenshot-2026-04-19-at-8.36.08-AM.png" alt="" class="wp-image-15696" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/Screenshot-2026-04-19-at-8.36.08-AM.png 585w, https://virtuallyfun.com/wp-content/uploads/2026/04/Screenshot-2026-04-19-at-8.36.08-AM-300x168.png 300w, https://virtuallyfun.com/wp-content/uploads/2026/04/Screenshot-2026-04-19-at-8.36.08-AM-500x279.png 500w" sizes="auto, (max-width: 585px) 100vw, 585px" /></figure>



<p class="wp-block-paragraph">Now if you think you can just blindly run devrv, you&#8217;ll 99% of the time be in for a bad time as you need to initialize a working Win32-&gt;POSIX cross environment.  Me being, me I just put this into another CMD file:</p>



<pre class="wp-block-code"><code>title devsrv
@set PATH=c:\bin;c:\mstools\bin;%PATH%
@set Lib=c:\mstools\posix\lib;c:\usr\lib
@set Include=c:\mstools\posix\h;c:\usr\include
@set TEMP=c:\temp
@set tmp=c:\tmp
@c:\bin\devsrv</code></pre>



<p class="wp-block-paragraph">I&#8217;ve already started to place headers &amp; libraries into a more &#8216;UNIX&#8217; like path structure with /usr/include &amp; /usr/lib although by default the MSFT scripts expect things to live in the SDK world.  But I do have goals of running GCC and dealing with weird paths isn&#8217;t my goal as the less I have to fight, the better.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="628" height="460" src="https://virtuallyfun.com/wp-content/uploads/2026/04/image-18.png" alt="" class="wp-image-15697" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/image-18.png 628w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-18-300x220.png 300w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-18-410x300.png 410w" sizes="auto, (max-width: 628px) 100vw, 628px" /><figcaption class="wp-element-caption">Compiling &#8216;hi&#8217; from within the POSIX subsystem</figcaption></figure>



<p class="wp-block-paragraph">  Now with devsrv running it cannot call the C compiler, and the linker.  It will fail at first as it&#8217;s expecting to link against NTDLL.LIB as in the Pre-release/Beta days there was a &#8216;ntdll&#8217; you had to link against.  It isn&#8217;t there in the RTM Windows NT, so it&#8217;s kind of clear that although POSIX shipped it was basically abandonded during the development cycle, and nobody expected anyone to actually do anthying with it.  Or at best find the KB article and maybe run vi.</p>



<p class="wp-block-paragraph">Or you could just fix &amp; rebuild the linker proxy, ld.c and remove the offending line:</p>



<pre class="wp-block-code"><code>char *def_lib&#91;] = /* Default library */
{
   "libcpsx.lib",
   "psxdll.lib",
   "ntdll.lib",
   "psxrtl.lib",
   SNULL
};</code></pre>



<p class="wp-block-paragraph">And re-compile.  Which of course is time to show yet another CMD file that sets up a Win32 environment enough to cross compile to POSIX:</p>



<pre class="wp-block-code"><code>title posix cross
@set CPU=i386
@set PATH=c:\posix\bin;c:\mstools\bin;%PATH%
@set Lib=c:\mstools\posix\lib;c:\usr\lib;%lib%
@set Include=c:\mstools\posix\h;c:\usr\include;%include%
@set TERM=ansi
@set TERMCAP=//C/etc/termcap
@set _POSIX_TERM=on
@set TEMP=c:\temp
@set tmp=c:\tmp
@set MAKEPATH=C:\posix\src\MK-RULES</code></pre>



<p class="wp-block-paragraph">So now I can build things from the Win32 side of life, like the LD proxy, or even &#8216;cross compile&#8217; a simple enough hello world from Win32:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="628" height="267" src="https://virtuallyfun.com/wp-content/uploads/2026/04/image-19.png" alt="" class="wp-image-15698" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/image-19.png 628w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-19-300x128.png 300w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-19-500x213.png 500w" sizes="auto, (max-width: 628px) 100vw, 628px" /></figure>



<p class="wp-block-paragraph">See wasn&#8217;t that fun?!</p>



<p class="wp-block-paragraph">Since I already have a version of <a href="https://github.com/neozeed/gcc-1.40-msvc" target="_blank" rel="noreferrer noopener">GCC-1.40 building with the Microsoft C compiler</a> this seemed like a great leg up on building a POSIX version.  And naturally to make it more complete building bison-1.16 is also required.  Since I have Bison building on normal Win32, this wasn&#8217;t much of a problem.  The weird hurdle came in the C Preprocessor where I found out that POSIX is missing some seemingly vital stuff like fstat!  </p>



<pre class="wp-block-code"><code>int                 
file_size_and_mode (fd, mode_pointer, size_pointer)
     int fd;
     int *mode_pointer;
     long int *size_pointer;
{ 
#if 0
//this is missing from posix
  struct stat sbuf;
  
  if (fstat (fd, &amp;sbuf) &lt; 0) return (-1);
  if (mode_pointer) *mode_pointer = sbuf.st_mode;
  if (size_pointer) *size_pointer = sbuf.st_size;
#endif
  return 0;
}</code></pre>



<p class="wp-block-paragraph">Also, for some reason I can&#8217;t link any real programs that call unlink, I have to proxy that to a stub file that has no includes, define unlink as Xunlink, then link against that stube and it all links fine.  I know WTF?!  I don&#8217;t get it ether.  But I wanted to build stuff so these are&#8230; tradeoffs that I made to just short-cut the whole thing.  Maybe I&#8217;ll go back and look and try to figure it out.  As I see in the POSIX util source mutiple things call fstat, so maybe it&#8217;s happier when linked from Win32?</p>



<p class="wp-block-paragraph">To complete the round trip, since we already know the Link386 from the SDK and early Visual C++ will happily accept Xenix OMF files, I can use the <a href="https://github.com/neozeed/gas-1.38-xenix-" target="_blank" rel="noreferrer noopener">GNU Assembler that targets Xenix</a>, and then get a round tripped GCC on POSIX NT!</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="638" height="336" src="https://virtuallyfun.com/wp-content/uploads/2026/04/image-23.png" alt="" class="wp-image-15702" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/image-23.png 638w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-23-300x158.png 300w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-23-500x263.png 500w" sizes="auto, (max-width: 638px) 100vw, 638px" /><figcaption class="wp-element-caption">GCC running on POSIX NT!</figcaption></figure>
</div>


<p class="wp-block-paragraph">And there we have it!</p>



<h2 class="wp-block-heading">Installing it for the BRAVE</h2>



<p class="wp-block-paragraph">I&#8217;ve gone ahead and uploaded my working directories to archive.org here: <a href="https://archive.org/details/posix-4" target="_blank" rel="noreferrer noopener">POSIX-4</a>.</p>



<p class="wp-block-paragraph">I guess I could have found my old zip/unzip for NT 3.1 but I didn&#8217;t I stuck to PAX which surprisingly is in NT 3.1. It&#8217;s not quite as friendly as TAR but you can copy posix4.tar to the C: drive and just extract it with &#8216;pax -r -f posix4.tar&#8217;</p>



<p class="wp-block-paragraph">I should note for some reason trying to extract it from my tranfer disk, causes a BLUESCREEN in the HPFS device driver on NT 3.1&#8230; Bummer.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="480" height="253" src="https://virtuallyfun.com/wp-content/uploads/2026/04/image-12.png" alt="" class="wp-image-15689" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/image-12.png 480w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-12-300x158.png 300w" sizes="auto, (max-width: 480px) 100vw, 480px" /><figcaption class="wp-element-caption">extracting my posix all in one package</figcaption></figure>
</div>


<p class="wp-block-paragraph">Once all the files are unpacked the first thing I do is make a Program Item on Program Manager for the Posix shell.  All the hard work is done, you just have to path it to c:\posix\shell.cmd</p>



<p class="wp-block-paragraph">This is how I setup mine, so YMMV</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="506" height="225" src="https://virtuallyfun.com/wp-content/uploads/2026/04/image-20.png" alt="" class="wp-image-15699" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/image-20.png 506w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-20-300x133.png 300w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-20-500x222.png 500w" sizes="auto, (max-width: 506px) 100vw, 506px" /><figcaption class="wp-element-caption">Shell Program Item</figcaption></figure>
</div>


<p class="wp-block-paragraph">And the last part is the DEVSRV.  This is how I setup mine, with the emphasis on running minimized.  It does and can crash from time to time so I wouldn&#8217;t try to wrap it as a service or anything that creative.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="473" height="205" src="https://virtuallyfun.com/wp-content/uploads/2026/04/image-21.png" alt="" class="wp-image-15700" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/image-21.png 473w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-21-300x130.png 300w" sizes="auto, (max-width: 473px) 100vw, 473px" /><figcaption class="wp-element-caption">DevSRV Program Item</figcaption></figure>
</div>


<p class="wp-block-paragraph">And then I move mine to the startup items, so that way, every time I login, I now have the devsrv all ready for my POSIX experiments!</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="402" height="181" src="https://virtuallyfun.com/wp-content/uploads/2026/04/image-22.png" alt="" class="wp-image-15701" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/image-22.png 402w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-22-300x135.png 300w" sizes="auto, (max-width: 402px) 100vw, 402px" /></figure>
</div>


<p class="wp-block-paragraph">Now you can just logoff/log back in, and you are ready for some POSIX GCC adventures.</p>



<p class="wp-block-paragraph">It&#8217;s a shame that back then I just was totally unaware of that Xenix OMF GAS version.  I pretty much had given up on Xenix 386 back then, as I never could find the developer&#8217;s kit, as they had gatekept people off the platform.  Linux is where all the excitement was, as not only did it have GCC, but you also had full source.  Even if I&#8217;d had access to GCC on Xenix, with no libc no headers it wasn&#8217;t going to go very far.</p>



<p class="wp-block-paragraph">Credit to Microsoft though, they did learn with that $3,000 OS/2 SDK, that if you paywall the low end developers away, nobody writes for your platform.  Although Microsoft did lose their way on this when they stopped QuickC, forcing new users to pay for the full thing.  They didn&#8217;t realize how much territory they ceded by charging for the C compiler to GCC until it was too late, as all &#8216;starving university&#8217; kids are GNU kids now (Yes I know CLANG is where it&#8217;s at today, thats&#8217;s Apple&#8217;s lesson I guess in there).  By the time they did free as in beer limited &#8220;<a href="https://archive.org/details/microsoft-visual-c-toolkit-2003" target="_blank" rel="noreferrer noopener">Visual C++ Toolkit 2003</a>&#8221; it was already far too late.</p>



<p class="wp-block-paragraph">The POSIX subsystem was never going to be all that useful, as it was pretty clear if NT became a competent UNIX, nobody would write Win32 server software.  But considering one of the best features to be added to Windows 10/Server 2016 was the WSL subsystem, we already crossed that bridge.</p>



<h2 class="wp-block-heading">Addendum</h2>



<p class="wp-block-paragraph">I thought it&#8217;d be &#8216;fun&#8217; to do this from Citrix as it easily allows me to map drives making life MUCH easier, but nothing worked.  I went thorugh installing NT 3.5 it&#8217;s SDK and Visual C++ 2 and noticed that nothing ran on that either.  Maybe it&#8217;s Qemu?</p>



<p class="wp-block-paragraph">So I just jumped forward to NT 4.0, because why not??</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="455" height="171" src="https://virtuallyfun.com/wp-content/uploads/2026/04/image-24.png" alt="" class="wp-image-15705" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/image-24.png 455w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-24-300x113.png 300w" sizes="auto, (max-width: 455px) 100vw, 455px" /><figcaption class="wp-element-caption">make on NT 4.0 POSIX</figcaption></figure>



<p class="wp-block-paragraph">Turns out it doesn&#8217;t work either.</p>



<p class="wp-block-paragraph">Well sure vi does work, but the whole &#8216;cc&#8217; cross thing is just plain deprecated after 3.1&#8230; It&#8217;s like whatever attempt at POSIX being useable was fully given up on.  The only other interesting thing on the NT 3.5 resource kit, is that it <em>does</em> mention GCC being part of the kit, but obviously that never happened.  Politics I suppose.</p>



<p class="wp-block-paragraph">So now I really remember why I never really bothered with the environment, as it basically became unusable by Windows NT 3.5</p>



<h2 class="wp-block-heading">Running at home!</h2>



<p class="wp-block-paragraph">I&#8217;ve gone ahead, and uploaded the source to github, and included a binary release.  So you can try this on your own Windows NT 3.1 machine, or try the fight with NT 3.5 or higher and go through the fight yourself.</p>



<p class="wp-block-paragraph"><a href="https://github.com/neozeed/windowsnt31_posix" target="_blank" rel="noreferrer noopener">https://github.com/neozeed/windowsnt31_posix</a></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="634" height="473" src="https://virtuallyfun.com/wp-content/uploads/2026/04/image-25.png" alt="" class="wp-image-15708" srcset="https://virtuallyfun.com/wp-content/uploads/2026/04/image-25.png 634w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-25-300x224.png 300w, https://virtuallyfun.com/wp-content/uploads/2026/04/image-25-402x300.png 402w" sizes="auto, (max-width: 634px) 100vw, 634px" /></figure>



<p class="wp-block-paragraph">And yes, I did get <a href="https://github.com/neozeed/hack-1.03" target="_blank" rel="noreferrer noopener">hack-1.03</a> running!</p>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
					<wfw:commentRss>https://virtuallyfun.com/2026/04/19/fun-with-posx-subsystem-on-nt/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Yet another GCC 1.40 *SOME ASSEBMLY REQUIRED</title>
		<link>https://virtuallyfun.com/2026/02/08/yet-another-gcc-1-40-some-assebmly-required/</link>
					<comments>https://virtuallyfun.com/2026/02/08/yet-another-gcc-1-40-some-assebmly-required/#respond</comments>
		
		<dc:creator><![CDATA[neozeed]]></dc:creator>
		<pubDate>Sun, 08 Feb 2026 13:33:41 +0000</pubDate>
				<category><![CDATA[80386]]></category>
		<category><![CDATA[assembly]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[i386]]></category>
		<category><![CDATA[Win32]]></category>
		<guid isPermaLink="false">https://virtuallyfun.com/?p=15612</guid>

					<description><![CDATA[Oh sure I&#8217;ve done this ages ago, getting GCC 1.40 to compile with old Microsoft C compilers, and then target Win32, it&#8217;s not that &#8216;special&#8217;. But I thought I&#8217;d try to get them to build with MASM so I could &#8230; <a href="https://virtuallyfun.com/2026/02/08/yet-another-gcc-1-40-some-assebmly-required/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="779" src="https://virtuallyfun.com/wp-content/uploads/2026/02/Screenshot-2026-02-07-at-7.22.17-PM-1024x779.png" alt="" class="wp-image-15613" srcset="https://virtuallyfun.com/wp-content/uploads/2026/02/Screenshot-2026-02-07-at-7.22.17-PM-1024x779.png 1024w, https://virtuallyfun.com/wp-content/uploads/2026/02/Screenshot-2026-02-07-at-7.22.17-PM-300x228.png 300w, https://virtuallyfun.com/wp-content/uploads/2026/02/Screenshot-2026-02-07-at-7.22.17-PM-768x584.png 768w, https://virtuallyfun.com/wp-content/uploads/2026/02/Screenshot-2026-02-07-at-7.22.17-PM-395x300.png 395w, https://virtuallyfun.com/wp-content/uploads/2026/02/Screenshot-2026-02-07-at-7.22.17-PM.png 1210w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">phoon</figcaption></figure>



<p class="wp-block-paragraph">Oh sure I&#8217;ve done this ages ago, getting GCC 1.40 to compile with old Microsoft C compilers, and then target Win32, it&#8217;s not that &#8216;special&#8217;.  But I thought I&#8217;d try to get them to build with MASM so I could just distribute this with an assembler.  Spelling out the joke of some assembly required.</p>



<p class="wp-block-paragraph">Although I wasn&#8217;t going to target/host OS/2 I was ideally going straight to Win32, the MASM 6.11 assembler couldn&#8217;t assemble the MSVC 1.0 / MSC/386 8.0 compiler&#8217;s assembly output, I needed to use the MASM 7 from Visual C++ 2003; namely:</p>



<pre class="wp-block-code"><code>Microsoft (R) Macro Assembler Version 7.10.3077 Copyright (C) Microsoft Corporation. All rights reserved.</code></pre>



<p class="wp-block-paragraph">MASM 6.11 was having issues with pushing OFFSET&#8217;s ie:</p>



<pre class="wp-block-code"><code>push OFFSET _obstack</code></pre>



<p class="wp-block-paragraph">when they were defined as:</p>



<pre class="wp-block-code"><code>COMM _obstack:BYTE:024H</code></pre>



<p class="wp-block-paragraph">Chat GPT to the rescue knowing that later MASM&#8217;s will just handle it just fine.  And it was right!  I know AI gets a bad rep, but surprisingly (or not when you think about what it&#8217;s been trained on), it&#8217;s got some great insight to some old things like seemingly common software tools, and old environments.</p>



<p class="wp-block-paragraph">I didn&#8217;t bother trying to use Microsoft C/386 6.0 &amp; MASM386 5.1 to see if it&#8217;ll handle CC1, as that seems to be a bit extreme. and I wanted this to run on semi modern Win32 stuff.  More so that there isn&#8217;t a 64bit SMP aware OS/2 with a modern web browser.  Kind of sad to be honese, but it&#8217;s 2026, and here we are.</p>



<p class="wp-block-paragraph">I as always stick to the <a href="https://github.com/neozeed/gas-1.38-xenix-">Xenix GAS port</a> that outputs 386 OMF objects that earlier linker&#8217;s can happily auto-convert to coff and use on Win32.  One day I feel I should ask why they were cross compiling NT/i386 from OS/2 1.21 instead of using Xenix?!  Must have been some fundamental NTOS/2 thing I suppose.</p>



<p class="wp-block-paragraph">I guess a refresher for anyone comming in out of the cold here&#8217;s a really poorly done block diagram of what goes on when a traditional (GCC) compiler runs.  Explaniation is here: <a href="https://virtuallyfun.com/2024/01/08/so-it-turns-out-gcc-could-have-been-available-on-windows-nt-the-entire-time/">so it turns out GCC could have been available on Windows NT the entire time</a>.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="384" src="https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-program-flow-1024x384.png" alt="GCC program flow" class="wp-image-13731" srcset="https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-program-flow-1024x384.png 1024w, https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-program-flow-300x112.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-program-flow-768x288.png 768w, https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-program-flow-1536x575.png 1536w, https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-program-flow-500x187.png 500w, https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-program-flow.png 1962w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">Long story there was that the Xenix GAS emits an ancient 386 OMF format that for unknown reaons the older Microsoft Linkers happily accept and auto convert into COFF, the file format of the future (Future being 1988).  I guess for better. or worse we never got NT/ELF.  Oh and speaking of further weird, the IBM version of their LINK386 doesn&#8217;t like the Xenix 386 OMF.  Bummer.</p>



<p class="wp-block-paragraph">One thing I found out is that the MASM v7 doesn&#8217;t output COFF by default, rather it&#8217;s 386 OMF!  you need to add the /coff flag to force it to be more Win32 friendly.  Kind of unexpected behaviour.</p>



<p class="wp-block-paragraph">I tried to make this simple as, clone the repo and run &#8216;build.cmd&#8217; it&#8217;ll link up GCC and then build the test programs, and clean up after itself.</p>



<p class="wp-block-paragraph"><a href="https://github.com/neozeed/gcc140-masm" target="_blank" rel="noreferrer noopener">https://github.com/neozeed/gcc140-masm</a></p>



<p class="wp-block-paragraph">I&#8217;d tried to emit assembly for the Xenix GAS, but for some reason it&#8217;s struggling with floating point.  I&#8217;m not sure, I tried using chat gpt to debug but it get&#8217;s confused on how this whole bizzare tool chain is working.  I guess I can&#8217;t blame it.</p>



<p class="wp-block-paragraph">Sorry it&#8217;s been a while, been feeling &#8216;life&#8217; lately.  I had some i7 project as a kicker for a retro Windows 10 build thing to do but watchign the RAM crissis unfold and well life&#8230; I just got feeling like it&#8217;s so irrelevant who&#8217;d care.  That and it&#8217;s insane watching $1.11 worth of DDR3 RAM now selling for $30++ &#8230;. and more and more chip manufacturers are exiting.  So it felt like maybe go back and do more with less.  Even a low end machine can assemble this in seconds!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://virtuallyfun.com/2026/02/08/yet-another-gcc-1-40-some-assebmly-required/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Qemu / GCC / Tiger aka assumptions on GCC v3 performance</title>
		<link>https://virtuallyfun.com/2025/01/25/qemu-gcc-tiger-aka-assumptions-on-gcc-v3-performance/</link>
					<comments>https://virtuallyfun.com/2025/01/25/qemu-gcc-tiger-aka-assumptions-on-gcc-v3-performance/#comments</comments>
		
		<dc:creator><![CDATA[neozeed]]></dc:creator>
		<pubDate>Sat, 25 Jan 2025 23:57:18 +0000</pubDate>
				<category><![CDATA[gcc]]></category>
		<category><![CDATA[OS X]]></category>
		<guid isPermaLink="false">https://virtuallyfun.com/?p=15124</guid>

					<description><![CDATA[Well this took a shocking turn; I&#8217;d always seen on Windows that Qemu built with GCC 3.4.5 was not only faster, but more stable than GCC 4.x when regarding version 0.10 (I&#8217;m not even going to entertain later versions, as &#8230; <a href="https://virtuallyfun.com/2025/01/25/qemu-gcc-tiger-aka-assumptions-on-gcc-v3-performance/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Well this took a shocking turn;</p>



<p class="wp-block-paragraph">I&#8217;d always seen on Windows that Qemu built with GCC 3.4.5 was not only faster, but more stable than GCC 4.x when regarding version 0.10 (I&#8217;m not even going to entertain later versions, as this is about old software).</p>



<p class="wp-block-paragraph">I&#8217;ll have to post more, but I&#8217;ve basically learned nothing from all my other Pentium 4 / i915 chipset disasters, and now have my 8th system up and running!</p>



<p class="wp-block-paragraph">by default it has GCC 4.0.0 for i386, and a GCC 3.x for PowerPC building.  Natrually, with assumption in hand, how do you build GCC 3 for Intel?</p>



<p class="wp-block-paragraph">Thankfully, the question was asked on Mac OS X Hints a few decades ago:</p>



<p class="wp-block-paragraph"><a href="https://web.archive.org/web/20070610073818/http://www.macosxhints.com/article.php?story=20060423105014540">https://web.archive.org/web/20070610073818/http://www.macosxhints.com/article.php?story=20060423105014540</a></p>



<p class="wp-block-paragraph">And it was saved in the wayback machine, because, preserving the past is hard.</p>



<p class="wp-block-paragraph">The steps are pretty simple:</p>



<pre class="wp-block-code"><code>$ tar -zxf gcc_os-1819.tar.gz

3. Fix a line that causes it to not compile: in the file gcc_os-1819/gcc/gcc.c, on line 5883, change the line to look like this:

(char ) v&#91;q - vt] = 0;

4. Make a build directory and run configure. I installed my compiler in /opt/gcc3, and I only built the C compiler. This would not work for building C++ or Cocoa applications.
$ mkdir build
$ cd build
$ ../gcc_os-1819/configure --prefix=/opt/gcc3 --enable-languages=c</code></pre>



<p class="wp-block-paragraph">Which was great except where on earth am I going to find this old GCC?</p>



<p class="wp-block-paragraph">In retrospect there are 2 places, naturally, <a href="https://web.archive.org/web/20070522183410/http://www.opensource.apple.com/darwinsource/DevToolsNov2005/">archive.org kept a copy of the Apple pages</a>, the other being <a href="https://github.com/apple-oss-distributions/gcc_os/tree/9a5b37fe8795ad7fe7b5b030987239290a239860" target="_blank" rel="noreferrer noopener">github</a>.</p>



<p class="wp-block-paragraph">For the 2-3 people who will be interested in this kind of thing 20 years from now I went ahead and did the single patch, and built binaries and put them on github over at <a href="https://github.com/neozeed/gcc_os-1819_Marklar" target="_blank" rel="noreferrer noopener">gcc_os-1819_Marklar</a>.</p>



<p class="wp-block-paragraph">For testing, I&#8217;m using a VMDK with MS-DOS 5.00 no config.sys and DooM v1.1 running the timedemo both with no sound.  (<a href="https://doomwiki.org/wiki/Parameter">gametics/realtics)*35=fps</a>. and in this case, demo1 of DooM v1.1 is 1077 gameticks.</p>



<pre class="wp-block-code"><code>GCC 3.5     gcc version 3.5.0 20041003 (Apple Computer, Inc. build 3506)
GCC 4.0     gcc version 4.0.0 (Apple Computer, Inc. build 5026)</code></pre>



<p class="wp-block-paragraph">no draw (ticks)</p>



<pre class="wp-block-code"><code>GCC 3.5       6/7/7
GCC 4.0       6/7/6</code></pre>



<p class="wp-block-paragraph">draw-16bit screen depth (ticks)</p>



<pre class="wp-block-code"><code>GCC 3.5       1074/1074/1077
GCC 4.0       948/947/949</code></pre>



<p class="wp-block-paragraph">And now for the bad news, it turns out that GCC 4.0 is just slightly faster than GCC 3.3</p>



<p class="wp-block-paragraph">I couldn&#8217;t believe it either.</p>



<p class="wp-block-paragraph">For anyone that cares, DOSbox SVN builds more or less okay on Tiger with some small fix to the MIDI compatibility code (#ifdef stuff, the MIDI works fine!) and it&#8217;s timings are for no draw</p>



<pre class="wp-block-code"><code>DOSBox          566/560/565</code></pre>



<p class="wp-block-paragraph">and drawing on a 32bit screen (16bit is incompatible)</p>



<pre class="wp-block-code"><code>DOSBox          22/26/25</code></pre>



<p class="wp-block-paragraph">The takeaway is that the CPU is much faster on Qemu, but screen rendering is much faster with DOSBox.  DOSBox uses SDL, so let&#8217;s go one further, and rebuild Qemu with SDL instead of it&#8217;s Cocoa support!  So how we doing in the tick department?</p>



<pre class="wp-block-code"><code>GCC 3.5       1005/999/1000
GCC 4.0       885/886/882</code></pre>



<p class="wp-block-paragraph">The real killer would of course be trying a newer version of GCC.  Which I tried several, but Apple had done something really strange to them, where they product self-modifying code by default.  And the assembler in 10.4.1 can&#8217;t handle that.</p>



<pre class="wp-block-code"><code>unknown section attribute: self_modifying_code</code></pre>



<p class="wp-block-paragraph">No really, it&#8217;s a thing!</p>



<p class="wp-block-paragraph">Obviously, I updated my <a href="https://github.com/apple-opensource-mirror/cctools/commits/master/" target="_blank" rel="noreferrer noopener">cc-tools</a> to 622.9, and guess what?</p>



<p class="wp-block-paragraph">I tried :</p>



<ul class="wp-block-list">
<li>gcc-5247</li>



<li>gcc-5250</li>



<li>gcc-5370</li>
</ul>



<p class="wp-block-paragraph">All give the following:</p>



<pre class="wp-block-code"><code>Illegal instruction</code></pre>



<p class="wp-block-paragraph">Is this some DTK Pentium 4 thing?  Or a Tiger 10.4.1 thing?</p>



<p class="wp-block-paragraph">verbose output for the curious:</p>



<pre class="wp-block-code"><code>Viglen:~/tmp2 jsteve$ gcc -v hi.c -o hi
Using built-in specs.
Target: i686-apple-darwin8.1.0
Configured with: ../gcc-5247/configure --prefix=/opt/gcc-5247 --enable-languages=c
Thread model: posix
gcc version 4.0.1 (Apple Computer, Inc. build 5247)
 /opt/gcc-5247/libexec/gcc/i686-apple-darwin8.1.0/4.0.1/cc1 -quiet -v -D__DYNAMIC__ hi.c -fPIC -quiet -dumpbase hi.c -auxbase hi -version -o /var/tmp//ccq5CJ5D.s
ignoring nonexistent directory "/opt/gcc-5247/lib/gcc/i686-apple-darwin8.1.0/4.0.1/../../../../i686-apple-darwin8.1.0/include"
#include "..." search starts here:
#include &lt;...> search starts here:
 /usr/local/include
 /opt/gcc-5247/include
 /opt/gcc-5247/lib/gcc/i686-apple-darwin8.1.0/4.0.1/include
 /usr/include
 /System/Library/Frameworks
 /Library/Frameworks
End of search list.
GNU C version 4.0.1 (Apple Computer, Inc. build 5247) (i686-apple-darwin8.1.0)
        compiled by GNU C version 4.0.0 (Apple Computer, Inc. build 5026).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 8944321fb1b2a413196eb995bbfd7ab0
hi.c: In function 'main':
hi.c:3: warning: return type of 'main' is not 'int'
 as -arch i386 -force_cpusubtype_ALL -o /var/tmp//ccFyDIlr.o /var/tmp//ccq5CJ5D.s
 /opt/gcc-5247/libexec/gcc/i686-apple-darwin8.1.0/4.0.1/collect2 -dynamic -arch i386 -weak_reference_mismatches non-weak -o hi -lcrt1.o /opt/gcc-5247/lib/gcc/i686-apple-darwin8.1.0/4.0.1/crt2.o -L/opt/gcc-5247/lib/gcc/i686-apple-darwin8.1.0/4.0.1 -L/opt/gcc-5247/lib/gcc/i686-apple-darwin8.1.0/4.0.1/../../.. /var/tmp//ccFyDIlr.o -lgcc -lSystem
Viglen:~/tmp2 jsteve$ ./hi
Illegal instruction</code></pre>



<p class="wp-block-paragraph">I&#8217;m not entirely sure.</p>



<p class="wp-block-paragraph">I need a Snow Leopard machine.</p>



<p class="wp-block-paragraph">Also DosBox SVN wasn&#8217;t too hard to build, and runs great.</p>



<figure class="wp-block-video"><video height="720" style="aspect-ratio: 1280 / 720;" width="1280" controls src="https://virtuallyfun.com/wp-content/uploads/2025/01/Virtually-Fun-Whats-better-than-DooM？-Two-DooMs-at-the-same-time-1883212447802089472.mp4"></video></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://virtuallyfun.com/2025/01/25/qemu-gcc-tiger-aka-assumptions-on-gcc-v3-performance/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		<enclosure url="https://virtuallyfun.com/wp-content/uploads/2025/01/Virtually-Fun-Whats-better-than-DooM？-Two-DooMs-at-the-same-time-1883212447802089472.mp4" length="1711810" type="video/mp4" />

			</item>
		<item>
		<title>Happy 2025!</title>
		<link>https://virtuallyfun.com/2025/01/02/happy-2025/</link>
					<comments>https://virtuallyfun.com/2025/01/02/happy-2025/#respond</comments>
		
		<dc:creator><![CDATA[neozeed]]></dc:creator>
		<pubDate>Thu, 02 Jan 2025 18:24:59 +0000</pubDate>
				<category><![CDATA[80386]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[OS/2]]></category>
		<category><![CDATA[OS/2 2.0]]></category>
		<category><![CDATA[PS/2]]></category>
		<category><![CDATA[random updates]]></category>
		<guid isPermaLink="false">https://virtuallyfun.com/?p=15084</guid>

					<description><![CDATA[With large language models being all the rage, I found this tweet (x?) on twitter (x?), from Alex Cheema, discussing Andrej Karpathy&#8217;s port of a LLM, to C llma2.c, and then converting it to build with Borland C v5 as &#8230; <a href="https://virtuallyfun.com/2025/01/02/happy-2025/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">With large language models being all the rage, I found this <a href="https://x.com/alexocheema/status/1873402372996944354" target="_blank" rel="noreferrer noopener">tweet (x?) on twitter (x?)</a>, from <a href="https://x.com/alexocheema" target="_blank" rel="noreferrer noopener">Alex Cheema</a>, discussing <a href="https://x.com/karpathy" target="_blank" rel="noreferrer noopener">Andrej Karpathy&#8217;</a>s port of a LLM, to C <a href="https://github.com/karpathy/llama2.c" target="_blank" rel="noreferrer noopener">llma2.c</a>, and then converting it to build with Borland C v5 as <a href="https://github.com/exo-explore/llama98.c" target="_blank" rel="noreferrer noopener">llma98.c</a> .</p>



<p class="wp-block-paragraph">Well naturally I had to take that source code, and make it more C89 happy!</p>



<p class="wp-block-paragraph">I found this magical sed recipe over on <a href="https://stackoverflow.com/questions/4000017/changing-comments-from-c-style-to-c-style" target="_blank" rel="noreferrer noopener">stack overflow</a>:</p>



<pre class="wp-block-code"><code>  sed -e 'sX// *\(.*&#91;^ ]\) *$X/* \1 */X' &lt; oldfile > newfile </code></pre>



<p class="wp-block-paragraph">Thanks <a href="https://stackoverflow.com/users/4047753/preston-crow" target="_blank" rel="noreferrer noopener">Preston Crow</a>!</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="640" height="480" src="https://virtuallyfun.com/wp-content/uploads/2025/01/llamma-2-89-on-os2-6.78.png" alt="" class="wp-image-15085" srcset="https://virtuallyfun.com/wp-content/uploads/2025/01/llamma-2-89-on-os2-6.78.png 640w, https://virtuallyfun.com/wp-content/uploads/2025/01/llamma-2-89-on-os2-6.78-300x225.png 300w, https://virtuallyfun.com/wp-content/uploads/2025/01/llamma-2-89-on-os2-6.78-400x300.png 400w" sizes="auto, (max-width: 640px) 100vw, 640px" /><figcaption class="wp-element-caption">llamma 89 on OS/2 6.78</figcaption></figure>



<p class="wp-block-paragraph">So, with some really minor hacking, and my <a href="https://virtuallyfun.com/2024/02/10/porting-gcc-to-32bit-os-2/" target="_blank" rel="noreferrer noopener">port of GCC 1.40 to OS/2</a>, I was shockingly up and running in no time!  I should add again that I do kind of enjoy the much older GCC since it was capable of being built with &#8216;vendor&#8217; tools, in this case the <a href="https://virtuallyfun.com/2024/01/08/so-it-turns-out-gcc-could-have-been-available-on-windows-nt-the-entire-time/" target="_blank" rel="noreferrer noopener">December 1991 Windows NT pre-release C compiler</a>.</p>



<p class="wp-block-paragraph">I didn&#8217;t bother &#8216;fixing&#8217; the timing code, as honestly it doesn&#8217;t matter, running this on my PS/2 Model 60 with the SLC50 upgrade card is incredibly slow.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="768" src="https://virtuallyfun.com/wp-content/uploads/2025/01/3-hours-on-my-ps2-model-60-1024x768.jpg" alt="" class="wp-image-15087" srcset="https://virtuallyfun.com/wp-content/uploads/2025/01/3-hours-on-my-ps2-model-60-1024x768.jpg 1024w, https://virtuallyfun.com/wp-content/uploads/2025/01/3-hours-on-my-ps2-model-60-300x225.jpg 300w, https://virtuallyfun.com/wp-content/uploads/2025/01/3-hours-on-my-ps2-model-60-768x576.jpg 768w, https://virtuallyfun.com/wp-content/uploads/2025/01/3-hours-on-my-ps2-model-60-1536x1152.jpg 1536w, https://virtuallyfun.com/wp-content/uploads/2025/01/3-hours-on-my-ps2-model-60-2048x1536.jpg 2048w, https://virtuallyfun.com/wp-content/uploads/2025/01/3-hours-on-my-ps2-model-60-400x300.jpg 400w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">Seriously, this is me running the llama for 3 hours!</figcaption></figure>



<p class="wp-block-paragraph">At best it&#8217;s about a word every two minutes, getting this far was over 3 hours of runtime.</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Running LLAMA-2 on my PS/2!" width="584" height="329" src="https://www.youtube.com/embed/BFH7wLBKRV4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">I have a feeling much like MP3, where the ideas are significantly older than when they found mainstream success, there is a lesson here to the impatient ones, that just because something doesn&#8217;t work today, or seem incredibly unwieldy, it doesn&#8217;t mean decades later it&#8217;ll be incredibly popular.</p>



<p class="wp-block-paragraph">For anyone wondering, I also built one that uses the TNT extender, and it seems to require 4MB of RAM.  Absolute beast of a 32bit machine for 1987, but here we are.</p>



<p class="wp-block-paragraph">So yeah, Happy 2025!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://virtuallyfun.com/2025/01/02/happy-2025/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Compiling Linux 0.11 using the December 1991 Windows NT Pre-release</title>
		<link>https://virtuallyfun.com/2024/08/02/compiling-linux-0-11-using-the-december-1991-windows-nt-pre-release/</link>
					<comments>https://virtuallyfun.com/2024/08/02/compiling-linux-0-11-using-the-december-1991-windows-nt-pre-release/#respond</comments>
		
		<dc:creator><![CDATA[neozeed]]></dc:creator>
		<pubDate>Fri, 02 Aug 2024 12:13:21 +0000</pubDate>
				<category><![CDATA[cross compiler]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows NT 3.1]]></category>
		<guid isPermaLink="false">https://virtuallyfun.com/?p=14730</guid>

					<description><![CDATA[It&#8217;s no secret that I do enjoy building silly &#8220;what if&#8221; things. And this is going to be one of the more impractical ones. Building on previous work, where I had built GCC 1.40 using the OS/2 hosted Microsoft C &#8230; <a href="https://virtuallyfun.com/2024/08/02/compiling-linux-0-11-using-the-december-1991-windows-nt-pre-release/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">It&#8217;s no secret that I do enjoy building silly &#8220;what if&#8221; things.  And this is going to be one of the more impractical ones.</p>



<p class="wp-block-paragraph">Building on previous work, where <a href="https://virtuallyfun.com/2024/01/08/so-it-turns-out-gcc-could-have-been-available-on-windows-nt-the-entire-time/" target="_blank" rel="noreferrer noopener">I had built GCC 1.40 using the OS/2 hosted Microsoft C compiler</a> that shipped with this Pre-Release, and using <a href="https://virtuallyfun.com/2015/10/09/building-linux-0-11-on-windows-10/" target="_blank" rel="noreferrer noopener">MinGW to build Linux 0.11</a>, it was time to combine the two, like chocolate &amp; peanut butter!</p>



<figure class="wp-block-video"><video height="480" style="aspect-ratio: 854 / 480;" width="854" controls src="https://virtuallyfun.com/wp-content/uploads/2024/08/combo.mp4"></video><figcaption class="wp-element-caption">Yes, it&#8217;s from 1981.  I&#8217;m that old to remember this.</figcaption></figure>



<h2 class="wp-block-heading">Getting NT ready</h2>



<p class="wp-block-paragraph">The first thing I wanted was to install the Pre-Release onto a HPFS disk.  I&#8217;ve uploaded this over on <a href="https://archive.org/details/dec-1991-prepped.7z" target="_blank" rel="noreferrer noopener">archive.org (Windows NT December 1991 prepped for Qemu<span style="color: rgb(44, 44, 44); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 14px; white-space-collapse: collapse;"></span>)</a>.  I took the CD-ROM image, removed all the MIPS stuff, built a boot floppy, and setup the paths so that the floppy can boot onto the secondary hard disk to a &#8216;full&#8217; version of NT.  This lets me format the C: drive as HPFS, and then do a selective install of Windows NT to ensure that that the software tools (compiler) are installed.</p>



<p class="wp-block-paragraph">I use a specially patched vintage QEMU build, <a href="https://archive.org/download/dec-1991-prepped.7z/qemu-0.14.0.7z" target="_blank" rel="noreferrer noopener">qemu-0.14.0.7z</a> which kind of makes it &#8216;easier&#8217;, along with the needed disk images in <a href="https://archive.org/download/dec-1991-prepped.7z/dec-1991-prepped.7z">dec-1991-prepped.7z</a></p>



<pre class="wp-block-code"><code>qemu.exe -L pc-bios -m 64 -net none -hda nt1991.vmdk -hdb nt1991-cd.vmdk -fda boot.vfd -boot a</code></pre>



<p class="wp-block-paragraph">This will bring up the boot selection menu.  The default option is fine, you can just hit enter.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="722" height="432" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-01.png" alt="" class="wp-image-14732" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-01.png 722w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-01-300x180.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-01-500x300.png 500w" sizes="auto, (max-width: 722px) 100vw, 722px" /><figcaption class="wp-element-caption">boot NT from D:</figcaption></figure>



<p class="wp-block-paragraph">NT will load up and you now have to login as the SYSTEM user.  We need the advanced permissions to format the hard disk.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-02.png" alt="" class="wp-image-14733" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-02.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-02-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-02-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /><figcaption class="wp-element-caption">Login as &#8216;system&#8217;</figcaption></figure>



<p class="wp-block-paragraph">From the desktop we first format the C: drive as HPFS.  I made icons for all this stuff to try to make it as easy as possible.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-03.png" alt="" class="wp-image-14742" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-03.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-03-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-03-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /></figure>



<p class="wp-block-paragraph">You&#8217;ll get asked to confirm you want to do this, and give the disk a creative name.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-04.png" alt="" class="wp-image-14741" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-04.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-04-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-04-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /></figure>



<p class="wp-block-paragraph">And with the disk formatted it&#8217;s time to start the setup process.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-05.png" alt="" class="wp-image-14740" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-05.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-05-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-05-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /></figure>



<p class="wp-block-paragraph">Who are you?</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-06.png" alt="" class="wp-image-14739" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-06.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-06-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-06-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /></figure>



<p class="wp-block-paragraph">And what slick account do you want?  It doesn&#8217;t matter tbh.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-07.png" alt="" class="wp-image-14738" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-07.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-07-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-07-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /></figure>



<p class="wp-block-paragraph">I&#8217;m going to do a custom install as the NIC&#8217;s aren&#8217;t supported, and even if they were it&#8217;s just NetBEUI anyways.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-08.png" alt="" class="wp-image-14737" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-08.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-08-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-08-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /></figure>



<p class="wp-block-paragraph">And select your hardware platform.  NT basically only supports this config, so it doesn&#8217;t matter.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-09.png" alt="" class="wp-image-14736" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-09.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-09-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-09-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /></figure>



<p class="wp-block-paragraph">The default target drive is our C drive, which we had just formatted to HPFS.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-10.png" alt="" class="wp-image-14735" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-10.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-10-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-10-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /></figure>



<p class="wp-block-paragraph">Next, I unchecked everything only leaving the MS Tools</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-11.png" alt="" class="wp-image-14734" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-11.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-11-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-11-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /></figure>



<p class="wp-block-paragraph">It&#8217;ll offer the samples &amp; help files.  I always install them as I eventually need examples of stuff to steal, and to learn that including &lt;windows.h> won&#8217;t work right unless you manually define a -Di386 on the command line.  I&#8217;m saving you this pain right now up front.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-12.png" alt="" class="wp-image-14745" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-12.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-12-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-12-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /></figure>



<p class="wp-block-paragraph">Files will copy, and on a modern machine this takes seconds.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-13.png" alt="" class="wp-image-14744" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-13.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-13-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-13-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /></figure>



<p class="wp-block-paragraph">And there we go!</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-14.png" alt="" class="wp-image-14743" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-14.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-14-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-14-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /></figure>



<p class="wp-block-paragraph">And Windows NT is installed.</p>



<p class="wp-block-paragraph">Yay.</p>



<p class="wp-block-paragraph">I put in a &#8216;CAD&#8217; feature in this Qemu hitting control+alt+d will send the familiar pattern, and after a few times NT will reboot.  We are pretty much done with NT for the moment, but congrats you&#8217;ve installed the December 1991 Pre-release onto a HPFS disk for those sweet long long file names!</p>



<h2 class="wp-block-heading">Going over the strategy:</h2>



<p class="wp-block-paragraph">I&#8217;ve already built GCC 1.40 for NT, so what is the rest of the stuff needed to build Linux?  It&#8217;s a quick checklist but here goes, in no specific order:</p>



<ul class="wp-block-list">
<li><s>GCC 1.40</s></li>



<li>bin86</li>



<li>binutils</li>



<li><s>gas 1.38</s></li>



<li>bison</li>



<li>unzip</li>



<li>zip</li>
</ul>



<p class="wp-block-paragraph">Luckily as part of building on Windows 10 using MinGW, I had fixed the weird file issues as MS-DOS/Windows NT/OS2 handle text/binary files, as we went through with how <a href="https://virtuallyfun.com/2024/04/28/compiling-ms-dos-4-0-from-dos-4-0-on-a-ps-2/" target="_blank" rel="noreferrer noopener">Github mangled MS-DOS 4.00</a>.</p>



<p class="wp-block-paragraph">The primary reason I wanted a working zip/unzip was to deal with long file names, and to auto convert text files.  And this ended up being an incredible waste of time trying to get the &#8216;old&#8217;s code on the Info-Zip page.</p>



<figure class="wp-block-image size-large"><a href="https://sourceforge.net/projects/infozip/files/UnZip%205.x%20and%20earlier/" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="1024" height="418" src="https://virtuallyfun.com/wp-content/uploads/2024/08/infozip-old-downloads-1024x418.jpg" alt="" class="wp-image-14748" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/infozip-old-downloads-1024x418.jpg 1024w, https://virtuallyfun.com/wp-content/uploads/2024/08/infozip-old-downloads-300x123.jpg 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/infozip-old-downloads-768x314.jpg 768w, https://virtuallyfun.com/wp-content/uploads/2024/08/infozip-old-downloads-500x204.jpg 500w, https://virtuallyfun.com/wp-content/uploads/2024/08/infozip-old-downloads.jpg 1119w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a><figcaption class="wp-element-caption">Info-Zip&#8217;s old downloads. Version 5 only!</figcaption></figure>



<p class="wp-block-paragraph">I&#8217;m sure like everything else, the old versions are removed as they probably suffer from some catastrophic security issue with overflows.  The issue I ran into is that the version 5 stuff uses so many features of shipping NT, to even 2000 that it was going to be a LOT of work to get this far.  The quicker &amp; easier path as always turned out to be a time machine.</p>



<p class="wp-block-paragraph">Thankfully, since I had made a copy of the UTZOO archives, I was able to fish out, both <a href="https://github.com/neozeed/Info-Zip-3.1" target="_blank" rel="noreferrer noopener">version 3.1</a> from the archives.  Also known as &#8220;Portable UnZIP 3.1&#8221;, parts <a href="https://altavista.superglobalmegacorp.com/usenet/b181/comp/sources/misc/1833.txt" target="_blank" rel="noreferrer noopener">1</a>/<a href="https://altavista.superglobalmegacorp.com/usenet/b181/comp/sources/misc/1834.txt" target="_blank" rel="noreferrer noopener">2</a>/<a href="https://altavista.superglobalmegacorp.com/usenet/b181/comp/sources/misc/1835.txt" target="_blank" rel="noreferrer noopener">3</a>.  I also found <a href="https://github.com/neozeed/Info-Zip-4.1" target="_blank" rel="noreferrer noopener">version 4.1</a> as well.  And people wonder why you want to save these &#8216;huge&#8217; data sets. If the lawyers could have their way, they would obliterate all history.</p>



<p class="wp-block-paragraph">I spent a lot of time messing with Makefiles, as linking &amp; object conversion on old NT is a big deal, and not the kind of thing you want to do more than once.  Another big pain is that large files become delete only.  I don&#8217;t know what the deal with notepad is, but I could remove text, but not change or add.  I solved that by wrapping a number of things by including it in another file with some #define work to go around it. Needless to say, that sucked.</p>



<p class="wp-block-paragraph">One thing that constantly threw issues is that this version of Windows doesn&#8217;t handle Unix style signals.  I removed all the signal catch/throw stuff, and the binaries ran fine.  Why on earth does &#8216;strip&#8217; need signals is beyond me, but it runs fine without them!</p>



<h2 class="wp-block-heading">Bringing it together.</h2>



<p class="wp-block-paragraph">From my &#8220;<a href="https://archive.org/details/linux-0.11-compile-ntdec1991-bins" target="_blank" rel="noreferrer noopener">Build artifacts from Building Linux 0.11 on Windows NT build 239, December 1991</a>&#8221; page, grab the two files, <a href="https://archive.org/download/linux-0.11-compile-ntdec1991-bins/bin.zip" target="_blank" rel="noreferrer noopener">bin.zip</a> &amp; <a href="https://archive.org/download/linux-0.11-compile-ntdec1991-bins/source0.zip" target="_blank" rel="noreferrer noopener">source0.zip</a>.</p>



<p class="wp-block-paragraph">On Windows I just unzip the bin.zip file and leave source.0.zip intact into a directly say something like temp.  Then I can use a cool feature of Qemu where it can mount a directory as a read-only FAT disk.  This saves a lot of time!</p>



<p class="wp-block-paragraph">Running Qemu like this:</p>



<pre class="wp-block-code"><code>qemu.exe -L pc-bios -m 64 -net none -hda nt1991.vmdk -hdb fat:temp -fda boot.vfd</code></pre>



<p class="wp-block-paragraph">Will drop to the bootloader. Hit enter to login, and you&#8217;ll be at the desktop.  Hit enter again, and open a command prompt.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-15.png" alt="" class="wp-image-14750" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-15.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-15-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-15-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /><figcaption class="wp-element-caption">open the command prompt</figcaption></figure>



<p class="wp-block-paragraph">By default, the Numlock is messing with the arrow keys (I think it&#8217;s mapping to the old 83 key keyboard no matter what?)  Hit num-lock and your arrow keys should kind of work.  It&#8217;s a great time saver.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-16b.png" alt="" class="wp-image-14752" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-16b.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-16b-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-16b-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /><figcaption class="wp-element-caption">copy the binaries to \bin &amp; get ready to unzip</figcaption></figure>



<p class="wp-block-paragraph">I copied the binaries &amp; the ygcc.cmd file into the \bin directory, created a \proj directory and get ready to unzip all the source code.  For some reason this version of unzip doesn&#8217;t understand the zip compression, so it&#8217;s just storing instead, much like TAR.  It&#8217;s not that involved but unzip with the -d flag so it creates directories as needed.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-17.png" alt="" class="wp-image-14753" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-17.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-17-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-17-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /><figcaption class="wp-element-caption">unzipped</figcaption></figure>



<p class="wp-block-paragraph">This will let us keep long file names.  HPFS is case insensitive, but it also preserves the case, so don&#8217;t worry about the names being all weird.  It doesn&#8217;t matter.</p>



<p class="wp-block-paragraph">One thing worth mentioning is that even though the C pre-processor does compile it just hangs when trying to run it.  I&#8217;m not sure what is wrong exactly, but it&#8217;s just not worth fighting.  Instead, I had the better idea, of using the Microsoft C compiler to pre-process the source.  Apparently, this is how they originally built Windows NT, pre-processing on OS/2, then uploading the pre-processed files to a SUN workstation with the i860 compiler and downloading the objects to be converted &amp; linked.  Wow that must have been tedious!</p>



<p class="wp-block-paragraph">I created a CMD file &#8216;ygcc.cmd&#8217; to run the cl386 pre-processor, call CC1 &amp; GAS and clean up afterwards.</p>



<pre class="wp-block-code"><code>cl386 -nologo /u /EP -I\include -D__GNUC__ -Dunix -Di386 -D__unix__ -D__i386__ -D__OPTIMIZE__ %2 > \tmp\xxx.cpp
\bin\cc1 -version -quiet -O -fstrength-reduce -fomit-frame-pointer -fcombine-regs -o /tmp/xxx.s /tmp/xxx.cpp
\bin\ax386 -v -o %1 /tmp/xxx.s
@del \tmp\xxx.s
@del \tmp\xxx.cpp</code></pre>



<p class="wp-block-paragraph">It&#8217;s not pretty but it works!</p>



<h2 class="wp-block-heading">Building</h2>



<p class="wp-block-paragraph">Before you can build Linux, you need to create both a \tmp &amp; \temp directory.  Also the include files need to be copied to the \include directory to make the pre-processor happier.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-18b.png" alt="" class="wp-image-14755" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-18b.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-18b-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-18b-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /></figure>



<p class="wp-block-paragraph">I&#8217;ve tried to make this as simple as possible there is a &#8216;blind.cmd&#8217; file which I built that&#8217;ll manually compile Linux.  There is no error checking.</p>



<p class="wp-block-paragraph">And saving everyone the excitement here is an animation of the build process</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="480" height="357" src="https://virtuallyfun.com/wp-content/uploads/2024/08/build-linux011-ntdec1991.gif" alt="" class="wp-image-14749"/><figcaption class="wp-element-caption">Actually compiling Linux</figcaption></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="512" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-19.png" alt="" class="wp-image-14756" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-19.png 642w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-19-300x239.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-19-376x300.png 376w" sizes="auto, (max-width: 642px) 100vw, 642px" /><figcaption class="wp-element-caption">compiled!</figcaption></figure>



<p class="wp-block-paragraph">And there we go! All compiled!</p>



<p class="wp-block-paragraph">From there it&#8217;s a matter of copying the Image file out of the VM, I used the boot floppy and 7zip&#8217;s ability to extract FAT images, and then boot up Qemu using the Image file as a &#8216;floppy&#8217; as back in the day we used to rawrite these to floppy disks. </p>



<pre class="wp-block-code"><code>qemu.exe -L pc-bios -m 64 -net none -hda nt1991.vmdk -hdb fat:temp -fda boot\IMAGE -boot a</code></pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="722" height="432" src="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-20.png" alt="" class="wp-image-14757" srcset="https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-20.png 722w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-20-300x180.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/08/install-patched-1991-20-500x300.png 500w" sizes="auto, (max-width: 722px) 100vw, 722px" /><figcaption class="wp-element-caption">And there we go, Linux 0.11 booted!</figcaption></figure>



<p class="wp-block-paragraph">I don&#8217;t have a root filesystem, so the panic is expected, but yes, we just cross compiled Linux from Windows NT, circa 1991!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://virtuallyfun.com/2024/08/02/compiling-linux-0-11-using-the-december-1991-windows-nt-pre-release/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		<enclosure url="https://virtuallyfun.com/wp-content/uploads/2024/08/combo.mp4" length="1485267" type="video/mp4" />

			</item>
		<item>
		<title>DooM, GCC &#038; AI</title>
		<link>https://virtuallyfun.com/2024/05/30/doom-gcc-ai/</link>
					<comments>https://virtuallyfun.com/2024/05/30/doom-gcc-ai/#respond</comments>
		
		<dc:creator><![CDATA[neozeed]]></dc:creator>
		<pubDate>Thu, 30 May 2024 10:01:27 +0000</pubDate>
				<category><![CDATA[doom]]></category>
		<category><![CDATA[gcc]]></category>
		<guid isPermaLink="false">https://virtuallyfun.com/?p=14461</guid>

					<description><![CDATA[Using AI to get a working fixed point math routine that was far too hard for my small brain. <a href="https://virtuallyfun.com/2024/05/30/doom-gcc-ai/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">One of the things that always annoyed me about DooM is the fixed point math.  It relies on a 64bit data type, which many 32bit platform just lack.  Namely the <a href="https://github.com/neozeed/doomnew-for-dos/blob/b3f75f29d4911d6ee51facfa7a10f4ef6ea92942/m_fixed.c#L44" target="_blank" rel="noreferrer noopener">FixedMul</a> &amp; <a href="https://github.com/neozeed/doomnew-for-dos/blob/b3f75f29d4911d6ee51facfa7a10f4ef6ea92942/m_fixed.c#L58" target="_blank" rel="noreferrer noopener">FixedDiv</a>. </p>



<pre class="wp-block-code"><code>fixed_t FixedMul
( fixed_t a,
fixed_t b )
{
return ((long long) a * (long long) b) &gt;&gt; FRACBITS;
}</code></pre>



<p class="wp-block-paragraph"> They are generally re-written into assembly, at least for the i386 getting around the whole 64bit on a 32bit platform.</p>



<pre class="wp-block-code"><code>FixedMul:	
	pushl %ebp
	movl %esp,%ebp
	movl 8(%ebp),%eax
	imull 12(%ebp)
	shrdl $16,%edx,%eax
	popl %ebp
	ret

FixedDiv2:
	pushl %ebp
	movl %esp,%ebp
	movl 8(%ebp),%eax
	cdq
	shldl $16,%eax,%edx
	sall	$16,%eax
	idivl	12(%ebp)
	popl %ebp
	ret</code></pre>



<p class="wp-block-paragraph">So that&#8217;d always been the &#8216;catch&#8217; when porting Doom is that you either need a &#8216;long long&#8217; data type, or the custom assembly or you basically are out of luck. </p>



<p class="wp-block-paragraph">I know I&#8217;m a weird person, but I do like going backwards in terms of software, while most people want latest GCC 14 targeting old machines or some other hack, I prefer the opposite, trying to get the oldest stuff running on something new(er).  In this case, it&#8217;s GCC 1.27.</p>



<p class="wp-block-paragraph">While much of the old GCC history is lost, I did my best to collect as many versions as I could find here, along with doing patches in reverse to &#8216;reconstruct&#8217; many old versions.  <a href="https://archive.org/download/oldgcc1x" target="_blank" rel="noreferrer noopener">The results are on archive.org</a>. And what is significant from this, is the first version of GCC with i386 support appears in version 1.27.</p>



<p class="wp-block-paragraph">From the internals-1 file we can find out that we all have William Schelter to thank for doing the bulk of the 386 port of GCC.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">William Schelter did most of the work on the Intel 80386 support.</p>
<cite>Internals-1 &#8211; gcc 1.27</cite></blockquote>



<p class="wp-block-paragraph">With the first commit being on May 29th, 1988:</p>



<pre class="wp-block-preformatted">Sun May 29 00:20:23 1988 Richard Stallman (rms at sugar-bombs.ai.mit.edu)<br>...<br>	* tm-att386.h: New file.</pre>



<h2 class="wp-block-heading">GCC 1.25</h2>



<p class="wp-block-paragraph">The first GCC with i386 parts is 1.25, however it tends to emit the instruction movsbl, which GAS doesn&#8217;t like.  Comparing the output to GCC 1.40 reveals this:</p>



<pre class="wp-block-code"><code>-	movsbl -12(%ebp),%ax
+	movsbw -12(%ebp),%ax</code></pre>



<p class="wp-block-paragraph">It&#8217;s trivial enough to change to a movsbw, but there are some other issues going on, and even the Infocom &#8217;87 interpreter won&#8217;t fully build &amp; run.  The files input.c &amp; print.c have to be built with a later version of GCC, in this case I used GCC 1.40.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="577" src="https://virtuallyfun.com/wp-content/uploads/2024/06/infocom-87-mostly-built-with-gcc-125-1024x577.png" alt="" class="wp-image-14485" srcset="https://virtuallyfun.com/wp-content/uploads/2024/06/infocom-87-mostly-built-with-gcc-125-1024x577.png 1024w, https://virtuallyfun.com/wp-content/uploads/2024/06/infocom-87-mostly-built-with-gcc-125-300x169.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/06/infocom-87-mostly-built-with-gcc-125-768x433.png 768w, https://virtuallyfun.com/wp-content/uploads/2024/06/infocom-87-mostly-built-with-gcc-125-500x282.png 500w, https://virtuallyfun.com/wp-content/uploads/2024/06/infocom-87-mostly-built-with-gcc-125.png 1115w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">8&amp;% compiled with GCC 1.25!</figcaption></figure>



<p class="wp-block-paragraph">However when using the old XenixNT build thing I did, I do get a runnable EXE! </p>



<figure class="wp-block-image size-large"><a href="https://archive.org/details/gcc-1.25-i386" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="1024" height="577" src="https://virtuallyfun.com/wp-content/uploads/2024/05/gcc-1.25-i386-v2-1024x577.png" alt="" class="wp-image-14463" srcset="https://virtuallyfun.com/wp-content/uploads/2024/05/gcc-1.25-i386-v2-1024x577.png 1024w, https://virtuallyfun.com/wp-content/uploads/2024/05/gcc-1.25-i386-v2-300x169.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/05/gcc-1.25-i386-v2-768x433.png 768w, https://virtuallyfun.com/wp-content/uploads/2024/05/gcc-1.25-i386-v2-500x282.png 500w, https://virtuallyfun.com/wp-content/uploads/2024/05/gcc-1.25-i386-v2.png 1115w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a><figcaption class="wp-element-caption">GCC 1.25 targeting DJGPP v1</figcaption></figure>



<p class="wp-block-paragraph">I added the BSD targeting files from 1.27 allowing it to generate the needed underscores in the right places, as 1.25 by default only supports AT&amp;T syntax.  I guess the best way to illustrate it is to compile the compiler twice, once as the AT&amp;T compiler, and the next being the BSD compiler, and compare their output:</p>



<pre class="wp-block-code"><code>cc1-att.exe hi.cpp -quiet -dumpbase hi.c -version -o hi-att.s
GNU C version 1.25 (80386, ATT syntax) compiled by GNU C version 4.8.1.

.text
.LC0:
        .byte 0x31,0x2e,0x32,0x35,0x0
.LC1:
        .byte 0x68,0x65,0x6c,0x6c,0x6f,0x20,0x66,0x72,0x6f,0x6d
        .byte 0x20,0x25,0x73,0xa,0x0
        .align 2
.globl main
main:
        pushl %ebp
        movl %esp,%ebp
        pushl $.LC0
        pushl $.LC1
        call printf
.L1:
        leave
        ret</code></pre>



<p class="wp-block-paragraph">And then looking at the BSD syntax:</p>



<pre class="wp-block-code"><code>cc1-bsd.exe hi.cpp -quiet -dumpbase hi.c -version -o hi-bsd.s
GNU C version 1.25 (80386, BSD syntax) compiled by GNU C version 4.8.1.

        .file   "hi.c"
.text
LC0:
        .byte 0x31,0x2e,0x32,0x35,0x0
LC1:
        .byte 0x68,0x65,0x6c,0x6c,0x6f,0x20,0x66,0x72,0x6f,0x6d
        .byte 0x20,0x25,0x73,0xa,0x0
        .align 1
.globl _main
_main:
        pushl %ebp
        movl %esp,%ebp
        pushl $LC0
        pushl $LC1
        call _printf
L1:
        leave
        ret</code></pre>



<p class="wp-block-paragraph">As you can see main: becomes _main:, just as labels (LC0/LC1) have a prepended, while in BSD they do not.  There are no doubt countless other nuanced differences, but for the assembler &amp; operating system to match you want these to align.  Thankfully calling conventions are mostly the same per processor so you can add the underscores to the AT&amp;T target and get something that&#8217;ll run, not only on DJGPP but also Win32, as MinGW32 uses BSD syntax at its heart!</p>



<pre class="wp-block-code"><code>C:\xdjgpp.v1\src\26&gt;gcc hi-bsd.s -o hi.exe

C:\xdjgpp.v1\src\26&gt;wsl file hi.exe
hi.exe: PE32 executable (console) Intel 80386, for MS Windows

C:\xdjgpp.v1\src\26&gt;hi
hello from 1.25</code></pre>



<p class="wp-block-paragraph">Not that we really need to go all the way and have GCC 1.25 running on anything much, although at the same time it&#8217;s kind of fun!</p>



<h2 class="wp-block-heading">Reaching out for help</h2>



<p class="wp-block-paragraph">The oldest &amp; most robust GCC is 1.27, and I&#8217;d been able to use that to build DooM before, but the caveat is of course the fixed point math.  I&#8217;d asked smarter people than I years ago about this problem, and basically was told to figure it out for myself.  After all its &#8216;trivial&#8217;.  But alas, I&#8217;m not smart.  What I would do is build the fixed point math with GCC and try to re-work that into other compilers, although again for platforms without GCC or the target CPU lacking the 64bit data type is well.. fatal.</p>



<p class="wp-block-paragraph">But AI, sadly for it, is compelled to help.  So I just went ahead and asked and got a surprising result!</p>



<figure class="wp-block-image size-full"><a href="https://virtuallyfun.com/wp-content/uploads/2024/05/sydney-long-long-fixed-point.png" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="787" height="711" src="https://virtuallyfun.com/wp-content/uploads/2024/05/sydney-long-long-fixed-point.png" alt="" class="wp-image-14465" srcset="https://virtuallyfun.com/wp-content/uploads/2024/05/sydney-long-long-fixed-point.png 787w, https://virtuallyfun.com/wp-content/uploads/2024/05/sydney-long-long-fixed-point-300x271.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/05/sydney-long-long-fixed-point-768x694.png 768w, https://virtuallyfun.com/wp-content/uploads/2024/05/sydney-long-long-fixed-point-332x300.png 332w" sizes="auto, (max-width: 787px) 100vw, 787px" /></a><figcaption class="wp-element-caption">Sydney strikes back!</figcaption></figure>



<p class="wp-block-paragraph">It&#8217;s very C++ like but it&#8217;s trivial enough to make it into old C.</p>



<figure class="wp-block-image size-full is-resized"><a href="https://virtuallyfun.com/wp-content/uploads/2024/05/doom-sydney-fixed.gif"><img loading="lazy" decoding="async" width="240" height="151" src="https://virtuallyfun.com/wp-content/uploads/2024/05/doom-sydney-fixed.gif" alt="" class="wp-image-14466" style="width:633px;height:auto"/></a><figcaption class="wp-element-caption">Sydney&#8217;s fixed-point guess</figcaption></figure>



<p class="wp-block-paragraph">Well on the one hand it does actually load up and play.  But the controls go wild and I&#8217;m pulled into the intersection of these boxes, and unable to move.  And as I rotate the floor and walls clip in and out.  It&#8217;s very weird.</p>



<p class="wp-block-paragraph">Not knowing anything about anything, I saw this &#8216;guard&#8217; on the fixed division and tried to add that to the multiply:</p>



<pre class="wp-block-code"><code>	if ( (abs(a)&gt;&gt;14) &gt;= abs(b))
		return (a^b)&lt;0 ? MININT : MAXINT;</code></pre>



<p class="wp-block-paragraph">And I got something even weirder!</p>



<figure class="wp-block-image size-full is-resized"><a href="https://virtuallyfun.com/wp-content/uploads/2024/05/doom-sydney-fixed-abs.gif"><img loading="lazy" decoding="async" width="240" height="151" src="https://virtuallyfun.com/wp-content/uploads/2024/05/doom-sydney-fixed-abs.gif" alt="" class="wp-image-14467" style="width:628px;height:auto"/></a><figcaption class="wp-element-caption">Now with absolute guards!</figcaption></figure>



<p class="wp-block-paragraph">Not only that but the engine crashes!  Not good.</p>



<p class="wp-block-paragraph">After thinking about it on and off, asking for more help and going nowhere, I just gave up.  It&#8217;s something beyond my skill, and apparently the AI as well.  Until I had one of those moments in a dream where I had somehow told myself I bet the integers are not unsigned, and obviously fixed-point math needs all the bits, and it&#8217;s such a trivial fix, that even I should have figured it out.</p>



<p class="wp-block-paragraph">I woke up at 4am and fired up the computer to see if it did anything.  I was surprised to see that yes, in fact the integers were signed.  I added the one key word, and recompiled using GCC 2.2:</p>



<figure class="wp-block-image size-full is-resized"><a href="https://virtuallyfun.com/wp-content/uploads/2024/05/doom-sydney-fixed_unsigned.gif"><img loading="lazy" decoding="async" width="240" height="151" src="https://virtuallyfun.com/wp-content/uploads/2024/05/doom-sydney-fixed_unsigned.gif" alt="" class="wp-image-14469" style="width:631px;height:auto"/></a><figcaption class="wp-element-caption">Now with unsigned integers</figcaption></figure>



<p class="wp-block-paragraph">And it RAN!  I tried GCC 1.39, and too ran!  I then made sure there was no assembly modules being called accidentally, and then re-built with GCC 1.27, and yeah, it <em>runs</em>!</p>



<p class="wp-block-paragraph">Armed with a simple port of DooM to Win32, I went ahead and put in the fixed-point solution, and used Visual C++ 1.10 aka Microsoft C/C++ 8.0 to build DooM, and yes it works there too!</p>



<p class="wp-block-paragraph">In the end I guarded it around a long long type, as I&#8217;m sure it&#8217;s much more faster, but for those without the types or any assembly skill, here is the solution:</p>



<pre class="wp-block-code"><code>/* Fixme. __USE_C_FIXED__ or something. */
fixed_t
FixedMul
        ( fixed_t a,
        fixed_t b )
{
#ifdef HAVE_LONG_LONG
    return ((long long) a * (long long) b) &gt;&gt; FRACBITS;
#else
    unsigned int ah,al,bh,bl,result;

    ah = (a &gt;&gt; FRACBITS);
    al = (a &amp; (FRACUNIT-1));
    bh = (b &gt;&gt; FRACBITS);
    bl = (b &amp; (FRACUNIT-1));

    /* Multiply the parts separately    */
    result = (ah * bh) &lt;&lt; FRACBITS;     /* High*High    */
    result += ah * bl;                  /* High*Low     */
    result += al * bh;                  /* Low*High     */
    /* Low*Low part doesn't need to be calculated because it doesn't contribute to the result after shifting

    // Shift right by FRACBITS to get the fixed-point result                                            */
    result += (al * bl) &gt;&gt; FRACBITS;

    return (fixed_t)result;
#endif
}

/* */
/* FixedDiv, C version. */
/* */
fixed_t
FixedDiv2
        ( fixed_t a,
        fixed_t b )
{
#ifdef HAVE_LONG_LONG
        long long c;
        c = ((long long)a&lt;&lt;16) / ((long long)b);
        return (fixed_t) c;
#else
        double c;

        c = ((double)a) / ((double)b) * FRACUNIT;

        if (c &gt;= 2147483648.0 || c &lt; -2147483648.0)
                I_Error("FixedDiv: divide by zero");
        return (fixed_t) c;
#endif
}

fixed_t
FixedDiv
        ( fixed_t a,
        fixed_t b )
{
        if ( (abs(a)&gt;&gt;14) &gt;= abs(b))
                return (a^b)&lt;0 ? MININT : MAXINT;
        return FixedDiv2 (a,b);
}</code></pre>



<p class="wp-block-paragraph">I haven&#8217;t tested it on Big Endian machines yet.  I&#8217;ve updated my <a href="https://sourceforge.net/p/crossdjgppv1/DooM/ci/master/tree/" target="_blank" rel="noreferrer noopener">terrible DooM engine port</a>, along with <a href="https://github.com/neozeed/doomnew-for-dos" target="_blank" rel="noreferrer noopener">Doom-New for DOS</a>.   Additionally, I&#8217;ve been able to confirm it works with Watcom 9-OpenWatcom 2.  It might even work with 7 &amp; 8 but I haven&#8217;t tried.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://virtuallyfun.com/2024/05/30/doom-gcc-ai/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Thunking for fun &#038; a lack of profit</title>
		<link>https://virtuallyfun.com/2024/02/19/thunking-for-fun-a-lack-of-profit/</link>
					<comments>https://virtuallyfun.com/2024/02/19/thunking-for-fun-a-lack-of-profit/#respond</comments>
		
		<dc:creator><![CDATA[neozeed]]></dc:creator>
		<pubDate>Mon, 19 Feb 2024 00:35:16 +0000</pubDate>
				<category><![CDATA[80386]]></category>
		<category><![CDATA[assembly]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[i386]]></category>
		<category><![CDATA[OS/2]]></category>
		<category><![CDATA[OS/2 2.0]]></category>
		<guid isPermaLink="false">https://virtuallyfun.com/?p=13988</guid>

					<description><![CDATA[So, with a renewed interest in OS/2 betas, I&#8217;d been getting stuff into the direction of doing some full screen video. I&#8217;d copied and pasted stuff before and gotten QuakeWorld running, and I was looking forward to this challenge. The &#8230; <a href="https://virtuallyfun.com/2024/02/19/thunking-for-fun-a-lack-of-profit/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">So, with a renewed interest in OS/2 betas, I&#8217;d been getting stuff into the direction of doing some full screen video.  I&#8217;d copied and pasted stuff before and gotten QuakeWorld running, and I was looking forward to this challenge.  The whole thing hinges on the VIO calls in OS/2 like VioScrLock, VioGetPhysBuf, VioScrUnLock etc etc.  I found a nifty sample program <a href="https://jeffpar.github.io/kbarchive/kb/059/Q59837/" target="_blank" rel="noreferrer noopener">Q59837</a> which shows how to map into the MDA card&#8217;s text RAM and clear it.</p>



<p class="wp-block-paragraph">It&#8217;s a 16bit program, but first I got it to run on EMX with just a few minor changes, like removing far pointers.  Great.  But I wanted to build it with my <a href="https://virtuallyfun.com/2024/02/11/targeting-os-2-with-visual-studio-2003/" target="_blank" rel="noreferrer noopener">cl386 experiments</a> and that went off the edge.  First there are some very slick macros, and Microsoft C just can&#8217;t deal with them.  Fine I&#8217;ll use <a href="https://virtuallyfun.com/2024/02/10/porting-gcc-to-32bit-os-2/" target="_blank" rel="noreferrer noopener">GCC</a>.  Then I had to get emximpl working so I could build an import library for VIO calls.  I exported the assembly from GCC, and mangled it enough to where I could link it with the old Microsoft linker, and things were looking good!  I could clear the video buffer on OS/2 2.00 GA.</p>



<p class="wp-block-paragraph">Now why was it working? What is a THUNK?  Well it turns out in the early OS/2 2.0 development, they were going to cut loose all the funky text mode video, keyboard &amp; mouse support and go all in on the graphical Presentation Manager.</p>



<figure class="wp-block-image size-full"><a href="/wp-content/uploads/2024/02/605-busy-desktop.png" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="797" height="593" src="/wp-content/uploads/2024/02/605-busy-desktop.png" alt="" class="wp-image-13992" srcset="https://virtuallyfun.com/wp-content/uploads/2024/02/605-busy-desktop.png 797w, https://virtuallyfun.com/wp-content/uploads/2024/02/605-busy-desktop-300x223.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/02/605-busy-desktop-768x571.png 768w, https://virtuallyfun.com/wp-content/uploads/2024/02/605-busy-desktop-403x300.png 403w" sizes="auto, (max-width: 797px) 100vw, 797px" /></a><figcaption class="wp-element-caption">Presentation Manager from OS/2 6.605</figcaption></figure>



<p class="wp-block-paragraph">Instead, they were going to leave that old stuff in the past, and 16bit only for keeping some backwards compatibility.  And the only way a 32bit program can use those old 16bit API&#8217;s for video/keyboard/mouse (etc) is to call from 32bit mode into 16bit mode, then copy that data out of 16bit mode into 32bit mode.  This round trip is called thunking, and well this sets up where it all goes wrong. </p>



<p class="wp-block-paragraph">Then I tried one of the earlier PM looking betas <a href="https://archive.org/details/os2-2.0-6.605" target="_blank" rel="noreferrer noopener">6.605</a>, and quickly it crashed!</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="887" height="292" src="/wp-content/uploads/2024/02/SYS_2070.png" alt="" class="wp-image-13989" srcset="https://virtuallyfun.com/wp-content/uploads/2024/02/SYS_2070.png 887w, https://virtuallyfun.com/wp-content/uploads/2024/02/SYS_2070-300x99.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/02/SYS_2070-768x253.png 768w, https://virtuallyfun.com/wp-content/uploads/2024/02/SYS_2070-500x165.png 500w" sizes="auto, (max-width: 887px) 100vw, 887px" /><figcaption class="wp-element-caption">SYS2070:</figcaption></figure>



<p class="wp-block-paragraph">Well this was weird.  Obviously, I wanted to display help</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="895" height="362" src="/wp-content/uploads/2024/02/SYS_2070_2.png" alt="" class="wp-image-13990" srcset="https://virtuallyfun.com/wp-content/uploads/2024/02/SYS_2070_2.png 895w, https://virtuallyfun.com/wp-content/uploads/2024/02/SYS_2070_2-300x121.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/02/SYS_2070_2-768x311.png 768w, https://virtuallyfun.com/wp-content/uploads/2024/02/SYS_2070_2-500x202.png 500w" sizes="auto, (max-width: 895px) 100vw, 895px" /><figcaption class="wp-element-caption">Explanation:</figcaption></figure>



<p class="wp-block-paragraph">This ended up being a long winded way of saying that there is missing calls from DOSCALL1.DLL.  Looking through all the EMX thunking code, I came to the <a href="https://github.com/neozeed/Q59837-mono/blob/main/thunk0.asm#L12" target="_blank" rel="noreferrer noopener">low level assembly</a>, that actually implemented the thunking.</p>



<pre class="wp-block-code"><code>EXTRN   DosFlatToSel:PROC
EXTRN   DosSelToFlat:PROC</code></pre>



<p class="wp-block-paragraph">After looking at the doscalls import library, sure enough they just don&#8217;t exist.  I did the most unspeakable thing and looked at the online help for guidance:</p>



<figure class="wp-block-image size-full"><a href="/wp-content/uploads/2024/02/no-vio.png" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="738" height="197" src="/wp-content/uploads/2024/02/no-vio.png" alt="" class="wp-image-13991" srcset="https://virtuallyfun.com/wp-content/uploads/2024/02/no-vio.png 738w, https://virtuallyfun.com/wp-content/uploads/2024/02/no-vio-300x80.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/02/no-vio-500x133.png 500w" sizes="auto, (max-width: 738px) 100vw, 738px" /></a><figcaption class="wp-element-caption">No VIO</figcaption></figure>



<p class="wp-block-paragraph">So it turns out that in the early beta phase, there was no support for any of the 16bit IO from 32bit mode.  There was no thunking at all.  You were actually expected to use Presentation Manager.</p>



<p class="wp-block-paragraph">YUCK</p>



<p class="wp-block-paragraph">For anyone crazy enough to care, I uploaded this onto github <a href="https://github.com/neozeed/Q59837-mono/" target="_blank" rel="noreferrer noopener">Q59837-mono</a></p>



<p class="wp-block-paragraph">It did work on the GA however so I guess I&#8217;m still on track there.  </p>
]]></content:encoded>
					
					<wfw:commentRss>https://virtuallyfun.com/2024/02/19/thunking-for-fun-a-lack-of-profit/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Porting GCC to 32bit OS/2</title>
		<link>https://virtuallyfun.com/2024/02/10/porting-gcc-to-32bit-os-2/</link>
					<comments>https://virtuallyfun.com/2024/02/10/porting-gcc-to-32bit-os-2/#comments</comments>
		
		<dc:creator><![CDATA[neozeed]]></dc:creator>
		<pubDate>Sat, 10 Feb 2024 17:35:06 +0000</pubDate>
				<category><![CDATA[cross compiler]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[gnu]]></category>
		<category><![CDATA[OS/2]]></category>
		<category><![CDATA[OS/2 2.0]]></category>
		<guid isPermaLink="false">https://virtuallyfun.com/?p=13919</guid>

					<description><![CDATA[I know what you are going to think, that it was already done, and it was called EMX. Or was it GCC/2? Well sure but what if you are not running the GA (General availability) version of OS/2. For example, &#8230; <a href="https://virtuallyfun.com/2024/02/10/porting-gcc-to-32bit-os-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">I know what you are going to think, that it was already done, and it was called EMX.  Or was it GCC/2?  Well sure but what if you are not running the GA (General availability) version of OS/2.  For example, years ago I had managed to get Citrix Multiuser 2.0, and it&#8217;s not at the GA level.  All that is available is some ancient beta version of Microsoft C 5.2 from 1989?!</p>



<p class="wp-block-paragraph">A little while back I had worked on getting GCC to build and run on the FPU enabled versions of Windows NT from 1991.  I had mentioned that it turns out thanks to the Xenix assembler, that GCC had been basically available the entire time Windows NT had been available, but lamented that since the OS/2 compiler is 16/32bit, the 5.2 compiler couldn&#8217;t handle compiling GCC without blowing it&#8217;s heap.  16bit issues in a 64bit world.</p>



<p class="wp-block-paragraph">However after doing some research on all the early cl386 compilers I could get my hands on, including the Windows NT Pre-release ones, I&#8217;d noticed that if I built CC1.EXE (the actual compiler) first for Win32, then rebuilt those object files with the December NT Pre-release compiler, that some versions of LINK386 from the OS/2 2.1 DDK would actually link with them.  And sure enough it worked!</p>



<figure class="wp-block-image size-full"><a href="/wp-content/uploads/2024/02/first-hello-from-GCC-on-OS2.png" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="703" height="462" src="/wp-content/uploads/2024/02/first-hello-from-GCC-on-OS2.png" alt="" class="wp-image-13920" srcset="https://virtuallyfun.com/wp-content/uploads/2024/02/first-hello-from-GCC-on-OS2.png 703w, https://virtuallyfun.com/wp-content/uploads/2024/02/first-hello-from-GCC-on-OS2-300x197.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/02/first-hello-from-GCC-on-OS2-456x300.png 456w" sizes="auto, (max-width: 703px) 100vw, 703px" /></a><figcaption class="wp-element-caption">First life of GCC on OS/2</figcaption></figure>



<p class="wp-block-paragraph">I have to admit I was pretty amazed, I had managed to &#8216;cross compile&#8217; GCC using quite the tool chain.</p>



<p class="wp-block-paragraph">First the compiler from the December NT Pre-release CD-ROM is shipped as a 16bit OS/2 compiler, but I&#8217;m using Windows 11.  First I use the MS-DOS player with a quick fix from crazyc to allow Phar Lap 286|Dos Extender to run, which provides a basic enough OS/2 emulation to allow the compiler to run under &#8216;dos&#8217;.  The linker on the DDK suffers the same fate as far as it also being 16bit.  However the combination of MS-DOS player &amp; Phar Lap gets stuff working!  The only weird catch is that the 386 emulator causes strange floating point related crashes, while the 286 or 486 emulators work fine.</p>



<p class="wp-block-paragraph">Now targeting OS/2 or running on OS/2 isn&#8217;t all that new, but building it from a Microsoft C compiler is.  And now of course you&#8217;ll ask yourself, who cares? why is it interesting?</p>



<p class="wp-block-paragraph">Well, the vast majority of the GCC ports to OS/2 don&#8217;t support the OMF object file binary standard, instead they used the much outdated a.out format, and rely on tools to convert the objects if needed.  Additionally, they have DLL dependencies, and other startup issues with things needing to be setup.  And of course they rely on a binary standard that is &#8216;GA&#8217;.  *HOWEVER* by using a Microsoft compiler, I have OMF object files that the OS/2 built in system linker LINK386 can understand.  So in plain English I can just relink the compiler and it&#8217;ll run on a new &#8216;version&#8217; of unsupported OS/2.</p>



<p class="wp-block-paragraph">I made a diskette image with my objects &amp; a linker script and in a few moments I had it running!</p>



<figure class="wp-block-image size-full"><a href="/wp-content/uploads/2024/02/first-hello-from-GCC-on-OS2-6.123.png" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="798" height="438" src="/wp-content/uploads/2024/02/first-hello-from-GCC-on-OS2-6.123.png" alt="" class="wp-image-13922" srcset="https://virtuallyfun.com/wp-content/uploads/2024/02/first-hello-from-GCC-on-OS2-6.123.png 798w, https://virtuallyfun.com/wp-content/uploads/2024/02/first-hello-from-GCC-on-OS2-6.123-300x165.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/02/first-hello-from-GCC-on-OS2-6.123-768x422.png 768w, https://virtuallyfun.com/wp-content/uploads/2024/02/first-hello-from-GCC-on-OS2-6.123-500x274.png 500w" sizes="auto, (max-width: 798px) 100vw, 798px" /></a><figcaption class="wp-element-caption">GCC running on OS/2 2.00 6.123</figcaption></figure>



<p class="wp-block-paragraph">The substantial thing here is that the binary format for OS/2 changed twice, and each release introduced changes that broke binary compatibility, in an effort to force people onto the new tools.  So there is no way that the old &#8216;LE&#8217; format would ever work.  And you can see it&#8217;s running!  In addition I could take the same object files, and copy them to my Citrix server, and likewise it was just a matter of linking, and it too now has GCC!</p>



<figure class="wp-block-image size-full"><a href="/wp-content/uploads/2024/02/emxomf-in-action.png" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="902" height="533" src="/wp-content/uploads/2024/02/emxomf-in-action.png" alt="" class="wp-image-13923" srcset="https://virtuallyfun.com/wp-content/uploads/2024/02/emxomf-in-action.png 902w, https://virtuallyfun.com/wp-content/uploads/2024/02/emxomf-in-action-300x177.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/02/emxomf-in-action-768x454.png 768w, https://virtuallyfun.com/wp-content/uploads/2024/02/emxomf-in-action-500x295.png 500w" sizes="auto, (max-width: 902px) 100vw, 902px" /></a><figcaption class="wp-element-caption">Converting a.out to OMF via emxomf</figcaption></figure>



<p class="wp-block-paragraph">One annoying thing is that the LINK386 that ships with OS/2 2.00 GA doesn&#8217;t like the output of the Xenix assembler, so I built the a.out traditional assembler, and the emxomf tool to convert the a.out to OMF, and that worked well.</p>



<p class="wp-block-paragraph">I still have much to mess with, including the pre-processor &amp; main &#8216;gcc&#8217; program.  I have not built anything beyond a trivial program, so there is indeed much more work to be done before I can even try anything challenging.  Some programs like emxomf have portions in the debug support that require the &#8216;long long&#8217; type, which obviously Microsoft compilers from 1989-1991 don&#8217;t have, so I&#8217;ll have to re-build them with GCC.</p>



<p class="wp-block-paragraph">Ive been putting my <a href="https://github.com/neozeed/cl386-research" target="_blank" rel="noreferrer noopener">ports onto github (cl386-research)</a> as it handles the rapid changes well enough.  It&#8217;s a bit of a complex setup and it involves using a build system that <a href="https://archive.org/details/cl386-research-v2" target="_blank" rel="noreferrer noopener">I&#8217;ve put over on archive.org here: cl386-research-v2</a>.</p>



<p class="wp-block-paragraph">Not that I can imagine anyone wanting to try but I&#8217;ve uploaded some disks with the objects.  Copy them to a hard drive, and run the &#8216;build.cmd&#8217; command and it&#8217;ll link to a native freestanding executable.</p>



<ul class="wp-block-list">
<li><a href="https://archive.org/download/os2_gcc_objects_10_2_2024/cc1-object.vfd" target="_blank" rel="noreferrer noopener">cc1</a></li>



<li><a href="https://archive.org/download/os2_gcc_objects_10_2_2024/as386-object.vfd" target="_blank" rel="noreferrer noopener">as386</a></li>



<li><a href="https://archive.org/download/os2_gcc_objects_10_2_2024/emxomf-object.vfd" target="_blank" rel="noreferrer noopener">emxomf</a></li>
</ul>



<p class="wp-block-paragraph">I&#8217;ll explain it more with a post later, along with going over all the versions of cl386 I&#8217;ve acquired, over the years in more of a part 2: <a href="https://virtuallyfun.com/2024/02/11/targeting-os-2-with-visual-studio-2003/" target="_blank" rel="noreferrer noopener">Targeting OS/2 with Visual Studio 2003</a>!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://virtuallyfun.com/2024/02/10/porting-gcc-to-32bit-os-2/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>So it turns out GCC could have been available on Windows NT the entire time!</title>
		<link>https://virtuallyfun.com/2024/01/08/so-it-turns-out-gcc-could-have-been-available-on-windows-nt-the-entire-time/</link>
					<comments>https://virtuallyfun.com/2024/01/08/so-it-turns-out-gcc-could-have-been-available-on-windows-nt-the-entire-time/#respond</comments>
		
		<dc:creator><![CDATA[neozeed]]></dc:creator>
		<pubDate>Mon, 08 Jan 2024 18:32:14 +0000</pubDate>
				<category><![CDATA[cross compiler]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[Win32]]></category>
		<category><![CDATA[Windows NT 3.1]]></category>
		<guid isPermaLink="false">https://virtuallyfun.com/?p=13729</guid>

					<description><![CDATA[This is going to be a bit convoluted but here goes.. GCC isn&#8217;t a monolithic compiler, instead it&#8217;s various parts are separate programs. This lets us tackle it one part at a time. And/Or bypass a lot of it until &#8230; <a href="https://virtuallyfun.com/2024/01/08/so-it-turns-out-gcc-could-have-been-available-on-windows-nt-the-entire-time/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">This is going to be a bit convoluted but here goes..  GCC isn&#8217;t a monolithic compiler, instead it&#8217;s various parts are separate programs.  This lets us tackle it one part at a time.  And/Or bypass a lot of it until I want to tackle it.</p>



<figure class="wp-block-image size-large"><a href="https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-program-flow.png"><img loading="lazy" decoding="async" width="1024" height="384" src="https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-program-flow-1024x384.png" alt="" class="wp-image-13731" srcset="https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-program-flow-1024x384.png 1024w, https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-program-flow-300x112.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-program-flow-768x288.png 768w, https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-program-flow-1536x575.png 1536w, https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-program-flow-500x187.png 500w, https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-program-flow.png 1962w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a><figcaption class="wp-element-caption">Flow of GCC</figcaption></figure>



<p class="wp-block-paragraph">I&#8217;m sure many people have explained this far better than I ever could but in C you write source files (obviously), the pre-processor reads those and &#8216;header&#8217; files that describe interfaces to libraries, other objects, various macros and definitions (magical numbers) and the pre-processor will read those files, and do simple macro expansion and test insert/replacements to generate a single .i file at the end of it&#8217;s run.</p>



<p class="wp-block-paragraph">The C compiler (cc1) now reads that single .i file and translates it into native assembly.  This allows for &#8216;mid/high level&#8217; aspects of C to be machine independent (portable) but now will be written into a very system dependant assembly file, the single .S file.  One thing of note is that so far everything is text files.  You can edit the assembly file as you would any document, or even further &#8216;process&#8217; it if needed/wanted.</p>



<p class="wp-block-paragraph">The assembler <a href="https://github.com/neozeed/gas-1.38-xenix-" target="_blank" rel="noreferrer noopener">ax386</a> (GAS) will then read the single assembly file and write a a binary object file hi.OBJ.  There typically isn&#8217;t all that much to be said about assemblers although fancier ones allow for really strong Macro capabilities like Microsoft MASM.</p>



<p class="wp-block-paragraph">From here on, it&#8217;s all binary objects!</p>



<p class="wp-block-paragraph">The linker then takes your object files, and links them together with other system objects and system libraries into an executable, in this case.  Linkers can build all kinds of other things, but for now we&#8217;re just pretending its static C compilation like it&#8217;s the 1970&#8217;s.</p>



<p class="wp-block-paragraph">At it&#8217;s heart GCC processes text files.</p>



<p class="wp-block-paragraph">The first part in this insane experiment, is to build <a href="https://archive.org/details/oldgcc1x" target="_blank" rel="noreferrer noopener">GCC 1.40</a> with Microsoft Visual C++ 1.0.  Surprisingly it didn&#8217;t take an insane amount of messing with stuff, and I got an executable!  But everything it compiled failed to assemble.  Looking at this fragment, even if you don&#8217;t know i386 assembly you might spot the error:</p>



<pre class="wp-block-code"><code>main:
        pushl %ebp
        a b,c
        pushl %esi
        pushl %ebx</code></pre>



<p class="wp-block-paragraph">Yeah, it&#8217;s the &#8220;a b,c&#8221; part.  Those are NOT valid i386 opcodes!  </p>



<p class="wp-block-paragraph">Just because it compiled didn&#8217;t mean it actually worked.</p>



<p class="wp-block-paragraph">I used MinGW to build the same source, same Makefile, and I got a working executable.  Annoyed I started compiling random files with Microsoft C, and finally found the file that broke it all, it turned out to be insn-output.c needing to be compiled with the &#8220;/D__STDC__&#8221; flags.  A quick modification of the Makefile and now I have a working CC1!</p>



<p class="wp-block-paragraph">Okay, great, it&#8217;s well known back in the early dangerous ages of the 1980&#8217;s/1990&#8217;s that everyone wasn&#8217;t running Linux, nor were binary distributions of GCC that far spread, rather I think to re-enforce the source was available it was expected that you&#8217;d use your system compiler.  Systems like <a href="https://sourceforge.net/projects/crossdjgppv1/" target="_blank" rel="noreferrer noopener">DJGPP</a>/<a href="https://sourceforge.net/projects/crossemx/" target="_blank" rel="noreferrer noopener">EMX</a> take the path of binding a.out object files into something that MS-DOS can run via a dos extender, or the bind utility to allow you to run the a.out on OS/2.  What I wan&#8217;t to do is verify that in fact <a href="https://archive.org/details/windows-nt-3.1-build-239">Windows NT was a viable host for GCC back in the public pre-releases of 1991</a>.</p>



<p class="wp-block-paragraph">I&#8217;m sticking with the December build 239 version as it has working floating point.  Something that GCC has intrinsic support of, and I don&#8217;t feel like trying to work out emulation.</p>



<p class="wp-block-paragraph">The next step is to try to build it with the family mode-OS/2 version of the C compiler, which of course lead to the real issue of this 16bit hosted cross compiler:</p>



<pre class="wp-block-code"><code>        cl386 /u /Od /Ic:\MSVC32S\C386\INCLUDE /I. /Iconfig /c combine.c
Microsoft (R) Microsoft 386 C Compiler. Version 1.00.075
Copyright (c) Microsoft Corp 1984-1989. All rights reserved.

combine.c
combine.c(1734) : fatal error C1002: compiler is out of heap space in Pass 2
NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x2'
Stop.
</code></pre>



<p class="wp-block-paragraph">Very frustrating.  I tried mixing and matching from Visual C++ 1.0 &amp; this old compiler, and while it did compile, it doesn&#8217;t run. does it mean anything?!</p>



<figure class="wp-block-image size-full"><a href="https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-140-compiled-on-nt.png"><img loading="lazy" decoding="async" width="797" height="288" src="https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-140-compiled-on-nt.png" alt="" class="wp-image-13734" srcset="https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-140-compiled-on-nt.png 797w, https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-140-compiled-on-nt-300x108.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-140-compiled-on-nt-768x278.png 768w, https://virtuallyfun.com/wp-content/uploads/2024/01/gcc-140-compiled-on-nt-500x181.png 500w" sizes="auto, (max-width: 797px) 100vw, 797px" /></a><figcaption class="wp-element-caption">GCC 1.40 compiled by Microsoft 386 C Compiler. Version 1.00.075</figcaption></figure>



<p class="wp-block-paragraph">I should point out that this should be an expected working configuration as GCC does build on Xenix using the 32bit Microsoft C 5.1/386 compiler.  Furthered again that Xenix and these 1991 versions of NT use the same 32bit OMF object format.  And expanding on the Xenixnt experiment using the Xenix&#8217;ified GAS assembler with old Visual C++ includes &amp; libraries to produce a possible retro-early port of GCC to NT, the next move is to bulid GAS on NT.</p>



<figure class="wp-block-image size-full"><a href="https://virtuallyfun.com/wp-content/uploads/2024/01/xenix-gas-on-nt.png"><img loading="lazy" decoding="async" width="793" height="286" src="https://virtuallyfun.com/wp-content/uploads/2024/01/xenix-gas-on-nt.png" alt="" class="wp-image-13735" srcset="https://virtuallyfun.com/wp-content/uploads/2024/01/xenix-gas-on-nt.png 793w, https://virtuallyfun.com/wp-content/uploads/2024/01/xenix-gas-on-nt-300x108.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/01/xenix-gas-on-nt-768x277.png 768w, https://virtuallyfun.com/wp-content/uploads/2024/01/xenix-gas-on-nt-500x180.png 500w" sizes="auto, (max-width: 793px) 100vw, 793px" /></a><figcaption class="wp-element-caption">Xenix GAS 1.38 compiled by by Microsoft 386 C Compiler. Version 1.00.075</figcaption></figure>



<p class="wp-block-paragraph">GAS gave me some weird issues with ctype.h where it runs fine with the one from Visual C++ 1.0 but the OS/2 &amp; NT pre-release both fail.  However the old Pre-release compiler cannot deal with the much newer ctype include file.  So after much hammering I amputated whatever was bothering it, and it&#8217;s just enough to build &amp; run. Great!</p>



<p class="wp-block-paragraph">Going back to the phases, I used a simple hello world program:</p>



<pre class="wp-block-code"><code>void main() {
 printf("Hello World!\n");
}</code></pre>



<p class="wp-block-paragraph">While not being a good program, it doesn&#8217;t include stdio.h, nor does it return anything. It&#8217;s terrible.  But in this case it allows me to be lazy and sidestep the pre-processor cpp.exe.  This way I can just directly run it through cc1 and get my assembler file hi.S</p>



<p class="wp-block-paragraph">Next I pass it to ax386 (GAS) and get the resulting object file hi.OBJ</p>



<p class="wp-block-paragraph">And finally link it with link.exe in this case.</p>



<figure class="wp-block-image size-full"><a href="https://virtuallyfun.com/wp-content/uploads/2024/01/hello-world-from-dec-1991.png"><img loading="lazy" decoding="async" width="793" height="286" src="https://virtuallyfun.com/wp-content/uploads/2024/01/hello-world-from-dec-1991.png" alt="" class="wp-image-13736" srcset="https://virtuallyfun.com/wp-content/uploads/2024/01/hello-world-from-dec-1991.png 793w, https://virtuallyfun.com/wp-content/uploads/2024/01/hello-world-from-dec-1991-300x108.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/01/hello-world-from-dec-1991-768x277.png 768w, https://virtuallyfun.com/wp-content/uploads/2024/01/hello-world-from-dec-1991-500x180.png 500w" sizes="auto, (max-width: 793px) 100vw, 793px" /></a><figcaption class="wp-element-caption">Hello World from GCC 1.40 on NT!</figcaption></figure>



<p class="wp-block-paragraph">And with all the drama I&#8217;ve now compiled a simple hello world program on Windows NT.</p>



<p class="wp-block-paragraph">If it were 1991, I would hollow out gcc.c so it doesn&#8217;t use signals or forks to invoke the needed phases, and of course build the pre-processor.  In addition, libgcc needs to be compiled to allow for floating point operations to work correctly.  None of which is impossible, although I&#8217;m not sure it&#8217;s all that needed as it isn&#8217;t 1991.</p>



<figure class="wp-block-image size-full"><a href="https://archive.org/details/phoon-on-1991-dec-nt" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="797" height="283" src="https://virtuallyfun.com/wp-content/uploads/2024/01/phoon-on-1991-dec-nt.png" alt="" class="wp-image-13755" srcset="https://virtuallyfun.com/wp-content/uploads/2024/01/phoon-on-1991-dec-nt.png 797w, https://virtuallyfun.com/wp-content/uploads/2024/01/phoon-on-1991-dec-nt-300x107.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/01/phoon-on-1991-dec-nt-768x273.png 768w, https://virtuallyfun.com/wp-content/uploads/2024/01/phoon-on-1991-dec-nt-500x178.png 500w" sizes="auto, (max-width: 797px) 100vw, 797px" /></a><figcaption class="wp-element-caption">phoon</figcaption></figure>



<p class="wp-block-paragraph">With a little bit more work, I got the floating point support to compile, which relies on both a working &#8216;native&#8217; compiler, and a working GCC to compile the 2nd half.  I usually use <a href="https://www.acme.com/software/phoon/">phoon</a>, or <a href="https://www.acme.com/software/phoon/">Phases of the Moon</a>, to test floating point, and as you can see, it&#8217;s working!</p>



<p class="wp-block-paragraph">I&#8217;m not sure if there was a 32bit version of Microsoft C/386 available for Microsoft OS/2 2.00 betas.  Also, I don&#8217;t know if the Microsoft link386 for OS/2 can also link Xenix 386 object files?  Would it have been possible to bootstrap GCC/GAS on Microsoft OS/2 2.00?  I really don&#8217;t know, and as of this writing no versions of the old Microsoft OS/2 2.00 betas have surfaced.</p>



<p class="wp-block-paragraph"><strong>** update</strong> from the future, turns out that I found a way to convince the cl386 compilers from the NT Pre-Releases in 1991 to re-build an existing GCC that was built for NT.  The catch is the linker, LINK386 of course, as the format was constantly changing.  However the object files are fine, and I was able to just copy them over on diskette and re-link the compiler.  It even ran.  It&#8217;s not tested at all, so it turns out the 1989 compiler wasn&#8217;t good enough, but the 1991 was.</p>



<figure class="wp-block-image size-full"><a href="/wp-content/uploads/2024/02/gcc-on-early-os2-beta.png" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="798" height="438" src="/wp-content/uploads/2024/02/gcc-on-early-os2-beta.png" alt="" class="wp-image-13916" srcset="https://virtuallyfun.com/wp-content/uploads/2024/02/gcc-on-early-os2-beta.png 798w, https://virtuallyfun.com/wp-content/uploads/2024/02/gcc-on-early-os2-beta-300x165.png 300w, https://virtuallyfun.com/wp-content/uploads/2024/02/gcc-on-early-os2-beta-768x422.png 768w, https://virtuallyfun.com/wp-content/uploads/2024/02/gcc-on-early-os2-beta-500x274.png 500w" sizes="auto, (max-width: 798px) 100vw, 798px" /></a><figcaption class="wp-element-caption">GCC 1.40 on OS/2 2.00 beta 6.123</figcaption></figure>



<p class="wp-block-paragraph">It&#8217;s interesting to me to see that <a href="https://virtuallyfun.com/2014/09/26/did-you-know-that-gcc-used-to-support-windows-nt/" target="_blank" rel="noreferrer noopener">even before GCC 2.6</a>, that vintage versions from 1991 would compile and run directly on Windows NT.</p>



<p class="wp-block-paragraph">I uploaded the source on <a href="https://github.com/neozeed/gcc-140_gas-138_WindowsNT_v239">github</a>, along with <a href="https://github.com/neozeed/gcc-140_gas-138_WindowsNT_v239/releases">some binaries</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://virtuallyfun.com/2024/01/08/so-it-turns-out-gcc-could-have-been-available-on-windows-nt-the-entire-time/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Since people were asking for xMach binaries</title>
		<link>https://virtuallyfun.com/2023/07/11/since-people-were-asking-for-xmach-binaries/</link>
					<comments>https://virtuallyfun.com/2023/07/11/since-people-were-asking-for-xmach-binaries/#respond</comments>
		
		<dc:creator><![CDATA[neozeed]]></dc:creator>
		<pubDate>Tue, 11 Jul 2023 07:00:10 +0000</pubDate>
				<category><![CDATA[cross compiler]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[lites]]></category>
		<category><![CDATA[mach]]></category>
		<guid isPermaLink="false">http://virtuallyfun.com/?p=12961</guid>

					<description><![CDATA[Since binaries had been requested, along with the old elf cross compiler I thought I&#8217;d try that new fangled github binary releases. This is just taken from old artifacts from the old Building OSkit &#38; xMach adventures. I had made &#8230; <a href="https://virtuallyfun.com/2023/07/11/since-people-were-asking-for-xmach-binaries/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><a href="https://virtuallyfun.com/wp-content/uploads/2023/07/xmach-booted-2023-linux-cal.png"><img loading="lazy" decoding="async" width="722" height="427" src="https://virtuallyfun.com/wp-content/uploads/2023/07/xmach-booted-2023-linux-cal.png" alt="" class="wp-image-12962" srcset="https://virtuallyfun.com/wp-content/uploads/2023/07/xmach-booted-2023-linux-cal.png 722w, https://virtuallyfun.com/wp-content/uploads/2023/07/xmach-booted-2023-linux-cal-300x177.png 300w, https://virtuallyfun.com/wp-content/uploads/2023/07/xmach-booted-2023-linux-cal-500x296.png 500w" sizes="auto, (max-width: 722px) 100vw, 722px" /></a><figcaption class="wp-element-caption">xMach doing it&#8217;s Linux calibration</figcaption></figure>



<p class="wp-block-paragraph">Since binaries had been requested, along with the old elf cross compiler I thought I&#8217;d try that new fangled <a href="https://github.com/neozeed/xMach/releases/tag/v1_0" target="_blank" rel="noreferrer noopener">github binary releases</a>.</p>



<ul class="wp-block-list">
<li><a href="https://github.com/neozeed/xMach/releases/download/v1_0/i586-linux2.tar.gz">i586-linux2.tar.gz</a></li>



<li><a href="https://github.com/neozeed/xMach/releases/download/v1_0/Mach">Mach</a></li>



<li><a href="https://github.com/neozeed/xMach/releases/download/v1_0/emulator.Lites.1.1.u3">emulator.Lites.1.1.u3</a></li>



<li><a href="https://github.com/neozeed/xMach/releases/download/v1_0/startup.Lites.1.1.u3.STD+WS+ext2fs+msdosfs+slice+mach4">startup.Lites.1.1.u3.STD+WS+ext2fs+msdosfs+slice+mach4</a></li>
</ul>



<p class="wp-block-paragraph">This is just taken from old artifacts from the old <a rel="noreferrer noopener" href="/2020/09/03/building-oskit/" target="_blank">Building OSkit</a> &amp; <a href="/2021/06/09/xmach/" target="_blank" rel="noreferrer noopener">xMach</a> adventures.</p>



<p class="wp-block-paragraph">I had made a vmdk, <a rel="noreferrer noopener" href="https://master.dl.sourceforge.net/project/bsd42/4BSD%20under%20Windows/v0.4/MachUK22-lites.vmdk.7z?viasf=1" target="_blank">MachUK22-lites.vmdk.7z</a> as well, not sure if that helps anyone.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://virtuallyfun.com/2023/07/11/since-people-were-asking-for-xmach-binaries/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
