force use of pandoc version >= 3.1.12.2
The `bin/pandoc-wrapper.sh` tool will verify that the ssytem has a recent enough version of `pandoc(1)`. We explain why we insist on `pandoc(1)`. version >= 3.1.12.2 in comments where the $PANDOC_MIN_VERSION is set. Added `--wrap=preserve` as a default argument to `pandoc(1)`. While this change will impact every HTML file generated, we believe this will improve the ability of someone to look at the generated HTML and correlate with the original markdown. Changed `bin/pandoc-wrapper.sh` VERSION from "1.4.2 2024-03-17" to "1.4.3 2024-03-18". Performed `make www` to achieve all of the above and to generate HTML using the new `--wrap=preserve` `pandoc(1)` mode.
This commit is contained in:
1 parent
9eb7a54e9f
commit
b0b212acb1
402 files changed
+37061
-55132
No files matched your search
+102
-153
@@ -129,9 +129,9 @@
|
||||
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Adrian_Mariano">Adrian
|
||||
Mariano</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#Adrian_Mariano">Adrian Mariano</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -145,8 +145,7 @@ Mariano</a><br> Location: <a href="../../location.html#US">US</a> -
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: known bug - please help us fix
|
||||
STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<p>For more detailed information see <a
|
||||
href="../../bugs.html#1992_adrian">1992 adrian bugs</a>.</p>
|
||||
<p>For more detailed information see <a href="../../bugs.html#1992_adrian">1992 adrian bugs</a>.</p>
|
||||
<h2 id="try">Try:</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">./try.sh</span></span></code></pre></div>
|
||||
<p>For the slow minded, try:</p>
|
||||
@@ -157,39 +156,35 @@ about regular expressions and state machines.</p>
|
||||
<p>NOTE: Some compilers have had trouble optimizing this entry.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="adrians-grep-adgrep">ADrian’s GREP (adgrep)</h3>
|
||||
<p>For those confused by the complexity of full-blown
|
||||
<code>egrep(1)</code> style regular expressions, this program offers an
|
||||
alternative. It implements an equivalent search, using a deterministic
|
||||
finite automaton.</p>
|
||||
<p>For those confused by the complexity of full-blown <code>egrep(1)</code> style regular
|
||||
expressions, this program offers an alternative. It implements an equivalent
|
||||
search, using a deterministic finite automaton.</p>
|
||||
<p>A deterministic finite automaton consists of a finite set of states,
|
||||
along with transition rules to move from one state to another, an
|
||||
initial state, and a set of accepting states. The automaton takes a
|
||||
string as input and begins in the start state. It reads a character of
|
||||
the string and consults the rules for the current state, moving to the
|
||||
new state indicated by the appropriate rule. This process is repeated
|
||||
until the string is consumed. If the current state at this point is one
|
||||
of the accepting states, then the string is accepted.</p>
|
||||
<p>The deterministic finite automaton is specified as a series of rules
|
||||
for each state:</p>
|
||||
along with transition rules to move from one state to another, an initial
|
||||
state, and a set of accepting states. The automaton takes a string as
|
||||
input and begins in the start state. It reads a character of the string
|
||||
and consults the rules for the current state, moving to the new state
|
||||
indicated by the appropriate rule. This process is repeated until the
|
||||
string is consumed. If the current state at this point is one of the
|
||||
accepting states, then the string is accepted.</p>
|
||||
<p>The deterministic finite automaton is specified as a series of rules for
|
||||
each state:</p>
|
||||
<pre><code><state> chars1 <dest1> chars2 <dest2> ...</code></pre>
|
||||
<p><code>chars1</code> is a list of characters (<em>only the first
|
||||
8</em> are significant) which should trigger a transition to
|
||||
<code><dest1></code>. <code><dest1></code> is another state
|
||||
which should have a similar specification somewhere. A state is
|
||||
accepting if it is specified in square brackets: <code>[final]</code>;
|
||||
state strings are significant to only eight characters like
|
||||
<code>chars1</code>.</p>
|
||||
<h3 id="example-1-matches-abc">Example 1: matches
|
||||
<code>^abc$</code></h3>
|
||||
<p><code>chars1</code> is a list of characters (<em>only the first 8</em> are significant) which
|
||||
should trigger a transition to <code><dest1></code>. <code><dest1></code> is another state which
|
||||
should have a similar specification somewhere. A state is accepting if
|
||||
it is specified in square brackets: <code>[final]</code>; state strings are
|
||||
significant to only eight characters like <code>chars1</code>.</p>
|
||||
<h3 id="example-1-matches-abc">Example 1: matches <code>^abc$</code></h3>
|
||||
<pre><code><q0> a <q1> The first state to appear is the start state
|
||||
<q1> b <q2>
|
||||
<q2> c [q3]
|
||||
[q3]</code></pre>
|
||||
<p>Technically, a deterministic finite automaton should have a rule for
|
||||
each possible input character at each state. To simplify descriptions of
|
||||
the automata, if no rule is present, the string will not be accepted.
|
||||
Also, the <code>.</code> character matches any character if it occurs
|
||||
first in the character list.</p>
|
||||
<p>Technically, a deterministic finite automaton should have a rule for each
|
||||
possible input character at each state. To simplify descriptions of the
|
||||
automata, if no rule is present, the string will not be accepted. Also,
|
||||
the <code>.</code> character matches any character if it occurs first in the
|
||||
character list.</p>
|
||||
<h3 id="example-2-abc">Example 2: <code>^abc</code></h3>
|
||||
<pre><code><q0> a <q1>
|
||||
<q1> b <q2>
|
||||
@@ -216,168 +211,122 @@ first in the character list.</p>
|
||||
<q3> f <q4>
|
||||
<q4> g [q5]
|
||||
[q5]</code></pre>
|
||||
<p>With the automaton specification in <code>filename</code>, invoke the
|
||||
program by typing</p>
|
||||
<div class="sourceCode" id="cb12"><pre
|
||||
class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./adrian</span> filename</span></code></pre></div>
|
||||
<p>With the automaton specification in <code>filename</code>, invoke the program by
|
||||
typing</p>
|
||||
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./adrian</span> filename</span></code></pre></div>
|
||||
<p>It will read the file and print out all the lines which the automaton
|
||||
accepts. If the file cannot be opened, a system error message will be
|
||||
printed. If the input contains errors, then an error message along with
|
||||
the number of the offending line will be printed to stderr. The number
|
||||
of rules for each state is limited to 17. If more than 17 rules are
|
||||
present, you get the error <code>too_many_rules</code>, and the state
|
||||
that was being processed is printed. Error <code>no_destination</code>
|
||||
occurs if you specify a set of characters, but no destination state, and
|
||||
error <code>too_many_states</code> occurs if your automaton has more
|
||||
than 257 states.</p>
|
||||
accepts. If the file cannot be opened, a system error message will
|
||||
be printed. If the input contains errors, then an error message along
|
||||
with the number of the offending line will be printed to stderr. The
|
||||
number of rules for each state is limited to 17. If more than 17 rules
|
||||
are present, you get the error <code>too_many_rules</code>, and the state that was
|
||||
being processed is printed. Error <code>no_destination</code> occurs if you specify a
|
||||
set of characters, but no destination state, and error <code>too_many_states</code>
|
||||
occurs if your automaton has more than 257 states.</p>
|
||||
<p>Running:</p>
|
||||
<div class="sourceCode" id="cb13"><pre
|
||||
class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./adrian</span> from <span class="op"><</span> your_mailbox</span></code></pre></div>
|
||||
<p>will perform a function similar to that of the unix <code>from</code>
|
||||
command.</p>
|
||||
<p>If no filename is specified on the command line, then
|
||||
<code>__FILE__</code> is used as the specification for the automaton.
|
||||
(Originally this was <code>"adgrep.c"</code> but the file was renamed to
|
||||
<code>adrian.c</code> by the judges and for more portability the arg was
|
||||
changed to <code>__FILE__</code>.) In this case, the program will search
|
||||
for matches to the regular expression:</p>
|
||||
<div class="sourceCode" id="cb13"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./adrian</span> from <span class="op"><</span> your_mailbox</span></code></pre></div>
|
||||
<p>will perform a function similar to that of the unix <code>from</code> command.</p>
|
||||
<p>If no filename is specified on the command line, then <code>__FILE__</code> is used as the
|
||||
specification for the automaton. (Originally this was <code>"adgrep.c"</code> but the file
|
||||
was renamed to <code>adrian.c</code> by the judges and for more portability the arg was
|
||||
changed to <code>__FILE__</code>.) In this case, the program will search for matches to
|
||||
the regular expression:</p>
|
||||
<pre><code>^.[^|C][^w[Q]*(Q|[w[]c).*|^.[C|]$</code></pre>
|
||||
<p>I suggest using <code>adrian.c</code> as input, and storing the
|
||||
output in <code>adwc.c</code>:</p>
|
||||
<div class="sourceCode" id="cb15"><pre
|
||||
class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./adrian</span> <span class="op"><</span> adrian.c <span class="op">></span> adwc.c</span></code></pre></div>
|
||||
<p>Compiling the new file, <code>adwc.c</code>, yields a clone of the
|
||||
unix <code>wc</code> command. It runs on one file, defaulting to
|
||||
<code>"adrian.c"</code> if no file is given (again, this was changed to
|
||||
be <code>__FILE__</code>) and displays the number of lines, words, and
|
||||
bytes in the input file.</p>
|
||||
<p>I suggest using <code>adrian.c</code> as input, and storing the output in <code>adwc.c</code>:</p>
|
||||
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./adrian</span> <span class="op"><</span> adrian.c <span class="op">></span> adwc.c</span></code></pre></div>
|
||||
<p>Compiling the new file, <code>adwc.c</code>, yields a clone of the unix <code>wc</code> command. It
|
||||
runs on one file, defaulting to <code>"adrian.c"</code> if no file is given (again, this
|
||||
was changed to be <code>__FILE__</code>) and displays the number of lines, words, and bytes
|
||||
in the input file.</p>
|
||||
<p>Another possibly interesting automaton can be created by slightly
|
||||
adjusting the <code>adrian.c</code> file. Change the first line to
|
||||
read</p>
|
||||
adjusting the <code>adrian.c</code> file. Change the first line to read</p>
|
||||
<div class="sourceCode" id="cb16"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="co">/* . echo| . */</span></span></code></pre></div>
|
||||
<p>and repeat the process above</p>
|
||||
<div class="sourceCode" id="cb17"><pre
|
||||
class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./adrian</span> <span class="op"><</span>adrian.c <span class="op">></span> adecho.c</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb17"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./adrian</span> <span class="op"><</span>adrian.c <span class="op">></span> adecho.c</span></code></pre></div>
|
||||
<p>The new file now contains all lines which match</p>
|
||||
<pre><code>^.[^5|m^]*[m^]([e=p,;]|[^e=+p,;].*)$</code></pre>
|
||||
<p>Compile and run. This is an <code>echo(1)</code> clone. Note the
|
||||
efficient algorithm employed.</p>
|
||||
<p>Compile and run. This is an <code>echo(1)</code> clone. Note the efficient algorithm
|
||||
employed.</p>
|
||||
<p>Two other adjustments to the first line also yield useful results. By
|
||||
changing it to</p>
|
||||
<div class="sourceCode" id="cb19"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="co">/* . head; . */</span></span></code></pre></div>
|
||||
<p>you can search for matches to</p>
|
||||
<pre><code>^.[^W]*W..*$</code></pre>
|
||||
<p>By some freak happenstance, lines of <code>adrian.c</code> which
|
||||
match this regular expression form a unix <code>head(1)</code> command.
|
||||
It prints the first ten lines of the file specified on the command line
|
||||
or <code>adrian.c</code> if no file is specified (again this was changed
|
||||
to <code>__FILE__</code>).</p>
|
||||
<p>By some freak happenstance, lines of <code>adrian.c</code> which match this regular
|
||||
expression form a unix <code>head(1)</code> command. It prints the first ten lines of
|
||||
the file specified on the command line or <code>adrian.c</code> if no file is
|
||||
specified (again this was changed to <code>__FILE__</code>).</p>
|
||||
<p>By setting the first line to</p>
|
||||
<div class="sourceCode" id="cb21"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="co">/* . basename . */</span></span></code></pre></div>
|
||||
<p>a clone of the unix <code>basename(1)</code> command can be
|
||||
unearthed. The automaton will search for</p>
|
||||
<p>a clone of the unix <code>basename(1)</code> command can be unearthed. The automaton will
|
||||
search for</p>
|
||||
<pre><code>^.[^j]*jr.*$</code></pre>
|
||||
<p>on standard input. And the program which results by running
|
||||
<code>adrian.c</code> through this filter requires two parameters. The
|
||||
first is meant to be a filename, and the second, an extension. All
|
||||
leading pathname components are removed from the filename, and the
|
||||
extension is removed if present. The resulting base name is printed to
|
||||
stdout.</p>
|
||||
<p>on standard input. And the program which results by running <code>adrian.c</code>
|
||||
through this filter requires two parameters. The first is meant to be a
|
||||
filename, and the second, an extension. All leading pathname components
|
||||
are removed from the filename, and the extension is removed if present.
|
||||
The resulting base name is printed to stdout.</p>
|
||||
<p>Lastly, by setting the first line to</p>
|
||||
<div class="sourceCode" id="cb23"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="co">/* . sleep . */</span></span></code></pre></div>
|
||||
<p>you can search for</p>
|
||||
<pre><code>^.[^(~][^s]*sl.*$</code></pre>
|
||||
<p>Filtering <code>adrian.c</code> through this search yields a clone of
|
||||
the <code>sleep(1)</code> command. Invoke with a single integer
|
||||
parameter, and it will pause for that many seconds.</p>
|
||||
<p>If either <code>adbasename</code> or <code>adsleep</code> is invoked
|
||||
with too few parameters, the program will print the error message:</p>
|
||||
<p>Filtering <code>adrian.c</code> through this search yields a clone of the <code>sleep(1)</code>
|
||||
command. Invoke with a single integer parameter, and it will pause for that
|
||||
many seconds.</p>
|
||||
<p>If either <code>adbasename</code> or <code>adsleep</code> is invoked with too few parameters,
|
||||
the program will print the error message:</p>
|
||||
<blockquote>
|
||||
<p>Segmentation fault (core dumped)</p>
|
||||
</blockquote>
|
||||
<p>(The exact text of the above error messages varies from machine to
|
||||
machine.) The four programs which read from stdin require lines shorter
|
||||
than 999 characters.</p>
|
||||
<p>The other info files are <code>adrian.grep.[1-6]</code> which contain
|
||||
the six examples that appear above, and from, which is used to emulate
|
||||
the unix <code>from</code> command. For reasons of clarity, the name
|
||||
<code>"from"</code> should probably not be changed if possible. I
|
||||
wouldn’t want to be accused of confusing people by giving the input
|
||||
files weird names.</p>
|
||||
<p>If you want to change the default input filename (line 80) you must
|
||||
be careful to choose a name that doesn’t match the wrong search
|
||||
patterns, introducing extra lines into one of the programs (again, this
|
||||
was changed to be <code>__FILE__</code>).</p>
|
||||
machine.) The four programs which read from stdin require lines
|
||||
shorter than 999 characters.</p>
|
||||
<p>The other info files are <code>adrian.grep.[1-6]</code> which contain the six
|
||||
examples that appear above, and from, which is used to emulate the
|
||||
unix <code>from</code> command. For reasons of clarity, the name <code>"from"</code> should
|
||||
probably not be changed if possible. I wouldn’t want to be accused of
|
||||
confusing people by giving the input files weird names.</p>
|
||||
<p>If you want to change the default input filename (line 80) you must be
|
||||
careful to choose a name that doesn’t match the wrong search patterns,
|
||||
introducing extra lines into one of the programs (again, this was changed to be
|
||||
<code>__FILE__</code>).</p>
|
||||
<p>The program will produce at least one warning and possible several
|
||||
when compiled depending on the compiler.</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0
|
||||
License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights
|
||||
Reserved. You are free to share and adapt this file under the terms of
|
||||
this license:</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0 License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
|
||||
You are free to share and adapt this file under the terms of this license:</p>
|
||||
<pre><code>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</code></pre>
|
||||
<p>For more information, see:
|
||||
https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
<p>For more information, see: https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
|
||||
<!-- 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-1992adrian"><a name="inventory"></a>Inventory for
|
||||
1992/adrian</h1>
|
||||
<h1 id="inventory-for-1992adrian"><a name="inventory"></a>Inventory for 1992/adrian</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/1992/adrian/adrian.c">adrian.c</a>
|
||||
- entry source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/Makefile">Makefile</a>
|
||||
- entry Makefile</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.orig.c">adrian.orig.c</a>
|
||||
- original source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.grep.1">adrian.grep.1</a>
|
||||
- agrep script</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.grep.2">adrian.grep.2</a>
|
||||
- agrep script</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.grep.3">adrian.grep.3</a>
|
||||
- agrep script</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.grep.4">adrian.grep.4</a>
|
||||
- agrep script</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.grep.5">adrian.grep.5</a>
|
||||
- agrep script</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.grep.from">adrian.grep.from</a>
|
||||
- agrep script</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.grep.try">adrian.grep.try</a>
|
||||
- agrep script</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/try.sh">try.sh</a>
|
||||
- how to run</li>
|
||||
<li><a href="1992_adrian.tar.bz2">1992_adrian.tar.bz2</a> - download
|
||||
entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.c">adrian.c</a> - entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.orig.c">adrian.orig.c</a> - original source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.grep.1">adrian.grep.1</a> - agrep script</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.grep.2">adrian.grep.2</a> - agrep script</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.grep.3">adrian.grep.3</a> - agrep script</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.grep.4">adrian.grep.4</a> - agrep script</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.grep.5">adrian.grep.5</a> - agrep script</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.grep.from">adrian.grep.from</a> - agrep script</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/adrian.grep.try">adrian.grep.try</a> - agrep script</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/try.sh">try.sh</a> - how to run</li>
|
||||
<li><a href="1992_adrian.tar.bz2">1992_adrian.tar.bz2</a> - download entry source</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/1992/adrian/.entry.json">.entry.json</a>
|
||||
- description of entry in JSON</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/.gitignore">.gitignore</a>
|
||||
- list of files that should not be committed under git</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/.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>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/README.md">README.md</a>
|
||||
- markdown source for index.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/adrian/README.md">README.md</a> - markdown source for index.html</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||||
|
||||
+60
-89
@@ -129,9 +129,9 @@
|
||||
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Albert_van_der_Horst">Albert van
|
||||
der Horst</a><br> Location: <a href="../../location.html#NL">NL</a> -
|
||||
<em>Kingdom of the Netherlands</em> (<em>Netherlands</em>) <br><br></li>
|
||||
<li>Name: <a href="../../authors.html#Albert_van_der_Horst">Albert van der Horst</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 -->
|
||||
@@ -141,21 +141,19 @@ der Horst</a><br> Location: <a href="../../location.html#NL">NL</a> -
|
||||
|
||||
<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> all</span></code></pre></div>
|
||||
<p>An <a href="#alternate-code">alternate version</a> exists that fixes
|
||||
a bug.</p>
|
||||
<p>An <a href="#alternate-code">alternate version</a> exists that fixes a bug.</p>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: known bug - please help us fix</code></pre>
|
||||
<p>For more detailed information see <a
|
||||
href="../../bugs.html#1992_albert">1992 albert bugs</a>.</p>
|
||||
<p>For more detailed information see <a href="../../bugs.html#1992_albert">1992 albert 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">./albert</span> number</span></code></pre></div>
|
||||
<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">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>An alternate version of this entry, <a
|
||||
href="albert.alt.c">albert.alt.c</a>, is provided. Leo Broukhis, before
|
||||
he was an IOCCC judge, sent the IOCCC judges this Email message:</p>
|
||||
<p>An alternate version of this entry, <a href="albert.alt.c">albert.alt.c</a>, is provided.
|
||||
Leo Broukhis, before he was an IOCCC judge, sent the IOCCC
|
||||
judges this Email message:</p>
|
||||
<pre><code>From: leo _at_ zycad -dot- com (Leo Broukhis)
|
||||
Date: Tue, 30 Jan 96 17:37:51 PST
|
||||
To: judges _at_ toad -dot- com
|
||||
@@ -170,124 +168,97 @@ in albert.orig.c that has been fixed in albert.c,
|
||||
I've found a number exposing another bug: 10000000001 (that's 9 0's).
|
||||
Both albert and albert.orig loop without printing anything, although
|
||||
the first factor is 101 and is usually found in an instant.</code></pre>
|
||||
<p>The <a href="albert.c">albert.alt.c</a> file is the fixed file,
|
||||
whereas the <a href="albert.c">albert.c</a> is the file before applying
|
||||
Leo Broukhis’ fix.</p>
|
||||
<p>The <a href="albert.c">albert.alt.c</a> file is the fixed file, whereas the
|
||||
<a href="albert.c">albert.c</a> is the file before applying Leo Broukhis’ fix.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<p>To compile this alternate version:</p>
|
||||
<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="fu">make</span> alt</span></code></pre></div>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>albert.alt</code> as you would <code>albert</code>
|
||||
above.</p>
|
||||
<p>Use <code>albert.alt</code> as you would <code>albert</code> above.</p>
|
||||
<h3 id="alternate-try">Alternate try:</h3>
|
||||
<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="ex">./try.alt.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>We were impressed with the speed at which it was able to factor
|
||||
arbitrarily large numbers consisting of factors that fit into a
|
||||
long.</p>
|
||||
arbitrarily large numbers consisting of factors that fit into
|
||||
a long.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p>The Obfuscated version of the Horst algorithm.</p>
|
||||
<p>This program will factor unlimited length numbers and print the
|
||||
factors in ascending order. Numbers of one digit (e.g. 8) are rejected
|
||||
without notice.</p>
|
||||
<p>It quits as soon as there is at most one factor left, but that factor
|
||||
will not be shown. It accomplishes this efficiently, without resorting
|
||||
to division or multiplication, until the candidate factor no longer fits
|
||||
in a signed long.</p>
|
||||
<p>The nicest way is to rename the program into e.g. 4294967297 if you
|
||||
want to factor Fermat’s 4th number. Then just run it.</p>
|
||||
<p>Or you may type <code>./albert <some-number></code> A nice one
|
||||
is also (30 ones):</p>
|
||||
factors in ascending order. Numbers of one digit (e.g. 8)
|
||||
are rejected without notice.</p>
|
||||
<p>It quits as soon as there is at most one factor left, but that factor will not
|
||||
be shown. It accomplishes this efficiently, without resorting to division or
|
||||
multiplication, until the candidate factor no longer fits in a signed long.</p>
|
||||
<p>The nicest way is to rename the program into e.g. 4294967297
|
||||
if you want to factor Fermat’s 4th number. Then just run it.</p>
|
||||
<p>Or you may type <code>./albert <some-number></code>
|
||||
A nice one is also (30 ones):</p>
|
||||
<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">./albert</span> 111111111111111111111111111111</span></code></pre></div>
|
||||
<p>Apart from the foregoing there are no special execution
|
||||
instructions.</p>
|
||||
<p>Apart from the foregoing there are no special execution instructions.</p>
|
||||
<p>To customize the program into a factorizer of a fixed number, use</p>
|
||||
<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="fu">cc</span> albert.c <span class="at">-o</span> 4294967297</span></code></pre></div>
|
||||
<p>or some such.</p>
|
||||
<p>There are no data files used, and it is not possible to feed input
|
||||
via <code>stdin</code>.</p>
|
||||
<p>I think this program is a nice example of algorithmic obfuscation.
|
||||
Several times two similar algorithms are merged into one. Then you need
|
||||
quite some tricks to get it running, such as long jumps through
|
||||
recursive subroutines. I felt like a sword smith, welding the sword very
|
||||
long, folding it again to the proper length, keep on hammering till it
|
||||
is tight, then fold again. Always keeping it at the proper red hot
|
||||
temperature, but not too hot lest the hardness fades.</p>
|
||||
<p>The strict naming conventions for subroutines did not make things
|
||||
much clearer after all, but it was not supposed to.</p>
|
||||
<p>I would like to draw attention to the robustness of the program with
|
||||
respect to error handling and the nice stopping criterion. The aesthetic
|
||||
appeal of some lines is at the expense of clearness, I apologize.</p>
|
||||
<p>Running the program through the C-beautifier reveals nothing, it will
|
||||
only destroy some of the lay out. Running the program through lint shows
|
||||
the usual remarks for a K&R program. Defeating this through casts
|
||||
does not make a program cleaner in my opinion.</p>
|
||||
<p>I think this program is a nice example of algorithmic obfuscation. Several
|
||||
times two similar algorithms are merged into one. Then you need quite some
|
||||
tricks to get it running, such as long jumps through recursive subroutines. I
|
||||
felt like a sword smith, welding the sword very long, folding it again to the
|
||||
proper length, keep on hammering till it is tight, then fold again. Always
|
||||
keeping it at the proper red hot temperature, but not too hot lest the hardness
|
||||
fades.</p>
|
||||
<p>The strict naming conventions for subroutines did not make things much clearer
|
||||
after all, but it was not supposed to.</p>
|
||||
<p>I would like to draw attention to the robustness of the program with respect to
|
||||
error handling and the nice stopping criterion. The aesthetic appeal of some
|
||||
lines is at the expense of clearness, I apologize.</p>
|
||||
<p>Running the program through the C-beautifier reveals nothing, it will only
|
||||
destroy some of the lay out. Running the program through lint shows the usual
|
||||
remarks for a K&R program. Defeating this through casts does not make a program
|
||||
cleaner in my opinion.</p>
|
||||
<h3 id="hints">Hints</h3>
|
||||
<p>Here are some hints, but they may not be too helpful:</p>
|
||||
<ol type="1">
|
||||
<li>The Horst algorithm is described in the Hobby Computer Club
|
||||
Newsletter, year 82, part 4, a real Dutch treat. Assembly, C and Forth
|
||||
version have been around for some years.</li>
|
||||
<li>The Horst algorithm is described in the Hobby Computer Club Newsletter, year
|
||||
82, part 4, a real Dutch treat. Assembly, C and Forth version have been around
|
||||
for some years.</li>
|
||||
<li>Does fractal programming exist after all?</li>
|
||||
<li>You remember the Toom-Cook algorithm in Knuth? It uses iteration
|
||||
instead of recursion and is quite jumpy. This program shares these
|
||||
disadvantages in a modified form.</li>
|
||||
<li>You remember the Toom-Cook algorithm in Knuth? It uses iteration instead of
|
||||
recursion and is quite jumpy. This program shares these disadvantages in a
|
||||
modified form.</li>
|
||||
<li>The Conversion is to be found in Knuth, not so the Observation. The
|
||||
Observation: “if it ends in a zero, it is divisible by ten”.</li>
|
||||
</ol>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0
|
||||
License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights
|
||||
Reserved. You are free to share and adapt this file under the terms of
|
||||
this license:</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0 License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
|
||||
You are free to share and adapt this file under the terms of this license:</p>
|
||||
<pre><code>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</code></pre>
|
||||
<p>For more information, see:
|
||||
https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
<p>For more information, see: https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
|
||||
<!-- 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-1992albert"><a name="inventory"></a>Inventory for
|
||||
1992/albert</h1>
|
||||
<h1 id="inventory-for-1992albert"><a name="inventory"></a>Inventory for 1992/albert</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/1992/albert/albert.c">albert.c</a>
|
||||
- entry source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/albert/Makefile">Makefile</a>
|
||||
- entry Makefile</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/albert/albert.alt.c">albert.alt.c</a>
|
||||
- alternative source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/albert/albert.orig.c">albert.orig.c</a>
|
||||
- original source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/albert/try.alt.sh">try.alt.sh</a>
|
||||
- how to run alternative code</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/albert/try.sh">try.sh</a>
|
||||
- how to run</li>
|
||||
<li><a href="1992_albert.tar.bz2">1992_albert.tar.bz2</a> - download
|
||||
entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/albert/albert.c">albert.c</a> - entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/albert/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/albert/albert.alt.c">albert.alt.c</a> - alternative source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/albert/albert.orig.c">albert.orig.c</a> - original source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/albert/try.alt.sh">try.alt.sh</a> - how to run alternative code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/albert/try.sh">try.sh</a> - how to run</li>
|
||||
<li><a href="1992_albert.tar.bz2">1992_albert.tar.bz2</a> - download entry source</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/1992/albert/.entry.json">.entry.json</a>
|
||||
- description of entry in JSON</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/albert/.gitignore">.gitignore</a>
|
||||
- list of files that should not be committed under git</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/albert/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/albert/.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>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/albert/README.md">README.md</a>
|
||||
- markdown source for index.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/albert/README.md">README.md</a> - markdown source for index.html</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||||
|
||||
+23
-47
@@ -129,9 +129,9 @@
|
||||
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Anthony_C_Howe">Anthony C.
|
||||
Howe</a><br> Location: <a href="../../location.html#CA">CA</a> -
|
||||
<em>Canada</em> <br><br></li>
|
||||
<li>Name: <a href="../../authors.html#Anthony_C_Howe">Anthony C. Howe</a><br>
|
||||
Location: <a href="../../location.html#CA">CA</a> - <em>Canada</em>
|
||||
<br><br></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -145,71 +145,47 @@ Howe</a><br> Location: <a href="../../location.html#CA">CA</a> -
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./ant</span> Makefile</span>
|
||||
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./ant</span> Makefile rule</span></code></pre></div>
|
||||
<p>where <code>Makefile</code> is a Makefile to use and
|
||||
<code>rule</code> is an optional rule to use.</p>
|
||||
<p>where <code>Makefile</code> is a Makefile to use and <code>rule</code> is an optional rule to use.</p>
|
||||
<h2 id="try">Try:</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">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>Like much of POSIX, obfuscation has its place. Your task is to figure
|
||||
out where.</p>
|
||||
<p>Like much of POSIX, obfuscation has its place. Your task is to
|
||||
figure out where.</p>
|
||||
<p>This entry comes complete with a POSIX-like command description.
|
||||
Interested POSIX balloters should lobby the IEEE for an obfuscated P1003
|
||||
subcommittee.</p>
|
||||
Interested POSIX balloters should lobby the IEEE for an obfuscated
|
||||
P1003 subcommittee.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p>See the file <a href="ant.README">ant.README</a>.</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0
|
||||
License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights
|
||||
Reserved. You are free to share and adapt this file under the terms of
|
||||
this license:</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0 License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
|
||||
You are free to share and adapt this file under the terms of this license:</p>
|
||||
<pre><code>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</code></pre>
|
||||
<p>For more information, see:
|
||||
https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
<p>For more information, see: https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
|
||||
<!-- 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-1992ant"><a name="inventory"></a>Inventory for
|
||||
1992/ant</h1>
|
||||
<h1 id="inventory-for-1992ant"><a name="inventory"></a>Inventory for 1992/ant</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/1992/ant/ant.c">ant.c</a>
|
||||
- entry source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/Makefile">Makefile</a>
|
||||
- entry Makefile</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/ant.orig.c">ant.orig.c</a>
|
||||
- original source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/try.sh">try.sh</a>
|
||||
- how to run</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/ant.README">ant.README</a>
|
||||
- am man page</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/ant.test.mk">ant.test.mk</a>
|
||||
- how to compile</li>
|
||||
<li><a href="1992_ant.tar.bz2">1992_ant.tar.bz2</a> - download entry
|
||||
source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/ant.c">ant.c</a> - entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/ant.orig.c">ant.orig.c</a> - original source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/try.sh">try.sh</a> - how to run</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/ant.README">ant.README</a> - am man page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/ant.test.mk">ant.test.mk</a> - how to compile</li>
|
||||
<li><a href="1992_ant.tar.bz2">1992_ant.tar.bz2</a> - download entry source</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/1992/ant/.entry.json">.entry.json</a>
|
||||
- description of entry in JSON</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/.gitignore">.gitignore</a>
|
||||
- list of files that should not be committed under git</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/.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>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/README.md">README.md</a>
|
||||
- markdown source for index.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/README.md">README.md</a> - markdown source for index.html</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||||
|
||||
+91
-131
@@ -130,8 +130,8 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Sean_Barrett">Sean Barrett</a><br>
|
||||
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown
|
||||
location</em> <br><br></li>
|
||||
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
|
||||
<br><br></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -152,70 +152,57 @@ location</em> <br><br></li>
|
||||
<p>Notice how many statements it takes to do anything useful?</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p>What you shouldn’t think about <code>buzzard.1</code>:</p>
|
||||
<p><code>buzzard.1</code> doesn’t just do a mass of
|
||||
<code>#define</code>s as its obfuscation.</p>
|
||||
<h3 id="what-you-should-be-glad-about">What you should be glad
|
||||
about:</h3>
|
||||
<p><code>buzzard.1</code> doesn’t just do a mass of <code>#define</code>s as its obfuscation.</p>
|
||||
<h3 id="what-you-should-be-glad-about">What you should be glad about:</h3>
|
||||
<p>I didn’t just submit the post-C-preprocessed output as an entry.</p>
|
||||
<h4 id="cute-trick-warning">Cute trick warning</h4>
|
||||
<p><code>buzzard.1</code> contains only a numeric
|
||||
<code>printf(3)</code>, yet sometimes it prints out short strings.</p>
|
||||
<p><code>buzzard.1</code> contains only a numeric <code>printf(3)</code>, yet sometimes it prints out
|
||||
short strings.</p>
|
||||
<h3 id="what-it-does">What it does</h3>
|
||||
<p><code>buzzard.1</code> is a simple mathematical program. It expects
|
||||
two numeric arguments.</p>
|
||||
<p><code>buzzard.1</code> is a simple mathematical program. It expects two numeric
|
||||
arguments.</p>
|
||||
<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="ex">./buzzard.1</span> 0 <span class="op"><</span>num<span class="op">></span></span></code></pre></div>
|
||||
<p>will print out the factorial of <code><num></code>.</p>
|
||||
<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">./buzzard.1</span> <span class="op"><</span>num1<span class="op">></span> <span class="op"><</span>num2<span class="op">></span></span></code></pre></div>
|
||||
<p>will print out the largest common factor of <code>num1</code> and
|
||||
<code>num2</code>.</p>
|
||||
<p>will print out the largest common factor of <code>num1</code> and <code>num2</code>.</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="ex">./buzzard.1</span> 1 <span class="op"><</span>num2<span class="op">></span></span></code></pre></div>
|
||||
<p>will print out a factor of <code>num2</code> if it’s composite, or
|
||||
else it will print a string informing you that <code>num2</code> is
|
||||
prime.</p>
|
||||
<p>If the first argument is less than 0, it prints out an error
|
||||
message.</p>
|
||||
<p>will print out a factor of <code>num2</code> if it’s composite, or else
|
||||
it will print a string informing you that <code>num2</code> is prime.</p>
|
||||
<p>If the first argument is less than 0, it prints out an
|
||||
error message.</p>
|
||||
<h3 id="what-it-is">What it is</h3>
|
||||
<p><code>buzzard.1</code> is a translator from a pseudo-assembly
|
||||
language into a subset of C suitable for execution on Charles Babbage’s
|
||||
Analytical Engine. Or rather, the <code>#define</code>s in
|
||||
<code>buzzard.1</code> are that translator. The rest of
|
||||
<code>buzzard.1</code> is a <code>buzzard.1</code> program. If you run
|
||||
the whole mess through CPP and a beautifier, you will see that all you
|
||||
have is a loop that runs until a variable is not 0, and a sequence of
|
||||
assignment statements. The assignment statements are all of the form
|
||||
<code>a op= b</code> or <code>a = b</code>. The Engine actually allowed
|
||||
‘a = b op c’. Only <code>+</code>, <code>-</code>, <code>/</code>, and
|
||||
<code>*</code> are used–no boolean or bitwise operators. The infinite
|
||||
loop could have been simulated on the AE by connecting the
|
||||
already-processed card stack to the input card stack.</p>
|
||||
<p><code>buzzard.1</code> is a translator from a pseudo-assembly language into a subset of C
|
||||
suitable for execution on Charles Babbage’s Analytical Engine. Or rather, the
|
||||
<code>#define</code>s in <code>buzzard.1</code> are that translator. The rest of <code>buzzard.1</code> is a
|
||||
<code>buzzard.1</code> program. If you run the whole mess through CPP and a beautifier, you
|
||||
will see that all you have is a loop that runs until a variable is not 0, and a
|
||||
sequence of assignment statements. The assignment statements are all of the
|
||||
form <code>a op= b</code> or <code>a = b</code>. The Engine actually allowed ‘a = b op c’. Only <code>+</code>,
|
||||
<code>-</code>, <code>/</code>, and <code>*</code> are used–no boolean or bitwise operators. The infinite loop
|
||||
could have been simulated on the AE by connecting the already-processed card
|
||||
stack to the input card stack.</p>
|
||||
<h3 id="how-to-try-to-understand-it">How to try to understand it</h3>
|
||||
<p><em>Don’t</em> expand the <code>#define</code>s! Rather, decipher
|
||||
what they do. Some of them are mere obfuscation fodder, put in to
|
||||
encourage you to run it through CPP.</p>
|
||||
<h3 id="what-it-doesnt-do-quite-right-as-an-emulator">What it doesn’t do
|
||||
quite right as an emulator</h3>
|
||||
<p>Because of the definitional constraints, calls to
|
||||
<code>atoi(argv[#])</code> also appear inside the loop. These could be
|
||||
put outside–the initial values of the “registers” on the AE–but the
|
||||
macro conventions being used didn’t lend themselves to it.</p>
|
||||
<p><em>Don’t</em> expand the <code>#define</code>s! Rather, decipher what they do.
|
||||
Some of them are mere obfuscation fodder, put in to encourage
|
||||
you to run it through CPP.</p>
|
||||
<h3 id="what-it-doesnt-do-quite-right-as-an-emulator">What it doesn’t do quite right as an emulator</h3>
|
||||
<p>Because of the definitional constraints, calls to <code>atoi(argv[#])</code> also appear
|
||||
inside the loop. These could be put outside–the initial values of the
|
||||
“registers” on the AE–but the macro conventions being used didn’t lend
|
||||
themselves to it.</p>
|
||||
<h3 id="theoretical-observations">Theoretical observations</h3>
|
||||
<p>The simulated comparison operations only work with a certain range of
|
||||
numbers; numbers that are too large will cause the output code to fail
|
||||
to simulate the input code. This means that this implementation of
|
||||
<code>buzzard.1</code> would not be Turing-complete, even if the AE
|
||||
could process indefinitely-sized numbers. However, this is actually a
|
||||
constraint that no actual computer can meet, either, so we can conclude
|
||||
that if an AE, with card bins connected as suggested above, were hooked
|
||||
up to a memory unit of sufficient size, it would be as Turing complete
|
||||
as any existing machine (or, for those who interpret that excessively
|
||||
critically, i.e. “not at all” for both, we can simply say that the AE
|
||||
could simulate any existing machine–although not quickly). This would be
|
||||
a good place to site some references on the AE, but I don’t have
|
||||
any.</p>
|
||||
<h3
|
||||
id="definition-of-the-input-language-to-buzzard.1-or-what-exactly-do-all-the-macros-do">Definition
|
||||
of the input language to buzzard.1 (OR What Exactly Do All The Macros
|
||||
Do?)</h3>
|
||||
<p>The simulated comparison operations only work with a certain range of numbers;
|
||||
numbers that are too large will cause the output code to fail to simulate the
|
||||
input code. This means that this implementation of <code>buzzard.1</code> would not be
|
||||
Turing-complete, even if the AE could process indefinitely-sized numbers.
|
||||
However, this is actually a constraint that no actual computer can meet, either,
|
||||
so we can conclude that if an AE, with card bins connected as suggested above,
|
||||
were hooked up to a memory unit of sufficient size, it would be as Turing
|
||||
complete as any existing machine (or, for those who interpret that excessively
|
||||
critically, i.e. “not at all” for both, we can simply say that the AE could
|
||||
simulate any existing machine–although not quickly). This would be a good
|
||||
place to site some references on the AE, but I don’t have any.</p>
|
||||
<h3 id="definition-of-the-input-language-to-buzzard.1-or-what-exactly-do-all-the-macros-do">Definition of the input language to buzzard.1 (OR What Exactly Do All The Macros Do?)</h3>
|
||||
<p>[Don’t read this unless you’re stumped!]</p>
|
||||
<pre><code>
|
||||
MACRO FUNCTION MNEMONIC
|
||||
@@ -248,20 +235,18 @@ G(x,y) let x = the value if the yth argument Get argument
|
||||
T end of code; begin output section Terminate
|
||||
X(y) print out hexadecimal value of y heXadecimal
|
||||
T end of output section and program Terminate</code></pre>
|
||||
<p>You can figure out the other macros yourself. In the sample program,
|
||||
I’ve actually implemented subroutines by saving a return address in a
|
||||
variable and then jumping to a routine– specifically, a routine that
|
||||
converts a number into BCD, so it can be output by the hexadecimal
|
||||
output statement.</p>
|
||||
<h3 id="how-it-works-i.e.-how-to-get-useful-programs-from-a-op-b">How it
|
||||
works, i.e., how to get useful programs from a op= b</h3>
|
||||
<p>The essential statement to be able to make interesting programs is
|
||||
the conditional (given that we have loops). Since all you can do in the
|
||||
given operation output set is assignment, we implement “conditional
|
||||
assignment”:</p>
|
||||
<p>You can figure out the other macros yourself. In the sample program, I’ve
|
||||
actually implemented subroutines by saving a return address in a variable and
|
||||
then jumping to a routine– specifically, a routine that converts a number into
|
||||
BCD, so it can be output by the hexadecimal output statement.</p>
|
||||
<h3 id="how-it-works-i.e.-how-to-get-useful-programs-from-a-op-b">How it works, i.e., how to get useful programs from a op= b</h3>
|
||||
<p>The essential statement to be able to make interesting
|
||||
programs is the conditional (given that we have loops).
|
||||
Since all you can do in the given operation output set is
|
||||
assignment, we implement “conditional assignment”:</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> <span class="op">(</span>x<span class="op">)</span> y <span class="op">=</span> z<span class="op">;</span></span></code></pre></div>
|
||||
<p>To implement this, we constrain <code>x</code> to be either 0 or 1,
|
||||
and simply compute:</p>
|
||||
<p>To implement this, we constrain <code>x</code> to be either 0 or 1, and
|
||||
simply compute:</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>y <span class="op">=</span> <span class="op">(</span>z <span class="op">*</span> x<span class="op">)</span> <span class="op">+</span> <span class="op">(</span>y <span class="op">*</span> <span class="op">(</span><span class="dv">1</span><span class="op">-</span>x<span class="op">));</span></span></code></pre></div>
|
||||
<p>This is more obscured by factoring out common terms and restricting
|
||||
ourselves to two operand operations:</p>
|
||||
@@ -271,86 +256,61 @@ ourselves to two operand operations:</p>
|
||||
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a>y <span class="op">+=</span> temp<span class="op">;</span> <span class="op">(</span>y <span class="op">==</span> <span class="op">(</span>z<span class="op">-</span>y<span class="op">)*</span>x <span class="op">+</span> y<span class="op">)</span></span>
|
||||
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a> <span class="op">(</span> <span class="op">==</span> z<span class="op">*</span>x <span class="op">-</span> y<span class="op">*</span>x <span class="op">+</span> y<span class="op">)</span></span>
|
||||
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a> <span class="op">(</span> <span class="op">==</span> z<span class="op">*</span>x <span class="op">+</span> y<span class="op">*(</span><span class="dv">1</span><span class="op">-</span>x<span class="op">))</span></span></code></pre></div>
|
||||
<p>Next we imagine we have a <a
|
||||
href="https://en.wikipedia.org/wiki/Program_counter">pc</a>. “I’m
|
||||
supposed to execute statement pc next”, says our emulator. But suppose
|
||||
we’re not currently coming up on statement pc. To handle this, we simply
|
||||
make every operation conditional on the pc having the correct value:</p>
|
||||
<p>Next we imagine we have a <a href="https://en.wikipedia.org/wiki/Program_counter">pc</a>.
|
||||
“I’m supposed to execute statement pc next”, says our emulator. But suppose
|
||||
we’re not currently coming up on statement pc. To handle this, we simply make
|
||||
every operation conditional on the pc having the correct value:</p>
|
||||
<div class="sourceCode" id="cb12"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> <span class="op">(</span>pc <span class="op">==</span> some_constant<span class="op">)</span> y <span class="op">=</span> z<span class="op">;</span></span></code></pre></div>
|
||||
<p>To combine this with other operations, we simply multiply by our
|
||||
(<code>pc == some_constant</code>) flag right after the above
|
||||
<code>temp *= x</code>.</p>
|
||||
<p>To evaluate <code>pc == some_constant</code> requires one more trick.
|
||||
We assume that numbers can only be in some limited range. Then we use
|
||||
successive additions and divisions to reduce that number down to
|
||||
<code>-1</code>, <code>0</code>, or <code>1</code>. You could, for
|
||||
instance, do this by using mod by <code>2</code> and div by
|
||||
<code>2</code> to count bits, stopping after, say, <code>32</code>
|
||||
iterations. The number you get is between <code>0..32</code>, so another
|
||||
<code>6</code> iterations on it reduces it to <code>0..6</code>. Three
|
||||
iterations on this produces <code>0..2</code> (<code>3</code> would be
|
||||
<code>7</code>), and then two iterations on this produces 0 or 1.
|
||||
Instead I use a shorter two-divide approach that assumes I’m allowed to
|
||||
use numbers slightly larger than the numbers I’m operating on.</p>
|
||||
(<code>pc == some_constant</code>) flag right after the above <code>temp *= x</code>.</p>
|
||||
<p>To evaluate <code>pc == some_constant</code> requires one more trick. We assume that
|
||||
numbers can only be in some limited range. Then we use successive additions and
|
||||
divisions to reduce that number down to <code>-1</code>, <code>0</code>, or <code>1</code>. You could, for
|
||||
instance, do this by using mod by <code>2</code> and div by <code>2</code> to count bits, stopping
|
||||
after, say, <code>32</code> iterations. The number you get is between <code>0..32</code>, so another
|
||||
<code>6</code> iterations on it reduces it to <code>0..6</code>. Three iterations on this produces
|
||||
<code>0..2</code> (<code>3</code> would be <code>7</code>), and then two iterations on this produces 0 or 1.
|
||||
Instead I use a shorter two-divide approach that assumes I’m allowed to use
|
||||
numbers slightly larger than the numbers I’m operating on.</p>
|
||||
<p>A similar approach is used to detect positive numbers.</p>
|
||||
<p>Note that the obvious code to compute <code>y/x</code> will not work
|
||||
correctly, because every value is computed, even if the pc is not set
|
||||
correctly; if <code>x</code> is ever <code>0</code> when the real C code
|
||||
reaches this computation the program will die. (This was discovered the
|
||||
hard way.) The solution is to stick <code>x</code> in a temporary, and
|
||||
if the current code is not about to be executed, set the temporary to
|
||||
<code>1</code>.</p>
|
||||
<p>Thanks to Bill Pugh for bringing the loop-ability of the AE to my
|
||||
attention.</p>
|
||||
<p><code>buzzard.1</code> was originally named ‘cb’, for obvious
|
||||
reasons, and is dedicated to the memory of Charles Barrett.</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0
|
||||
License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights
|
||||
Reserved. You are free to share and adapt this file under the terms of
|
||||
this license:</p>
|
||||
<p>Note that the obvious code to compute <code>y/x</code> will not work correctly,
|
||||
because every value is computed, even if the pc is not set correctly;
|
||||
if <code>x</code> is ever <code>0</code> when the real C code reaches this computation the
|
||||
program will die. (This was discovered the hard way.) The solution
|
||||
is to stick <code>x</code> in a temporary, and if the current code is not about
|
||||
to be executed, set the temporary to <code>1</code>.</p>
|
||||
<p>Thanks to Bill Pugh for bringing the loop-ability of the AE to
|
||||
my attention.</p>
|
||||
<p><code>buzzard.1</code> was originally named ‘cb’, for obvious reasons, and is
|
||||
dedicated to the memory of Charles Barrett.</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0 License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
|
||||
You are free to share and adapt this file under the terms of this license:</p>
|
||||
<pre><code>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</code></pre>
|
||||
<p>For more information, see:
|
||||
https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
<p>For more information, see: https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
|
||||
<!-- 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-1992buzzard.1"><a name="inventory"></a>Inventory
|
||||
for 1992/buzzard.1</h1>
|
||||
<h1 id="inventory-for-1992buzzard.1"><a name="inventory"></a>Inventory for 1992/buzzard.1</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/1992/buzzard.1/buzzard.1.c">buzzard.1.c</a>
|
||||
- entry source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.1/Makefile">Makefile</a>
|
||||
- entry Makefile</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.1/buzzard.1.orig.c">buzzard.1.orig.c</a>
|
||||
- original source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.1/try.sh">try.sh</a>
|
||||
- how to run</li>
|
||||
<li><a href="1992_buzzard.1.tar.bz2">1992_buzzard.1.tar.bz2</a> -
|
||||
download entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.1/buzzard.1.c">buzzard.1.c</a> - entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.1/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.1/buzzard.1.orig.c">buzzard.1.orig.c</a> - original source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.1/try.sh">try.sh</a> - how to run</li>
|
||||
<li><a href="1992_buzzard.1.tar.bz2">1992_buzzard.1.tar.bz2</a> - download entry source</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/1992/buzzard.1/.entry.json">.entry.json</a>
|
||||
- description of entry in JSON</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.1/.gitignore">.gitignore</a>
|
||||
- list of files that should not be committed under git</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.1/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.1/.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>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.1/README.md">README.md</a>
|
||||
- markdown source for index.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.1/README.md">README.md</a> - markdown source for index.html</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||||
|
||||
@@ -121,25 +121,22 @@
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<p><a href="buzzard.2.README.md">buzzard.2.README.md</a> this file<br />
|
||||
<a href="buzzard.2.design.md">buzzard.2.design.md</a> description of
|
||||
FIRST (design documentation of THIRD)<br />
|
||||
<a href="buzzard.2.design.md">buzzard.2.design.md</a> description of FIRST (design documentation of THIRD)<br />
|
||||
<a href="third">third</a> implementation of THIRD in FIRST<br />
|
||||
<a href="help.th">help.th</a> online listing of THIRD primitives<br />
|
||||
</p>
|
||||
<h1 id="first-demos">FIRST demos:</h1>
|
||||
<p>Use <code>./first < <demo></code>.</p>
|
||||
<p><a href="demo1.1st">demo1.1st</a> prints Hello World! assuming
|
||||
ASCII</p>
|
||||
<p><a href="demo1.1st">demo1.1st</a> prints Hello World! assuming ASCII</p>
|
||||
<h1 id="third-demos">THIRD demos:</h1>
|
||||
<p>Use <code>cat third <demo> | ./first</code>.</p>
|
||||
<h2 id="demo-files">Demo files:</h2>
|
||||
<p><a href="demo1.th">demo1.th</a> prints Hello World! regardless of
|
||||
character set <a href="demo2.th">demo2.th</a> demonstrates a simple loop
|
||||
<a href="demo3.th">demo3.th</a> demonstrates a simple if test <a
|
||||
href="demo4.th">demo4.th</a> recursive factorial calculating on the way
|
||||
up <a href="demo5.th">demo5.th</a> recursive factorial calculating on
|
||||
the way down <a href="demo6.th">demo6.th</a> demonstrates switching from
|
||||
compiler to execution mode</p>
|
||||
<p><a href="demo1.th">demo1.th</a> prints Hello World! regardless of character set
|
||||
<a href="demo2.th">demo2.th</a> demonstrates a simple loop
|
||||
<a href="demo3.th">demo3.th</a> demonstrates a simple if test
|
||||
<a href="demo4.th">demo4.th</a> recursive factorial calculating on the way up
|
||||
<a href="demo5.th">demo5.th</a> recursive factorial calculating on the way down
|
||||
<a href="demo6.th">demo6.th</a> demonstrates switching from compiler to execution mode</p>
|
||||
<h1 id="interactive-third">Interactive THIRD:</h1>
|
||||
<p>Use <code>cat third - | ./first</code>.</p>
|
||||
<p>To include the primitive on-line help, use
|
||||
|
||||
@@ -122,62 +122,63 @@
|
||||
|
||||
<h1 id="first-third-almost-forth">FIRST & THIRD (almost FORTH)</h1>
|
||||
<p>FORTH is a language mostly familiar to users of “small” machines.
|
||||
FORTH programs are small because they are interpreted–a function call in
|
||||
FORTH takes two bytes. FORTH is an extendable language– built-in
|
||||
primitives are indistinguishable from user-defined <em>words</em>. FORTH
|
||||
interpreters are small because much of the system can be coded in
|
||||
FORTH–only a small number of primitives need to be implemented. Some
|
||||
FORTH interpreters can also compile defined words into machine code,
|
||||
resulting in a fast system.</p>
|
||||
FORTH programs are small because they are interpreted–a function
|
||||
call in FORTH takes two bytes. FORTH is an extendable language–
|
||||
built-in primitives are indistinguishable from user-defined
|
||||
<em>words</em>. FORTH interpreters are small because much of the system
|
||||
can be coded in FORTH–only a small number of primitives need to
|
||||
be implemented. Some FORTH interpreters can also compile defined
|
||||
words into machine code, resulting in a fast system.</p>
|
||||
<p>FIRST is an incredibly small language which is sufficient for
|
||||
defining the language THIRD, which is mostly like FORTH. There are some
|
||||
differences, and THIRD is probably just enough like FORTH for those
|
||||
differences to be disturbing to regular FORTH users.</p>
|
||||
<p>The only existing FIRST interpreter is written in obfuscated C, and
|
||||
rings in at under 800 bytes of source code, although through deletion of
|
||||
both whitespace and obfuscation it can be brought to about 650
|
||||
defining the language THIRD, which is mostly like FORTH. There are
|
||||
some differences, and THIRD is probably just enough like FORTH for
|
||||
those differences to be disturbing to regular FORTH users.</p>
|
||||
<p>The only existing FIRST interpreter is written in obfuscated C,
|
||||
and rings in at under 800 bytes of source code, although through
|
||||
deletion of both whitespace and obfuscation it can be brought to about 650
|
||||
bytes.</p>
|
||||
<p>This document FIRST defines the FIRST environment and primitives,
|
||||
with relevant design decision explanations. It secondly documents the
|
||||
general strategies we will use to implement THIRD. The THIRD section
|
||||
demonstrates how the complete THIRD system is built up using FIRST.</p>
|
||||
with relevant design decision explanations. It secondly documents
|
||||
the general strategies we will use to implement THIRD. The THIRD
|
||||
section demonstrates how the complete THIRD system is built up
|
||||
using FIRST.</p>
|
||||
<h2 id="section-1-first">Section 1: FIRST</h2>
|
||||
<h3 id="environment">Environment</h3>
|
||||
<p>FIRST implements a virtual machine. The machine has three chunks of
|
||||
memory: “main memory”, “the stack”, and “string storage”. When the
|
||||
virtual machine wishes to do random memory accesses, they come out of
|
||||
main memory–it cannot access the stack or string storage.</p>
|
||||
<p>FIRST implements a virtual machine. The machine has three chunks
|
||||
of memory: “main memory”, “the stack”, and “string storage”. When
|
||||
the virtual machine wishes to do random memory accesses, they come
|
||||
out of main memory–it cannot access the stack or string storage.</p>
|
||||
<p>The stack is simply a standard LIFO data structure that is used
|
||||
implicitly by most of the FIRST primitives. The stack is made up of
|
||||
<code>int</code>s, whatever size they are on the host machine.</p>
|
||||
implicitly by most of the FIRST primitives. The stack is made up
|
||||
of <code>int</code>s, whatever size they are on the host machine.</p>
|
||||
<p>String storage is used to store the names of built-in and defined
|
||||
primitives. Separate storage is used for these because it allows the C
|
||||
code to use C string operations, reducing C source code size.</p>
|
||||
primitives. Separate storage is used for these because it allows
|
||||
the C code to use C string operations, reducing C source code size.</p>
|
||||
<p>Main memory is a large array of <code>int</code>s. When we speak of
|
||||
addresses, we actually mean indices into main memory. Main memory is
|
||||
used for two things, primarily: the return stack and the dictionary.</p>
|
||||
<p>The return stack is a LIFO data structure, independent of the
|
||||
above-mentioned “stack”, which is used by FIRST to keep track of
|
||||
function call return addresses.</p>
|
||||
<p>The dictionary is a list of words. Each word contains a header and a
|
||||
data field. In the header is the address of the previous word, an index
|
||||
into the string storage indicating where the name of this word is
|
||||
stored, and a “code pointer”. The code pointer is simply an integer
|
||||
which names which “machine-language-primitive” implements this
|
||||
instruction. For example, for defined words the code pointer names the
|
||||
“run some code” primitive, which pushes the current program counter onto
|
||||
the return stack and sets the counter to the address of the data field
|
||||
for this word.</p>
|
||||
<p>There are several important pointers into main memory. There is a
|
||||
pointer to the most recently defined word, which is used to start
|
||||
searches back through memory when compiling words. There is a pointer to
|
||||
the top of the return stack. There is a pointer to the current end of
|
||||
the dictionary, used while compiling.</p>
|
||||
<p>For the last two pointers, namely the return stack pointer and the
|
||||
dictionary pointer, there is an important distinction: the pointers
|
||||
themselves are stored in main memory (in <code>FIRST</code>’s main
|
||||
memory). This is critical, because it means FIRST programs can get at
|
||||
them without any further primitives needing to be defined.</p>
|
||||
addresses, we actually mean indices into main memory. Main memory
|
||||
is used for two things, primarily: the return stack and the dictionary.</p>
|
||||
<p>The return stack is a LIFO data structure, independent of
|
||||
the above-mentioned “stack”, which is used by FIRST to keep
|
||||
track of function call return addresses.</p>
|
||||
<p>The dictionary is a list of words. Each word contains a header
|
||||
and a data field. In the header is the address of the previous word,
|
||||
an index into the string storage indicating where the name of this
|
||||
word is stored, and a “code pointer”. The code pointer is simply
|
||||
an integer which names which “machine-language-primitive” implements
|
||||
this instruction. For example, for defined words the code pointer
|
||||
names the “run some code” primitive, which pushes the current program
|
||||
counter onto the return stack and sets the counter to the address of
|
||||
the data field for this word.</p>
|
||||
<p>There are several important pointers into main memory. There is
|
||||
a pointer to the most recently defined word, which is used to start
|
||||
searches back through memory when compiling words. There is a pointer
|
||||
to the top of the return stack. There is a pointer to the current
|
||||
end of the dictionary, used while compiling.</p>
|
||||
<p>For the last two pointers, namely the return stack pointer and
|
||||
the dictionary pointer, there is an important distinction: the pointers
|
||||
themselves are stored in main memory (in <code>FIRST</code>’s main memory). This
|
||||
is critical, because it means FIRST programs can get at them without
|
||||
any further primitives needing to be defined.</p>
|
||||
<h3 id="instructions">Instructions</h3>
|
||||
<p>There are two kinds of FIRST instructions, normal instructions and
|
||||
immediate instructions. Immediate instructions do something significant
|
||||
@@ -196,8 +197,7 @@ means that by default FIRST simply compiles things.</p>
|
||||
<0 less than 0 pop top element of stack, push 1 if < 0 else 0</code></pre>
|
||||
<p>Note that we can synthesize addition and negation from binary minus,
|
||||
but we cannot synthesize a time efficient divide or multiply from it.
|
||||
<code><0</code> is synthesize-able, but only in a non-portable
|
||||
way.</p>
|
||||
<code><0</code> is synthesize-able, but only in a non-portable way.</p>
|
||||
<h4 id="memory-operations">Memory Operations</h4>
|
||||
<pre><code>SYMBOL NAME FUNCTION
|
||||
|
||||
@@ -216,16 +216,14 @@ _read read a space-delimited word, find it in the
|
||||
dictionary, and compile a pointer to
|
||||
that word's code pointer onto the
|
||||
current end of the dictionary</code></pre>
|
||||
<p>Although <code>_read</code> could be synthesized from key, we need
|
||||
<code>_read</code> to be able to compile words to be able to start any
|
||||
syntheses.</p>
|
||||
<p>Although <code>_read</code> could be synthesized from key, we need <code>_read</code> to be able
|
||||
to compile words to be able to start any syntheses.</p>
|
||||
<h4 id="execution-operations">Execution Operations</h4>
|
||||
<pre><code>NAME FUNCTION
|
||||
|
||||
exit leave the current function: pop the return stack
|
||||
into the program counter</code></pre>
|
||||
<h4 id="immediate-compilation-operations">Immediate (compilation)
|
||||
Operations</h4>
|
||||
<h4 id="immediate-compilation-operations">Immediate (compilation) Operations</h4>
|
||||
<pre><code>SYMBOL NAME FUNCTION
|
||||
|
||||
: define read in the next space-delimited word, add it to
|
||||
@@ -237,32 +235,31 @@ Operations</h4>
|
||||
immediate immediate when used immediately after a name following a ':',
|
||||
it makes the word being defined run whenever
|
||||
it is typed.</code></pre>
|
||||
<p><code>:</code> cannot be synthesized, because we could not synthesize
|
||||
anything. <code>immediate</code> has to be an immediate operation, so it
|
||||
could not be synthesized unless by default operations were immediate;
|
||||
but that would preclude our being able to do any useful compilation.</p>
|
||||
<p><code>:</code> cannot be synthesized, because we could not synthesize anything.
|
||||
<code>immediate</code> has to be an immediate operation, so it could not be
|
||||
synthesized unless by default operations were immediate; but that
|
||||
would preclude our being able to do any useful compilation.</p>
|
||||
<h4 id="stack-operations">Stack Operations</h4>
|
||||
<pre><code>NAME FUNCTION
|
||||
|
||||
pick pop top of stack, use as index into stack and copy up
|
||||
that element</code></pre>
|
||||
<p>If the data stack were stored in main memory, we could synthesize
|
||||
<code>pick</code>; but putting the stack and stack pointer in main
|
||||
memory would significantly increase the C source code size.</p>
|
||||
<p>There are three more primitives, but they are “internal only”– they
|
||||
have no names and no dictionary entries. The first is
|
||||
<code>pushint</code>. It takes the next integer out of the instruction
|
||||
stream and pushes it on the stack. This could be synthesized, but
|
||||
probably not without using integer constants. It is generated by
|
||||
<code>_read</code> when the input is not a known word. The second is
|
||||
<code>compile me</code>. When this instruction is executed, a pointer to
|
||||
the word’s data field is appended to the dictionary. The third is
|
||||
<code>run me</code>–the word’s data field is taken to be a stream of
|
||||
pointers to words, and is executed.</p>
|
||||
<p>One last note about the environment: FIRST builds a very small word
|
||||
internally that it executes as its main loop. This word calls
|
||||
<code>_read</code> and then calls itself. Each time it calls itself, it
|
||||
uses up a word on the return stack, so it will eventually trash things.
|
||||
<p>If the data stack were stored in main memory, we could synthesize <code>pick</code>;
|
||||
but putting the stack and stack pointer in main memory would significantly
|
||||
increase the C source code size.</p>
|
||||
<p>There are three more primitives, but they are “internal only”–
|
||||
they have no names and no dictionary entries. The first is
|
||||
<code>pushint</code>. It takes the next integer out of the instruction stream
|
||||
and pushes it on the stack. This could be synthesized, but probably
|
||||
not without using integer constants. It is generated by <code>_read</code> when
|
||||
the input is not a known word. The second is <code>compile me</code>. When
|
||||
this instruction is executed, a pointer to the word’s data field is
|
||||
appended to the dictionary. The third is <code>run me</code>–the word’s data
|
||||
field is taken to be a stream of pointers to words, and is executed.</p>
|
||||
<p>One last note about the environment: FIRST builds a very small
|
||||
word internally that it executes as its main loop. This word calls
|
||||
<code>_read</code> and then calls itself. Each time it calls itself, it uses
|
||||
up a word on the return stack, so it will eventually trash things.
|
||||
This is discussed some more in section 2.</p>
|
||||
<p>Here’s a handy summary of all the FIRST words:</p>
|
||||
<pre><code>WORD DESCRIPTION
|
||||
@@ -275,18 +272,18 @@ _read read a word from input and compile a pointer to it
|
||||
exit stop running the current function
|
||||
: compile the header of a definition
|
||||
immediate modify the header to create an immediate word</code></pre>
|
||||
<p>Here is a sample FIRST program. I’m assuming you’re using the ASCII
|
||||
character set. FIRST does not depend upon ASCII, but since FIRST has no
|
||||
syntax for character constants, one normally has to use decimal values.
|
||||
This can be avoided using <code>getchar(3)</code>, though. Oh. One other
|
||||
odd thing. FIRST initially builds its symbol table by calling
|
||||
<code>:</code> several times, so it needs to get the names of the base
|
||||
<p>Here is a sample FIRST program. I’m assuming you’re using
|
||||
the ASCII character set. FIRST does not depend upon ASCII, but
|
||||
since FIRST has no syntax for character constants, one normally has
|
||||
to use decimal values. This can be avoided using <code>getchar(3)</code>, though.
|
||||
Oh. One other odd thing. FIRST initially builds its symbol table
|
||||
by calling <code>:</code> several times, so it needs to get the names of the base
|
||||
symbols as its first 13 words of input. You could even name them
|
||||
differently if you wanted.</p>
|
||||
<p>These FIRST programs have FORTH comments in them: they are contained
|
||||
inside parentheses. FIRST programs cannot have FORTH comments; but I
|
||||
need some device to indicate what’s going on. (THIRD programs are an
|
||||
entirely different subject.)</p>
|
||||
inside parentheses. FIRST programs cannot have FORTH comments; but I need
|
||||
some device to indicate what’s going on. (THIRD programs are an entirely
|
||||
different subject.)</p>
|
||||
<pre><code> ( Our first line gives the symbols for the built-ins )
|
||||
: immediate _read @ ! - * / <0 exit echo key _pick
|
||||
|
||||
@@ -315,73 +312,68 @@ test
|
||||
Hello
|
||||
)</code></pre>
|
||||
<h2 id="section-2-motivating-third">Section 2: Motivating THIRD</h2>
|
||||
<p>What is missing from FIRST? There are a large number of important
|
||||
primitives that aren’t implemented, but which are easy to implement.
|
||||
<code>drop</code>, which throws away the top of the stack, can be
|
||||
implemented as <code>{ 0 * + }</code> – that is, multiply the top of the
|
||||
stack by <code>0</code> (which turns the top of the stack into a
|
||||
<code>0</code>), and then add the top two elements of the stack.</p>
|
||||
<p>What is missing from FIRST? There are a large number of
|
||||
important primitives that aren’t implemented, but which are
|
||||
easy to implement. <code>drop</code>, which throws away the top of the
|
||||
stack, can be implemented as <code>{ 0 * + }</code> – that is, multiply
|
||||
the top of the stack by <code>0</code> (which turns the top of the stack
|
||||
into a <code>0</code>), and then add the top two elements of the stack.</p>
|
||||
<p><code>dup</code>, which copies the top of the stack, can be easily
|
||||
implemented using temporary storage locations. Conveniently, FIRST
|
||||
leaves memory locations <code>3</code>, <code>4</code>, and
|
||||
<code>5</code> unused. So we can implement <code>dup</code> by writing
|
||||
the top of stack into <code>3</code>, and then reading it out twice:
|
||||
<code>{ 3 ! 3 @ 3 @ }</code>.</p>
|
||||
<p>We will never use the FIRST primitive <code>pick</code> in building
|
||||
THIRD, just to show that it can be done; <code>pick</code> is only
|
||||
provided because <code>pick</code> itself cannot be built out of the
|
||||
rest of <code>FIRST</code>’s building blocks.</p>
|
||||
<p>So, instead of worrying about stack primitives and the like, what
|
||||
else is missing from FIRST? We get recursion, but no control flow–no
|
||||
conditional operations. We cannot at the moment write a looping routine
|
||||
which terminates.</p>
|
||||
<p>Another glaring dissimilarity between FIRST and FORTH is that there
|
||||
is no “command mode”–you cannot be outside of a <code>:</code>
|
||||
definition and issue some straight commands to be executed. Also, as we
|
||||
noted above, we cannot do comments.</p>
|
||||
<p>FORTH also provides a system for defining new data types, using the
|
||||
words (in one version of FORTH) <code>builds and does</code>. We would
|
||||
like to implement these words as well.</p>
|
||||
<p>As the highest priority thing, we will build control flow structures
|
||||
first. Once we have control structures, we can write recursive routines
|
||||
that terminate, and we are ready to tackle tasks like parsing, and the
|
||||
building of a command mode.</p>
|
||||
<p>By the way, location <code>0</code> holds the dictionary pointer,
|
||||
location <code>1</code> holds the return stack pointer, and location
|
||||
<code>2</code> should always be <code>0</code>–it’s a fake dictionary
|
||||
entry that means <code>pushint</code>.</p>
|
||||
implemented using temporary storage locations. Conveniently,
|
||||
FIRST leaves memory locations <code>3</code>, <code>4</code>, and <code>5</code> unused. So we can
|
||||
implement <code>dup</code> by writing the top of stack into <code>3</code>, and then
|
||||
reading it out twice: <code>{ 3 ! 3 @ 3 @ }</code>.</p>
|
||||
<p>We will never use the FIRST primitive <code>pick</code> in building THIRD,
|
||||
just to show that it can be done; <code>pick</code> is only provided because
|
||||
<code>pick</code> itself cannot be built out of the rest of <code>FIRST</code>’s building
|
||||
blocks.</p>
|
||||
<p>So, instead of worrying about stack primitives and the
|
||||
like, what else is missing from FIRST? We get recursion, but
|
||||
no control flow–no conditional operations. We cannot at the
|
||||
moment write a looping routine which terminates.</p>
|
||||
<p>Another glaring dissimilarity between FIRST and FORTH is
|
||||
that there is no “command mode”–you cannot be outside of a
|
||||
<code>:</code> definition and issue some straight commands to be executed.
|
||||
Also, as we noted above, we cannot do comments.</p>
|
||||
<p>FORTH also provides a system for defining new data types,
|
||||
using the words (in one version of FORTH) <code>builds and does</code>.
|
||||
We would like to implement these words as well.</p>
|
||||
<p>As the highest priority thing, we will build control flow
|
||||
structures first. Once we have control structures, we can
|
||||
write recursive routines that terminate, and we are ready to
|
||||
tackle tasks like parsing, and the building of a command mode.</p>
|
||||
<p>By the way, location <code>0</code> holds the dictionary pointer, location
|
||||
<code>1</code> holds the return stack pointer, and location <code>2</code> should always
|
||||
be <code>0</code>–it’s a fake dictionary entry that means <code>pushint</code>.</p>
|
||||
<h2 id="section-3-building-third">Section 3: Building THIRD</h2>
|
||||
<p>In this section we’ll eventually have real comments.</p>
|
||||
<p>The first thing we have to do is give the symbols for our
|
||||
built-ins.</p>
|
||||
<p>The first thing we have to do is give the symbols for our built-ins.</p>
|
||||
<pre><code>: immediate _read @ ! - * / < exit echo key _pick</code></pre>
|
||||
<p>Next we want to be mildly self commenting, so we define the word
|
||||
<code>r</code> to push the <em>address of the return stack pointer</em>
|
||||
onto the stack–NOT the value of the return stack pointer. (In fact, when
|
||||
we run <code>r</code>, the value of the return stack pointer is
|
||||
temporarily changed.)</p>
|
||||
<p>Next we want to be mildly self commenting, so we define the word <code>r</code> to push
|
||||
the <em>address of the return stack pointer</em> onto the stack–NOT the value of the
|
||||
return stack pointer. (In fact, when we run <code>r</code>, the value of the return stack
|
||||
pointer is temporarily changed.)</p>
|
||||
<pre><code>: r 1 exit</code></pre>
|
||||
<p>Next, we’re currently executing a short loop that contains
|
||||
<code>_read</code> and recursion, which is slowly blowing up the return
|
||||
stack. So let’s define a new word, from which you can never return. What
|
||||
it does is drops the top value off the return stack, calls
|
||||
<code>_read</code>, then calls itself. Because it kills the top of the
|
||||
return stack, it can recurse indefinitely.</p>
|
||||
<p>Next, we’re currently executing a short loop that contains <code>_read</code> and
|
||||
recursion, which is slowly blowing up the return stack. So let’s define a new
|
||||
word, from which you can never return. What it does is drops the top value off
|
||||
the return stack, calls <code>_read</code>, then calls itself. Because it kills the top of
|
||||
the return stack, it can recurse indefinitely.</p>
|
||||
<pre><code>: ]
|
||||
r @ Get the value of the return stack pointer
|
||||
1 - Subtract one
|
||||
r ! Store it back into the return stack pointer
|
||||
_read Read and compile one word
|
||||
] Start over</code></pre>
|
||||
<p>Notice that we don’t need to exit, since we never come back. Also,
|
||||
it’s possible that an immediate word may get run during
|
||||
<code>_read</code>, and that <code>_read</code> will never return!</p>
|
||||
<p>Notice that we don’t need to exit, since we never come back. Also, it’s
|
||||
possible that an immediate word may get run during <code>_read</code>, and that <code>_read</code>
|
||||
will never return!</p>
|
||||
<p>Now let’s get compile running.</p>
|
||||
<pre><code>: main immediate ]
|
||||
main</code></pre>
|
||||
<p>Next off, I’m going to do this the easy but non-portable way, and put
|
||||
some character constant definitions in. I wanted them at the top of the
|
||||
file, but that would have burned too much of the return stack.</p>
|
||||
<p>Next off, I’m going to do this the easy but non-portable way, and put some
|
||||
character constant definitions in. I wanted them at the top of the file, but
|
||||
that would have burned too much of the return stack.</p>
|
||||
<pre><code>: '"' 34 exit
|
||||
: ')' 41 exit
|
||||
: '\n' 10 exit
|
||||
@@ -390,29 +382,28 @@ file, but that would have burned too much of the return stack.</p>
|
||||
: '-' 45 exit
|
||||
|
||||
: cr '\n' echo exit</code></pre>
|
||||
<p>Next, we want to define some temporary variables for locations
|
||||
<code>3</code>, <code>4</code>, and <code>5</code>, since this’ll make
|
||||
our code look clearer.</p>
|
||||
<p>Next, we want to define some temporary variables for locations <code>3</code>, <code>4</code>, and
|
||||
<code>5</code>, since this’ll make our code look clearer.</p>
|
||||
<pre><code>: _x 3 @ exit
|
||||
: _x! 3 ! exit
|
||||
: _y 4 @ exit
|
||||
: _y! 4 ! exit
|
||||
</code></pre>
|
||||
<p>OK. Now, we want to make THIRD look vaguely like FORTH, so we’re
|
||||
going to define <code>;</code>. What <code>;</code> ought to do is
|
||||
terminate a compilation, and turn control over to the command-mode
|
||||
handler. We don’t have one, so all we want <code>;</code> to do for now
|
||||
is compile <code>exit</code> at the end of the current word. To do this
|
||||
we’ll need several other words.</p>
|
||||
<p>Swap by writing out the top two elements into temps, and then reading
|
||||
them back in the other order.</p>
|
||||
<p>OK. Now, we want to make THIRD look vaguely like FORTH,
|
||||
so we’re going to define <code>;</code>. What <code>;</code> ought to do is
|
||||
terminate a compilation, and turn control over to the
|
||||
command-mode handler. We don’t have one, so all we want
|
||||
<code>;</code> to do for now is compile <code>exit</code> at the end of the
|
||||
current word. To do this we’ll need several other words.</p>
|
||||
<p>Swap by writing out the top two elements into temps, and
|
||||
then reading them back in the other order.</p>
|
||||
<pre><code>: swap _x! _y! _x _y exit</code></pre>
|
||||
<p>Take another look and make sure you see why that works, since it
|
||||
LOOKS like I’m reading them back in the same order–in fact, it not only
|
||||
looks like it, but I AM!</p>
|
||||
<p>Addition might be nice to have. To add, we need to negate the top
|
||||
element of the stack, and then subtract. To negate, we subtract from
|
||||
<code>0</code>.</p>
|
||||
<p>Take another look and make sure you see why that works,
|
||||
since it LOOKS like I’m reading them back in the same
|
||||
order–in fact, it not only looks like it, but I AM!</p>
|
||||
<p>Addition might be nice to have. To add, we need to
|
||||
negate the top element of the stack, and then subtract.
|
||||
To negate, we subtract from <code>0</code>.</p>
|
||||
<pre><code>: +
|
||||
0 swap -
|
||||
-
|
||||
@@ -420,12 +411,13 @@ element of the stack, and then subtract. To negate, we subtract from
|
||||
</code></pre>
|
||||
<p>Create a copy of the top of stack.</p>
|
||||
<pre><code>: dup _x! _x _x exit</code></pre>
|
||||
<p>Get a mnemonic name for our dictionary pointer–we need to compile
|
||||
stuff, so it goes through this.</p>
|
||||
<p>Get a mnemonic name for our dictionary pointer–we need
|
||||
to compile stuff, so it goes through this.</p>
|
||||
<pre><code>: h 0 exit</code></pre>
|
||||
<p>We’re going to need to advance that pointer, so let’s make a generic
|
||||
pointer-advancing function. Given a pointer to a memory location,
|
||||
increment the value at that memory location.</p>
|
||||
<p>We’re going to need to advance that pointer, so let’s
|
||||
make a generic pointer-advancing function.
|
||||
Given a pointer to a memory location, increment the value
|
||||
at that memory location.</p>
|
||||
<pre><code>: inc
|
||||
dup @ Get another copy of the address, and get the value
|
||||
so now we have value, address on top of stack.
|
||||
@@ -441,12 +433,13 @@ stack into the dictionary, and advance the pointer</p>
|
||||
h inc And increment the dictionary pointer
|
||||
exit</code></pre>
|
||||
<p><code>'</code> is a standard FORTH word. It should push the address
|
||||
of the word that follows it onto the stack. We could do this by making
|
||||
<code>'</code> immediate, but then it’d need to parse the next word.
|
||||
Instead, we compile the next word as normal. When <code>'</code> is
|
||||
executed, the top of the return stack will point into the instruction
|
||||
stream immediately after the <code>'</code>. We push the word there, and
|
||||
advance the return stack pointer so that we don’t execute it.</p>
|
||||
of the word that follows it onto the stack. We could
|
||||
do this by making <code>'</code> immediate, but then it’d need to
|
||||
parse the next word. Instead, we compile the next word
|
||||
as normal. When <code>'</code> is executed, the top of the return
|
||||
stack will point into the instruction stream immediately
|
||||
after the <code>'</code>. We push the word there, and advance the
|
||||
return stack pointer so that we don’t execute it.</p>
|
||||
<pre><code>: '
|
||||
r @ Get the address of the top of return stack
|
||||
We currently have a pointer to the top of return stack
|
||||
@@ -469,18 +462,19 @@ the address of <code>exit</code> onto the stack, then writes it out.</p>
|
||||
exit And we should return</code></pre>
|
||||
<p>Now let’s test out <code>;</code> by defining a useful word:</p>
|
||||
<pre><code>: drop 0 * + ;</code></pre>
|
||||
<p>Since we have <code>inc</code>, we ought to make
|
||||
<code>dec</code>:</p>
|
||||
<p>Since we have <code>inc</code>, we ought to make <code>dec</code>:</p>
|
||||
<pre><code>: dec dup @ 1 - swap ! ;</code></pre>
|
||||
<p>Our next goal, now that we have <code>;</code>, is to implement
|
||||
<code>if-then</code>. To do this, we’ll need to play fast and loose with
|
||||
the return stack, so let’s make some words to save us some effort.</p>
|
||||
<p>First we want a word that pops off the top of the normal stack and
|
||||
pushes it on top of the return stack. We’ll call this <code>tor</code>,
|
||||
for TO-Return-stack. It sounds easy, but when <code>tor</code> is
|
||||
running, there’s an extra value on the return stack–<code>tor</code>’s
|
||||
return address! So we have to pop that off first… We better just bite
|
||||
the bullet and code it out–but we can’t really break it into smaller
|
||||
<code>if-then</code>. To do this, we’ll need to play fast and
|
||||
loose with the return stack, so let’s make some
|
||||
words to save us some effort.</p>
|
||||
<p>First we want a word that pops off the top of the normal
|
||||
stack and pushes it on top of the return stack. We’ll
|
||||
call this <code>tor</code>, for TO-Return-stack. It sounds easy,
|
||||
but when <code>tor</code> is running, there’s an extra value on the
|
||||
return stack–<code>tor</code>’s return address! So we have to pop
|
||||
that off first… We better just bite the bullet and
|
||||
code it out–but we can’t really break it into smaller
|
||||
words, because that’ll trash the return stack.</p>
|
||||
<pre><code>: tor
|
||||
r @ @ Get the value off the top of the return stack
|
||||
@@ -489,8 +483,8 @@ words, because that’ll trash the return stack.</p>
|
||||
r @ 1 + r ! Increment the return stack pointer--but can't use inc
|
||||
r @ ! Store our return address back on the return stack
|
||||
;</code></pre>
|
||||
<p>Next we want the opposite routine, which pops the top of the return
|
||||
stack, and puts it on the normal stack.</p>
|
||||
<p>Next we want the opposite routine, which pops the top
|
||||
of the return stack, and puts it on the normal stack.</p>
|
||||
<pre><code>: fromr
|
||||
r @ @ Save old value
|
||||
r @ 1 - r ! Decrement pointer
|
||||
@@ -498,25 +492,26 @@ stack, and puts it on the normal stack.</p>
|
||||
swap Bring return address to top
|
||||
r @ ! Store it and return
|
||||
;</code></pre>
|
||||
<p>Now, if we have a routine that’s recursing, and we want to be polite
|
||||
about the return stack, right before we recurse we can run
|
||||
<code>{ fromr drop }</code> so the stack won’t blow up. This means,
|
||||
though, that the first time we enter this recursive routine, we blow our
|
||||
<em>real</em> return address–so when we’re done, we’ll return up two
|
||||
levels. To save a little, we make <code>tail</code> mean
|
||||
<code>{ fromr drop }</code>; however, it’s more complex since there’s a
|
||||
new value on top of the return stack.</p>
|
||||
<p>Now, if we have a routine that’s recursing, and we
|
||||
want to be polite about the return stack, right before
|
||||
we recurse we can run <code>{ fromr drop }</code> so the stack won’t
|
||||
blow up. This means, though, that the first time we
|
||||
enter this recursive routine, we blow our <em>real</em> return
|
||||
address–so when we’re done, we’ll return up two levels.
|
||||
To save a little, we make <code>tail</code> mean <code>{ fromr drop }</code>;
|
||||
however, it’s more complex since there’s a new value on
|
||||
top of the return stack.</p>
|
||||
<pre><code>: tail fromr fromr drop tor ;</code></pre>
|
||||
<p>Now, we want to do <code>if</code>. To do this, we need to convert
|
||||
values to boolean values. The next few words set this up.</p>
|
||||
values to boolean values. The next few words set this
|
||||
up.</p>
|
||||
<p><code>minus</code> gives us unary negation.</p>
|
||||
<pre><code>: minus 0 swap - ;</code></pre>
|
||||
<p>If top of stack is boolean, <code>bnot</code> gives us inverse</p>
|
||||
<pre><code>: bnot 1 swap - ;</code></pre>
|
||||
<p>To compare two numbers, subtract and compare to <code>0</code>.</p>
|
||||
<pre><code>: < - <0 ;</code></pre>
|
||||
<p><code>logical</code> turns the top of stack into either
|
||||
<code>0</code> or <code>1</code>.</p>
|
||||
<p><code>logical</code> turns the top of stack into either <code>0</code> or <code>1</code>.</p>
|
||||
<pre><code>: logical
|
||||
dup Get two copies of it
|
||||
0 < 1 if < 0, 0 otherwise
|
||||
@@ -526,14 +521,13 @@ values to boolean values. The next few words set this up.</p>
|
||||
;</code></pre>
|
||||
<p><code>not</code> returns 1 if top of stack is 0, and 0 otherwise</p>
|
||||
<pre><code>: not logical bnot ;</code></pre>
|
||||
<p>We can test equality by subtracting and comparing to
|
||||
<code>0</code>.</p>
|
||||
<p>We can test equality by subtracting and comparing to <code>0</code>.</p>
|
||||
<pre><code>: = - not ;</code></pre>
|
||||
<p>Just to show how you compute a branch: Suppose you’ve compiled a call
|
||||
to branch, and immediately after it is an integer constant with the
|
||||
offset of how far to branch. To branch, we use the return stack to read
|
||||
the offset, and add that on to the top of the return stack, and
|
||||
return.</p>
|
||||
<p>Just to show how you compute a branch: Suppose you’ve
|
||||
compiled a call to branch, and immediately after it is
|
||||
an integer constant with the offset of how far to branch.
|
||||
To branch, we use the return stack to read the offset, and
|
||||
add that on to the top of the return stack, and return.</p>
|
||||
<pre><code>: branch
|
||||
r @ Address of top of return stack
|
||||
@ Our return address
|
||||
@@ -542,12 +536,12 @@ return.</p>
|
||||
+ The address we want to execute at
|
||||
r @ ! Store it back onto the return stack
|
||||
;</code></pre>
|
||||
<p>For conditional branches, we want to branch by a certain amount if
|
||||
true, otherwise we want to skip over the branch offset constant–that is,
|
||||
branch by one. Assuming that the top of the stack is the branch offset,
|
||||
and the second on the stack is <code>1</code> if we should branch, and
|
||||
<code>0</code> if not, the following computes the correct branch
|
||||
offset.</p>
|
||||
<p>For conditional branches, we want to branch by a certain
|
||||
amount if true, otherwise we want to skip over the branch
|
||||
offset constant–that is, branch by one. Assuming that
|
||||
the top of the stack is the branch offset, and the second
|
||||
on the stack is <code>1</code> if we should branch, and <code>0</code> if not, the
|
||||
following computes the correct branch offset.</p>
|
||||
<pre><code>: computebranch 1 - * 1 + ;</code></pre>
|
||||
<p>Branch if the value on top of the stack is <code>0</code>.</p>
|
||||
<pre><code>: notbranch
|
||||
@@ -558,31 +552,31 @@ offset.</p>
|
||||
r @ ! Store it
|
||||
;</code></pre>
|
||||
<p><code>here</code> is a standard FORTH word which returns a pointer to
|
||||
the current dictionary address–that is, the value of the dictionary
|
||||
pointer.</p>
|
||||
the current dictionary address–that is, the value of
|
||||
the dictionary pointer.</p>
|
||||
<pre><code>: here h @ ;</code></pre>
|
||||
<p>We’re ALL SET to compile <code>if...else...then</code> constructs!
|
||||
Here’s what we do. When we get <code>if</code>, we compile a call to
|
||||
<code>notbranch</code>, and then compile a dummy offset, because we
|
||||
don’t know where the <code>then</code> will be. On the <em>stack</em> we
|
||||
leave the address where we compiled the dummy offset. <code>then</code>
|
||||
will calculate the offset and fill it in for us.</p>
|
||||
Here’s what we do. When we get <code>if</code>, we compile a call
|
||||
to <code>notbranch</code>, and then compile a dummy offset, because
|
||||
we don’t know where the <code>then</code> will be. On the <em>stack</em>
|
||||
we leave the address where we compiled the dummy offset.
|
||||
<code>then</code> will calculate the offset and fill it in for us.</p>
|
||||
<pre><code>: if immediate
|
||||
' notbranch , Compile notbranch
|
||||
here Save the current dictionary address
|
||||
0 , Compile a dummy value
|
||||
;</code></pre>
|
||||
<p><code>then</code> expects the address to <code>fixup</code> to be on
|
||||
the stack.</p>
|
||||
<p><code>then</code> expects the address to <code>fixup</code> to be on the stack.</p>
|
||||
<pre><code>: then immediate
|
||||
dup Make another copy of the address
|
||||
here Find the current location, where to branch to
|
||||
swap - Calculate the difference between them
|
||||
swap ! Bring the address to the top, and store it.
|
||||
;</code></pre>
|
||||
<p>Now that we can do <code>if...then</code> statements, we can do some
|
||||
parsing! Let’s introduce real FORTH comments. <code>find-)</code> will
|
||||
scan the input until it finds a <code>)</code>, and exit.</p>
|
||||
<p>Now that we can do <code>if...then</code> statements, we can do
|
||||
some parsing! Let’s introduce real FORTH comments.
|
||||
<code>find-)</code> will scan the input until it finds a <code>)</code>, and
|
||||
exit.</p>
|
||||
<pre><code>: find-)
|
||||
key Read in a character
|
||||
')' = Compare it to close parentheses
|
||||
|
||||
+155
-225
@@ -130,8 +130,8 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Sean_Barrett">Sean Barrett</a><br>
|
||||
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown
|
||||
location</em> <br><br></li>
|
||||
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
|
||||
<br><br></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -141,11 +141,11 @@ location</em> <br><br></li>
|
||||
|
||||
<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> all</span></code></pre></div>
|
||||
<p>There is an alternate version of this program. See <a
|
||||
href="#alternate-code">Alternate code</a> below for details.</p>
|
||||
<p>There is an alternate version of this program. See <a href="#alternate-code">Alternate
|
||||
code</a> below for details.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<p>First, you must make sure that <code>first</code> is made first (even
|
||||
though <code>make all</code> should make first first :-) ):</p>
|
||||
<p>First, you must make sure that <code>first</code> is made first (even though <code>make all</code>
|
||||
should make first first :-) ):</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> first</span></code></pre></div>
|
||||
<p>Second:</p>
|
||||
<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="co"># get help:</span></span>
|
||||
@@ -163,147 +163,126 @@ though <code>make all</code> should make first first :-) ):</p>
|
||||
<h2 id="try">Try:</h2>
|
||||
<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="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>This alternate version, <a
|
||||
href="buzzard.2.alt.c">buzzard.2.alt.c</a>, does not contain a fix that
|
||||
the author notes in their remarks.</p>
|
||||
<p>This alternate version, <a href="buzzard.2.alt.c">buzzard.2.alt.c</a>, does not contain a
|
||||
fix that the author notes in their remarks.</p>
|
||||
<h3 id="alternate-build">Alternate build:</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="fu">make</span> alt</span></code></pre></div>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>buzzard.2.alt</code> as you would <code>buzzard.2</code>
|
||||
above.</p>
|
||||
<p>Use <code>buzzard.2.alt</code> as you would <code>buzzard.2</code> above.</p>
|
||||
<h3 id="alternate-try">Alternate 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">./try.alt.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>Have fun!</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="what-it-does">What it does</h3>
|
||||
<p><code>first</code> implements a relatively primitive stack machine.
|
||||
How primitive? It supplies 13 visible primitives: 3 arithmetic, 1
|
||||
comparison, 2 memory-access, 2 character I/O, 3 primitives for defining
|
||||
new words, 1 tokenizing, and 1 special stack operation. (There are also
|
||||
three internal operations for the stack machine: ‘push this integer’,
|
||||
‘call this code’, and ‘compile a call to this code’.)</p>
|
||||
<p>It is very difficult to accomplish anything with this set of
|
||||
primitives, but they do have an interesting property.</p>
|
||||
<p>This–what this interesting property is, or in other words what first
|
||||
is good for–is the major obfuscation; there are also minor source
|
||||
obfuscations, as well as some design tricks that are effectively
|
||||
obfuscations. Details on the obfuscations are below, and the interesting
|
||||
property is discussed much further down.</p>
|
||||
<p><code>first</code> implements a relatively primitive stack machine. How
|
||||
primitive? It supplies 13 visible primitives: 3 arithmetic,
|
||||
1 comparison, 2 memory-access, 2 character I/O, 3 primitives
|
||||
for defining new words, 1 tokenizing, and 1 special stack
|
||||
operation. (There are also three internal operations for
|
||||
the stack machine: ‘push this integer’, ‘call this code’,
|
||||
and ‘compile a call to this code’.)</p>
|
||||
<p>It is very difficult to accomplish anything with this set
|
||||
of primitives, but they do have an interesting property.</p>
|
||||
<p>This–what this interesting property is, or in other words
|
||||
what first is good for–is the major obfuscation; there are
|
||||
also minor source obfuscations, as well as some design tricks
|
||||
that are effectively obfuscations. Details on the obfuscations
|
||||
are below, and the interesting property is discussed much
|
||||
further down.</p>
|
||||
<h3 id="how-to-run-it">How to run it</h3>
|
||||
<p><code>first</code> expects you to first enter the names of the 13
|
||||
primitives, separated by whitespace–it doesn’t care what you name them,
|
||||
but if all the names aren’t unique, you won’t be able to use some of
|
||||
them. After this you may type any sequence of valid <code>first</code>
|
||||
input. Valid <code>first</code> input is defined as any sequence of
|
||||
whitespace-delimited tokens which consist of primitives, new words
|
||||
you’ve defined, and integers (as parsed by <code>"%d"</code>). Invalid
|
||||
input behaves unpredictably, but gives no warning messages. A sample
|
||||
program, <code>demo1.1st</code>, is included, but it only works on ASCII
|
||||
systems.</p>
|
||||
<p>Do not expect to be able to do anything interesting with
|
||||
<code>first</code>.</p>
|
||||
<p>To do something interesting, you need to feed <code>first</code> the
|
||||
file <a href="third">third</a> first. In unix, you can do</p>
|
||||
<div class="sourceCode" id="cb10"><pre
|
||||
class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> third help.th <span class="at">-</span> <span class="kw">|</span> <span class="ex">./first</span></span></code></pre></div>
|
||||
<p>to do this. Hopefully most operating systems will provide a way to do
|
||||
this. It may take some time for this to complete (I seem to remember it
|
||||
taking several minutes on an 8086 PC); <code>THIRD</code> will prompt
|
||||
you when it is finished. The file <a href="third">third</a> has not been
|
||||
obfuscated, due to sheer kindness on the author’s part.</p>
|
||||
<p>For more information on what you can do once you’ve piped <a
|
||||
href="third">third</a> into first, type <code>help</code> and consult <a
|
||||
href="https://en.wikipedia.org/wiki/Forth_(programming_language)">FORTH</a>
|
||||
manuals for further reference. Six sample THIRD programs are included in
|
||||
the files <code>demo1.th</code> through <code>demo6.th</code>. See <a
|
||||
href="buzzard.2.README.html">buzzard.2.README.html</a> for more
|
||||
information.</p>
|
||||
<p>Keep in mind that you are still running <code>first</code>, and are
|
||||
for the most part limited by <code>first</code>’s tokenizer (notably,
|
||||
unknown words will attempt to be parsed as integers.) It is possible to
|
||||
build a new parser that parses by hand, reading a single character at a
|
||||
time; however, such a parser cannot easily use the existing dictionary,
|
||||
and so would have to implement its own, thus requiring reimplementing
|
||||
all of <code>first</code> and <code>third</code> a second time–I did not
|
||||
care to tackle this project.</p>
|
||||
<p><code>first</code> expects you to first enter the names of the 13 primitives,
|
||||
separated by whitespace–it doesn’t care what you name them, but
|
||||
if all the names aren’t unique, you won’t be able to use some of
|
||||
them. After this you may type any sequence of valid <code>first</code> input.
|
||||
Valid <code>first</code> input is defined as any sequence of whitespace-delimited
|
||||
tokens which consist of primitives, new words you’ve defined, and
|
||||
integers (as parsed by <code>"%d"</code>). Invalid input behaves unpredictably,
|
||||
but gives no warning messages. A sample program, <code>demo1.1st</code>, is
|
||||
included, but it only works on ASCII systems.</p>
|
||||
<p>Do not expect to be able to do anything interesting with <code>first</code>.</p>
|
||||
<p>To do something interesting, you need to feed <code>first</code> the file
|
||||
<a href="third">third</a> first. In unix, you can do</p>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> third help.th <span class="at">-</span> <span class="kw">|</span> <span class="ex">./first</span></span></code></pre></div>
|
||||
<p>to do this. Hopefully most operating systems will provide a way to do this. It
|
||||
may take some time for this to complete (I seem to remember it taking several
|
||||
minutes on an 8086 PC); <code>THIRD</code> will prompt you when it is finished. The file
|
||||
<a href="third">third</a> has not been obfuscated, due to sheer kindness on the author’s
|
||||
part.</p>
|
||||
<p>For more information on what you can do once you’ve piped <a href="third">third</a> into
|
||||
first, type <code>help</code> and consult
|
||||
<a href="https://en.wikipedia.org/wiki/Forth_(programming_language)">FORTH</a> manuals for
|
||||
further reference. Six sample THIRD programs are included in the files
|
||||
<code>demo1.th</code> through <code>demo6.th</code>. See <a href="buzzard.2.README.html">buzzard.2.README.html</a>
|
||||
for more information.</p>
|
||||
<p>Keep in mind that you are still running <code>first</code>, and are for the most part
|
||||
limited by <code>first</code>’s tokenizer (notably, unknown words will attempt to be parsed
|
||||
as integers.) It is possible to build a new parser that parses by hand, reading
|
||||
a single character at a time; however, such a parser cannot easily use the
|
||||
existing dictionary, and so would have to implement its own, thus requiring
|
||||
reimplementing all of <code>first</code> and <code>third</code> a second time–I did not care to
|
||||
tackle this project.</p>
|
||||
<h3 id="compiling">Compiling</h3>
|
||||
<p><code>first</code> is reasonably portable. You may need to adjust the
|
||||
size of the buffers on smaller machines; <code>m[]</code> needs to be at
|
||||
least 2000 long, though.</p>
|
||||
<p>I say <code>first</code> is portable mainly because it uses native
|
||||
types. Unlike
|
||||
[FORTH](https://en.wikipedia.org/wiki/Forth_(programming_language),
|
||||
which traditionally allows byte and multi-byte operations, all
|
||||
operations are performed on C <code>int</code>s. That means
|
||||
<code>first</code> code is only as portable as the same code would be in
|
||||
C. As in C, the result of dividing <code>-1</code> by <code>2</code> is
|
||||
machine (or rather compiler) dependent.</p>
|
||||
<p><code>first</code> is reasonably portable. You may need to adjust the size of the buffers
|
||||
on smaller machines; <code>m[]</code> needs to be at least 2000 long, though.</p>
|
||||
<p>I say <code>first</code> is portable mainly because it uses native types. Unlike
|
||||
[FORTH](https://en.wikipedia.org/wiki/Forth_(programming_language), which
|
||||
traditionally allows byte and multi-byte operations, all operations are
|
||||
performed on C <code>int</code>s. That means <code>first</code> code is only as portable as the same
|
||||
code would be in C. As in C, the result of dividing <code>-1</code> by <code>2</code> is machine (or
|
||||
rather compiler) dependent.</p>
|
||||
<h3 id="how-is-first-obfuscated">How is first obfuscated?</h3>
|
||||
<p><code>first</code> is obfuscated in several ways. Some minor
|
||||
obfuscations like <code>&w[&m[1]][s]</code> for
|
||||
<code>s+m[w+1]</code> were in the original source but are no longer
|
||||
because, apparently, ANSI doesn’t allow it
|
||||
(<code>gcc -ansi -pedantic</code> doesn’t mind it, though.)</p>
|
||||
<p>Other related obfuscations are still present. The top of the stack is
|
||||
cached in a variable, which increases performance massively if the
|
||||
compiler can figure out to keep it in a register; it also obfuscates the
|
||||
code. (Unfortunately, the top of stack is a global variable and neither
|
||||
gcc nor most bundled compilers seem to <code>register</code> allocate
|
||||
it.)</p>
|
||||
<p>More significant are the design obfuscations. <code>m[0]</code> is
|
||||
the “dictionary pointer”, used when compiling words, and
|
||||
<code>m[1]</code> is the return stack index. Both are used as integer
|
||||
offsets into <code>m</code>. Both are kept in <code>m</code>, instead of
|
||||
as separate pointers, because they are then accessible to
|
||||
<code>first</code> programs, which is a crucial property of
|
||||
<code>first</code>. Similarly the way words are stored in the dictionary
|
||||
is not obvious, so it can be difficult to follow exactly what the
|
||||
<p><code>first</code> is obfuscated in several ways. Some minor obfuscations like
|
||||
<code>&w[&m[1]][s]</code> for <code>s+m[w+1]</code> were in the original source but are no longer
|
||||
because, apparently, ANSI doesn’t allow it (<code>gcc -ansi -pedantic</code> doesn’t mind
|
||||
it, though.)</p>
|
||||
<p>Other related obfuscations are still present. The top of the stack is cached in
|
||||
a variable, which increases performance massively if the compiler can figure out
|
||||
to keep it in a register; it also obfuscates the code. (Unfortunately, the top
|
||||
of stack is a global variable and neither gcc nor most bundled compilers seem to
|
||||
<code>register</code> allocate it.)</p>
|
||||
<p>More significant are the design obfuscations. <code>m[0]</code> is the “dictionary
|
||||
pointer”, used when compiling words, and <code>m[1]</code> is the return stack index. Both
|
||||
are used as integer offsets into <code>m</code>. Both are kept in <code>m</code>, instead of as
|
||||
separate pointers, because they are then accessible to <code>first</code> programs, which
|
||||
is a crucial property of <code>first</code>. Similarly the way words are stored in the
|
||||
dictionary is not obvious, so it can be difficult to follow exactly what the
|
||||
compiler words are doing.</p>
|
||||
<p>Assuming you’ve waded through all that, you still have to penetrate
|
||||
the most significant obfuscation. Traditionally, the question is whether
|
||||
a reader can answer the question “what will this do when I run it”. A
|
||||
reader who has deciphered <code>first</code> to this point may think
|
||||
they know the answer to this question, but they may not know the answer
|
||||
to the more important question, “what will this program do when given
|
||||
the right input?” <a
|
||||
href="https://en.wikipedia.org/wiki/Forth_(programming_language)">FORTH</a>
|
||||
aficionados, and especially FORTH implementers, may recognize the
|
||||
similarity of the internal compiler format to many FORTH internal
|
||||
representations, and, being aware that FORTH interpreters can often be
|
||||
self-compiling, may be suspicious that this program can compile FORTH,
|
||||
or a significant subset of it, or at least be capable of doing so if fed
|
||||
the right input. Of course, the name “THIRD” should be a dead giveaway,
|
||||
if the name “first” wasn’t. (These numbers were largely chosen because
|
||||
they were five letters long, like “FORTH”, and would not require
|
||||
truncation to five letters, which would be a dead giveaway. Besides,
|
||||
THIRD represents a step backwards, in more ways than one.)</p>
|
||||
<h3 id="what-exactly-is-first-then">What exactly is <code>first</code>,
|
||||
then?</h3>
|
||||
<p><code>first</code> is a tiny interpreter which implements a
|
||||
sufficient pseudo-subset of <a
|
||||
href="https://en.wikipedia.org/wiki/Forth_(programming_language)">FORTH</a>
|
||||
to allow it to bootstrap a relatively complete version of FORTH (based
|
||||
loosely on forth79), which I call THIRD. Complete relative to what, I’m
|
||||
not sure.</p>
|
||||
<p>I believe <code>first</code> is close to the smallest amount of code
|
||||
possible to get this effect <em>using forth-style primitives</em>, and
|
||||
still have some efficiency (it is possible to get by without
|
||||
multiplication if you have addition, obviously). In the design file,
|
||||
design, I give a justification for why each primitive in
|
||||
<p>Assuming you’ve waded through all that, you still have to penetrate the most
|
||||
significant obfuscation. Traditionally, the question is whether a reader can
|
||||
answer the question “what will this do when I run it”. A reader who has
|
||||
deciphered <code>first</code> to this point may think they know the answer to this
|
||||
question, but they may not know the answer to the more important question, “what
|
||||
will this program do when given the right input?”
|
||||
<a href="https://en.wikipedia.org/wiki/Forth_(programming_language)">FORTH</a> aficionados,
|
||||
and especially FORTH implementers, may recognize the similarity of the internal
|
||||
compiler format to many FORTH internal representations, and, being aware that
|
||||
FORTH interpreters can often be self-compiling, may be suspicious that this
|
||||
program can compile FORTH, or a significant subset of it, or at least be capable
|
||||
of doing so if fed the right input. Of course, the name “THIRD” should be a
|
||||
dead giveaway, if the name “first” wasn’t. (These numbers were largely chosen
|
||||
because they were five letters long, like “FORTH”, and would not require
|
||||
truncation to five letters, which would be a dead giveaway. Besides, THIRD
|
||||
represents a step backwards, in more ways than one.)</p>
|
||||
<h3 id="what-exactly-is-first-then">What exactly is <code>first</code>, then?</h3>
|
||||
<p><code>first</code> is a tiny interpreter which implements a sufficient pseudo-subset of
|
||||
<a href="https://en.wikipedia.org/wiki/Forth_(programming_language)">FORTH</a> to allow it
|
||||
to bootstrap a relatively complete version of FORTH (based loosely on forth79),
|
||||
which I call THIRD. Complete relative to what, I’m not sure.</p>
|
||||
<p>I believe <code>first</code> is close to the smallest amount of code possible to get this
|
||||
effect <em>using forth-style primitives</em>, and still have some efficiency (it is
|
||||
possible to get by without multiplication if you have addition, obviously). In
|
||||
the design file, design, I give a justification for why each primitive in
|
||||
<code>first</code> was included.</p>
|
||||
<p>THIRD is sorta slow, because <code>first</code> has so few primitives
|
||||
that many things that are primitives in <a
|
||||
href="https://en.wikipedia.org/wiki/Forth_(programming_language)">FORTH</a>
|
||||
(like swap) take a significant amount of time in THIRD.</p>
|
||||
<p>When you get the <code>Ok.</code> message from <code>third</code>,
|
||||
try out some sample <a
|
||||
href="https://en.wikipedia.org/wiki/Forth_(programming_language)">FORTH</a>
|
||||
code (<code>first</code> has no way of knowing if keyboard input is
|
||||
waiting, so it can’t actually prompt you in a normal way. It only prints
|
||||
<code>'Ok.'</code> after you define a word).</p>
|
||||
<div class="sourceCode" id="cb11"><pre
|
||||
class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="ex">2</span> 3 + . cr</span></code></pre></div>
|
||||
<p>THIRD is sorta slow, because <code>first</code> has so few primitives that many things that
|
||||
are primitives in
|
||||
<a href="https://en.wikipedia.org/wiki/Forth_(programming_language)">FORTH</a> (like swap)
|
||||
take a significant amount of time in THIRD.</p>
|
||||
<p>When you get the <code>Ok.</code> message from <code>third</code>, try out some sample
|
||||
<a href="https://en.wikipedia.org/wiki/Forth_(programming_language)">FORTH</a> code
|
||||
(<code>first</code> has no way of knowing if keyboard input is waiting, so it can’t actually prompt
|
||||
you in a normal way. It only prints <code>'Ok.'</code> after you define a word).</p>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="ex">2</span> 3 + . cr</span></code></pre></div>
|
||||
<p>(which adds 2 and 3, and print the result and a newline.)</p>
|
||||
<p>THIRD responds:</p>
|
||||
<pre><code>5</code></pre>
|
||||
@@ -312,115 +291,66 @@ class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#
|
||||
test</code></pre>
|
||||
<p>and THIRD responds</p>
|
||||
<pre><code>1 2 3 4 5 6 7 8 9 10</code></pre>
|
||||
<p>When in <code>THIRD</code>, you can see how much space you’re
|
||||
currently using by typing:</p>
|
||||
<p>When in <code>THIRD</code>, you can see how much space you’re currently
|
||||
using by typing:</p>
|
||||
<pre><code>here .</code></pre>
|
||||
<p>The number THIRD replies with is the number of machine words
|
||||
(<code>int</code>s) that the dictionary (the first code) takes up, plus
|
||||
the 512 <code>int</code>s for the return stack. If you compile the basic
|
||||
THIRD system without the help word (strings take up one <code>int</code>
|
||||
per character in the string!), you should find that you’re using around
|
||||
<p>The number THIRD replies with is the number of machine words (<code>int</code>s) that the
|
||||
dictionary (the first code) takes up, plus the 512 <code>int</code>s for the return stack.
|
||||
If you compile the basic THIRD system without the help word (strings take up one
|
||||
<code>int</code> per character in the string!), you should find that you’re using around
|
||||
1000 <code>int</code>s (plus the return stack).</p>
|
||||
<p>Thus THIRD gives you a relatively complete <a
|
||||
href="https://en.wikipedia.org/wiki/Forth_(programming_language)">FORTH</a>
|
||||
system in less than 700 chars of C source + about 1000 <code>int</code>s
|
||||
of memory–and it’s portable too (you could copy over the THIRD memory
|
||||
dump to another machine, in theory). If the above numbers seem to you to
|
||||
be mixing apples and oranges (C source and compiled THIRD code), note
|
||||
that you should in theory be able to stick the compiled THIRD code into
|
||||
the C source.</p>
|
||||
<p>Software Construction Company gets credit for rekindling my interest
|
||||
in FORTH and thus indirectly inspiring me to write this program.</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0
|
||||
License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights
|
||||
Reserved. You are free to share and adapt this file under the terms of
|
||||
this license:</p>
|
||||
<p>Thus THIRD gives you a relatively complete
|
||||
<a href="https://en.wikipedia.org/wiki/Forth_(programming_language)">FORTH</a> system in
|
||||
less than 700 chars of C source + about 1000 <code>int</code>s of memory–and it’s portable
|
||||
too (you could copy over the THIRD memory dump to another machine, in theory).
|
||||
If the above numbers seem to you to be mixing apples and oranges (C source and
|
||||
compiled THIRD code), note that you should in theory be able to stick the
|
||||
compiled THIRD code into the C source.</p>
|
||||
<p>Software Construction Company gets credit for rekindling my interest in FORTH
|
||||
and thus indirectly inspiring me to write this program.</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0 License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
|
||||
You are free to share and adapt this file under the terms of this license:</p>
|
||||
<pre><code>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</code></pre>
|
||||
<p>For more information, see:
|
||||
https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
<p>For more information, see: https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
|
||||
<!-- 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-1992buzzard.2"><a name="inventory"></a>Inventory
|
||||
for 1992/buzzard.2</h1>
|
||||
<h1 id="inventory-for-1992buzzard.2"><a name="inventory"></a>Inventory for 1992/buzzard.2</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/1992/buzzard.2/buzzard.2.c">buzzard.2.c</a>
|
||||
- entry source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/Makefile">Makefile</a>
|
||||
- entry Makefile</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/buzzard.2.alt.c">buzzard.2.alt.c</a>
|
||||
- alternative source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/buzzard.2.orig.c">buzzard.2.orig.c</a>
|
||||
- original source</li>
|
||||
<li><a href="buzzard.2.README.html">buzzard.2.README.html</a> - author
|
||||
description of files</li>
|
||||
<li><a href="buzzard.2.design.html">buzzard.2.design.html</a> - about
|
||||
the FORTH language</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/try.alt.sh">try.alt.sh</a>
|
||||
- how to run alternative code</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/try.sh">try.sh</a>
|
||||
- how to run</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/demo1.1st">demo1.1st</a>
|
||||
- FORTH source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/demo1.th">demo1.th</a>
|
||||
- FORTH source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/demo2.th">demo2.th</a>
|
||||
- FORTH source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/demo3.th">demo3.th</a>
|
||||
- FORTH source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/demo4.th">demo4.th</a>
|
||||
- FORTH source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/demo5.th">demo5.th</a>
|
||||
- FORTH source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/demo6.th">demo6.th</a>
|
||||
- FORTH source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/help.th">help.th</a>
|
||||
- FORTH source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/third">third</a>
|
||||
- the third source</li>
|
||||
<li><a href="1992_buzzard.2.tar.bz2">1992_buzzard.2.tar.bz2</a> -
|
||||
download entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/buzzard.2.c">buzzard.2.c</a> - entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/buzzard.2.alt.c">buzzard.2.alt.c</a> - alternative source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/buzzard.2.orig.c">buzzard.2.orig.c</a> - original source</li>
|
||||
<li><a href="buzzard.2.README.html">buzzard.2.README.html</a> - author description of files</li>
|
||||
<li><a href="buzzard.2.design.html">buzzard.2.design.html</a> - about the FORTH language</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/try.alt.sh">try.alt.sh</a> - how to run alternative code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/try.sh">try.sh</a> - how to run</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/demo1.1st">demo1.1st</a> - FORTH source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/demo1.th">demo1.th</a> - FORTH source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/demo2.th">demo2.th</a> - FORTH source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/demo3.th">demo3.th</a> - FORTH source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/demo4.th">demo4.th</a> - FORTH source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/demo5.th">demo5.th</a> - FORTH source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/demo6.th">demo6.th</a> - FORTH source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/help.th">help.th</a> - FORTH source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/third">third</a> - the third source</li>
|
||||
<li><a href="1992_buzzard.2.tar.bz2">1992_buzzard.2.tar.bz2</a> - download entry source</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/1992/buzzard.2/.entry.json">.entry.json</a>
|
||||
- description of entry in JSON</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/.gitignore">.gitignore</a>
|
||||
- list of files that should not be committed under git</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/.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>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/README.md">README.md</a>
|
||||
- markdown source for index.html</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/buzzard.2.README.md">buzzard.2.README.md</a>
|
||||
- markdown source for buzzard.2.README.html</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/buzzard.2.design.md">buzzard.2.design.md</a>
|
||||
- markdown source for buzzard.2.design.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/README.md">README.md</a> - markdown source for index.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/buzzard.2.README.md">buzzard.2.README.md</a> - markdown source for buzzard.2.README.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/buzzard.2/buzzard.2.design.md">buzzard.2.design.md</a> - markdown source for buzzard.2.design.html</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||||
|
||||
+143
-176
@@ -129,9 +129,9 @@
|
||||
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Andreas_Gustafsson">Andreas
|
||||
Gustafsson</a><br> Location: <a href="../../location.html#FI">FI</a> -
|
||||
<em>Republic of Finland </em> (<em>Finland</em>) <br><br></li>
|
||||
<li>Name: <a href="../../authors.html#Andreas_Gustafsson">Andreas Gustafsson</a><br>
|
||||
Location: <a href="../../location.html#FI">FI</a> - <em>Republic of Finland </em> (<em>Finland</em>)
|
||||
<br><br></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -141,21 +141,19 @@ Gustafsson</a><br> Location: <a href="../../location.html#FI">FI</a> -
|
||||
|
||||
<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> all</span></code></pre></div>
|
||||
<p>NOTE: we DISABLE the optimiser because having it enabled causes some
|
||||
invocations to crash in some systems.</p>
|
||||
<p>NOTE: we DISABLE the optimiser because having it enabled causes some invocations
|
||||
to crash in some systems.</p>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: uses gets() - change to fgets() if possible</code></pre>
|
||||
<p>For more detailed information see <a
|
||||
href="../../bugs.html#1992_gson">1992 gson bugs</a>.</p>
|
||||
<p>For more detailed information see <a href="../../bugs.html#1992_gson">1992 gson 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">./ag</span> word word2 word3 <span class="op"><</span> /path/to/dictionary</span></code></pre></div>
|
||||
<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">./try.sh</span></span></code></pre></div>
|
||||
<p>This script will determine (or try and determine) where your system
|
||||
dictionary is located and assuming that it can find one it’ll use that.
|
||||
It checks the following locations though the last one is more
|
||||
ironic:</p>
|
||||
<p>This script will determine (or try and determine) where your system dictionary
|
||||
is located and assuming that it can find one it’ll use that. It checks the
|
||||
following locations though the last one is more ironic:</p>
|
||||
<pre><code>/usr/share/dict/words
|
||||
/usr/share/lib/spell/words
|
||||
/usr/ucblib/dict/words
|
||||
@@ -169,65 +167,58 @@ ironic:</p>
|
||||
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a><span class="ex">./ag</span> ross perot <span class="op"><</span> /usr/share/dict/words</span>
|
||||
<span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a><span class="ex">./ag</span> paul e tsongas <span class="op"><</span> /usr/share/dict/words</span></code></pre></div>
|
||||
<p>where <code>/usr/share/dict/words</code> is the dictionary file.</p>
|
||||
<p>Then it uses the <a href="mkdict.sh">mkdict.sh</a> script to create a
|
||||
dictionary file out of the files <a href="README.md">README.md</a>, <a
|
||||
href="try.sh">try.sh</a> (itself) and <a href="Makefile">Makefile</a>
|
||||
and it repeats the same commands as above. In the case no dictionary
|
||||
file can be found in the first step it only runs the commands once with
|
||||
the created dictionary file.</p>
|
||||
<p>Then it uses the <a href="mkdict.sh">mkdict.sh</a> script to create a dictionary file out
|
||||
of the files <a href="README.md">README.md</a>, <a href="try.sh">try.sh</a> (itself) and
|
||||
<a href="Makefile">Makefile</a> and it repeats the same commands as above. In the case no
|
||||
dictionary file can be found in the first step it only runs the commands once
|
||||
with the created dictionary file.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>Recently some newspapers printed amusing anagrams of one of the names
|
||||
listed above. Run this program to find the anagrams they weren’t allowed
|
||||
to print!</p>
|
||||
<p>The author provided an obfuscated script that can be used to
|
||||
construct dictionaries which has been put in as <a
|
||||
href="mkdict.sh">mkdict.sh</a>. To use try:</p>
|
||||
<p>Recently some newspapers printed amusing anagrams of one of the
|
||||
names listed above. Run this program to find the anagrams they
|
||||
weren’t allowed to print!</p>
|
||||
<p>The author provided an obfuscated script that can be used to construct
|
||||
dictionaries which has been put in as <a href="mkdict.sh">mkdict.sh</a>. To use try:</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">cat</span> README.md <span class="kw">|</span> <span class="ex">./mkdict.sh</span> <span class="op">></span> words</span></code></pre></div>
|
||||
<p>Then try using the program as shown above with the file
|
||||
<code>words</code>.</p>
|
||||
<p>Then try using the program as shown above with the file <code>words</code>.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p>The name of the game:</p>
|
||||
<p>AG is short for either Anagram Generator or simply AnaGram. It might
|
||||
also be construed to mean Alphabet Game, and by pure coincidence it
|
||||
happens to be the author’s initials.</p>
|
||||
<p>AG is short for either Anagram Generator or simply AnaGram. It might also be
|
||||
construed to mean Alphabet Game, and by pure coincidence it happens to be the
|
||||
author’s initials.</p>
|
||||
<h3 id="what-it-does">What it does</h3>
|
||||
<p>AG takes one or more words as arguments, and tries to find anagrams
|
||||
of those words, i.e. words or sentences containing exactly the same
|
||||
letters.</p>
|
||||
<p>AG takes one or more words as arguments, and tries to find anagrams of those
|
||||
words, i.e. words or sentences containing exactly the same letters.</p>
|
||||
<h3 id="how-to-use-it">How to use it</h3>
|
||||
<p>To run AG, you need a dictionary file consisting of distinct words in
|
||||
the natural language of your choice, one word on each line. If your
|
||||
machine doesn’t have one already, you can make your own dictionary by
|
||||
concatenating a few hundred of your favourite Usenet articles and piping
|
||||
them through the following obfuscated shell script:</p>
|
||||
<p>To run AG, you need a dictionary file consisting of distinct words in the
|
||||
natural language of your choice, one word on each line. If your machine doesn’t
|
||||
have one already, you can make your own dictionary by concatenating a few
|
||||
hundred of your favourite Usenet articles and piping them through the following
|
||||
obfuscated shell script:</p>
|
||||
<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="co">#!/bin/sh</span></span>
|
||||
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="va">z</span><span class="op">=</span>a-z]<span class="kw">;</span><span class="fu">tr</span> [A-Z<span class="dt">\]</span> <span class="dt">\[</span><span class="va">$z</span><span class="kw">|</span><span class="fu">sed</span> s/[<span class="dt">\^</span><span class="va">$z</span>[<span class="dt">\^</span><span class="va">$z</span><span class="pp">*</span>/_/g<span class="kw">|</span><span class="fu">tr</span> _ <span class="dt">\\</span>012<span class="kw">|</span><span class="fu">grep</span> ..<span class="kw">|</span><span class="fu">sort</span> <span class="at">-u</span></span></code></pre></div>
|
||||
<p>Using articles from alt.folklore.computers is likely to make a more
|
||||
professional-looking dictionary than rec.arts.erotica.</p>
|
||||
<p>Using articles from alt.folklore.computers is likely to make
|
||||
a more professional-looking dictionary than rec.arts.erotica.</p>
|
||||
<p>AG must be run with the dictionary file as standard input.</p>
|
||||
<p>Because anagrams consisting of just a few words are generally more
|
||||
meaningful than those consisting of dozens of very short words, the
|
||||
number of words in the anagrams is limited to 3 by default. This limit
|
||||
can be changed using a numeric command line option, as in
|
||||
number of words in the anagrams is limited to 3 by default. This
|
||||
limit can be changed using a numeric command line option, as in
|
||||
<code>./ag -4 international obfuscated c code contest </usr/dict/words</code>.</p>
|
||||
<h3 id="bugs-and-limitations">Bugs and limitations</h3>
|
||||
<ul>
|
||||
<li>There is no error checking.</li>
|
||||
<li>Standard input must be seekable, so you can’t pipe the dictionary
|
||||
into AG.</li>
|
||||
<li>The input sentence and each line in the dictionary may contain at
|
||||
most 32 distinct letters, and each letter may occur at most 15
|
||||
times.</li>
|
||||
<li>Standard input must be seekable, so you can’t pipe the dictionary into AG.</li>
|
||||
<li>The input sentence and each line in the dictionary may contain at most 32
|
||||
distinct letters, and each letter may occur at most 15 times.</li>
|
||||
<li>Words in the dictionary may be at most 255 bytes long.</li>
|
||||
<li>AG cannot handle characters that sign-extend to negative
|
||||
values.</li>
|
||||
<li>Although AG works on both 16-bit and 32-bit machines, the size of
|
||||
the problems it can solve is severely limited on machines that limit the
|
||||
stack size to 64k or less.</li>
|
||||
<li>AG cannot handle characters that sign-extend to negative values.</li>
|
||||
<li>Although AG works on both 16-bit and 32-bit machines, the size of the problems
|
||||
it can solve is severely limited on machines that limit the stack size to 64k or
|
||||
less.</li>
|
||||
</ul>
|
||||
<h3 id="obfuscatory-notes">Obfuscatory notes</h3>
|
||||
<p>As you can see, AG takes advantage of the new ‘92 whitespace rules’
|
||||
to achieve a clear, readable, self-documenting layout. The identifiers
|
||||
<p>As you can see, AG takes advantage of the new ‘92 whitespace rules’ to
|
||||
achieve a clear, readable, self-documenting layout. The identifiers
|
||||
have been chosen in a way appropriate for an alphabet game, and common
|
||||
sources of bugs such as goto statements and malloc/free have been
|
||||
eliminated. As AG also refrains from abusing the preprocessor, it
|
||||
@@ -237,164 +228,140 @@ careful choice of algorithms. Some of the finer points of those
|
||||
algorithms are outlined in the spoiler below.</p>
|
||||
<h3 id="how-it-works">How it works:</h3>
|
||||
<p>Here follows a description of some of the data structures and
|
||||
algorithms used by AG. It is by no means complete, but it may help you
|
||||
get an idea about the general principles.</p>
|
||||
algorithms used by AG. It is by no means complete, but it may help
|
||||
you get an idea about the general principles.</p>
|
||||
<hr />
|
||||
<p>Internally, AG represents words and sentences as arrays of 32 4-bit
|
||||
integer elements. Each element represents the number of times a letter
|
||||
occurs in the word/sentence. There are 32 elements because 32 is a
|
||||
convenient power of two larger than the number of letters in most
|
||||
western alphabets, and the elements are 4 bits each because the same
|
||||
letter is unlikely to occur more than 15 times in a practical anagram
|
||||
generation problem.</p>
|
||||
<p>Internally, AG represents words and sentences as arrays of 32
|
||||
4-bit integer elements. Each element represents the number of
|
||||
times a letter occurs in the word/sentence. There are 32 elements
|
||||
because 32 is a convenient power of two larger than the number of
|
||||
letters in most western alphabets, and the elements are 4 bits
|
||||
each because the same letter is unlikely to occur more than 15
|
||||
times in a practical anagram generation problem.</p>
|
||||
<p>These <code>32*4</code>-bit arrays are actually stored in memory in a
|
||||
“bit-transposed” format, as arrays of four <code>long</code> values. It
|
||||
is assumed that a <code>long</code> is at least 32 bits. The first 4-bit
|
||||
letter count is formed by the least significant (<code>2^0</code>) bit
|
||||
in each of the four <code>long</code>s, the next one is formed by the
|
||||
<code>2^1</code> bits, etc.</p>
|
||||
“bit-transposed” format, as arrays of four <code>long</code> values. It is
|
||||
assumed that a <code>long</code> is at least 32 bits. The first 4-bit letter
|
||||
count is formed by the least significant (<code>2^0</code>) bit in each of the
|
||||
four <code>long</code>s, the next one is formed by the <code>2^1</code> bits, etc.</p>
|
||||
<p>This storage format makes it possible to add or subtract two such
|
||||
vectors of 32 4-bit values in parallel by simulating a set of 32 binary
|
||||
full adders in software using bitwise logical operations. E.g., all the
|
||||
LSBs of the result are formed in parallel by taking the exclusive OR of
|
||||
the LSBs in each summand, and 32 carry bits are formed in parallel in a
|
||||
similar way using a logical AND. Thus, 32 independent 4-bit additions
|
||||
can be performed by just four iterations of a loop containing some
|
||||
32-bit bitwise logical operations, but no arithmetic operations other
|
||||
than those implied by array indexing.</p>
|
||||
vectors of 32 4-bit values in parallel by simulating a set of 32
|
||||
binary full adders in software using bitwise logical operations.
|
||||
E.g., all the LSBs of the result are formed in parallel by taking
|
||||
the exclusive OR of the LSBs in each summand, and 32 carry bits
|
||||
are formed in parallel in a similar way using a logical AND.
|
||||
Thus, 32 independent 4-bit additions can be performed by just four
|
||||
iterations of a loop containing some 32-bit bitwise logical
|
||||
operations, but no arithmetic operations other than those implied
|
||||
by array indexing.</p>
|
||||
<p>Subtraction works similarly, and in fact AG only implements
|
||||
subtraction directly, handling addition by means of the identity
|
||||
<code>a+b = a-(0-b)</code>.</p>
|
||||
<p>In addition to this <code>32*4</code>-bit representation, AG also
|
||||
forms a so-called “signature” that is the bitwise OR of the four
|
||||
<code>long</code>s, which is equivalent to saying that the signature of
|
||||
a word contains a logical 1 in the bit positions corresponding to
|
||||
letters occurring at least once in that word.</p>
|
||||
<p>In addition to this <code>32*4</code>-bit representation, AG also forms a so-called
|
||||
“signature” that is the bitwise OR of the four <code>long</code>s, which is
|
||||
equivalent to saying that the signature of a word contains a logical 1
|
||||
in the bit positions corresponding to letters occurring at least once
|
||||
in that word.</p>
|
||||
<p>The first thing AG does is to construct a lookup table of 256
|
||||
<code>long</code>s, one for each 8-bit character value. The entry for a
|
||||
character will be zero if that character doesn’t appear in the sentence
|
||||
given on the command line, or it will have a single bit set if the
|
||||
character does appear in the sentence. By adding together the bit masks
|
||||
for all the letters in the input sentence using the transpose addition
|
||||
method described above, AG forms the <code>32*4</code> bit array
|
||||
representation of the input sentence.</p>
|
||||
character will be zero if that character doesn’t appear in the
|
||||
sentence given on the command line, or it will have a single bit
|
||||
set if the character does appear in the sentence. By adding
|
||||
together the bit masks for all the letters in the input sentence
|
||||
using the transpose addition method described above, AG forms the
|
||||
<code>32*4</code> bit array representation of the input sentence.</p>
|
||||
<p>The next action performed is reading the dictionary. Those words that
|
||||
contain letters not in the input sentence are immediately discarded.
|
||||
Words containing the right letters but in excessive numbers are
|
||||
eliminated in a separate check involving the <code>32*4</code> bit
|
||||
array.</p>
|
||||
eliminated in a separate check involving the <code>32*4</code> bit array.</p>
|
||||
<p>The remaining words, which will be referred to as “candidate words”,
|
||||
are stored in <code>32*4</code>-bit representation, together with their
|
||||
signatures and offsets into the dictionary file so that the plain-text
|
||||
version of a word can later be found for printing. This information is
|
||||
kept in a local <code>struct</code> in the dictionary-reading function,
|
||||
and memory is allocated for each candidate word simply by making another
|
||||
recursive call to that function.</p>
|
||||
<p>Each <code>struct</code> so allocated is linked into a fixed-size
|
||||
hash table of 4096 entries indexed by the 12 low bits of the word’s
|
||||
signature. When the dictionary-reading function encounters end-of-file,
|
||||
all the candidate words have been stored in nested activation records on
|
||||
the stack, accessible through the hash table.</p>
|
||||
are stored in <code>32*4</code>-bit representation, together with their signatures
|
||||
and offsets into the dictionary file so that the plain-text version of
|
||||
a word can later be found for printing. This information is kept in a
|
||||
local <code>struct</code> in the dictionary-reading function, and memory is
|
||||
allocated for each candidate word simply by making another recursive
|
||||
call to that function.</p>
|
||||
<p>Each <code>struct</code> so allocated is linked into a fixed-size hash table of
|
||||
4096 entries indexed by the 12 low bits of the word’s signature.
|
||||
When the dictionary-reading function encounters end-of-file, all the
|
||||
candidate words have been stored in nested activation records on the
|
||||
stack, accessible through the hash table.</p>
|
||||
<p>Generating the anagrams is then done by traversing the hash table and
|
||||
subtracting the letters of each word in the hash table from the “current
|
||||
sentence”, which initially is the sentence given on the command
|
||||
line.</p>
|
||||
subtracting the letters of each word in the hash table from the
|
||||
“current sentence”, which initially is the sentence given on the
|
||||
command line.</p>
|
||||
<p>The subtraction is performed in parallel on the 4-bit letter counts
|
||||
as described above, and if all 32 results are zero, an anagram has been
|
||||
found. If the result is negative for one or more of the letters (as
|
||||
indicated by one or more <code>1</code>s in a vector of 32 borrow bits
|
||||
returned by the subtraction routine), the word did not match the current
|
||||
sentence and is ignored. Finally, if the result contained only
|
||||
non-negative letter counts, we have found a partial anagram: a word
|
||||
containing some, but not all, of the letters in the current sentence. In
|
||||
this case we recursively try to find an anagram of the remaining
|
||||
letters. The depth of the recursion is limited to the maximum number of
|
||||
words in the anagram, as specified by the user.</p>
|
||||
<p>When the deepest recursion level has been reached, an optimization
|
||||
can be applied: because no further recursion will be done, there is no
|
||||
need to look for partial anagrams, and therefore AG only needs to check
|
||||
for words that contain exactly the same letters as the current sentence.
|
||||
Those words can be found simply by indexing the hash table with the
|
||||
signature of the current sentence.</p>
|
||||
as described above, and if all 32 results are zero, an anagram has
|
||||
been found. If the result is negative for one or more of the letters
|
||||
(as indicated by one or more <code>1</code>s in a vector of 32 borrow bits
|
||||
returned by the subtraction routine), the word did not match the
|
||||
current sentence and is ignored. Finally, if the result contained
|
||||
only non-negative letter counts, we have found a partial anagram:
|
||||
a word containing some, but not all, of the letters in the current
|
||||
sentence. In this case we recursively try to find an anagram of the
|
||||
remaining letters. The depth of the recursion is limited to the
|
||||
maximum number of words in the anagram, as specified by the user.</p>
|
||||
<p>When the deepest recursion level has been reached, an optimization can
|
||||
be applied: because no further recursion will be done, there is no
|
||||
need to look for partial anagrams, and therefore AG only needs to
|
||||
check for words that contain exactly the same letters as the current
|
||||
sentence. Those words can be found simply by indexing the hash table
|
||||
with the signature of the current sentence.</p>
|
||||
<p>Even when not on the deepest recursion level, AG generally avoids
|
||||
examining all the entries of the hash table. The idea is that we are not
|
||||
interested in hash buckets whose words contain any letters not in the
|
||||
current sentence; these buckets are exactly those whose index has a
|
||||
logical one in a bit position where the signature of the current
|
||||
sentence has a zero. Put another way, we want to loop through only those
|
||||
hash bucket indices <code>i</code> that contain zeroes in all the bit
|
||||
positions where the signature <code>s</code> of the current sentence
|
||||
contains a zero; this can be expressed in C as
|
||||
(<code>i & ~s == 0</code>).</p>
|
||||
<p>It is possible to loop through all such numbers in an efficient way
|
||||
by taking advantage of certain properties of binary arithmetic: by
|
||||
forcing the bits corresponding to zeroes in <code>s</code> to ones, we
|
||||
can make the carries generated in incrementing <code>i</code> propagate
|
||||
straight across those bits that should remain zero. For example, the
|
||||
following program prints all those 16-bit integers that contain zeroes
|
||||
in all even bit positions:</p>
|
||||
examining all the entries of the hash table. The idea is that we are
|
||||
not interested in hash buckets whose words contain any letters not
|
||||
in the current sentence; these buckets are exactly those whose index
|
||||
has a logical one in a bit position where the signature of the current
|
||||
sentence has a zero. Put another way, we want to loop through only
|
||||
those hash bucket indices <code>i</code> that contain zeroes in all the bit
|
||||
positions where the signature <code>s</code> of the current sentence contains
|
||||
a zero; this can be expressed in C as (<code>i & ~s == 0</code>).</p>
|
||||
<p>It is possible to loop through all such numbers in an efficient way by
|
||||
taking advantage of certain properties of binary arithmetic: by
|
||||
forcing the bits corresponding to zeroes in <code>s</code> to ones, we can make
|
||||
the carries generated in incrementing <code>i</code> propagate straight across
|
||||
those bits that should remain zero. For example, the following
|
||||
program prints all those 16-bit integers that contain zeroes in all
|
||||
even bit positions:</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>main<span class="op">(){</span><span class="dt">int</span> i<span class="op">=</span><span class="dv">0</span><span class="op">,</span>s<span class="op">=</span><span class="bn">0xAAAA</span><span class="op">;</span><span class="cf">do</span><span class="op">{</span>printf<span class="op">(</span><span class="st">"</span><span class="sc">%04x\t</span><span class="st">"</span><span class="op">,</span>i<span class="op">);}</span><span class="cf">while</span><span class="op">(</span>i<span class="op">=((</span>i<span class="op">|~</span>s<span class="op">)+</span><span class="dv">1</span><span class="op">)&</span>s<span class="op">);}</span></span></code></pre></div>
|
||||
<p>AG uses a similar method but works in the opposite direction, finding
|
||||
the next lower value with zeroes in given bit positions by propagating
|
||||
borrows across those bits. Some additional adjustments are made to the
|
||||
hash table index when initiating a recursive search, using similar
|
||||
bit-twiddling techniques.</p>
|
||||
borrows across those bits. Some additional adjustments are made
|
||||
to the hash table index when initiating a recursive search, using
|
||||
similar bit-twiddling techniques.</p>
|
||||
<p>Whenever an anagram has been found, it is printed by traversing a
|
||||
linked list formed by <code>struct</code>s in the activation records of
|
||||
the recursive invocations of the search function, seeking to the
|
||||
beginning of the word matched by that invocation, and copying the
|
||||
characters of the word directly from standard input to standard
|
||||
output.</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0
|
||||
License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights
|
||||
Reserved. You are free to share and adapt this file under the terms of
|
||||
this license:</p>
|
||||
linked list formed by <code>struct</code>s in the activation records of the
|
||||
recursive invocations of the search function, seeking to the beginning
|
||||
of the word matched by that invocation, and copying the characters of
|
||||
the word directly from standard input to standard output.</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0 License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
|
||||
You are free to share and adapt this file under the terms of this license:</p>
|
||||
<pre><code>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</code></pre>
|
||||
<p>For more information, see:
|
||||
https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
<p>For more information, see: https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
|
||||
<!-- 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-1992gson"><a name="inventory"></a>Inventory for
|
||||
1992/gson</h1>
|
||||
<h1 id="inventory-for-1992gson"><a name="inventory"></a>Inventory for 1992/gson</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/1992/gson/gson.c">gson.c</a>
|
||||
- entry source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/Makefile">Makefile</a>
|
||||
- entry Makefile</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/gson.orig.c">gson.orig.c</a>
|
||||
- original source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/try.sh">try.sh</a>
|
||||
- how to run</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/mkdict.sh">mkdict.sh</a>
|
||||
- tool to make the dictionary</li>
|
||||
<li><a href="1992_gson.tar.bz2">1992_gson.tar.bz2</a> - download entry
|
||||
source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/gson.c">gson.c</a> - entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/gson.orig.c">gson.orig.c</a> - original source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/try.sh">try.sh</a> - how to run</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/mkdict.sh">mkdict.sh</a> - tool to make the dictionary</li>
|
||||
<li><a href="1992_gson.tar.bz2">1992_gson.tar.bz2</a> - download entry source</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/1992/gson/.entry.json">.entry.json</a>
|
||||
- description of entry in JSON</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/.gitignore">.gitignore</a>
|
||||
- list of files that should not be committed under git</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/.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>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/README.md">README.md</a>
|
||||
- markdown source for index.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/README.md">README.md</a> - markdown source for index.html</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||||
|
||||
+71
-102
@@ -130,8 +130,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Ian_Collier">Ian Collier</a><br>
|
||||
Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom
|
||||
of Great Britain and Northern Ireland</em> (<em>United Kingdom</em>)
|
||||
Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom of Great Britain and Northern Ireland</em> (<em>United Kingdom</em>)
|
||||
<br><br></li>
|
||||
</ul>
|
||||
|
||||
@@ -151,71 +150,61 @@ of Great Britain and Northern Ireland</em> (<em>United Kingdom</em>)
|
||||
<p>To see a number of options and configurations:</p>
|
||||
<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">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>The program is more interesting to run on workstations that can make
|
||||
use of a Sun raster file. Others can make use of the -text flag for
|
||||
character oriented output.</p>
|
||||
<p>The program is more interesting to run on workstations that can make use of a
|
||||
Sun raster file. Others can make use of the -text flag for character oriented
|
||||
output.</p>
|
||||
<p>Of course, the source (layout) is self-documenting! :-)</p>
|
||||
<p>NOTE: The original winning source assumed that <code>exit(3)</code>
|
||||
returned a value which cause problems for some systems where
|
||||
<code>exit(3)</code> returns a void. The file <a href="imc.c">imc.c</a>
|
||||
has been modified to avoid this problem. The original file also declared
|
||||
argc to be a <code>long</code> which was fixed.</p>
|
||||
<p>NOTE: The original winning source assumed that <code>exit(3)</code> returned a value which
|
||||
cause problems for some systems where <code>exit(3)</code> returns a void. The file
|
||||
<a href="imc.c">imc.c</a> has been modified to avoid this problem. The original file also
|
||||
declared argc to be a <code>long</code> which was fixed.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="portability">Portability</h3>
|
||||
<p>This program depends upon the ASCII character set, and makes certain
|
||||
assumptions about the architecture. It naughtily declares the first
|
||||
argument to <code>main()</code> as a <code>long</code>, and passes a
|
||||
pointer to <code>long</code> instead of <code>char</code> to
|
||||
<code>fwrite(3)</code>, giving a length value of 32 bytes for an array
|
||||
of 8 <code>long</code>s. I guess that makes this program OK on most
|
||||
flavours of unix, but not on PCs.</p>
|
||||
<p>This program depends upon the ASCII character set, and makes certain assumptions
|
||||
about the architecture. It naughtily declares the first argument to <code>main()</code> as
|
||||
a <code>long</code>, and passes a pointer to <code>long</code> instead of <code>char</code> to <code>fwrite(3)</code>,
|
||||
giving a length value of 32 bytes for an array of 8 <code>long</code>s. I guess that makes
|
||||
this program OK on most flavours of unix, but not on PCs.</p>
|
||||
<h3 id="about-the-program">About the program</h3>
|
||||
<p>This program has several parameters; each of them has a default, so
|
||||
the program runs happily without any parameters. If you supply an
|
||||
incorrect parameter, an obfuscated error message results! :-) Should you
|
||||
want to run the program without knowing what it does, then supplying the
|
||||
single letter <code>t</code> as a parameter is a good move. Otherwise,
|
||||
direct the output into a file. The resulting file is most useful on
|
||||
SunOS, where the <code>file(1)</code> command will tell you what to do
|
||||
with it. For best results with the <code>t</code> option, you may want
|
||||
to change the definition of the <code>I</code> macro :-) Details appear
|
||||
later, though the formatting of the code is a large clue.</p>
|
||||
<p>All the code in this program appears between the <code>;</code> and
|
||||
<code>)</code> in <code>for(;;)</code>. That isn’t because I want to win
|
||||
the best one-liner, but merely because it makes the code so much more
|
||||
impenetrable :-) In fact running a pretty printer on the code hardly
|
||||
improves it at all. This program has the obligatory macros with
|
||||
unmatched parentheses, and the cleverly arranged macro names and
|
||||
parameters to spell out <code>"Ian Colliers Obfuscated C Code"</code>.
|
||||
If you expand macros, bear in mind that the more complex ones are best
|
||||
left as macros, because they have well-defined and nontrivial (IMHO)
|
||||
functions. These macros help to give the program’s parameter format its
|
||||
flexibility. The parameters are sorted out in a unique way (based on an
|
||||
idea by Pete Bevin) which hides very effectively their identities (and I
|
||||
think that using a variable called <code>_</code> adds a nice touch to
|
||||
the illegibility of the code). In this section of the code, the data
|
||||
types of the numbers checked against is varied, and just because you see
|
||||
a <code>,</code> doesn’t mean it has anything to do with commas! So I
|
||||
hope you will agree that this program is more than a little
|
||||
obfuscated…</p>
|
||||
<p>This program has several parameters; each of them has a default, so the
|
||||
program runs happily without any parameters. If you supply an incorrect
|
||||
parameter, an obfuscated error message results! :-) Should you want to
|
||||
run the program without knowing what it does, then supplying the single
|
||||
letter <code>t</code> as a parameter is a good move. Otherwise, direct the output
|
||||
into a file. The resulting file is most useful on SunOS, where the
|
||||
<code>file(1)</code> command will tell you what to do with it. For best results with
|
||||
the <code>t</code> option, you may want to change the definition of the <code>I</code> macro :-)
|
||||
Details appear later, though the formatting of the code is a large clue.</p>
|
||||
<p>All the code in this program appears between the <code>;</code> and <code>)</code> in
|
||||
<code>for(;;)</code>. That isn’t because I want to win the best one-liner, but
|
||||
merely because it makes the code so much more impenetrable :-) In fact
|
||||
running a pretty printer on the code hardly improves it at all. This
|
||||
program has the obligatory macros with unmatched parentheses, and the
|
||||
cleverly arranged macro names and parameters to spell out <code>"Ian Colliers Obfuscated C Code"</code>. If you expand macros, bear in mind that the more
|
||||
complex ones are best left as macros, because they have well-defined and
|
||||
nontrivial (IMHO) functions. These macros help to give the program’s
|
||||
parameter format its flexibility. The parameters are sorted out in a
|
||||
unique way (based on an idea by Pete Bevin) which hides very effectively
|
||||
their identities (and I think that using a variable called <code>_</code> adds a nice
|
||||
touch to the illegibility of the code). In this section of the code, the
|
||||
data types of the numbers checked against is varied, and just because
|
||||
you see a <code>,</code> doesn’t mean it has anything to do with commas! So I hope
|
||||
you will agree that this program is more than a little obfuscated…</p>
|
||||
<p>This is a Mandelbrot/Julia drawer. Normally it produces a monochrome
|
||||
Sun-format raster file. The version of <code>xloadimage</code> we have
|
||||
is able to view such files, and so is Sun’s <code>screenload</code>
|
||||
command. [Note: the header contains eight 4-byte integers, the byte
|
||||
order in which depends upon the machine. On Sun workstations they are
|
||||
stored MSB first].</p>
|
||||
Sun-format raster file. The version of <code>xloadimage</code> we have is able to
|
||||
view such files, and so is Sun’s <code>screenload</code> command. [Note: the header
|
||||
contains eight 4-byte integers, the byte order in which depends upon the
|
||||
machine. On Sun workstations they are stored MSB first].</p>
|
||||
<p>The program may be asked to produce text output instead of a raster
|
||||
file. Then the characters defined in the <code>I</code> macro will be
|
||||
used to create up to 16 different shades of grey. Quite a respectable
|
||||
picture can be gained by printing a <code>130x110</code> output on a <a
|
||||
href="https://en.wikipedia.org/wiki/Dot_matrix_printing">dot matrix 132
|
||||
column printer</a> with the linefeed set to 7 points. Text output also
|
||||
gives a good picture when used in an X window with small characters
|
||||
having a square aspect ratio.</p>
|
||||
<p>The options accepted by the program follow. Each option is a single
|
||||
letter; it may be preceded with a minus sign (or any character in
|
||||
<code>[!-/]</code>) and may be followed by other letters, so for
|
||||
example:</p>
|
||||
file. Then the characters defined in the <code>I</code> macro will be used to create
|
||||
up to 16 different shades of grey. Quite a respectable picture can be
|
||||
gained by printing a <code>130x110</code> output on a <a href="https://en.wikipedia.org/wiki/Dot_matrix_printing">dot matrix 132 column
|
||||
printer</a> with the linefeed
|
||||
set to 7 points. Text output also gives a good picture when used in an X window
|
||||
with small characters having a square aspect ratio.</p>
|
||||
<p>The options accepted by the program follow. Each option is a single letter; it
|
||||
may be preceded with a minus sign (or any character in <code>[!-/]</code>) and may be
|
||||
followed by other letters, so for example:</p>
|
||||
<ul>
|
||||
<li>m</li>
|
||||
<li>-m</li>
|
||||
@@ -232,13 +221,12 @@ be appended to the single-letter option, so</p>
|
||||
<li>-size123 100 200</li>
|
||||
<li>s100 200</li>
|
||||
</ul>
|
||||
<p>all mean the same (note that in <code>-size123</code> all characters
|
||||
following the initial <code>s</code> are ignored). Numbers need not be
|
||||
specified, as each has a default value. In all cases except for
|
||||
<code>j</code>, <code>t</code>, and <code>s</code> whenever it appears
|
||||
before <code>t</code>, specifying an option without numbers has no
|
||||
effect. (specifying <code>-s -t</code> has the effect of producing text
|
||||
with the default raster size; not a good idea!).</p>
|
||||
<p>all mean the same (note that in <code>-size123</code> all characters following the
|
||||
initial <code>s</code> are ignored). Numbers need not be specified, as each has a
|
||||
default value. In all cases except for <code>j</code>, <code>t</code>, and <code>s</code> whenever it
|
||||
appears before <code>t</code>, specifying an option without numbers has no effect.
|
||||
(specifying <code>-s -t</code> has the effect of producing text with the default
|
||||
raster size; not a good idea!).</p>
|
||||
<h3 id="options">Options</h3>
|
||||
<p>The options of this program are:</p>
|
||||
<pre><code>-centre x y (float x,y) Centre the picture at x+iy in the complex
|
||||
@@ -261,8 +249,8 @@ with the default raster size; not a good idea!).</p>
|
||||
x=768 y=768; default for text x=63 y=23)
|
||||
|
||||
-text Produce text instead of raster.</code></pre>
|
||||
<p>The colour of each point is determined by taking the bitwise AND of
|
||||
the number of iterations and the mask. For a raster, the point is black
|
||||
<p>The colour of each point is determined by taking the bitwise AND of the
|
||||
number of iterations and the mask. For a raster, the point is black
|
||||
(1-bit) if the result is zero, white otherwise. For text, the result of
|
||||
the operation determines the greyness of the character produced, with a
|
||||
blank for zero going up to a star for the maximum value. For a
|
||||
@@ -276,53 +264,34 @@ standard error to indicate its progress (one dot per pixel line).</p>
|
||||
<p>Here are a couple of good pictures to draw:</p>
|
||||
<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="ex">./imc</span> <span class="at">-s</span> 512,512 <span class="at">-f</span> 600000 <span class="at">-l</span> 512 <span class="at">-m</span> 16 <span class="at">-c.00805,.74274</span> <span class="op">></span> screen1.ras</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./imc</span> <span class="at">-s512,512</span> <span class="at">-j-.523,-.535</span> <span class="op">></span> screen2.ras</span></code></pre></div>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0
|
||||
License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights
|
||||
Reserved. You are free to share and adapt this file under the terms of
|
||||
this license:</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0 License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
|
||||
You are free to share and adapt this file under the terms of this license:</p>
|
||||
<pre><code>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</code></pre>
|
||||
<p>For more information, see:
|
||||
https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
<p>For more information, see: https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
|
||||
<!-- 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-1992imc"><a name="inventory"></a>Inventory for
|
||||
1992/imc</h1>
|
||||
<h1 id="inventory-for-1992imc"><a name="inventory"></a>Inventory for 1992/imc</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/1992/imc/imc.c">imc.c</a>
|
||||
- entry source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/imc/Makefile">Makefile</a>
|
||||
- entry Makefile</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/imc/imc.orig.c">imc.orig.c</a>
|
||||
- original source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/imc/try.sh">try.sh</a>
|
||||
- how to run</li>
|
||||
<li><a href="1992_imc.tar.bz2">1992_imc.tar.bz2</a> - download entry
|
||||
source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/imc/imc.c">imc.c</a> - entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/imc/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/imc/imc.orig.c">imc.orig.c</a> - original source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/imc/try.sh">try.sh</a> - how to run</li>
|
||||
<li><a href="1992_imc.tar.bz2">1992_imc.tar.bz2</a> - download entry source</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/1992/imc/.entry.json">.entry.json</a>
|
||||
- description of entry in JSON</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/imc/.gitignore">.gitignore</a>
|
||||
- list of files that should not be committed under git</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/imc/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/imc/.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>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/imc/README.md">README.md</a>
|
||||
- markdown source for index.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/imc/README.md">README.md</a> - markdown source for index.html</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||||
|
||||
+62
-81
@@ -123,121 +123,102 @@
|
||||
<!-- END: this line ends content from: inc/before-content.default.html -->
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h1 id="ninth-international-obfuscated-c-code-contest">Ninth
|
||||
International Obfuscated C Code Contest</h1>
|
||||
<p>View the <code>index.html</code> web page for the given winning entry
|
||||
for information on how on how to compile it and how to run the winning
|
||||
program. Look at the winning source and try to figure how it does what
|
||||
it does! You may then wish to look at the Author’s remarks for even more
|
||||
details.</p>
|
||||
<p>Use <code>make</code> to compile entries. It is possible that on BSD
|
||||
or non-Unix systems the Makefile needs to be changed. See the Makefile
|
||||
for details.</p>
|
||||
<p>Read over the Makefile for compile/build issues. Your system may
|
||||
require certain changes (add or remove a library, add or remove a
|
||||
<code>#define</code> i.e. the <code>-D</code> flag). A number of
|
||||
compilers had problems optimizing certain entries. Some compilers do
|
||||
optimize, but the resulting program does not work. By default we have
|
||||
left off <code>-O</code> from compile lines. You might want to add
|
||||
<code>-O</code> back, or add it back for certain entries where
|
||||
performance is important. (This was updated to use <code>-O3</code> in
|
||||
202n though sometimes an entry does not work if the compiler optimises
|
||||
the code and in this case it is disabled or explicitly set to level
|
||||
0.)</p>
|
||||
<p>This year marked an all time high for number of entries as well as
|
||||
the quality of entries. Nearly twice the usual number of entries made it
|
||||
<h1 id="ninth-international-obfuscated-c-code-contest">Ninth International Obfuscated C Code Contest</h1>
|
||||
<p>View the <code>index.html</code> web page for the given winning entry for information on how
|
||||
on how to compile it and how to run the winning program.
|
||||
Look at the winning source and try to figure how it does what it does!
|
||||
You may then wish to look at the Author’s remarks for even more details.</p>
|
||||
<p>Use <code>make</code> to compile entries. It is possible that on BSD or non-Unix
|
||||
systems the Makefile needs to be changed. See the Makefile for details.</p>
|
||||
<p>Read over the Makefile for compile/build issues. Your system may require
|
||||
certain changes (add or remove a library, add or remove a <code>#define</code> i.e. the
|
||||
<code>-D</code> flag). A number of compilers had problems optimizing certain entries.
|
||||
Some compilers do optimize, but the resulting program does not work. By default
|
||||
we have left off <code>-O</code> from compile lines. You might want to add <code>-O</code> back, or
|
||||
add it back for certain entries where performance is important. (This was
|
||||
updated to use <code>-O3</code> in 202n though sometimes an entry does not work if the
|
||||
compiler optimises the code and in this case it is disabled or explicitly set to
|
||||
level 0.)</p>
|
||||
<p>This year marked an all time high for number of entries as well as the
|
||||
quality of entries. Nearly twice the usual number of entries made it
|
||||
to the final judging rounds. Even when we raised the standards for
|
||||
winning, we still wound up giving out a few more awards than in previous
|
||||
years. The new size rules size probably contributed to the overall high
|
||||
quality.</p>
|
||||
years. The new size rules size probably contributed to the overall
|
||||
high quality.</p>
|
||||
<p>FYI: By tradition, we do not record the count of the number entries,
|
||||
nor do we give our our guess as to the number of entries received. For
|
||||
folks who wonder, we can say that we consumed about 2000 pages of output
|
||||
(printing between 2 and 4 normal pages per side) during the judging
|
||||
process this year.</p>
|
||||
nor do we give our our guess as to the number of entries
|
||||
received. For folks who wonder, we can say that we consumed
|
||||
about 2000 pages of output (printing between 2 and 4 normal
|
||||
pages per side) during the judging process this year.</p>
|
||||
<p>The new instructions for submitting entries worked well - we were
|
||||
able to write scripts to unpack them and eliminate duplicates.</p>
|
||||
<p>As promised last year, we accepted programs that made use of the X
|
||||
libraries for the first time. We now consider ANSI C compilers to be the
|
||||
“standard” version that the entries were compiled with.</p>
|
||||
libraries for the first time. We now consider ANSI C compilers to be
|
||||
the “standard” version that the entries were compiled with.</p>
|
||||
<p>Name and address information are separated from the actual program
|
||||
prior to judging. This eliminates any chance that we would bias our
|
||||
judging for/against any person or group. In the end, we are surprised as
|
||||
you are to see who has won. Even so, it is worth noting that <a
|
||||
href="../authors.html#Brian_Westley">Brian Westley</a> has submitted a
|
||||
winning entry for the past 6 years!</p>
|
||||
<h2 id="a-few-notes-regarding-future-contests">A few notes regarding
|
||||
future contests:</h2>
|
||||
judging for/against any person or group. In the end, we are surprised
|
||||
as you are to see who has won. Even so, it is worth noting that
|
||||
<a href="../authors.html#Brian_Westley">Brian Westley</a> has submitted
|
||||
a winning entry for the past 6 years!</p>
|
||||
<h2 id="a-few-notes-regarding-future-contests">A few notes regarding future contests:</h2>
|
||||
<p>We did not give awards to some traditional contest categories such as
|
||||
“Best Layout”. We felt that to do so would deny awards to more deserving
|
||||
entries. These categories have not been eliminated. We will likely be
|
||||
awarding them in future years.</p>
|
||||
“Best Layout”. We felt that to do so would deny awards to more
|
||||
deserving entries. These categories have not been eliminated. We will
|
||||
likely be awarding them in future years.</p>
|
||||
<p>We received a few entries whose instructions were rot13’d. While
|
||||
nothing was said about this in the rules, we found that it made the
|
||||
judging process a little harder, so we may request that this not be done
|
||||
this in the future.</p>
|
||||
judging process a little harder, so we may request that this not
|
||||
be done this in the future.</p>
|
||||
<p>Some thought has been given to a separate obfuscated perl contest.
|
||||
Watch comp.lang.perl for details!</p>
|
||||
<p>Be sure to wait until the 1993 rules are posted before submitting
|
||||
entries. We may fine tune the rules to reflect the some ideas above.</p>
|
||||
<p>Be sure to wait until the 1993 rules are posted before submitting entries.
|
||||
We may fine tune the rules to reflect the some ideas above.</p>
|
||||
<p>Please send us comments and suggestions what we have expressed above.
|
||||
Also include anything else that you would like to see in future
|
||||
contests. Send such email to:</p>
|
||||
Also include anything else that you would like to see in future contests.
|
||||
Send such email to:</p>
|
||||
<pre><code>...!{sun,pacbell,uunet,pyramid}!hoptoad!judges
|
||||
judges@toad.com</code></pre>
|
||||
<p>If you use, distribute or publish these entries in some way, please
|
||||
drop us a line. We enjoy seeing who, where and how the contest is
|
||||
used.</p>
|
||||
<p>If you use, distribute or publish these entries in some way, please drop
|
||||
us a line. We enjoy seeing who, where and how the contest is used.</p>
|
||||
<h2 id="final-comments">Final Comments</h2>
|
||||
<p><strong>IMPORTANT NOTE</strong>: The email addresses found above are
|
||||
for historical purposes only, and should not be used today. See <a
|
||||
href="../contact.html">contact.html</a> for up to date contact details
|
||||
as well as details on how to provide fixes to any of the entries. See
|
||||
also <a href="../faq.html">the IOCCC FAQ</a> for addition information on
|
||||
the IOCCC.</p>
|
||||
<p><strong>IMPORTANT NOTE</strong>: The email addresses found above are for historical
|
||||
purposes only, and should not be used today. See
|
||||
<a href="../contact.html">contact.html</a> for up to date contact details
|
||||
as well as details on how to provide fixes to any of the entries.
|
||||
See also <a href="../faq.html">the IOCCC FAQ</a> for addition information on the IOCCC.</p>
|
||||
<h2 id="credits">Credits:</h2>
|
||||
<p>We would like to thank Barbara Frezza for her role as official chef
|
||||
of the contest. Landon Noll and Larry Bassel appreciated the opportunity
|
||||
<p>We would like to thank Barbara Frezza for her role as official chef of
|
||||
the contest. Landon Noll and Larry Bassel appreciated the opportunity
|
||||
to serve as official taste testers. Yummo!</p>
|
||||
<h1 id="copyright-and-license">Copyright and License</h1>
|
||||
<p>Copyright (c) 1992,2023, Landon Curt Noll and Larry Bassel. All
|
||||
Rights Reserved. This work is licensed under a <a
|
||||
href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons
|
||||
CC BY-SA 4.0 DEED Attribution-ShareAlike 4.0 International</a> license.
|
||||
If you do use this work in some form, the <a href="../judges.html">IOCCC
|
||||
judges</a> would appreciate (but does not require) if you were to <a
|
||||
href="../contact.html">send us a note about your use</a>.</p>
|
||||
<p>Copyright (c) 1992,2023, Landon Curt Noll and Larry Bassel. All Rights Reserved.
|
||||
This work is licensed under a <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons CC BY-SA 4.0 DEED Attribution-ShareAlike
|
||||
4.0 International</a> license.
|
||||
If you do use this work in some form, the <a href="../judges.html">IOCCC judges</a> would appreciate
|
||||
(but does not require) if you were to <a href="../contact.html">send us a note about your use</a>.</p>
|
||||
|
||||
<!-- 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-year-index.sh via bin/md2html.sh -->
|
||||
|
||||
<!-- START: this line starts content generated by: bin/output-year-index.sh -->
|
||||
|
||||
<h1
|
||||
id="winning-entries-of-1992---the-9th-ioccc"><a name=inventory></a><a name=1992></a>Winning
|
||||
Entries of 1992 - The 9th IOCCC</h1>
|
||||
<p><strong>Download IOCCC</strong> <a
|
||||
href="1992/ioccc.1992.tar.bz2">1992 entry source</a></p>
|
||||
<h1 id="winning-entries-of-1992---the-9th-ioccc"><a name=inventory></a><a name=1992></a>Winning Entries of 1992 - The 9th IOCCC</h1>
|
||||
<p><strong>Download IOCCC</strong> <a href="1992/ioccc.1992.tar.bz2">1992 entry source</a></p>
|
||||
<ul>
|
||||
<li><a href="adrian/index.html">1992/adrian</a> - Most Educational</li>
|
||||
<li><a href="albert/index.html">1992/albert</a> - Most Useful
|
||||
Program</li>
|
||||
<li><a href="albert/index.html">1992/albert</a> - Most Useful Program</li>
|
||||
<li><a href="ant/index.html">1992/ant</a> - Best Utility</li>
|
||||
<li><a href="buzzard.1/index.html">1992/buzzard.1</a> - Most Obfuscated
|
||||
Algorithm</li>
|
||||
<li><a href="buzzard.2/index.html">1992/buzzard.2</a> - Best Language
|
||||
Tool</li>
|
||||
<li><a href="buzzard.1/index.html">1992/buzzard.1</a> - Most Obfuscated Algorithm</li>
|
||||
<li><a href="buzzard.2/index.html">1992/buzzard.2</a> - Best Language Tool</li>
|
||||
<li><a href="gson/index.html">1992/gson</a> - Most Humorous Output</li>
|
||||
<li><a href="imc/index.html">1992/imc</a> - Best Output</li>
|
||||
<li><a href="kivinen/index.html">1992/kivinen</a> - Best X Program</li>
|
||||
<li><a href="lush/index.html">1992/lush</a> - Worst Abuse of the C
|
||||
Preprocessor</li>
|
||||
<li><a href="lush/index.html">1992/lush</a> - Worst Abuse of the C Preprocessor</li>
|
||||
<li><a href="marangon/index.html">1992/marangon</a> - Best Game</li>
|
||||
<li><a href="nathan/index.html">1992/nathan</a> - Worst Abuse of the
|
||||
Rules</li>
|
||||
<li><a href="nathan/index.html">1992/nathan</a> - Worst Abuse of the Rules</li>
|
||||
<li><a href="vern/index.html">1992/vern</a> - Best of Show</li>
|
||||
<li><a href="westley/index.html">1992/westley</a> - Best Small
|
||||
Program</li>
|
||||
<li><a href="westley/index.html">1992/westley</a> - Best Small Program</li>
|
||||
</ul>
|
||||
<p> <strong>Jump to:</strong> <a href="#">top</a></p>
|
||||
|
||||
|
||||
+42
-66
@@ -130,8 +130,8 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Tero_Kivinen">Tero Kivinen</a><br>
|
||||
Location: <a href="../../location.html#FI">FI</a> - <em>Republic of
|
||||
Finland </em> (<em>Finland</em>) <br><br></li>
|
||||
Location: <a href="../../location.html#FI">FI</a> - <em>Republic of Finland </em> (<em>Finland</em>)
|
||||
<br><br></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,15 +142,13 @@ Finland </em> (<em>Finland</em>) <br><br></li>
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<p>If your machine support the X Window System, Version 11:</p>
|
||||
<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>We recommend that you try the alt version first so you can get a
|
||||
better idea of what this looked like back in 1992. See <a
|
||||
href="#original-code">original code</a> for the original should you wish
|
||||
to see what we mean.</p>
|
||||
<p>We recommend that you try the alt version first so you can get a better idea of
|
||||
what this looked like back in 1992. See <a href="#original-code">original code</a> for the
|
||||
original should you wish to see what we mean.</p>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: known bug - please help us fix</code></pre>
|
||||
<p>For more detailed information see <a
|
||||
href="../../bugs.html#1992_kivinen">1992 kivinen bugs</a>.</p>
|
||||
<p>For more detailed information see <a href="../../bugs.html#1992_kivinen">1992 kivinen 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">./kivinen.alt</span></span>
|
||||
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
@@ -159,42 +157,39 @@ href="../../bugs.html#1992_kivinen">1992 kivinen bugs</a>.</p>
|
||||
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="ex">./kivinen.alt</span> a b</span></code></pre></div>
|
||||
<p>See also the author’s remarks for other variations.</p>
|
||||
<h2 id="try">Try:</h2>
|
||||
<p>Also try changing the speed that the game moves. For instance if you
|
||||
wish to change the <code>usleep(3)</code> value to <code>30000</code>
|
||||
from <code>20000</code>, try:</p>
|
||||
<p>Also try changing the speed that the game moves. For instance if you wish to
|
||||
change the <code>usleep(3)</code> value to <code>30000</code> from <code>20000</code>, try:</p>
|
||||
<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="fu">make</span> clobber SLEEP=30000 alt <span class="co"># make it slower</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="fu">make</span> clobber SLEEP=10000 alt <span class="co"># make it faster</span></span></code></pre></div>
|
||||
<p>Then use the same syntax as above and described by the author.</p>
|
||||
<h2 id="original-code">Original code:</h2>
|
||||
<p>As noted above, the alt version is recommended because the code goes
|
||||
too fast in modern systems. If you wish to see the original you may do
|
||||
so with the original code.</p>
|
||||
<p>As noted above, the alt version is recommended because the code goes too fast in
|
||||
modern systems. If you wish to see the original you may do so with the original
|
||||
code.</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>
|
||||
<p>Use <code>kivinen</code> as you would <code>kivinen.alt</code>.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>The type of entertainment depends on number of arguments you have
|
||||
with the program. :-)</p>
|
||||
<p>NOTE: Some systems do not need (or have)
|
||||
<code>-lsocket -lresolv -lnsl</code>. Such systems should compile using
|
||||
<code>-lX11</code>.</p>
|
||||
<p>NOTE: The original winning source <a
|
||||
href="kivinen.orig.c">kivinen.orig.c</a> assumed that
|
||||
<code>exit(3)</code> returned a value which cause problems for some
|
||||
systems where <code>exit(3)</code> returns <code>void</code>. The file
|
||||
<a href="kivinen.c">kivinen.c</a> avoids this problem.</p>
|
||||
<p>The type of entertainment depends on number of arguments
|
||||
you have with the program. :-)</p>
|
||||
<p>NOTE: Some systems do not need (or have) <code>-lsocket -lresolv -lnsl</code>.
|
||||
Such systems should compile using <code>-lX11</code>.</p>
|
||||
<p>NOTE: The original winning source <a href="kivinen.orig.c">kivinen.orig.c</a> assumed that
|
||||
<code>exit(3)</code> returned a value which cause problems for some systems where <code>exit(3)</code> returns
|
||||
<code>void</code>. The file <a href="kivinen.c">kivinen.c</a> avoids this problem.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="x-entertainment-kit">X Entertainment Kit</h3>
|
||||
<p>This kit includes three games from the early era of video games
|
||||
designed for the X Window System Version 11 Release 5. It should work
|
||||
with earlier releases, though.</p>
|
||||
<p>This kit includes three games from the early era of video games designed for
|
||||
the X Window System Version 11 Release 5. It should work with earlier releases,
|
||||
though.</p>
|
||||
<h4 id="space-invaders">Space Invaders</h4>
|
||||
<p>The classic game of shooting aliens from outer space, trying to
|
||||
exterminate all life on earth. The game ends when the first line of
|
||||
aliens touches the ground, or destroy you. To win the game you must
|
||||
destroy all the aliens. If you evade out from the screen you lose.</p>
|
||||
exterminate all life on earth. The game ends when the first line
|
||||
of aliens touches the ground, or destroy you. To win the game you
|
||||
must destroy all the aliens. If you evade out from the screen you
|
||||
lose.</p>
|
||||
<h5 id="controls">Controls</h5>
|
||||
<ul>
|
||||
<li>Button 1 = Move left</li>
|
||||
@@ -218,8 +213,8 @@ miss it, game ends. To win you must catch all 30 pieces.</p>
|
||||
<li>Button 3 = Move right</li>
|
||||
</ul>
|
||||
<h3 id="starting-a-game">Starting a game</h3>
|
||||
<p>The type of the game is determined by the number of arguments given
|
||||
to the program.</p>
|
||||
<p>The type of the game is determined by the number of arguments
|
||||
given to the program.</p>
|
||||
<ul>
|
||||
<li>no arguments = Space Invaders</li>
|
||||
<li>1 argument = Breakout</li>
|
||||
@@ -232,58 +227,39 @@ to the program.</p>
|
||||
</ul>
|
||||
<p>…and so on…</p>
|
||||
<h3 id="scores">Scores</h3>
|
||||
<p>The exit value of the game is your score. The smaller the score the
|
||||
better it is. The exit value of zero means you have won.</p>
|
||||
<p>The exit value of the game is your score. The smaller the score
|
||||
the better it is. The exit value of zero means you have won.</p>
|
||||
<h3 id="features">Features</h3>
|
||||
<p>The game has a cheat system, which can be found after examining the
|
||||
event loop at the end of program. It is not a bug, it’s a feature!</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0
|
||||
License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights
|
||||
Reserved. You are free to share and adapt this file under the terms of
|
||||
this license:</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0 License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
|
||||
You are free to share and adapt this file under the terms of this license:</p>
|
||||
<pre><code>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</code></pre>
|
||||
<p>For more information, see:
|
||||
https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
<p>For more information, see: https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
|
||||
<!-- 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-1992kivinen"><a name="inventory"></a>Inventory for
|
||||
1992/kivinen</h1>
|
||||
<h1 id="inventory-for-1992kivinen"><a name="inventory"></a>Inventory for 1992/kivinen</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/1992/kivinen/kivinen.c">kivinen.c</a>
|
||||
- entry source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/kivinen/Makefile">Makefile</a>
|
||||
- entry Makefile</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/kivinen/kivinen.alt.c">kivinen.alt.c</a>
|
||||
- alternative source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/kivinen/kivinen.orig.c">kivinen.orig.c</a>
|
||||
- original source</li>
|
||||
<li><a href="1992_kivinen.tar.bz2">1992_kivinen.tar.bz2</a> - download
|
||||
entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/kivinen/kivinen.c">kivinen.c</a> - entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/kivinen/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/kivinen/kivinen.alt.c">kivinen.alt.c</a> - alternative source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/kivinen/kivinen.orig.c">kivinen.orig.c</a> - original source</li>
|
||||
<li><a href="1992_kivinen.tar.bz2">1992_kivinen.tar.bz2</a> - download entry source</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/1992/kivinen/.entry.json">.entry.json</a>
|
||||
- description of entry in JSON</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/kivinen/.gitignore">.gitignore</a>
|
||||
- list of files that should not be committed under git</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/kivinen/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/kivinen/.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>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/kivinen/README.md">README.md</a>
|
||||
- markdown source for index.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/kivinen/README.md">README.md</a> - markdown source for index.html</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||||
|
||||
+17
-37
@@ -129,9 +129,9 @@
|
||||
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Ed_Luke">Ed Luke</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#Ed_Luke">Ed Luke</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -144,8 +144,7 @@ America</em> (<em>United States</em>) <br><br></li>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: doesn't work with some compilers - please provide alternative code or fix for more compilers</code></pre>
|
||||
<p>For more detailed information see <a
|
||||
href="../../bugs.html#1992_lush">1992 lush bugs</a>.</p>
|
||||
<p>For more detailed information see <a href="../../bugs.html#1992_lush">1992 lush 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">./lush.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
@@ -156,53 +155,34 @@ program’s data!</p>
|
||||
<p>This program is yet another “Hello World.” program with a twist. The
|
||||
string Hello World has been encoded in the error messages the compiler
|
||||
generates when compiling the source.</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0
|
||||
License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights
|
||||
Reserved. You are free to share and adapt this file under the terms of
|
||||
this license:</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0 License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
|
||||
You are free to share and adapt this file under the terms of this license:</p>
|
||||
<pre><code>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</code></pre>
|
||||
<p>For more information, see:
|
||||
https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
<p>For more information, see: https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
|
||||
<!-- 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-1992lush"><a name="inventory"></a>Inventory for
|
||||
1992/lush</h1>
|
||||
<h1 id="inventory-for-1992lush"><a name="inventory"></a>Inventory for 1992/lush</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/1992/lush/lush.c">lush.c</a>
|
||||
- entry source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/lush/Makefile">Makefile</a>
|
||||
- entry Makefile</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/lush/lush.orig.c">lush.orig.c</a>
|
||||
- original source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/lush/lush.sh">lush.sh</a>
|
||||
- how to run</li>
|
||||
<li><a href="1992_lush.tar.bz2">1992_lush.tar.bz2</a> - download entry
|
||||
source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/lush/lush.c">lush.c</a> - entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/lush/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/lush/lush.orig.c">lush.orig.c</a> - original source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/lush/lush.sh">lush.sh</a> - how to run</li>
|
||||
<li><a href="1992_lush.tar.bz2">1992_lush.tar.bz2</a> - download entry source</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/1992/lush/.entry.json">.entry.json</a>
|
||||
- description of entry in JSON</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/lush/.gitignore">.gitignore</a>
|
||||
- list of files that should not be committed under git</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/lush/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/lush/.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>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/lush/README.md">README.md</a>
|
||||
- markdown source for index.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/lush/README.md">README.md</a> - markdown source for index.html</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||||
|
||||
+26
-48
@@ -129,9 +129,9 @@
|
||||
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Andrea_Marangoni">Andrea
|
||||
Marangoni</a><br> Location: <a href="../../location.html#IT">IT</a> -
|
||||
<em>Italian Republic</em> (<em>Italy</em>) <br><br></li>
|
||||
<li>Name: <a href="../../authors.html#Andrea_Marangoni">Andrea Marangoni</a><br>
|
||||
Location: <a href="../../location.html#IT">IT</a> - <em>Italian Republic</em> (<em>Italy</em>)
|
||||
<br><br></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -144,68 +144,46 @@ Marangoni</a><br> Location: <a href="../../location.html#IT">IT</a> -
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./marangon</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>The object is to refill the table with 5’s, by incrementing or
|
||||
decrementing numbers as needed. It is the side effects that get you into
|
||||
trouble. If you are not careful, you may find things “at 6’s and 7’s”.
|
||||
:-)</p>
|
||||
<p>The object is to refill the table with 5’s, by incrementing or decrementing
|
||||
numbers as needed. It is the side effects that get you into trouble. If you
|
||||
are not careful, you may find things “at 6’s and 7’s”. :-)</p>
|
||||
<p>NOTE: Some compilers have had trouble optimizing this entry.</p>
|
||||
<p>NOTE: Some systems need to compile with <code>-ltermcap</code> as
|
||||
well as <code>-lcurses</code>.</p>
|
||||
<p>NOTE: The original winning source <a
|
||||
href="marangon.orig.c">marangon.orig.c</a>, found in the archive
|
||||
directory, assumed that <code>exit(3)</code> returns a value which cause
|
||||
problems for some systems where <code>exit(3)</code> returns a
|
||||
<code>void</code>. The file <a href="marangon.c">marangon.c</a> avoids
|
||||
this problem.</p>
|
||||
<p>NOTE: Some systems need to compile with <code>-ltermcap</code> as well as <code>-lcurses</code>.</p>
|
||||
<p>NOTE: The original winning source <a href="marangon.orig.c">marangon.orig.c</a>, found in
|
||||
the archive directory, assumed that <code>exit(3)</code> returns a value which cause
|
||||
problems for some systems where <code>exit(3)</code> returns a <code>void</code>. The file
|
||||
<a href="marangon.c">marangon.c</a> avoids this problem.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p>It starts off by creating a table with number 5 in all places. The
|
||||
CPU melts the numbers and you must return them in original state. When
|
||||
you increase a number, all the other eight numbers next to it decrease
|
||||
and vice-versa.</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0
|
||||
License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights
|
||||
Reserved. You are free to share and adapt this file under the terms of
|
||||
this license:</p>
|
||||
<p>It starts off by creating a table with number 5 in all places. The CPU melts
|
||||
the numbers and you must return them in original state. When you increase a
|
||||
number, all the other eight numbers next to it decrease and vice-versa.</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0 License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
|
||||
You are free to share and adapt this file under the terms of this license:</p>
|
||||
<pre><code>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</code></pre>
|
||||
<p>For more information, see:
|
||||
https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
<p>For more information, see: https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
|
||||
<!-- 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-1992marangon"><a name="inventory"></a>Inventory
|
||||
for 1992/marangon</h1>
|
||||
<h1 id="inventory-for-1992marangon"><a name="inventory"></a>Inventory for 1992/marangon</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/1992/marangon/marangon.c">marangon.c</a>
|
||||
- entry source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/marangon/Makefile">Makefile</a>
|
||||
- entry Makefile</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/marangon/marangon.orig.c">marangon.orig.c</a>
|
||||
- original source</li>
|
||||
<li><a href="1992_marangon.tar.bz2">1992_marangon.tar.bz2</a> - download
|
||||
entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/marangon/marangon.c">marangon.c</a> - entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/marangon/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/marangon/marangon.orig.c">marangon.orig.c</a> - original source</li>
|
||||
<li><a href="1992_marangon.tar.bz2">1992_marangon.tar.bz2</a> - download entry source</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/1992/marangon/.entry.json">.entry.json</a>
|
||||
- description of entry in JSON</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/marangon/.gitignore">.gitignore</a>
|
||||
- list of files that should not be committed under git</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/marangon/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/marangon/.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>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/marangon/README.md">README.md</a>
|
||||
- markdown source for index.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/marangon/README.md">README.md</a> - markdown source for index.html</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||||
|
||||
+72
-100
@@ -129,10 +129,9 @@
|
||||
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Nathan_Sidwell">Nathan
|
||||
Sidwell</a><br> Location: <a href="../../location.html#GB">GB</a> -
|
||||
<em>United Kingdom of Great Britain and Northern Ireland</em>
|
||||
(<em>United Kingdom</em>) <br><br></li>
|
||||
<li>Name: <a href="../../authors.html#Nathan_Sidwell">Nathan Sidwell</a><br>
|
||||
Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom of Great Britain and Northern Ireland</em> (<em>United Kingdom</em>)
|
||||
<br><br></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -150,131 +149,104 @@ Sidwell</a><br> Location: <a href="../../location.html#GB">GB</a> -
|
||||
<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">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<h3 id="warning">WARNING:</h3>
|
||||
<p>The judges make no claim as to the strength or security of this
|
||||
program. It is likely to be nil, or the next best thing to it. Still,
|
||||
you might consider installing it in <code>/usr/games/nathan</code>.
|
||||
:-)</p>
|
||||
<h3 id="note-from-the-judges-about-the-winning-category">Note from the
|
||||
judges about the winning category::</h3>
|
||||
<p>The ‘winning’ category is also open to question. One could say that
|
||||
it is a ‘file obfuscator’. One could also say that it unintentionally
|
||||
abused the intent of rule #7 (that programs should be freely
|
||||
re-distributable). We suspect that the author may not have intended to
|
||||
do this, but that is the way things go sometimes.</p>
|
||||
<p>BTW, ‘abuse of the rules’ entries do not violate the rules. Entries
|
||||
that violate the rules are disqualified. Abuse of the rules entries are
|
||||
ones that tend to ‘stretch’ the limits and take the contest into
|
||||
unexpected territory.</p>
|
||||
<h3 id="historical-notes-from-the-judges-about-this-entry">Historical
|
||||
notes from the judges about this entry:</h3>
|
||||
<p>The US International Traffic in Arms Regulations controls certain
|
||||
exportations going out of the United States. The U.S. Munitions List
|
||||
gives the specific categories of restricted exports. Because this entry
|
||||
at one time appeared to fall under this restricted category, the judges
|
||||
originally were not able to distribute some winning entries outside of
|
||||
the US.</p>
|
||||
<p>Nathan Sidwell stated that he was willing to distribute the winning
|
||||
source. To read HIS instructions of how to obtain his winning program
|
||||
one was able to run:</p>
|
||||
<p>The judges make no claim as to the strength or security
|
||||
of this program. It is likely to be nil, or the next
|
||||
best thing to it. Still, you might consider installing
|
||||
it in <code>/usr/games/nathan</code>. :-)</p>
|
||||
<h3 id="note-from-the-judges-about-the-winning-category">Note from the judges about the winning category::</h3>
|
||||
<p>The ‘winning’ category is also open to question. One could say
|
||||
that it is a ‘file obfuscator’. One could also say that it
|
||||
unintentionally abused the intent of rule #7 (that programs
|
||||
should be freely re-distributable). We suspect that the author
|
||||
may not have intended to do this, but that is the way things go
|
||||
sometimes.</p>
|
||||
<p>BTW, ‘abuse of the rules’ entries do not violate the rules.
|
||||
Entries that violate the rules are disqualified. Abuse of the
|
||||
rules entries are ones that tend to ‘stretch’ the limits and
|
||||
take the contest into unexpected territory.</p>
|
||||
<h3 id="historical-notes-from-the-judges-about-this-entry">Historical notes from the judges about this entry:</h3>
|
||||
<p>The US International Traffic in Arms Regulations controls certain exportations
|
||||
going out of the United States. The U.S. Munitions List gives the specific
|
||||
categories of restricted exports. Because this entry at one time appeared to
|
||||
fall under this restricted category, the judges originally were not able to
|
||||
distribute some winning entries outside of the US.</p>
|
||||
<p>Nathan Sidwell stated that he was willing to distribute the winning source. To
|
||||
read HIS instructions of how to obtain his winning program one was able to run:</p>
|
||||
<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="fu">make</span> nathan</span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./nathan</span></span></code></pre></div>
|
||||
<p>to learn how to get a copy of the code.</p>
|
||||
<p>See the 1992/nathan.c file in the <a
|
||||
href="../../archive/historic/archive-1992.tar.bz2">archive/historic/archive-1992.tar.bz2</a>
|
||||
<p>See the 1992/nathan.c file in the
|
||||
<a href="../../archive/historic/archive-1992.tar.bz2">archive/historic/archive-1992.tar.bz2</a>
|
||||
tarball if you’re interested in this file.</p>
|
||||
<h3 id="personal-note-from-chongo">Personal note from chongo:</h3>
|
||||
<p>I think the situation showed just how ridiculous US crypto
|
||||
regulations really were/are. Certain US federal officials can get away
|
||||
with shipping arms to certain nations in apparent violation of US laws,
|
||||
but I personally can’t re-distribute a program contest entry to the
|
||||
network!</p>
|
||||
<p>I think the situation showed just how ridiculous US crypto regulations really
|
||||
were/are. Certain US federal officials can get away with shipping arms to
|
||||
certain nations in apparent violation of US laws, but I personally can’t
|
||||
re-distribute a program contest entry to the network!</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="program-use">Program use</h3>
|
||||
<p>This program is a hello world text encryptor/decryptor. It uses an
|
||||
enigma (I think) style encryption algorithm, where the encryption key
|
||||
character is modified by a value, determined from the previous
|
||||
character. Non-printable characters (those with ASCII values <
|
||||
<code>' '</code> or > <code>0x7e</code>) are passed unaltered, thus
|
||||
any kind of file may be successfully processed, but if the original is
|
||||
printable, the processed file will be too. The input is read from
|
||||
<code>stdin</code>, and the output presented to <code>stdout</code>. The
|
||||
key, a text string, is presented as a command argument. This is
|
||||
optional, and if omitted, the file is self-{de,en}crypted. To specify
|
||||
decryption, a <code>-</code> should be given before the key. (Actually
|
||||
encryption and decryption proper inverse operations, so you can use
|
||||
decrypt to scramble and encrypt to descramble, if you’re perverse.)</p>
|
||||
<h3 id="portability-a-little-knowledge-is-a-dangerous-thing">Portability
|
||||
(A little knowledge is a dangerous thing)</h3>
|
||||
enigma (I think) style encryption algorithm, where the encryption
|
||||
key character is modified by a value, determined from the previous
|
||||
character. Non-printable characters (those with ASCII values < <code>' '</code>
|
||||
or > <code>0x7e</code>) are passed unaltered, thus any kind of file may be
|
||||
successfully processed, but if the original is printable, the
|
||||
processed file will be too. The input is read from <code>stdin</code>, and the
|
||||
output presented to <code>stdout</code>. The key, a text string, is presented as
|
||||
a command argument. This is optional, and if omitted, the file is
|
||||
self-{de,en}crypted. To specify decryption, a <code>-</code> should be given
|
||||
before the key. (Actually encryption and decryption proper inverse
|
||||
operations, so you can use decrypt to scramble and encrypt to
|
||||
descramble, if you’re perverse.)</p>
|
||||
<h3 id="portability-a-little-knowledge-is-a-dangerous-thing">Portability (A little knowledge is a dangerous thing)</h3>
|
||||
<p>It’s written in ANSI C, and doesn’t even assume an ASCII character
|
||||
set, (it has an array of the characters to convert), so should be
|
||||
portable across many platforms. It passes
|
||||
<code>gcc -ansi -pedantic -O -Wall</code> with no warnings (You may get
|
||||
assignment in conditional warnings on other platforms though). Because
|
||||
I’ve heard that conditional jumps slow down fast processors, I’ve
|
||||
eliminated all the <code>if</code>s from the code; indeed, as its only
|
||||
one statement, it should compile to one instruction and a suitably
|
||||
designed CISC machine. To speed compilation, there is only one statement
|
||||
in the loop, so that another scoping level does not need to be
|
||||
opened.</p>
|
||||
<p>Being an encryptor/decryptor, you probably want the source code to be
|
||||
obfuscated, to hide the algorithm.</p>
|
||||
portable across many platforms. It passes <code>gcc -ansi -pedantic -O -Wall</code> with no warnings (You may get assignment in conditional
|
||||
warnings on other platforms though). Because I’ve heard that
|
||||
conditional jumps slow down fast processors, I’ve eliminated all
|
||||
the <code>if</code>s from the code; indeed, as its only one statement, it should
|
||||
compile to one instruction and a suitably designed CISC machine. To
|
||||
speed compilation, there is only one statement in the loop, so that
|
||||
another scoping level does not need to be opened.</p>
|
||||
<p>Being an encryptor/decryptor, you probably want the source code to
|
||||
be obfuscated, to hide the algorithm.</p>
|
||||
<h3 id="obfuscation">Obfuscation</h3>
|
||||
<p>In spite of the fact that it looks like a nice friendly hello world
|
||||
program, it isn’t (as documented above). (Short lines have been padded,
|
||||
as you’ll find if you look at an encrypted copy of the source.)</p>
|
||||
<p>I’ve also named some of the macros from commonly used functions, just
|
||||
to keep things muddy. Of course, all the variables are misnamed. The
|
||||
program is kept simply (one for statement), by serious overuse of
|
||||
<code>,</code> and <code>?:</code>. These are really confusing when used
|
||||
together, nested or put in argument lists (is that a comma operator, or
|
||||
argument separator?).</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0
|
||||
License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights
|
||||
Reserved. You are free to share and adapt this file under the terms of
|
||||
this license:</p>
|
||||
<p>I’ve also named some of the macros from commonly used functions, just to keep
|
||||
things muddy. Of course, all the variables are misnamed. The program is kept
|
||||
simply (one for statement), by serious overuse of <code>,</code> and <code>?:</code>. These are really
|
||||
confusing when used together, nested or put in argument lists (is that a comma
|
||||
operator, or argument separator?).</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0 License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
|
||||
You are free to share and adapt this file under the terms of this license:</p>
|
||||
<pre><code>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</code></pre>
|
||||
<p>For more information, see:
|
||||
https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
<p>For more information, see: https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
|
||||
<!-- 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-1992nathan"><a name="inventory"></a>Inventory for
|
||||
1992/nathan</h1>
|
||||
<h1 id="inventory-for-1992nathan"><a name="inventory"></a>Inventory for 1992/nathan</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/1992/nathan/nathan.c">nathan.c</a>
|
||||
- entry source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/nathan/Makefile">Makefile</a>
|
||||
- entry Makefile</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/nathan/nathan.orig.c">nathan.orig.c</a>
|
||||
- original source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/nathan/try.sh">try.sh</a>
|
||||
- how to run</li>
|
||||
<li><a href="1992_nathan.tar.bz2">1992_nathan.tar.bz2</a> - download
|
||||
entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/nathan/nathan.c">nathan.c</a> - entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/nathan/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/nathan/nathan.orig.c">nathan.orig.c</a> - original source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/nathan/try.sh">try.sh</a> - how to run</li>
|
||||
<li><a href="1992_nathan.tar.bz2">1992_nathan.tar.bz2</a> - download entry source</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/1992/nathan/.entry.json">.entry.json</a>
|
||||
- description of entry in JSON</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/nathan/.gitignore">.gitignore</a>
|
||||
- list of files that should not be committed under git</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/nathan/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/nathan/.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>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/nathan/README.md">README.md</a>
|
||||
- markdown source for index.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/nathan/README.md">README.md</a> - markdown source for index.html</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||||
|
||||
+79
-110
@@ -130,8 +130,8 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Vern_Paxson">Vern Paxson</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of
|
||||
America</em> (<em>United States</em>) <br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -144,8 +144,7 @@ America</em> (<em>United States</em>) <br><br></li>
|
||||
<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#1992_vern">1992 vern bugs</a>.</p>
|
||||
<p>For more detailed information see <a href="../../bugs.html#1992_vern">1992 vern 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">./vern</span> 3 <span class="co"># <-- default is 2</span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
@@ -163,155 +162,125 @@ suggested above. :-)</p>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="ex">65</span> 55</span>
|
||||
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="ex">66</span> 46</span></code></pre></div>
|
||||
<p>NOTE: Move values must be restricted to the range 00 to 77.</p>
|
||||
<p>NOTE: Because some mailers have problems with the original winning
|
||||
source, a slightly modified version with shorter lines has been
|
||||
provided.</p>
|
||||
<p>NOTE: Because some mailers have problems with the original winning source,
|
||||
a slightly modified version with shorter lines has been provided.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p>This program plays chess. You play the white pieces and the program
|
||||
the black pieces. Moves are entered as a two-digit number specifying the
|
||||
coordinates of the piece to be moved followed by another two-digit
|
||||
number specifying the coordinates of where to move it. Rows and columns
|
||||
are numbered starting with <code>(0,0)</code> for the upper-left-hand
|
||||
corner (black’s queen’s rook) and going to <code>(7,7)</code> for the
|
||||
lower-right-hand corner (white’s king’s rook). For example, the
|
||||
<code>PK4</code> opening for white is indicated as
|
||||
<code>"64 44" (without the quotes)</code>. Moves are read using
|
||||
<code>scanf()</code> so care should be taken to not enter the wrong
|
||||
number of fields.</p>
|
||||
<p>This program plays chess. You play the white pieces and the program the black
|
||||
pieces. Moves are entered as a two-digit number specifying the coordinates of
|
||||
the piece to be moved followed by another two-digit number specifying the
|
||||
coordinates of where to move it. Rows and columns are numbered starting with
|
||||
<code>(0,0)</code> for the upper-left-hand corner (black’s queen’s rook) and going to
|
||||
<code>(7,7)</code> for the lower-right-hand corner (white’s king’s rook). For example, the
|
||||
<code>PK4</code> opening for white is indicated as <code>"64 44" (without the quotes)</code>. Moves
|
||||
are read using <code>scanf()</code> so care should be taken to not enter the wrong number
|
||||
of fields.</p>
|
||||
<p>If the move you enter is illegal then you are just prompted again to
|
||||
move. If the move is legal then the new position is displayed and the
|
||||
program starts computing its response. For every 64 board positions it
|
||||
examines a “.” is printed. Once it has chosen its move it simply
|
||||
displays the board updated to reflect the move.</p>
|
||||
<p>Your move is prompted for using a string like
|
||||
<code>"1351 9 2 >"</code>. The first number is how many board
|
||||
positions the program examined when computing its previous response. The
|
||||
second number is its anticipated value for the move it just made (with
|
||||
larger numbers meaning an ultimately better board position for it), and
|
||||
the third number is the evaluation it assigns to the your current
|
||||
position (larger numbers meaning better positions for you). A
|
||||
<code>></code> indicates that you are not in check; for check it is
|
||||
changed to <code>!</code>.</p>
|
||||
<p>Your move is prompted for using a string like <code>"1351 9 2 >"</code>. The first
|
||||
number is how many board positions the program examined when computing
|
||||
its previous response. The second number is its anticipated value for
|
||||
the move it just made (with larger numbers meaning an ultimately better
|
||||
board position for it), and the third number is the evaluation it
|
||||
assigns to the your current position (larger numbers meaning better
|
||||
positions for you). A <code>></code> indicates that you are not in check; for
|
||||
check it is changed to <code>!</code>.</p>
|
||||
<p>There are a few limitations on play:</p>
|
||||
<ul>
|
||||
<li>castling can only be done on the king’s side.</li>
|
||||
<li>prohibitions against castling out of or through check are not
|
||||
enforced.</li>
|
||||
<li>prohibitions against castling if the king or rook have moved are not
|
||||
enforced.</li>
|
||||
<li>prohibitions against castling out of or through check are not enforced.</li>
|
||||
<li>prohibitions against castling if the king or rook have moved are not enforced.</li>
|
||||
<li>pawns are always promoted to queens.</li>
|
||||
<li>en passant is not allowed.</li>
|
||||
<li>the board-position-repeated-three-times and fifty-moves stalemates
|
||||
are not recognized.</li>
|
||||
<li>the board-position-repeated-three-times and fifty-moves stalemates are not
|
||||
recognized.</li>
|
||||
</ul>
|
||||
<p>If you checkmate the computer it prints “Rats!” and exits. If your
|
||||
own checkmate is imminent it prints “Har har.” but doesn’t exit so it
|
||||
can rub your nose in defeat (which may be a move or two away if you’re
|
||||
<p>If you checkmate the computer it prints “Rats!” and exits. If your own
|
||||
checkmate is imminent it prints “Har har.” but doesn’t exit so it can
|
||||
rub your nose in defeat (which may be a move or two away if you’re
|
||||
playing at a high “ply” - see the next paragraph). Stalemates are not
|
||||
recognized per se, but when selecting its move the program assigns a
|
||||
stalemate position a value of 0 so it will try for a stalemate if its
|
||||
other options are worse.</p>
|
||||
<p>The program takes one optional argument indicating the ply
|
||||
(lookahead) it should use. The default is 2, which is enough to keep it
|
||||
from making flaming blunders. The higher the ply, the better the play,
|
||||
and the longer you have to wait. For example, at a ply of 2, a response
|
||||
to the <code>PK4</code> opening takes about 1.8 CPU seconds on a SPARC
|
||||
ELC when compiled <code>-O</code> with Sun <code>cc</code>. A ply of 3
|
||||
takes 13 CPU seconds (and results in a different response to
|
||||
<code>PK4</code>) and a ply of 4 takes a little under 4 CPU minutes (and
|
||||
for <code>PK4</code> comes up with the same response as a ply of 3). A
|
||||
ply of 3 is in general good enough to avoid not only flaming blunders
|
||||
but also immediately stupid moves altogether. A ply of 4 will find all
|
||||
<p>The program takes one optional argument indicating the ply (lookahead) it should
|
||||
use. The default is 2, which is enough to keep it from making flaming blunders.
|
||||
The higher the ply, the better the play, and the longer you have to wait. For
|
||||
example, at a ply of 2, a response to the <code>PK4</code> opening takes about 1.8 CPU
|
||||
seconds on a SPARC ELC when compiled <code>-O</code> with Sun <code>cc</code>. A ply of 3 takes 13
|
||||
CPU seconds (and results in a different response to <code>PK4</code>) and a ply of 4 takes
|
||||
a little under 4 CPU minutes (and for <code>PK4</code> comes up with the same response as a
|
||||
ply of 3). A ply of 3 is in general good enough to avoid not only flaming
|
||||
blunders but also immediately stupid moves altogether. A ply of 4 will find all
|
||||
mate-in-two’s.</p>
|
||||
<h3 id="obfuscation">Obfuscation</h3>
|
||||
<p>This program is obfuscated in a number of ways. First, it abuses the
|
||||
contest rule regarding ‘;’, ‘{’, and ‘}’ in the source not counting
|
||||
against the non-whitespace character limit if followed by whitespace. As
|
||||
can be seen from the build file, certain combinations of these
|
||||
characters followed by a particular whitespace character are expanded at
|
||||
build time into much-needed text. Without this hack the program wouldn’t
|
||||
pass the character limit. A nice side effect is that the initial source
|
||||
is gloriously difficult to peruse. In particular, the Makefile does:</p>
|
||||
against the non-whitespace character limit if followed by whitespace.
|
||||
As can be seen from the build file, certain combinations of these
|
||||
characters followed by a particular whitespace character are expanded
|
||||
at build time into much-needed text. Without this hack the program
|
||||
wouldn’t pass the character limit. A nice side effect is that the
|
||||
initial source is gloriously difficult to peruse. In particular, the Makefile
|
||||
does:</p>
|
||||
<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="fu">sed</span> <span class="op"><</span>vern.c <span class="st">'s/{ /(/g;s/} /)/g;s/; /#define /'</span> <span class="kw">|</span> <span class="dt">\</span></span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">sed</span> <span class="st">'s/} /=/g;s/{ /i/g'</span> <span class="op">></span>vern.tmp.c</span></code></pre></div>
|
||||
<p>and compiles <code>vern.tmp.c</code>.</p>
|
||||
<p>Second, the rather ho-hum step has been taking of naming each
|
||||
variable with a one or two letter identifier to render it meaningless
|
||||
(and save space). This tactic is rather effective in a complex
|
||||
program.</p>
|
||||
<p>Third, the board is represented not as an array of pieces but rather
|
||||
as an array of function pointers (with a separate array representing
|
||||
<p>Second, the rather ho-hum step has been taking of naming each variable
|
||||
with a one or two letter identifier to render it meaningless (and save
|
||||
space). This tactic is rather effective in a complex program.</p>
|
||||
<p>Third, the board is represented not as an array of pieces but rather as
|
||||
an array of function pointers (with a separate array representing
|
||||
whether a piece is white or black). This obfuscates the program’s
|
||||
central data structure. There is one function per type of piece; when
|
||||
called they return 1 if the current move is illegal for that piece and 0
|
||||
if it is legal. The functions also as a side effect set a global
|
||||
called they return 1 if the current move is illegal for that piece and
|
||||
0 if it is legal. The functions also as a side effect set a global
|
||||
indicating the type of the piece (though the type can also be determined
|
||||
by comparing the function pointer with the function itself).</p>
|
||||
<p>Fourth, there are no independent routines for generating potential
|
||||
moves. Instead, the program generates its moves by brute force: for
|
||||
every piece it controls on the board, it attempts to move it to every
|
||||
square on the board. Those moves that are legal it then explores to see
|
||||
their effects (using <a
|
||||
href="https://en.wikipedia.org/wiki/Alpha-beta_pruning">alpha-beta
|
||||
search</a>). This tactic somewhat obfuscates the algorithm used by the
|
||||
program.</p>
|
||||
<p>Finally, there are three key constants that occur throughout the
|
||||
program: <code>64</code>, <code>8</code>, and <code>3</code>
|
||||
(<code>lg 8</code>). Rather than making these available at compile-time,
|
||||
<p>Fourth, there are no independent routines for generating potential moves.
|
||||
Instead, the program generates its moves by brute force: for every piece it
|
||||
controls on the board, it attempts to move it to every square on the board.
|
||||
Those moves that are legal it then explores to see their effects (using
|
||||
<a href="https://en.wikipedia.org/wiki/Alpha-beta_pruning">alpha-beta search</a>). This
|
||||
tactic somewhat obfuscates the algorithm used by the program.</p>
|
||||
<p>Finally, there are three key constants that occur throughout the program: <code>64</code>,
|
||||
<code>8</code>, and <code>3</code> (<code>lg 8</code>). Rather than making these available at compile-time,
|
||||
which provides a hint as to what the program is up to, they are computed
|
||||
probabilistically at run-time. An instance of the <a
|
||||
href="https://en.wikipedia.org/wiki/Renewal_theory#Inspection_paradox">“Inspection
|
||||
Paradox”</a> is used which happens to produce a value that on average is
|
||||
close to <code>.64</code>. <code>10000</code> instances of this value
|
||||
are computed, added up, and then divided by <code>100</code>. Sometimes
|
||||
the value produced will be <code>63</code> or <code>65</code> instead of
|
||||
<code>64</code> (but I’ve never observed any other values), so the
|
||||
result is then rounded to the nearest multiple of <code>4</code>, and
|
||||
then the other constants are derived from it.</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0
|
||||
License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights
|
||||
Reserved. You are free to share and adapt this file under the terms of
|
||||
this license:</p>
|
||||
probabilistically at run-time. An instance of the <a href="https://en.wikipedia.org/wiki/Renewal_theory#Inspection_paradox">“Inspection
|
||||
Paradox”</a> is
|
||||
used which happens to produce a value that on average is close to <code>.64</code>.
|
||||
<code>10000</code> instances of this value are computed, added up, and then divided by
|
||||
<code>100</code>. Sometimes the value produced will be <code>63</code> or <code>65</code> instead of <code>64</code> (but
|
||||
I’ve never observed any other values), so the result is then rounded to the
|
||||
nearest multiple of <code>4</code>, and then the other constants are derived from it.</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0 License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
|
||||
You are free to share and adapt this file under the terms of this license:</p>
|
||||
<pre><code>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</code></pre>
|
||||
<p>For more information, see:
|
||||
https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
<p>For more information, see: https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
|
||||
<!-- 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-1992vern"><a name="inventory"></a>Inventory for
|
||||
1992/vern</h1>
|
||||
<h1 id="inventory-for-1992vern"><a name="inventory"></a>Inventory for 1992/vern</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/1992/vern/vern.c">vern.c</a>
|
||||
- entry source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/vern/Makefile">Makefile</a>
|
||||
- entry Makefile</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/vern/vern.orig.c">vern.orig.c</a>
|
||||
- original source</li>
|
||||
<li><a href="1992_vern.tar.bz2">1992_vern.tar.bz2</a> - download entry
|
||||
source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/vern/vern.c">vern.c</a> - entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/vern/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/vern/vern.orig.c">vern.orig.c</a> - original source</li>
|
||||
<li><a href="1992_vern.tar.bz2">1992_vern.tar.bz2</a> - download entry source</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/1992/vern/.entry.json">.entry.json</a>
|
||||
- description of entry in JSON</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/vern/.gitignore">.gitignore</a>
|
||||
- list of files that should not be committed under git</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/vern/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/vern/.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>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/vern/README.md">README.md</a>
|
||||
- markdown source for index.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/vern/README.md">README.md</a> - markdown source for index.html</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||||
|
||||
+80
-123
@@ -129,9 +129,9 @@
|
||||
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Brian_Westley">Brian
|
||||
Westley</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#Brian_Westley">Brian Westley</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -145,33 +145,27 @@ Westley</a><br> Location: <a href="../../location.html#US">US</a> -
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: known bug - please help us fix</code></pre>
|
||||
<p>For more detailed information see <a
|
||||
href="../../bugs.html#1992_westley">1992 westley bugs</a>.</p>
|
||||
<p>For more detailed information see <a href="../../bugs.html#1992_westley">1992 westley bugs</a>.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<p>If lost:</p>
|
||||
<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">./whereami.sh</span> lat long</span></code></pre></div>
|
||||
<p>Where <code>lat</code> and <code>long</code> correspond to your
|
||||
latitude and longitude.</p>
|
||||
<p>NOTE: you <strong>MUST</strong> have a terminal that is at least 80
|
||||
columns for this to show properly. The <code>whereami</code> and
|
||||
<code>whereami.alt</code> code checks this but it is not prohibitive if
|
||||
it cannot be compiled and linked (it uses curses); instead one should
|
||||
just use the <code>westley</code> and <code>westley.alt</code> programs
|
||||
directly.</p>
|
||||
<p>Where <code>lat</code> and <code>long</code> correspond to your latitude and longitude.</p>
|
||||
<p>NOTE: you <strong>MUST</strong> have a terminal that is at least 80 columns for this to show
|
||||
properly. The <code>whereami</code> and <code>whereami.alt</code> code checks this but it is not
|
||||
prohibitive if it cannot be compiled and linked (it uses curses); instead one
|
||||
should just use the <code>westley</code> and <code>westley.alt</code> programs directly.</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">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>The author provided a version for the US which we added. To
|
||||
build:</p>
|
||||
<p>The author provided a version for the US which we added. To build:</p>
|
||||
<h3 id="alternate-build">Alternate 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> alt</span></code></pre></div>
|
||||
<h3 id="alternate-use">Alternate 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">./whereami.alt.sh</span> lat long</span></code></pre></div>
|
||||
<p>NOTE: this alternative version also needs a terminal with at least 80
|
||||
columns.</p>
|
||||
<p>NOTE: this alternative version also needs a terminal with at least 80 columns.</p>
|
||||
<h3 id="alternate-try">Alternate try:</h3>
|
||||
<p>The <a href="try.sh">try.sh</a> script uses both the original entry
|
||||
and the alternate code so one can try the same script for both:</p>
|
||||
<p>The <a href="try.sh">try.sh</a> script uses both the original entry and the alternate code
|
||||
so one can try the same script for both:</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="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>To find the approximate place where this entry was judged, type:</p>
|
||||
@@ -181,62 +175,56 @@ and the alternate code so one can try the same script for both:</p>
|
||||
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a><span class="ex">./westley</span> 37 <span class="at">-122</span> <span class="co"># </span><span class="al">NOTE</span><span class="co">: - means west of meridian</span></span></code></pre></div>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p>Run the program with your latitude & longitude as integer
|
||||
arguments; it will produce a map made up of <code>'!'</code> with the
|
||||
given position marked with either a <code>'"'</code> (if the position is
|
||||
over a <code>'!'</code>) or a <code>#</code> (if the position is over a
|
||||
space). Southern latitudes and western longitudes are entered as
|
||||
negative numbers. For example, to find San Francisco, run with
|
||||
<code>./whereami 38 -122</code>. The resolution of the map is five
|
||||
degrees horizontally, ten degrees vertically. The map is a Mercator
|
||||
projection with equal spacing of the latitudes, so the areas near the
|
||||
poles are very distorted. Latitudes near the poles and Antarctica are
|
||||
not shown.</p>
|
||||
<p>The program requires the ASCII character set, <code>putchar()</code>,
|
||||
<code>atoi()</code>, and a display that auto-wraps at 80 characters(!).
|
||||
If your display does not work this way, you will have to massage the
|
||||
output; for example, you can redirect it to a file and edit it with vi,
|
||||
arguments; it will produce a map made up of <code>'!'</code> with the given
|
||||
position marked with either a <code>'"'</code> (if the position is over a <code>'!'</code>)
|
||||
or a <code>#</code> (if the position is over a space). Southern latitudes
|
||||
and western longitudes are entered as negative numbers. For
|
||||
example, to find San Francisco, run with <code>./whereami 38 -122</code>. The
|
||||
resolution of the map is five degrees horizontally, ten degrees
|
||||
vertically. The map is a Mercator projection with equal spacing
|
||||
of the latitudes, so the areas near the poles are very distorted.
|
||||
Latitudes near the poles and Antarctica are not shown.</p>
|
||||
<p>The program requires the ASCII character set, <code>putchar()</code>, <code>atoi()</code>,
|
||||
and a display that auto-wraps at 80 characters(!). If your display
|
||||
does not work this way, you will have to massage the output;
|
||||
for example, you can redirect it to a file and edit it with vi,
|
||||
which will do auto-wrap for you.</p>
|
||||
<p>Lint complains that <code>main()</code> returns a random value and
|
||||
I’m not checking the value that <code>putchar()</code> returns.
|
||||
Scandalous!</p>
|
||||
<p>If you run it with fewer than 2 arguments, it will likely give you an
|
||||
exception, as it will access arguments that don’t exist and characters
|
||||
before a string constant.</p>
|
||||
<p>Lint complains that <code>main()</code> returns a random value and I’m not
|
||||
checking the value that <code>putchar()</code> returns. Scandalous!</p>
|
||||
<p>If you run it with fewer than 2 arguments, it will likely
|
||||
give you an exception, as it will access arguments that
|
||||
don’t exist and characters before a string constant.</p>
|
||||
<h3 id="how-it-works">How it works:</h3>
|
||||
<p>The map is printed as one long string of <code>' '</code> and
|
||||
<code>'!'</code> characters, with the auto-wrap used to stack up slices
|
||||
of 80. The map data is a string; the first character is how many
|
||||
<code>!</code>s are printed (<code>'A'</code>=1, <code>'B'</code>=2,
|
||||
etc), the second character is how many <code>' '</code>s, the third is
|
||||
how many <code>!</code>s, etc. ASCII characters less than
|
||||
<code>'A'</code> print no characters but still change the polarity, so
|
||||
any map of <code>' '</code>s and <code>'!'</code>s is possible. This is
|
||||
done in the <code>putchar()</code> argument as <code>33^l&1</code>,
|
||||
where <code>l</code> is the character <code>position+4</code>; if
|
||||
<code>l</code> is odd, <code>' '</code> is printed, if <code>l</code> is
|
||||
even, <code>'!'</code> is printed.</p>
|
||||
<p>The map is printed as one long string of <code>' '</code> and <code>'!'</code> characters,
|
||||
with the auto-wrap used to stack up slices of 80. The map data is
|
||||
a string; the first character is how many <code>!</code>s are printed
|
||||
(<code>'A'</code>=1, <code>'B'</code>=2, etc), the second character is how many <code>' '</code>s, the
|
||||
third is how many <code>!</code>s, etc. ASCII characters less than <code>'A'</code>
|
||||
print no characters but still change the polarity, so any map
|
||||
of <code>' '</code>s and <code>'!'</code>s is possible. This is done in the <code>putchar()</code>
|
||||
argument as <code>33^l&1</code>, where <code>l</code> is the character <code>position+4</code>; if
|
||||
<code>l</code> is odd, <code>' '</code> is printed, if <code>l</code> is even, <code>'!'</code> is printed.</p>
|
||||
<p>The position of latitude & longitude is changed into a single
|
||||
character position within the one long string via the first expression
|
||||
<code>d = latitude/10*80 - longitude/5 - offset</code>. The latitude is
|
||||
divided by ten because the vertical resolution is ten degrees, then
|
||||
multiplied by 80 because of the 80 character wrap (i.e. each ten degrees
|
||||
moves the position up or down one entire row). The longitude is divided
|
||||
by five and added, because five degrees of change moves the location one
|
||||
character. The signs are opposite because latitude is decreasing and
|
||||
longitude is increasing as you go from upper left to lower right. The
|
||||
offset is where the origin (latitude=0, longitude=0) is found.</p>
|
||||
<p>The position counting down to zero changes the <code>putchar()</code>
|
||||
from printing (<code>'!'</code> or <code>' '</code>) to printing
|
||||
(<code>'"'</code> or <code>'#'</code>).</p>
|
||||
<p>The <code>"H E L L O, W O R L D!"</code> string inside the data
|
||||
string prints the line of blanks past <a
|
||||
href="https://en.wikipedia.org/wiki/Tierra_del_Fuego">Tierra del
|
||||
Fuego</a> and the last blank line. It’s just for show, really.</p>
|
||||
<p>Since the resolution is coarse, a few coastal cities are shown to be
|
||||
just off the map; this is an unavoidable artifact. The map is reasonably
|
||||
accurate.</p>
|
||||
<h3 id="here-are-some-cities-you-might-like-to-try">Here are some cities
|
||||
you might like to try:</h3>
|
||||
character position within the one long string via the first
|
||||
expression <code>d = latitude/10*80 - longitude/5 - offset</code>. The
|
||||
latitude is divided by ten because the vertical resolution is
|
||||
ten degrees, then multiplied by 80 because of the 80 character
|
||||
wrap (i.e. each ten degrees moves the position up or down one
|
||||
entire row). The longitude is divided by five and added, because
|
||||
five degrees of change moves the location one character. The signs
|
||||
are opposite because latitude is decreasing and longitude is
|
||||
increasing as you go from upper left to lower right. The offset
|
||||
is where the origin (latitude=0, longitude=0) is found.</p>
|
||||
<p>The position counting down to zero changes the <code>putchar()</code> from
|
||||
printing (<code>'!'</code> or <code>' '</code>) to printing (<code>'"'</code> or <code>'#'</code>).</p>
|
||||
<p>The <code>"H E L L O, W O R L D!"</code> string inside the data string
|
||||
prints the line of blanks past <a href="https://en.wikipedia.org/wiki/Tierra_del_Fuego">Tierra del
|
||||
Fuego</a> and the last
|
||||
blank line. It’s just for show, really.</p>
|
||||
<p>Since the resolution is coarse, a few coastal cities are shown to
|
||||
be just off the map; this is an unavoidable artifact. The map
|
||||
is reasonably accurate.</p>
|
||||
<h3 id="here-are-some-cities-you-might-like-to-try">Here are some cities you might like to try:</h3>
|
||||
<ul>
|
||||
<li>New York 41 -74<br />
|
||||
</li>
|
||||
@@ -258,74 +246,43 @@ you might like to try:</h3>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a>n<span class="op">=</span><span class="st">"bnaBCOCXdBBHGYdAP[A M E R I C A].AqandkmavX|ELC}BOCd"</span></span>
|
||||
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="op">[</span>l<span class="op">++-</span><span class="dv">3</span><span class="op">];)</span><span class="cf">for</span><span class="op">(;</span>n<span class="op">--></span><span class="dv">64</span><span class="op">;)</span>putchar<span class="op">(!</span>d<span class="op">+++</span><span class="dv">33</span><span class="op">^</span>l<span class="op">&</span><span class="dv">1</span><span class="op">);}</span></span></code></pre></div>
|
||||
<p>The code will test the 80-column wrap and document itself if it is
|
||||
joined together as one 160-character line and listed. You should
|
||||
see:</p>
|
||||
joined together as one 160-character line and listed. You should see:</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>main<span class="op">(</span>l<span class="op">,</span>a<span class="op">,</span>n<span class="op">,</span>d<span class="op">)...</span></span>
|
||||
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="op">[</span>A M E R I C A<span class="op">]...</span></span></code></pre></div>
|
||||
<p>…going down the left edge if your terminal auto-wraps at 80
|
||||
characters.</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0
|
||||
License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights
|
||||
Reserved. You are free to share and adapt this file under the terms of
|
||||
this license:</p>
|
||||
<p>…going down the left edge if your terminal auto-wraps at 80 characters.</p>
|
||||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0 License:</h2>
|
||||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
|
||||
You are free to share and adapt this file under the terms of this license:</p>
|
||||
<pre><code>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</code></pre>
|
||||
<p>For more information, see:
|
||||
https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
<p>For more information, see: https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||||
|
||||
<!-- 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-1992westley"><a name="inventory"></a>Inventory for
|
||||
1992/westley</h1>
|
||||
<h1 id="inventory-for-1992westley"><a name="inventory"></a>Inventory for 1992/westley</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/1992/westley/westley.c">westley.c</a>
|
||||
- entry source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/Makefile">Makefile</a>
|
||||
- entry Makefile</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/westley.alt.c">westley.alt.c</a>
|
||||
- alternative source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/westley.alt.orig.c">westley.alt.orig.c</a>
|
||||
- original source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/westley.orig.c">westley.orig.c</a>
|
||||
- original source</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/try.sh">try.sh</a>
|
||||
- how to run</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/whereami.alt.sh">whereami.alt.sh</a>
|
||||
- alternative whereami tool</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/whereami.c">whereami.c</a>
|
||||
- tool to find your location on the map</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/whereami.sh">whereami.sh</a>
|
||||
- whereami tool</li>
|
||||
<li><a href="1992_westley.tar.bz2">1992_westley.tar.bz2</a> - download
|
||||
entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/westley.c">westley.c</a> - entry source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/westley.alt.c">westley.alt.c</a> - alternative source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/westley.alt.orig.c">westley.alt.orig.c</a> - original source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/westley.orig.c">westley.orig.c</a> - original source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/try.sh">try.sh</a> - how to run</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/whereami.alt.sh">whereami.alt.sh</a> - alternative whereami tool</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/whereami.c">whereami.c</a> - tool to find your location on the map</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/whereami.sh">whereami.sh</a> - whereami tool</li>
|
||||
<li><a href="1992_westley.tar.bz2">1992_westley.tar.bz2</a> - download entry source</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/1992/westley/.entry.json">.entry.json</a>
|
||||
- description of entry in JSON</li>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/.gitignore">.gitignore</a>
|
||||
- list of files that should not be committed under git</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/.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>
|
||||
<li><a
|
||||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/README.md">README.md</a>
|
||||
- markdown source for index.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/README.md">README.md</a> - markdown source for index.html</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||||
|
||||
Reference in new issue
Block a user