Files
Landon Curt Noll a1c86c8a7a add original C links to entry navigation bars
The navigation bar for a winning entry now has a "_Original C_" link
(between the ✅ and the Inventory on the right hand side) so that one
may easily view the original C code that was submitted for IOCCC judging.

Ran `make www timestamp` to perform the above.
2025-08-10 12:46:23 -07:00

766 lines
35 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@100..900&display=swap" rel="stylesheet">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>2024/kurdyukov3 - Prize in virtual quietus</title>
<link rel="icon" type="image/x-icon" href="../../favicon.ico">
<meta name="description" content="2024 IOCCC entry kurdyukov3 - Prize in virtual quietus">
<meta name="keywords" content="IOCCC, 2024, IOCCC 2024, IOCCC entry, kurdyukov3, Prize in virtual quietus">
</head>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- END: this line ends content from: inc/head.default.html -->
<!-- -->
<!-- This web page was formed via the tool: bin/readme2index.sh -->
<!-- The content of main section of this web page came from: 2024/kurdyukov3/README.md -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! Do not modify this web page, instead modify the file: 2024/kurdyukov3/README.md !!! -->
<!-- !!! Do not modify this web page, instead modify the file: 2024/kurdyukov3/README.md !!! -->
<!-- !!! Do not modify this web page, instead modify the file: 2024/kurdyukov3/README.md !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- Markdown content was converted into HTML via the tool: bin/md2html.sh -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/topbar.default.html -->
<div class="theader">
<nav class="topbar">
<div class="container">
<div class="logo">
<a href="../../index.html" class="logo-link">
IOCCC
</a>
</div>
<div class="topbar-items">
<div class="item">
<span class="item-header">
Entries
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../years.html" class="sub-item-link">
Winning entries
</a>
</div>
<div class="outfit-font">
<a href="../../authors.html" class="sub-item-link">
Winning authors
</a>
</div>
<div class="outfit-font">
<a href="../../location.html" class="sub-item-link">
Location of authors
</a>
</div>
<div class="outfit-font">
<a href="../../bugs.html" class="sub-item-link">
Bugs and (mis)features
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#fix_an_entry" class="sub-item-link">
Fixing entries
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#fix_author" class="sub-item-link">
Updating author info
</a>
</div>
</div>
</div>
<div class="item">
<span class="item-header">
Status
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../news.html" class="sub-item-link">
News
</a>
</div>
<div class="outfit-font">
<a href="../../status.html" class="sub-item-link">
Contest status
</a>
</div>
<div class="outfit-font">
<a href="../../next/rules.html" class="sub-item-link">
IOCCC rules
</a>
</div>
<div class="outfit-font">
<a href="../../next/guidelines.html" class="sub-item-link">
IOCCC guidelines
</a>
</div>
<div class="outfit-font">
<a href="../../markdown.html" class="sub-item-link">
Markdown guidelines
</a>
</div>
<div class="outfit-font">
<a href="../../SECURITY.html" class="sub-item-link">
Security policy
</a>
</div>
</div>
</div>
<div class="item">
<span class="item-header">
FAQ
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../faq.html" class="sub-item-link">
Frequently asked questions
</a>
</div>
<div class="outfit-font">
<a href="../../quick-start.html#enter" class="sub-item-link">
Enter the IOCCC
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#compiling" class="sub-item-link">
Compiling entries
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#running_entries" class="sub-item-link">
Running entries
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#help" class="sub-item-link">
How to help
</a>
</div>
</div>
</div>
<div class="item">
<span class="item-header">
About
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../index.html" class="sub-item-link">
Home page
</a>
</div>
<div class="outfit-font">
<a href="../../social.html" class="sub-item-link">
IOCCC social media
</a>
</div>
<div class="outfit-font">
<a href="../../about.html" class="sub-item-link">
About the IOCCC
</a>
</div>
<div class="outfit-font">
<a href="../../judges.html" class="sub-item-link">
The judges
</a>
</div>
<div class="outfit-font">
<a href="../../thanks-for-help.html" class="sub-item-link">
Thanks for the help
</a>
</div>
<div class="outfit-font">
<a href="../../contact.html" class="sub-item-link">
Contact us
</a>
</div>
</div>
</div>
</div>
</div>
</nav>
<div class="header-mobile-menu">
<noscript>
<a href="../../nojs-menu.html" class="topbar-js-label">
Please Enable JavaScript
</a>
</noscript>
<button id="header-open-menu-button" class="topbar-mobile-menu">
<img
src="../../png/hamburger-icon-open.png"
alt="hamburger style menu icon - open state"
width=48
height=48>
</button>
<button id="header-close-menu-button" class="hide-content">
<img
src="../../png/hamburger-icon-closed.png"
alt="hamburger style menu icon - closed state"
width=48
height=48>
</button>
<div id="mobile-menu-panel" class="hide-content">
<div class="mobile-menu-container">
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
Entries
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../years.html">
Winning entries
</a>
<a class="mobile-submenu-item" href="../../authors.html">
Winning authors
</a>
<a class="mobile-submenu-item" href="../../location.html">
Location of authors
</a>
<a class="mobile-submenu-item" href="../../bugs.html">
Bugs and (mis)features
</a>
<a class="mobile-submenu-item" href="../../faq.html#fix_an_entry">
Fixing entries
</a>
<a class="mobile-submenu-item" href="../../faq.html#fix_author">
Updating author info
</a>
<a class="mobile-submenu-item" href="../../thanks-for-help.html">
Thanks for the help
</a>
</div>
</div>
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
Status
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../news.html">
News
</a>
<a class="mobile-submenu-item" href="../../status.html">
Contest status
</a>
<a class="mobile-submenu-item" href="../../next/rules.html">
IOCCC rules
</a>
<a class="mobile-submenu-item" href="../../next/guidelines.html">
IOCCC guidelines
</a>
<a class="mobile-submenu-item" href="../../markdown.html">
Markdown guidelines
</a>
<a class="mobile-submenu-item" href="../../SECURITY.html">
Security policy
</a>
</div>
</div>
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
FAQ
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../faq.html">
Frequently asked questions
</a>
<a class="mobile-submenu-item" href="../../quick-start.html#enter">
Enter the IOCCC
</a>
<a class="mobile-submenu-item" href="../../faq.html#compiling">
Compiling entries
</a>
<a class="mobile-submenu-item" href="../../faq.html#running_entries">
Running entries
</a>
<a class="mobile-submenu-item" href="../../faq.html#help">
How to help
</a>
</div>
</div>
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
About
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../index.html">
Home page
</a>
<a class="mobile-submenu-item" href="../../social.html">
IOCCC social media
</a>
<a class="mobile-submenu-item" href="../../about.html">
About the IOCCC
</a>
<a class="mobile-submenu-item" href="../../judges.html">
The judges
</a>
<a class="mobile-submenu-item" href="../../contact.html">
Contact us
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
var headerOpenMenuButton = document.getElementById("header-open-menu-button");
var headerCloseMenuButton = document.getElementById("header-close-menu-button");
var mobileMenuPanel = document.getElementById("mobile-menu-panel");
headerOpenMenuButton.addEventListener("click", () => {
headerOpenMenuButton.classList.remove("topbar-mobile-menu");
headerOpenMenuButton.classList.add("hide-content");
headerCloseMenuButton.classList.remove("hide-content");
headerCloseMenuButton.classList.add("topbar-mobile-menu");
mobileMenuPanel.classList.remove("hide-content");
mobileMenuPanel.classList.add("topbar-mobile-panel");
});
headerCloseMenuButton.addEventListener("click", () => {
headerCloseMenuButton.classList.remove("topbar-mobile-menu");
headerCloseMenuButton.classList.add("hide-content");
mobileMenuPanel.classList.add("hide-content");
mobileMenuPanel.classList.remove("topbar-mobile-panel");
headerOpenMenuButton.classList.add("topbar-mobile-menu");
headerOpenMenuButton.classList.remove("hide-content");
});
</script>
<!-- END: this line ends content from: inc/topbar.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<a href="../../2011/zucker/index.html">
<img src="../../png/ioccc.png"
alt="IOCCC image by Matt Zucker"
width=300
height=110>
</a>
<h1>The International Obfuscated C Code Contest</h1>
<h2>2024/kurdyukov3 - Prize in virtual quietus</h2>
<h3>gaming VM and doom</h3>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/navbar.mid.html -->
<div class="navbar">
<a class="Left" href="../kurdyukov2/index.html">&larr; 2024/kurdyukov2</a>
<a class="Left" href="../index.html">&uarr; 2024 &uarr;</a>
<a class="Left" href="../kurdyukov4/index.html">2024/kurdyukov4 &rarr;</a>
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/prog.c">C code</a>
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/Makefile">Makefile</a>
<a class="Right" href="#inventory">Inventory</a>
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/prog.orig.c">Original C</a>
<a class="Right" href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.ioccc.org%2F2024%2Fkurdyukov3%2Findex.html">&#x2713;</a>
</div>
<!-- END: this line ends content from: inc/navbar.mid.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<div class="content" id="content">
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
<!-- START: this line starts content generated by: bin/output-index-author.sh -->
<h2 id="author">Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Ilya_Kurdyukov">Ilya Kurdyukov</a><br>
Location: <a href="../../location.html#RU">RU</a> - <em>Russian Federation</em> (<em>Russia</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
<!-- END: this line ends content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- BEFORE: 1st line of markdown file: 2024/kurdyukov3/README.md -->
<h2 id="award-presentation">Award presentation:</h2>
<p>Watch the <a href="https://www.youtube.com/@OurFavoriteUniverse">Our Favorite Universe</a>
YouTube show for this entry:</p>
<blockquote>
<p><a href="https://www.youtube.com/watch?v=iaXMwqR93iE">IOCCC28 - 2024/kurdyukov3 - Prize in virtual quietus</a></p>
</blockquote>
<h2 id="to-build">To build:</h2>
<pre><code> make all</code></pre>
<p>This above needs the <strong>X11</strong> development environment installed.</p>
<p>See the
FAQ on “<a href="../../faq.html#X11">X11</a>”
for more information on how to compile and run using <strong>X11</strong>.</p>
<h2 id="try">Try:</h2>
<pre><code> ./try.sh</code></pre>
<h2 id="alternate-code">Alternate code:</h2>
<p>While the main code is based on <strong>X11</strong>, the alternative is to use <strong>SDL2</strong> instead.</p>
<h3 id="alternate-build">Alternate build:</h3>
<pre><code> make alt</code></pre>
<p>This above needs the <strong>SDL2</strong> development environment installed.</p>
<p>See the
FAQ on “<a href="../../faq.html#SDL">SDL2</a>”
for more information on how to compile and run using <strong>SDL2</strong>.</p>
<h3 id="alternate-try">Alternate try:</h3>
<pre><code> ./try.alt.sh</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>The prize, “<strong>virtual quietus</strong>”, is a virtual reference to the doom that
awaits the execution .. of this code, let alone when your try to figure
out how the author was able to encode the virtual machine in under <strong>2.5K
bytes</strong> of <a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/prog.c">prog.c source code</a>!</p>
<p>You may face your doom in several ways. With the <code>make all</code> and
<code>try.sh</code> you may try the <strong>X11</strong> way into your doom. With <code>make alt</code>
and <code>try.alt.sh</code> <strong>SDL2</strong> your way into your doom.</p>
<p>While you may meet your doom in the twisty maze of passages while running
the program, can you reach an understanding of the maze of twisty passages
in the <a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/prog.c">prog.c source code</a>?</p>
<p><strong>NOTE</strong>: The implementation does without sound or mouse
input. You will need reply on your keyboard skills. The
<a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/try.sh">2024/kurdyukov3/try.sh</a>
demonstration script will give you some useful keyboard hints.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="obfuscated-gaming-virtual-machine">Obfuscated Gaming Virtual Machine</h3>
<p>In short, it is a virtual machine capable of running Doom 1/2 at full speed on modern office computers.
It can also be used as a sandbox for C programs and for creating ports for other games.</p>
<p>See detailed story below build/run instructions.</p>
<h3 id="build-instructions">Build instructions</h3>
<p>The instructions have been tested on a specific OS, on others they may differ in detail.</p>
<h5 id="x11-ubuntu">X11 (Ubuntu):</h5>
<pre><code> cc -O3 prog.c -o prog -X11</code></pre>
<ul>
<li>Needs “libx11-dev” package installed.</li>
</ul>
<h5 id="winapi-msys64">WinAPI (Msys64):</h5>
<pre><code> cc -O3 prog.win.c -o prog.exe -s -lGDI32 -lwinmm</code></pre>
<h5 id="sdl1.2-ubuntu">SDL1.2 (Ubuntu):</h5>
<pre><code> cc -O3 -I/usr/include/SDL prog.sdl.c -o prog -lSDL</code></pre>
<ul>
<li>Needs “libsdl1.2-dev” package installed.</li>
</ul>
<h5 id="sdl2-ubuntu">SDL2 (Ubuntu):</h5>
<pre><code> cc -O3 -I/usr/include/SDL2 prog.sdl.c -o prog -lSDL2</code></pre>
<ul>
<li>Needs “libsdl2-dev” package installed.</li>
</ul>
<h3 id="running-the-game">Running the game</h3>
<pre><code> ./prog doomp.bin</code></pre>
<ul>
<li><p>You will need the game resources, which are a .wad archive that you can grab from Doom 1/2 or its expansion packs. Doom has a shareware version available for free, you can download doom1.wad from it <a href="http://distro.ibiblio.org/pub/linux/distributions/slitaz/sources/packages/d/doom1.wad">here</a>. The resource file must be in the current directory when you run the VM.</p></li>
<li><p><code>doomp.bin</code> is a compressed binary of <code>doom.bin</code>, more on that below.</p></li>
</ul>
<h3 id="features-missing">Features missing</h3>
<ul>
<li>No sound/music.</li>
<li>No network game.</li>
<li>No mouse capture.</li>
</ul>
<h3 id="doom-port-hacks">Doom port hacks</h3>
<p>You can add command line arguments after the program binary. For example:</p>
<pre><code> ./prog doomp.bin -timedemo demo1</code></pre>
<p>This will launch performance testing.</p>
<ul>
<li><p>-1, -2, -3, -4, -5: Pixel size multiplier (default is 3), the original game runs at 320x200, which is too small for modern displays. Affects performance (scaling is done at the game side).</p></li>
<li><p>-upper : with this option, the game tries to use uppercase names for .wad/.svg files if no lowercase name is found. Useful for Linux, so you don’t need to rename files copied from DOS version.</p></li>
<li><p>-ridx N : the red color index in a pixel (0 to 3), may need adjustment if default doesn’t work for you.</p></li>
</ul>
<h3 id="the-story">The story</h3>
<h4 id="an-idea">An idea</h4>
<p>The idea of such a VM came up when I was looking at the winning works of the IOCCC competition, in which there are many games, in these games the game data is stored in separate files. So I think that in fact the complexity of games is not limited by the code size limit, as long as the game logic can be stored in a data file and then read and interpreted.</p>
<p>I also noticed emulators of virtual machines of a real CPU’s and abstract Turing machines.</p>
<p>The idea for porting this game comes from tech fans who play this game on smartwatches, fridges, digital cameras, and even a scientific calculator.</p>
<p>So can virtual machive limited by the IOCCC rules run Doom? Yes, this is a confirmation of that.</p>
<h4 id="predecessor">Predecessor</h4>
<p>This is actually VM mark II, because I was trying to write an obfuscated abstract virtual machine, it was too slow to run games, also difficult to program (but more complex than OISC), and I/O is limited by stdin/stdout. The good part is that the source code is small at ~380 bytes and that it can easily recursively emulate itself. But it was boring, so I kept thinking about how to do it better. The programs were written in assembly language consisting of handwritten NASM macros that emit opcodes for this VM (instead of x86 ones).</p>
<p>After I decided to emulate Doom in a VM, I had a question how I would compile the game source code into the binary code of a VM that never existed. And I tried the idea of ​​a workaround of compiling it into a 32-bit i386 binary and emulating a subset of the i386 instructions. I started writing an i386 emulator, but stopped halfway because I realized that this CISC architecture is too complex, so even if it complies with Rule 2B, it will have poor performance, and the code for graphics output and keyboard input may not even fit. After that I looked at the ARM thumb architecture, but even if it seems simpler to emulate - its instructions are too simple, and more instructions would be required compared to the same x86 code, so this option was also thrown out due to poor performance.</p>
<p>So, I went back to the predecessor and started rewriting and expanding its instruction set, but keeping it as small as possible in the amount of C code.</p>
<h4 id="c-compiler">C compiler</h4>
<p>After expanding the instruction set and reworking the assembler, I looked at basic C compilers that have backends for different architectures to create a backend for my own architecture. There was the Little C Compiler and the Tiny C Compiler that I knew before, of which I chose LCC because it has a parser for backends written mostly in pseudocode that is easier to work with. It is of course possible to make an LLVM backend, but creating an LLVM backend is much more complicated.</p>
<p>Choosing LCC turned out to be a good idea because I have successfully written my own backend. The downside to choosing LCC is that it is not very good at optimization, the generated code matches common compilers (like GCC) used with the -O0/-O1 switch.</p>
<h4 id="runtime-library">Runtime library</h4>
<p>Then I started writing implementations of common libc functions which include stuff like printf, malloc, memcpy, strcmp and so on. I wrote them in assembler because they are performance critical. It also required new code on the VM side in case of file I/O and timing functions.</p>
<p>And the final step was to add support for drawing in the window and handling keyboard events.</p>
<h4 id="the-doom-sources">The Doom sources</h4>
<p>These sources are available on <a href="https://github.com/id-Software/DOOM">github</a> from the id Software account and have been forked many times with some improvements and fixes. But I took the original code.</p>
<p>The original source code for Doom (linux-xdoom to be exact) required some fixes to run on a 64-bit OS that doesn’t need a 32-bit VM, but I fixed that so the same code would work in both the VM and linux, for a better debugging experience. Some other bugs have also been fixed, such as maintaining compatibility with the DOS version of the game and fixing the low detail mode. Some performance-critical functions have been rewritten in assembly (same as for the DOS game).</p>
<p>I’m not implemented network and sound support in a VM side, their interfaces replaced with a stub functions. I found a place for mouse support, but without mouse pointer capture (which is required for the FPS genre). Sound support isn’t very portable and difficult to fit in the contest restrictions.</p>
<h4 id="last-improvements">Last improvements</h4>
<p>After making the X11 version, to make this entry more portable - I also made alternate versions using WinAPI and SDL1.2/SDL2.</p>
<p>The binary code for this VM takes up a lot of space, so the Doom binary takes 1.4Mb, while x86_64 one is less than 0.5Mb. To deal with this I wrote an executable packer for the VM bytecode that reduced the size of the game binary to 0.2Mb.</p>
<h4 id="doom-port-sources">Doom port sources</h4>
<p>I don’t include modified Doom sources, but instead include a diff patch to avoid licensing issues.</p>
<h4 id="vm-sdk">VM SDK</h4>
<p>I also include the NASM macros used to generate binary code, the VM runtime library sources and the backend for LCC-4.2 (does not include the LCC sources) and a simple patch to enable the backend.</p>
<p>Use:</p>
<pre><code> ./prog lzmadec.bin &lt; sdk.zip.lzma &gt; sdk.zip</code></pre>
<p>to decompress the SDK (.zip archive is without compression).</p>
<p>Use:</p>
<pre><code> make sdk</code></pre>
<p>To build the LCC and Doom and all examples from source,
for those systems with a compatible x86 processor, and the <code>nasm(1)</code> tool,
the <code>*.bin</code> files may be produced via this <code>make samples</code> rule:</p>
<pre><code> samples: hello.bin loader.bin fizzbuzz.bin lzmadec.bin
%.bin: sdk/examples/%.asm sdk)asmlib/vm.asm
nasm -i sdk/asmlib/ -f bin -O9 $&lt; -o $@</code></pre>
<h3 id="vm-features-and-specifications">VM features and specifications</h3>
<ul>
<li>Interpreter of a 32-bit little-endian machine.</li>
<li>The interpreter is designed to work on both big and little-endian machines (tested only on LE).</li>
<li>Supported operations: +, -, &amp;, |, ^, *, /, %, &lt;&lt;, &gt;&gt;, ==, !=, &lt;, &lt;=, &gt;, &gt;=.</li>
<li>Supports 8/16/32-bit signed/unsigned operations.</li>
<li>Can access memory at a byte granularity and read from unaligned pointers.</li>
<li>Any 32-bit aligned memory location can act as a register.</li>
<li>A program running in a VM is sandboxed, it only has access to its working memory and can only call limited functions that interact with the user or the file system.</li>
</ul>
<h3 id="limitations">Limitations</h3>
<ul>
<li>No floating point support.</li>
<li>No support for 64-bit integers.</li>
<li>Divide overflow is not handled, the OS will terminate the VM process if this happens.</li>
<li>The amount of RAM must be a power of two (up to 4 GBytes).</li>
<li>Possible filenames are limited to alphanumeric characters, dot and underscore, and a length of 32. Any other characters are replaced by underscore. Since forward slashes are also filtered, it can only access files in the current directory.</li>
<li>Only two file access modes: open an existing one for reading or create a new one for writing, both in binary mode.</li>
<li>Can work with up to 8 file descriptors (the first three are standard streams).</li>
</ul>
<h3 id="other-demo-applications">Other demo applications</h3>
<ul>
<li>hello.bin : Simple “Hello World” program.</li>
<li>fizzbuzz.bin : Solution for well-known job interview task.</li>
<li>loader.bin : Loads another application from standard input into the VM’s memory and runs it.</li>
<li>window.bin : An example for the SDK on how to draw graphics and capture keyboard and mouse events.</li>
<li>lzmadec.bin : LZMA stream decoder.</li>
</ul>
<h3 id="web-version">Web version</h3>
<p>I also wrote a web version in javascript. It is in <code>ogvm.html</code>, start a local server with <code>$ python3 -m http.server 8000</code> and open <code>http://127.0.0.1:8000/ogvm.html</code> in your browser.
Files can be dragged into the window or read from the current directory.</p>
<h3 id="jit-version">JIT version</h3>
<p>An extended version with a fast JIT compiler (<code>prog.jit.c</code>) is also included. Supported architectures for JIT: x86/x86_64/aarch64/e2k. This version can also output graphics to a terminal window when using the <code>-DTERMIOS</code> option. For SDL use <code>-DSDL</code>.</p>
<h3 id="extra-notes">Extra notes</h3>
<p>This entry was written in September 2020 in one month, later only a bonus JIT was made. The patch for Doom was later used in the <a href="https://github.com/ilyakurdyukov/fpdoom">FPDoom</a> project (a port of Doom for feature phones).</p>
<!--
Copyright © 1984-2025 by Landon Curt Noll and Leonid A. Broukhis. All Rights Reserved.
You are free to share and adapt this file under the terms of this license:
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
For more information, see:
https://creativecommons.org/licenses/by-sa/4.0/
-->
<!-- AFTER: last line of markdown file: 2024/kurdyukov3/README.md -->
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
<!-- START: this line starts content generated by: bin/output-index-inventory.sh -->
<div id="inventory">
<h1 id="inventory-for-2024kurdyukov3">Inventory for 2024/kurdyukov3</h1>
</div>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/prog.c">prog.c</a> - entry source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/Makefile">Makefile</a> - entry Makefile</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/prog.orig.c">prog.orig.c</a> - original source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/try.alt.sh">try.alt.sh</a> - script to try alternate code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/try.sh">try.sh</a> - script to try entry</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/default.cfg">default.cfg</a> - configuration file</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/prog.jit.c">prog.jit.c</a> - extended version with a fast JIT compiler</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/prog.sdl.c">prog.sdl.c</a> - prog.c version that uses SDL2</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/prog.win.c">prog.win.c</a> - prog.c version that uses WinAPI</li>
<li><a href="ogvm.html">ogvm.html</a> - web version in javascript</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="2024_kurdyukov3.tar.bz2">2024_kurdyukov3.tar.bz2</a> - download entry tarball</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/README.md">README.md</a> - markdown source for this web page</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/doom1.wad">doom1.wad</a> - Doom1 WAD</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/doomp.bin">doomp.bin</a> - compressed binary of doom.bin</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/.entry.json">.entry.json</a> - entry summary and manifest in JSON</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/fizzbuzz.bin">fizzbuzz.bin</a> - Solution for well-known job interview task</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/.gitignore">.gitignore</a> - list of files that should not be committed under git</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/hello.bin">hello.bin</a> - Sample Hello World program</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/loader.bin">loader.bin</a> - Loads another application from standard input</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/lzmadec.bin">lzmadec.bin</a> - LZMA stream decoder</li>
<li><a href=".path">.path</a> - directory path from top level directory</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/sdk.zip.lzma">sdk.zip.lzma</a> - SDK in LZMA form</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/2024/kurdyukov3/window.bin">window.bin</a> - SDK to draw graphics and capture keyboard and mouse</li>
<li><a href="index.html">index.html</a> - this web page</li>
</ul>
<hr style="width:10%;text-align:left;margin-left:0">
<h4>
Jump to: <a href="#">top</a>
</h4>
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
<!-- END: this line ends content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
</div>
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/footer.inventory.html -->
<!--
Copyright © 1984-2025 by Landon Curt Noll. All Rights Reserved.
You are free to share and adapt this file under the terms of this license:
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
For more information, see:
https://creativecommons.org/licenses/by-sa/4.0/
-->
<div class="footer">
<div id="copyright"><h3>Copyright &copy; 1984-2025 by Landon Curt Noll:
<a href="https://creativecommons.org/faq/#what-does-some-rights-reserved-mean"
target="_blank"
rel="license noopener noreferrer">Some Rights Reserved</a></h3>
<p>
This work is <b>licensed by Landon Curt Noll</b> under
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/?ref=chooser-v1"
target="_blank"
rel="license noopener noreferrer"
style="display:inline-block;">CC BY-SA 4.0</a></b>.
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
src="../../png/cc.png"
alt="cc inside circle symbol">
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
src="../../png/by.png"
alt="person inside circle symbol">
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
src="../../png/sa.png"
alt="arrow looping back on itself inside circle symbol"><br>
You should <b>carefully review</b> the
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode.en"
target="_blank"
rel="license noopener noreferrer">CC BY-SA 4.0 LEGAL CODE</a></b>
before using the licensed material.<br>
You may wish to review the
<b><a href="../../license.html"
target="_blank"
rel="license noopener noreferrer">highlights of some of the key features and terms</a></b>
of <b>CC BY-SA 4.0</b>.<br>
</p>
</div>
<div id="coda"><h3>Coda</h3>
<p>
<a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.ioccc.org%2F2024%2Fkurdyukov3%2Findex.html" rel="nofollow">Nu HTML check this web page</a><br>
<a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a><br>
</p>
</div>
</div>
<!-- END: this line ends content from: inc/footer.inventory.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->