Renamed `ioccc.ico` to `favicon.ico`. Correctly added use of `favicon.ico` to all constructed HTML headers. Fixed the smart quote in HTML elements problem. Moved HTML "DO NOT EDIT" comments down below at the bottom of the HTML phase 1 section. According to to the Nu Html Checker, a charset attribute on a meta element found after the first 1024 bytes. Changed `bin/md2html.sh` VERSION from "1.1.3 2024-03-28" to "1.2 2024-03-30". Improved `bin/gen-status.sh` to adjust the "status_update" value only when the "contest_status" is changed. Performed a `make www` to perform and test the above under macOS.
588 lines
48 KiB
HTML
588 lines
48 KiB
HTML
<!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">
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
||
<title>1984/mullender - Grand Prize</title>
|
||
<link rel="icon" type="image/x-icon" href="../../favicon.ico">
|
||
<meta name="description" content="1984 IOCCC entry mullender - Grand Prize">
|
||
<meta name="keywords" content="IOCCC, 1984, IOCCC 1984, IOCCC entry, mullender, Grand Prize">
|
||
</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: 1984/mullender/README.md -->
|
||
<!-- -->
|
||
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 1984/mullender/README.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 1984/mullender/README.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 1984/mullender/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/header.default.html -->
|
||
|
||
<div class="header">
|
||
<img src="../../png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
|
||
<h1>The International Obfuscated C Code Contest</h1>
|
||
<h2>1984/mullender - Grand Prize</h2>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/header.default.html -->
|
||
<!-- START: this line starts content from: inc/topnav.last.html -->
|
||
|
||
<div class="topnav">
|
||
<a class="Left" href="../laman/index.html">← laman</a>
|
||
<a class="Left" href="../index.html">↑ 1984 ↑</a>
|
||
<a class="Left Disabled" href="#">last entry</a>
|
||
<a class="Right" href="https://github.com/ioccc-src/temp-test-ioccc/1984/mullender/mullender.c">C code</a>
|
||
<a class="Right" href="https://github.com/ioccc-src/temp-test-ioccc/1984/mullender/Makefile">Makefile</a>
|
||
<a class="Right" href="#inventory">Inventory</a>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/topnav.last.html -->
|
||
<!-- START: this line starts content from: inc/begin-row.default.html -->
|
||
|
||
<div class="row">
|
||
|
||
<!-- END: this line ends content from: inc/begin-row.default.html -->
|
||
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
|
||
|
||
<div class="leftcolumn">
|
||
|
||
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
|
||
<!-- START: this line starts content from: inc/sidenav.default.html -->
|
||
|
||
<div class="sidenav">
|
||
<a href="#content">Jump to contents</a>
|
||
</div>
|
||
<hr>
|
||
<div class="sidenav">
|
||
<a href="../../index.html">IOCCC Home</a>
|
||
<a href="../../years.html">Winning Entries</a>
|
||
<a href="../../authors.html">People who have won</a>
|
||
<a href="../../location.html">Location of authors</a>
|
||
</div>
|
||
<hr>
|
||
<div class="sidenav">
|
||
<a href="../../news.html">IOCCC News</a>
|
||
<a href="../../status.html">Contest status</a>
|
||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||
<a href="../../faq.html">FAQ</a>
|
||
</div>
|
||
<hr>
|
||
<div class="sidenav">
|
||
<a href="../../bugs.html">Bugs & (mis)features</a>
|
||
<a href="../../faq.html#fix_an_entry">Fixing IOCCC entries</a>
|
||
<a href="../../faq.html#fix_web_site">Fixing the web site</a>
|
||
<a href="../../faq.html#fix_author">Fixing author info</a>
|
||
<a href="../../thanks-for-help.html">Thanks for the help</a>
|
||
</div>
|
||
<hr>
|
||
<div class="sidenav">
|
||
<a href="../../judges.html">The IOCCC Judges</a>
|
||
<a href="../../contact.html">Contacting the IOCCC</a>
|
||
</div>
|
||
<hr>
|
||
<div class="sidenav">
|
||
<a href="#top">Jump to top</a>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/sidenav.default.html -->
|
||
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
|
||
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
|
||
|
||
<div class="rightcolumn">
|
||
|
||
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
|
||
<!-- START: this line starts content from: inc/before-content.default.html -->
|
||
|
||
<a name="content"></a>
|
||
|
||
<!-- 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="authors"><a name="author"></a>Authors:</h2>
|
||
<ul>
|
||
<li>Name: <a href="../../authors.html#Robbert_van_Renesse">Robbert van Renesse</a><br>
|
||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||
<br><br></li>
|
||
<li>Name: <a href="../../authors.html#Sjoerd_Mullender">Sjoerd Mullender</a><br>
|
||
Location: <a href="../../location.html#NL">NL</a> - <em>Kingdom of the Netherlands</em> (<em>Netherlands</em>)
|
||
<br><br></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 -->
|
||
|
||
<h2 id="to-build">To build:</h2>
|
||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> alt</span></code></pre></div>
|
||
<p>NOTE: the original code will not work on any system other than
|
||
<a href="https://en.wikipedia.org/wiki/VAX-11">VAX-11</a> and
|
||
<a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a> and this is why we encourage you
|
||
to use the alt version instead. See <a href="#original-code">original code</a> below for
|
||
the original version.</p>
|
||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||
<p>The current status of this entry is:</p>
|
||
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||
<p>For more detailed information see <a href="../../bugs.html#1984_mullender">1984 mullender bugs</a>.</p>
|
||
<h2 id="to-use">To use:</h2>
|
||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./mullender.alt</span> <span class="pp">[</span><span class="ss">microseconds</span><span class="pp">]</span></span></code></pre></div>
|
||
<p>Hit ctrl-c/intr to exit the program.</p>
|
||
<p>The default microseconds is 190000 as this is approximately how long it slept in
|
||
the original entry but it can be no lower than 5000 as any lower doesn’t work
|
||
very well. This feature is so you can experiment with different speeds in
|
||
between writes. It can be useful if your CPU is too fast :-)</p>
|
||
<p>The author stated that the original version also had a delay but the difference
|
||
is it required one to hit enter for it to print another line; the alt code will
|
||
start over once it times out or if one hits a key.</p>
|
||
<p>Note that the microseconds is argc and it uses <code>atoi()</code> which does NOT check for
|
||
overflow!</p>
|
||
<p>BTW: is there such a thing as too fast a CPU ? :-) Actually yes for certain code
|
||
which is probably not as uncommon as you think :-).</p>
|
||
<h2 id="try">Try:</h2>
|
||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./mullender.alt</span></span>
|
||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
|
||
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./mullender.alt</span> 5000 <span class="co"># wait for 5000 microseconds and see what happens</span></span>
|
||
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a></span>
|
||
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="ex">./mullender.alt</span> 20000 <span class="co"># wait for 20000 microseconds and see what happens</span></span>
|
||
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a></span>
|
||
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a><span class="ex">./mullender.alt</span> 100000 <span class="co"># wait for 100000 microseconds and see what happens</span></span></code></pre></div>
|
||
<p>What happens if you hit enter after it reaches the end of the line? Why? What
|
||
happens after some time of waiting?</p>
|
||
<h2 id="original-code">Original code:</h2>
|
||
<p>This original code will only execute correctly if your machine is a
|
||
<a href="https://en.wikipedia.org/wiki/VAX-11">VAX-11</a> or
|
||
<a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a>. In the following years, 1985 on,
|
||
machine dependent code was discouraged.</p>
|
||
<h3 id="original-build">Original build:</h3>
|
||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> all</span></code></pre></div>
|
||
<h3 id="original-use">Original use:</h3>
|
||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./mullender</span></span></code></pre></div>
|
||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||
<p>Without question, this C program is the one of the most obfuscated C program
|
||
that has ever been received! Like all great contest entries, it resulted in a
|
||
change of rules for the following year. To prevent a flood of similar programs,
|
||
the rules were changed, requesting non-machine specific code.</p>
|
||
<p>This program was selected for the 1987 t-shirt collection.</p>
|
||
<p>The C startup routine (via <a href="https://en.wikipedia.org/wiki/Crt0">crt0.o</a>)
|
||
transfers control to a location named <code>main</code>. In this case, <code>main</code> just happens
|
||
to be in the data area. The array of <code>short</code>s, which has been further
|
||
obfuscated by use of different data types, just happens to form a meaningful set
|
||
of <a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a> and
|
||
<a href="https://en.wikipedia.org/wiki/VAX">VAX</a> instructions.</p>
|
||
<p>The first word is a <a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a> branch
|
||
instruction that branches to the rest of the
|
||
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a> code.</p>
|
||
<p>On the VAX <code>main</code> is called with the <a href="https://jcsites.juniata.edu/faculty/rhodes/org/instr.htm#CALLS">calls
|
||
instruction</a>
|
||
which uses the first word of the subroutine as a mask of registers to be saved.
|
||
So on the VAX the first word can be anything. The real VAX code starts with the
|
||
second word.</p>
|
||
<p>This small program makes direct calls to the <code>write()</code> Unix system call to
|
||
produce a message on the screen. Can you guess what is printed? We knew you
|
||
couldn’t! :-)</p>
|
||
<p>What happens if you hit enter after it writes a line of output?</p>
|
||
<p>BTW: to this day, 2023, this remains one of my (Landon Curt Noll’s) all time
|
||
favorite entries!</p>
|
||
<h3 id="gentab.c">gentab.c</h3>
|
||
<p>In 2023 remarks were discovered from <a href="../../authors.html#Sjoerd_Mullender">Sjoerd
|
||
Mullender</a>, one of the authors, and so was the
|
||
program that was used by the authors to generate the array that he referred to.
|
||
Because <a href="a.out.h">a.out.h</a>, which <a href="gentab.c">gentab.c</a> uses, is not available in
|
||
all systems (like macOS) and more importantly because we wanted it to be as
|
||
close to as the original as possible we used a copy of
|
||
<a href="https://raw.githubusercontent.com/dspinellis/unix-history-repo/Research-Release/usr/include/a.out.h" class="uri">https://raw.githubusercontent.com/dspinellis/unix-history-repo/Research-Release/usr/include/a.out.h</a>
|
||
in the <em>fabulous</em> <a href="https://github.com/dspinellis/unix-history-repo/tree/Research-Release">Unix History
|
||
Repo</a>.</p>
|
||
<h3 id="gentab-build">gentab build:</h3>
|
||
<p><code>gentab.c</code> can be built like:</p>
|
||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> gentab</span></code></pre></div>
|
||
<h3 id="gentab-use">gentab use:</h3>
|
||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./gentab</span> file</span></code></pre></div>
|
||
<h3 id="gentab-try">gentab try:</h3>
|
||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./gentab</span> gentab <span class="op">></span> g.c</span></code></pre></div>
|
||
<p>NOTE: it is highly unlikely that you will be able to run the output of <code>gentab</code>
|
||
but it should at least compile.</p>
|
||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||
<h3 id="notes-from-the-judges">Notes from the judges:</h3>
|
||
<p>These remarks, found at
|
||
<a href="https://lainsystems.com/posts/exploring-mullender-dot-c/">https://lainsystems.com/posts/exploring-mullender-dot-c/</a>,
|
||
were provided by Sjoerd Mullender years later. We thank the author of the
|
||
article for the quote! For a more detailed analysis, taken from the book Obfuscated C
|
||
and Other Mysteries, see below. We hope that this is okay with the author of the
|
||
book. Considering that the analysis is entirely the authors’ comments we don’t
|
||
think this will be a problem. Unfortunately the excerpt was PDF and it did not
|
||
copy paste well. We had to go back and forth to type so it’s possible he made a
|
||
typo though he also fixed some typos found in the extract. As for the other
|
||
comments:</p>
|
||
<h3 id="remarks-from-the-author">Remarks from the author:</h3>
|
||
<p>I have never known a lot about the <a href="https://en.wikipedia.org/wiki/VAX">VAX</a>
|
||
<a href="https://en.wikipedia.org/wiki/Assembly_language">assembly</a>, so we used the C
|
||
compiler to create the VAX code. We didn’t write it ourselves from scratch as we
|
||
did with the <a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a>
|
||
code. This is the reason why the <a href="https://en.wikipedia.org/wiki/VAX">VAX</a> code
|
||
is more complex, including the extra data after the
|
||
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a> code.</p>
|
||
<p>Robbert and I were students at the <a href="https://vu.nl/en">VU (Free University in
|
||
Amsterdam)</a> at the time (mathematics with CS as our major
|
||
since there was no CS curriculum when we started). We had an assignment to
|
||
create a pair of programs for the computer networks course. The programs were
|
||
supposed to send data reliably from one program to the other over an unreliable
|
||
channel. This channel was simulated with a pair of
|
||
<a href="https://en.wikipedia.org/wiki/Pipeline_(software)">pipes</a>.</p>
|
||
<p>We decided for fun to create an
|
||
<a href="https://en.wikipedia.org/wiki/Obfuscation_(software)">obfuscated</a> set of
|
||
programs, only for the
|
||
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a>, to do this, but
|
||
circumventing the channel (i.e. cheating, hence the needed obfuscation.). Our
|
||
programs worked and we handed them in.</p>
|
||
<p>Of course, the teacher had a good laugh and then rejected our submission. (We
|
||
knew him well, so we could get away with this.)</p>
|
||
<p>Then the <a href="https://www.ioccc.org">IOCCC</a> came along. I don’t remember how we
|
||
heard about it, but at the time there was a world-wide messaging network Usenet
|
||
where we read a bunch of newsgroups. I’m sure it was <a href="https://groups.google.com/g/net.lang.c/c/lx-TAuEyeRI/m/HdOOnNx6LC0J">announced
|
||
there</a> and we saw
|
||
it.</p>
|
||
<p>Since we had just recently created these <a href="https://en.wikipedia.org/wiki/Obfuscation_(software)">obfuscated
|
||
programs</a>) we decided we could
|
||
use the same technique for an obfuscated C program. We upped the ante a bit by
|
||
making it “portable”.</p>
|
||
<p>To add to the
|
||
<a href="https://en.wikipedia.org/wiki/Obfuscation_(software)">obfuscation</a>), we used
|
||
different formats for the integers in the array: some in decimal, some in octal,
|
||
some in hexadecimal, and when the value would fit, some as an ASCII character.</p>
|
||
<p>The rest is history.</p>
|
||
<p>Since this was the first contest, we hadn’t seen any old entries, nor had any of
|
||
the other contestants. Of course we knew about <code>#define</code> and tricks you could do
|
||
with that, but we didn’t need that for this program. In fact, we made it as
|
||
“standard” as possible. At the time there was this program called <code>cb</code> or C
|
||
beautifier which would re-indent your program to make the layout look better.
|
||
Our program is idempotent under <code>cb</code>.</p>
|
||
<h3 id="more-detailed-analysis">More detailed analysis</h3>
|
||
<p>When this program is compiled, the compiler places the array somewhere in
|
||
memory, just like it places any compiled code somewhere in memory. Usually, the
|
||
C startup code (<a href="https://en.wikipedia.org/wiki/Crt0">crt0.o</a>) calls a routine
|
||
named <code>main()</code>. The loader fills in the address in the startup code, but at
|
||
least on the old systems where this program ran, it doesn’t know that the
|
||
<code>main()</code> in this program isn’t code but data!</p>
|
||
<p>When the program is run, the C startup code transfers control to the location
|
||
<code>main</code>. The contents of the array just happen to be machine instructions for
|
||
both a <a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a> and a
|
||
<a href="https://en.wikipedia.org/wiki/VAX">VAX</a>.</p>
|
||
<p>On the <a href="https://en.wikipedia.org/wiki/VAX">VAX</a>, the routine <code>main()</code> is called
|
||
with the <code>calls</code> instruction. This instruction uses the first (2-byte)
|
||
<a href="https://en.wikipedia.org/wiki/Word_(computer_architecture)">word</a> of the called
|
||
routine as a mask of
|
||
<a href="https://en.wikipedia.org/wiki/Processor_register">registers</a> that are to be
|
||
saved on the <a href="https://en.wikipedia.org/wiki/Stack_(abstract_data_type)">stack</a>.
|
||
In other words, on the VAX the first word can be anything. On the
|
||
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a>, the first word
|
||
is a <a href="https://en.wikipedia.org/wiki/Branch_(computer_science)">branch</a>
|
||
<a href="https://en.wikipedia.org/wiki/Instruction_set_architecture#Instructions">instruction</a>
|
||
that branches over the VAX code. The PDP and VAX codes are thus completely
|
||
separate.</p>
|
||
<p>The <a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a> and
|
||
<a href="https://en.wikipedia.org/wiki/VAX">VAX</a> codes implement the same algorithm:</p>
|
||
<div class="sourceCode" id="cb10"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> <span class="op">(;;)</span> <span class="op">{</span></span>
|
||
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> write<span class="op">(</span><span class="dv">1</span><span class="op">,</span> <span class="st">" :-)</span><span class="sc">\b\b\b\b</span><span class="st">"</span><span class="op">,</span> <span class="dv">9</span><span class="op">);</span></span>
|
||
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a> delay<span class="op">();</span></span>
|
||
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span></code></pre></div>
|
||
<p>The result is that the symbols <code>:-)</code> move across the screen. <code>delay</code> is
|
||
implemented differently on the
|
||
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a>, where we used a
|
||
nonexistent system call (<code>sys 55</code>), and on the
|
||
<a href="https://en.wikipedia.org/wiki/VAX">VAX</a> where we used a delay loop.</p>
|
||
<p>My co-author, Robbert, and I had earlier written a similar program for an
|
||
assignment on the <a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a>. <a href="https://groups.google.com/g/net.lang.c/c/lx-TAuEyeRI/m/HdOOnNx6LC0J">Along
|
||
came</a> the
|
||
first <a href="https://www.ioccc.org">Obfuscated C Code Contest</a>, and
|
||
we decided that we should write a program like this, but make it run on two
|
||
different <a href="https://en.wikipedia.org/wiki/Computer_architecture">architectures</a>.</p>
|
||
<p>We didn’t think long about what the program should do, so it does something very
|
||
simple.</p>
|
||
<p>We started with writing the
|
||
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a> code in assembly.
|
||
We both knew <a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a> assembly so that was
|
||
no problem. The assembly code we came up with is as follows:</p>
|
||
<div class="sourceCode" id="cb11"><pre class="sourceCode asm"><code class="sourceCode fasm"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="fu">pdp:</span></span>
|
||
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">mov</span> pc<span class="op">,</span>r4</span>
|
||
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> tst <span class="op">-(</span>r4<span class="op">)</span></span>
|
||
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a> <span class="bu">sub</span> <span class="op">$</span><span class="bn">9</span><span class="op">,</span> r4</span>
|
||
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a> <span class="bu">mov</span> r4<span class="op">,</span><span class="fl">0</span><span class="bn">f</span></span>
|
||
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a> <span class="bu">mov</span> <span class="op">$</span><span class="bn">1</span><span class="op">,</span> r0</span>
|
||
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a> sys <span class="dv">4</span><span class="co">; 0:0; 9</span></span>
|
||
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a> <span class="bu">mov</span> <span class="op">$</span><span class="bn">1000</span><span class="op">,</span> r2</span>
|
||
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a>1:</span>
|
||
<span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a> sys <span class="dv">55</span></span>
|
||
<span id="cb11-11"><a href="#cb11-11" aria-hidden="true" tabindex="-1"></a> sob r2<span class="op">,</span><span class="bn">1b</span></span>
|
||
<span id="cb11-12"><a href="#cb11-12" aria-hidden="true" tabindex="-1"></a> br pdp</span></code></pre></div>
|
||
<p>This is not the code we originally wrote, but it is the code that we ultimately
|
||
used in the program. The string to be printed is shared by the
|
||
<a href="https://en.wikipedia.org/wiki/VAX">VAX</a> and the
|
||
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a>
|
||
code and is located between the two sections.</p>
|
||
<p>First, the program deals with figuring out the address of the string. Then the
|
||
<a href="https://en.wikipedia.org/wiki/Program_counter">program counter</a> is saved in a
|
||
scratch <a href="https://en.wikipedia.org/wiki/Processor_register">register</a>. Since the
|
||
program counter points at the second
|
||
<a href="https://en.wikipedia.org/wiki/Instruction_set_architecture#Instructions">instruction</a>,
|
||
we subtract 2 from the scratch register in the second instruction. Then we
|
||
subtract the length of the string and store the result in the location with
|
||
label 0. This has to do with the calling sequence of <a href="https://en.wikipedia.org/wiki/System_call">system
|
||
calls</a> on the
|
||
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a>. Following the
|
||
<code>sys</code> instruction is the system call number (4 for <code>write()</code>), the address of
|
||
the buffer (pointed to by label 0), and the length of the buffer (9). The <a href="https://en.wikipedia.org/wiki/File_descriptor">file
|
||
descriptor</a> is in register <code>r0</code>.
|
||
The rest of the code implements a delay loop. In each iteration, a non-existing
|
||
system call (55) slows things down.</p>
|
||
<p>We assembled this program and extracted the <a href="https://en.wikipedia.org/wiki/Machine_code">machine
|
||
code</a> from the resulting <a href="https://en.wikipedia.org/wiki/Object_file">object
|
||
file</a>. We used this code in the
|
||
<a href="https://en.wikipedia.org/wiki/VAX">VAX</a> part. Since neither of us were fluent in
|
||
VAX <a href="https://en.wikipedia.org/wiki/Assembly_language">assembly</a>, we wrote the
|
||
VAX code in C and massaged the
|
||
<a href="https://en.wikipedia.org/wiki/Compiler">compiler</a> output. The VAX assembly
|
||
program that we came up with is as follows:</p>
|
||
<div class="sourceCode" id="cb12"><pre class="sourceCode asm"><code class="sourceCode fasm"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="fu">vax:</span> .<span class="dt">word</span> <span class="dv">0400</span> <span class="op">+</span> <span class="op">(</span>pdp <span class="op">-</span> vax<span class="op">)</span> <span class="op">/</span> <span class="dv">2</span> <span class="op">-</span> <span class="dv">1</span></span>
|
||
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a>1:</span>
|
||
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a> pushl <span class="op">$</span><span class="bn">9</span></span>
|
||
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a> pushal str</span>
|
||
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a> pushl <span class="op">$</span><span class="bn">1</span></span>
|
||
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a> calls <span class="op">$</span><span class="bn">3</span><span class="op">,</span> write</span>
|
||
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a> cvtwl <span class="op">$</span><span class="bn">32767</span><span class="op">,</span> r2</span>
|
||
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a></span>
|
||
<span id="cb12-9"><a href="#cb12-9" aria-hidden="true" tabindex="-1"></a>2:</span>
|
||
<span id="cb12-10"><a href="#cb12-10" aria-hidden="true" tabindex="-1"></a> decl r2</span>
|
||
<span id="cb12-11"><a href="#cb12-11" aria-hidden="true" tabindex="-1"></a> jneq <span class="dv">2</span><span class="er">b</span></span>
|
||
<span id="cb12-12"><a href="#cb12-12" aria-hidden="true" tabindex="-1"></a> jbr <span class="bn">1b</span></span>
|
||
<span id="cb12-13"><a href="#cb12-13" aria-hidden="true" tabindex="-1"></a></span>
|
||
<span id="cb12-14"><a href="#cb12-14" aria-hidden="true" tabindex="-1"></a><span class="fu">write:</span> .<span class="dt">word</span> <span class="dv">0</span></span>
|
||
<span id="cb12-15"><a href="#cb12-15" aria-hidden="true" tabindex="-1"></a> chmk <span class="op">$</span><span class="bn">4</span></span>
|
||
<span id="cb12-16"><a href="#cb12-16" aria-hidden="true" tabindex="-1"></a> <span class="cf">ret</span></span>
|
||
<span id="cb12-17"><a href="#cb12-17" aria-hidden="true" tabindex="-1"></a></span>
|
||
<span id="cb12-18"><a href="#cb12-18" aria-hidden="true" tabindex="-1"></a><span class="fu">str:</span> .ascii <span class="st">" :-)\b\b\b\b"</span></span>
|
||
<span id="cb12-19"><a href="#cb12-19" aria-hidden="true" tabindex="-1"></a></span>
|
||
<span id="cb12-20"><a href="#cb12-20" aria-hidden="true" tabindex="-1"></a><span class="fu">pdp:</span> .<span class="dt">word</span> <span class="dv">4548</span><span class="op">,</span> <span class="dv">3044</span><span class="op">,</span> <span class="dv">58820</span><span class="op">,</span> <span class="dv">9</span><span class="op">,</span> <span class="dv">4407</span><span class="op">,</span> <span class="dv">6</span><span class="op">,</span> <span class="dv">5568</span><span class="op">,</span> <span class="dv">1</span><span class="op">,</span> <span class="dv">35076</span><span class="op">,</span> <span class="dv">0</span><span class="op">,</span> <span class="dv">9</span><span class="op">,</span> <span class="dv">5570</span><span class="op">,</span> <span class="dv">512</span><span class="op">,</span> <span class="dv">35117</span><span class="op">,</span> <span class="dv">32386</span><span class="op">,</span> <span class="dv">496</span></span></code></pre></div>
|
||
<p>The first word (after the label <code>vax</code>) is the
|
||
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a> <a href="https://en.wikipedia.org/wiki/Branch_(computer_science)">branch
|
||
instruction</a>.
|
||
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a> branch
|
||
instructions are octal <code>400+</code> the distance divided by 2. The string that both
|
||
the <a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a> and
|
||
<a href="https://en.wikipedia.org/wiki/VAX">VAX</a>
|
||
programs use is after the <code>str</code> label, and the
|
||
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a> code is after the
|
||
pdp label.</p>
|
||
<p>On the <a href="https://en.wikipedia.org/wiki/VAX">VAX</a>, the program
|
||
<a href="https://en.wikipedia.org/wiki/Stack_(abstract_data_type)">pushes</a> 9 (the length
|
||
of the string), the address of the string and 1 (the <a href="https://en.wikipedia.org/wiki/File_descriptor">file
|
||
descriptor</a> on the
|
||
<a href="https://en.wikipedia.org/wiki/Stack_(abstract_data_type)">stack</a> and calls
|
||
<code>write(2)</code>. Since we didn’t know the exact calling sequence for <a href="https://en.wikipedia.org/wiki/System_call">system
|
||
calls</a>, we just copied the source for
|
||
the <code>write(2)</code> system call stub into our program. After <code>write(2)</code> finishes, the
|
||
program executes a delay loop, after which it jumps back to the start of the
|
||
program.</p>
|
||
<p>We assembled this program, and extracted the <a href="https://en.wikipedia.org/wiki/Machine_code">machine
|
||
code</a> from the <a href="https://en.wikipedia.org/wiki/Object_file">object
|
||
file</a>. After this we only had to
|
||
convert the machine code to <a href="https://en.wikipedia.org/wiki/ASCII">ASCII</a> and
|
||
write a little bit of C to glue everything together. We wanted to use different
|
||
formats for each constant in the resulting array, and we wanted to choose the
|
||
format randomly. So we wrote a program to choose an appropriate format at
|
||
random. The program we wrote for that follows. This program actually also
|
||
extracted the machine code from the object file.</p>
|
||
<blockquote>
|
||
<p>NOTE from judges: see <a href="gentab.c">gentab.c</a> for a copy of this file that can be
|
||
compiled in modern systems.</p>
|
||
</blockquote>
|
||
<div class="sourceCode" id="cb13"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a>\#include <span class="op"><</span>stdio<span class="op">.</span>h<span class="op">></span></span>
|
||
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a>\#include <span class="op"><</span>a<span class="op">.</span>out<span class="op">.</span>h<span class="op">></span></span>
|
||
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a></span>
|
||
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a>main<span class="op">(</span>argc<span class="op">,</span> argv<span class="op">)</span> <span class="dt">char</span> <span class="op">**</span>argv<span class="op">;</span></span>
|
||
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
|
||
<span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a> <span class="dt">register</span> <span class="dt">FILE</span> <span class="op">*</span>fp<span class="op">;</span></span>
|
||
<span id="cb13-7"><a href="#cb13-7" aria-hidden="true" tabindex="-1"></a> <span class="dt">register</span> <span class="dt">short</span> pos <span class="op">=</span> <span class="dv">0</span><span class="op">,</span> c<span class="op">,</span> n<span class="op">;</span></span>
|
||
<span id="cb13-8"><a href="#cb13-8" aria-hidden="true" tabindex="-1"></a> <span class="dt">register</span> <span class="dt">char</span> <span class="op">*</span>fmt<span class="op">;</span></span>
|
||
<span id="cb13-9"><a href="#cb13-9" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>argc <span class="op">!=</span> <span class="dv">2</span><span class="op">)</span> <span class="op">{</span></span>
|
||
<span id="cb13-10"><a href="#cb13-10" aria-hidden="true" tabindex="-1"></a> fprintf <span class="op">(</span>stderr<span class="op">,</span> <span class="st">"Usage: </span><span class="sc">%s</span><span class="st"> file</span><span class="sc">\n</span><span class="st">"</span><span class="op">,</span> argv<span class="op">[</span><span class="dv">0</span><span class="op">]);</span></span>
|
||
<span id="cb13-11"><a href="#cb13-11" aria-hidden="true" tabindex="-1"></a> exit <span class="op">(</span><span class="dv">1</span><span class="op">);</span></span>
|
||
<span id="cb13-12"><a href="#cb13-12" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
|
||
<span id="cb13-13"><a href="#cb13-13" aria-hidden="true" tabindex="-1"></a></span>
|
||
<span id="cb13-14"><a href="#cb13-14" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">((</span>fp <span class="op">=</span> fopen<span class="op">(</span>argv<span class="op">[</span><span class="dv">1</span><span class="op">],</span> <span class="st">"r"</span><span class="op">))</span> <span class="op">==</span> NULL<span class="op">)</span> <span class="op">{</span></span>
|
||
<span id="cb13-15"><a href="#cb13-15" aria-hidden="true" tabindex="-1"></a> fprintf<span class="op">(</span>stderr<span class="op">,</span> <span class="st">"</span><span class="sc">%s</span><span class="st">: can't open </span><span class="sc">%s\n</span><span class="st">"</span><span class="op">,</span> argv<span class="op">[</span><span class="dv">0</span><span class="op">],</span> argv<span class="op">[</span><span class="dv">1</span><span class="op">]);</span></span>
|
||
<span id="cb13-16"><a href="#cb13-16" aria-hidden="true" tabindex="-1"></a> exit<span class="op">(</span><span class="dv">2</span><span class="op">);</span></span>
|
||
<span id="cb13-17"><a href="#cb13-17" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
|
||
<span id="cb13-18"><a href="#cb13-18" aria-hidden="true" tabindex="-1"></a></span>
|
||
<span id="cb13-19"><a href="#cb13-19" aria-hidden="true" tabindex="-1"></a> fseek <span class="op">(</span>fp<span class="op">,</span> <span class="op">(</span><span class="dt">long</span><span class="op">)</span> <span class="kw">sizeof</span> <span class="op">(</span><span class="kw">struct</span> exec<span class="op">),</span> <span class="dv">0</span><span class="op">);</span></span>
|
||
<span id="cb13-20"><a href="#cb13-20" aria-hidden="true" tabindex="-1"></a> printf<span class="op">(</span><span class="st">"/* portable between VAX and PDP11 */</span><span class="sc">\n\n</span><span class="st">"</span><span class="op">);</span></span>
|
||
<span id="cb13-21"><a href="#cb13-21" aria-hidden="true" tabindex="-1"></a> printf <span class="op">(</span><span class="st">"short main[] = {</span><span class="sc">\n</span><span class="st">"</span><span class="op">);</span></span>
|
||
<span id="cb13-22"><a href="#cb13-22" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> <span class="op">(;;)</span> <span class="op">{</span></span>
|
||
<span id="cb13-23"><a href="#cb13-23" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>pos <span class="op">==</span> <span class="dv">0</span><span class="op">)</span></span>
|
||
<span id="cb13-24"><a href="#cb13-24" aria-hidden="true" tabindex="-1"></a> printf<span class="op">(</span><span class="st">"</span><span class="sc">\t</span><span class="st">"</span><span class="op">);</span></span>
|
||
<span id="cb13-25"><a href="#cb13-25" aria-hidden="true" tabindex="-1"></a></span>
|
||
<span id="cb13-26"><a href="#cb13-26" aria-hidden="true" tabindex="-1"></a> c<span class="op">=</span>getc<span class="op">(</span>fp<span class="op">)</span> <span class="op">&</span> <span class="bn">0377</span><span class="op">;</span></span>
|
||
<span id="cb13-27"><a href="#cb13-27" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>feof<span class="op">(</span>fp<span class="op">))</span> <span class="cf">break</span><span class="op">;</span></span>
|
||
<span id="cb13-28"><a href="#cb13-28" aria-hidden="true" tabindex="-1"></a> n <span class="op">=</span> getc<span class="op">(</span>fp<span class="op">)</span> <span class="op"><<</span> <span class="dv">8</span><span class="op">|</span>c<span class="op">;</span></span>
|
||
<span id="cb13-29"><a href="#cb13-29" aria-hidden="true" tabindex="-1"></a></span>
|
||
<span id="cb13-30"><a href="#cb13-30" aria-hidden="true" tabindex="-1"></a> <span class="cf">switch</span> <span class="op">(</span>rand<span class="op">()</span> <span class="op">%</span> <span class="dv">5</span><span class="op">)</span> <span class="op">{</span></span>
|
||
<span id="cb13-31"><a href="#cb13-31" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> <span class="dv">0</span><span class="op">:</span></span>
|
||
<span id="cb13-32"><a href="#cb13-32" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> <span class="dv">1</span><span class="op">:</span></span>
|
||
<span id="cb13-33"><a href="#cb13-33" aria-hidden="true" tabindex="-1"></a> fmt <span class="op">=</span> <span class="st">"</span><span class="sc">%d</span><span class="st">"</span><span class="op">;</span> <span class="cf">break</span><span class="op">;</span></span>
|
||
<span id="cb13-34"><a href="#cb13-34" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> <span class="dv">2</span><span class="op">:</span></span>
|
||
<span id="cb13-35"><a href="#cb13-35" aria-hidden="true" tabindex="-1"></a> fmt <span class="op">=</span> <span class="st">"</span><span class="sc">%u</span><span class="st">"</span><span class="op">;</span> <span class="cf">break</span><span class="op">;</span></span>
|
||
<span id="cb13-36"><a href="#cb13-36" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> <span class="dv">3</span><span class="op">:</span></span>
|
||
<span id="cb13-37"><a href="#cb13-37" aria-hidden="true" tabindex="-1"></a> fmt <span class="op">=</span> <span class="st">"0</span><span class="sc">%o</span><span class="st">"</span><span class="op">;</span> <span class="cf">break</span><span class="op">;</span></span>
|
||
<span id="cb13-38"><a href="#cb13-38" aria-hidden="true" tabindex="-1"></a> <span class="cf">case</span> <span class="dv">4</span><span class="op">:</span></span>
|
||
<span id="cb13-39"><a href="#cb13-39" aria-hidden="true" tabindex="-1"></a> fmt <span class="op">=</span> <span class="st">"0x</span><span class="sc">%x</span><span class="st">"</span><span class="op">;</span> <span class="cf">break</span><span class="op">;</span></span>
|
||
<span id="cb13-40"><a href="#cb13-40" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
|
||
<span id="cb13-41"><a href="#cb13-41" aria-hidden="true" tabindex="-1"></a></span>
|
||
<span id="cb13-42"><a href="#cb13-42" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span><span class="dv">32</span> <span class="op"><=</span> n <span class="op">&&</span> n <span class="op"><</span> <span class="dv">127</span> <span class="op">&&</span> <span class="op">(</span>rand<span class="op">()</span> <span class="op">%</span> <span class="dv">4</span><span class="op">))</span> fmt <span class="op">=</span> <span class="st">"'</span><span class="sc">%c</span><span class="st">'"</span><span class="op">;</span></span>
|
||
<span id="cb13-43"><a href="#cb13-43" aria-hidden="true" tabindex="-1"></a> printf<span class="op">(</span>n <span class="op"><</span> <span class="dv">8</span> <span class="op">?</span> <span class="st">"</span><span class="sc">%d</span><span class="st">"</span> <span class="op">:</span> fmt<span class="op">,</span> n<span class="op">);</span></span>
|
||
<span id="cb13-44"><a href="#cb13-44" aria-hidden="true" tabindex="-1"></a> printf<span class="op">(</span><span class="st">","</span><span class="op">);</span></span>
|
||
<span id="cb13-45"><a href="#cb13-45" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>pos<span class="op">++</span> <span class="op">==</span> <span class="dv">8</span><span class="op">)</span> <span class="op">{</span></span>
|
||
<span id="cb13-46"><a href="#cb13-46" aria-hidden="true" tabindex="-1"></a> printf<span class="op">(</span><span class="st">"</span><span class="sc">\n</span><span class="st">"</span><span class="op">);</span></span>
|
||
<span id="cb13-47"><a href="#cb13-47" aria-hidden="true" tabindex="-1"></a> pos <span class="op">=</span> <span class="dv">0</span><span class="op">;</span></span>
|
||
<span id="cb13-48"><a href="#cb13-48" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
|
||
<span id="cb13-49"><a href="#cb13-49" aria-hidden="true" tabindex="-1"></a> <span class="cf">else</span> printf<span class="op">(</span><span class="st">" "</span><span class="op">);</span></span>
|
||
<span id="cb13-50"><a href="#cb13-50" aria-hidden="true" tabindex="-1"></a></span>
|
||
<span id="cb13-51"><a href="#cb13-51" aria-hidden="true" tabindex="-1"></a> printf<span class="op">(</span><span class="st">"};</span><span class="sc">\n</span><span class="st">"</span><span class="op">);</span></span>
|
||
<span id="cb13-52"><a href="#cb13-52" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
|
||
<span id="cb13-53"><a href="#cb13-53" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
|
||
<p>As can be seen, there is a slight preference for decimal, and also a character
|
||
format is sometimes used, but only if the data is a printable ASCII character.</p>
|
||
<p>When we ran this program, we were almost completely satisfied with the result.
|
||
The only problem we had was that the program had chosen an
|
||
<a href="https://en.wikipedia.org/wiki/Octal">octal</a> representation for the first word.
|
||
Since everybody knows what a <a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a>
|
||
branch instruction looks like (everyone knows that the traditional magic word
|
||
for an executable, <code>0407</code>, is a <a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a>
|
||
<a href="https://en.wikipedia.org/wiki/Branch_(computer_science)">branch</a>), we changed
|
||
that to decimal. After checking the size of the resulting program we saw that it
|
||
was one byte too long. The limit was 512 bytes, and our program was 513 bytes.
|
||
So we changed the word <code>and</code> in the comment to <code>&&</code>.</p>
|
||
<!--
|
||
|
||
Copyright © 1984-2024 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/
|
||
|
||
-->
|
||
|
||
<!-- 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 -->
|
||
|
||
<h1 id="inventory-for-1984mullender"><a name="inventory"></a>Inventory for 1984/mullender</h1>
|
||
<p><a href="#top">Jump to top</a></p>
|
||
<h2 id="primary-files">Primary files</h2>
|
||
<ul>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1984/mullender/mullender.c">mullender.c</a> - entry source</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1984/mullender/Makefile">Makefile</a> - entry Makefile</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1984/mullender/mullender.alt.c">mullender.alt.c</a> - alternative source</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1984/mullender/mullender.orig.c">mullender.orig.c</a> - original source</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1984/mullender/a.out.h">a.out.h</a> - header file for gentab.c for compatibility with 1984 systems</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1984/mullender/gentab.c">gentab.c</a> - author tool to create constants</li>
|
||
<li><a href="1984_mullender.tar.bz2">1984_mullender.tar.bz2</a> - download entry</li>
|
||
</ul>
|
||
<h2 id="secondary-files">Secondary files</h2>
|
||
<ul>
|
||
<li><a href="index.html">index.html</a> - entry home page</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1984/mullender/README.md">README.md</a> - markdown source for index.html</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1984/mullender/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1984/mullender/.gitignore">.gitignore</a> - list of files that should not be committed under git</li>
|
||
<li><a href=".path">.path</a> - directory path from top directory</li>
|
||
</ul>
|
||
|
||
<!-- 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 -->
|
||
|
||
<!-- END: this line ends content from: inc/after-content.default.html -->
|
||
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
|
||
<!-- START: this line starts content from: inc/end-row.default.html -->
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/end-row.default.html -->
|
||
<!-- START: this line starts content from: inc/footer.default.html -->
|
||
|
||
<!--
|
||
|
||
Copyright © 1984-2024 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">
|
||
<h2>Copyright and CC BY-SA 4.0 License</h2>
|
||
<p>This file and web page is:</p>
|
||
<blockquote><b>Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.</b></p></blockquote>
|
||
<p>You are free to share and adapt this file under the terms of this license:</p>
|
||
<blockquote><b>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</b></blockquote>
|
||
<p>For more information, see:</p>
|
||
<blockquote><a
|
||
href="https://creativecommons.org/licenses/by-sa/4.0/">https://creativecommons.org/licenses/by-sa/4.0/</a></blockquote>
|
||
<h2>Coda</h2>
|
||
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F1984%2Fmullender%2Findex.html">Nu HTML check this web page</a></p>
|
||
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/footer.default.html -->
|
||
<!-- START: this line starts content from: inc/bottom.default.html -->
|
||
|
||
</body>
|
||
</html>
|
||
|
||
<!-- END: this line ends content from: inc/bottom.default.html -->
|