improved indentation and whitespace for markdown code blocks

All code blocks in markdown have been intended by at least 4 spaces.

We add `--tab-stop=8` to all `pandoc(1)` executions in order to set
a better tab stop indentation, especially for tab intended code blocks.

Changed `bin/pandoc-wrapper.sh` VERSION from "1.5.3 2024-03-26"
to "1.6 2024-03-31".

Fixed `1991/brnstnd/sorta.README.md` so that the sorta code
is code blocks.

Removed unneeded paragraph group in copyright in `inc/footer.default.html`.

Fixed excess whitespace after list Author on entry `index.html` page.

Changed `bin/output-index-author.sh` VERSION from "1.5.2 2024-03-26"
to "1.6 2024-03-31".

Performed `make www` to perform the above and test under macOS.

TODO: Fix the problem of the initial line of code being extra intended.
TODO: Fix excess whitespace around code that is inline.
This commit is contained in:
Landon Curt Noll committed 2024-04-01 04:48:48 -07:00
1 parent b84c27ce02
commit a996f8d2b8
734 files changed
+16723 -16963

No files matched your search

+2 -2
View File
@@ -69,8 +69,8 @@ Also include anything else that you would like to see in future contests.
Send such email to:
```
...!{sun,pacbell,uunet,pyramid}!hoptoad!judges
judges@toad.com
...!{sun,pacbell,uunet,pyramid}!hoptoad!judges
judges@toad.com
```
If you use, distribute or publish these entries in some way, please drop
+44 -44
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
@@ -10,8 +10,8 @@ make all
The current status of this entry is:
```
STATUS: known bug - please help us fix
STATUS: INABIAF - please **DO NOT** fix
STATUS: known bug - please help us fix
STATUS: INABIAF - please **DO NOT** fix
```
For more detailed information see [1992 adrian bugs](../../bugs.html#1992_adrian).
@@ -20,13 +20,13 @@ For more detailed information see [1992 adrian bugs](../../bugs.html#1992_adrian
## Try:
```sh
./try.sh
./try.sh
```
For the slow minded, try:
```sh
./adsleep 32767
./adsleep 32767
```
@@ -59,7 +59,7 @@ The deterministic finite automaton is specified as a series of rules for
each state:
```
<state> chars1 <dest1> chars2 <dest2> ...
<state> chars1 <dest1> chars2 <dest2> ...
```
`chars1` is a list of characters (_only the first 8_ are significant) which
@@ -72,10 +72,10 @@ significant to only eight characters like `chars1`.
### Example 1: matches `^abc$`
```
<q0> a <q1> The first state to appear is the start state
<q1> b <q2>
<q2> c [q3]
[q3]
<q0> a <q1> The first state to appear is the start state
<q1> b <q2>
<q2> c [q3]
[q3]
```
Technically, a deterministic finite automaton should have a rule for each
@@ -88,54 +88,54 @@ character list.
### Example 2: `^abc`
```
<q0> a <q1>
<q1> b <q2>
<q2> c [q3]
[q3] . [q3]
<q0> a <q1>
<q1> b <q2>
<q2> c [q3]
[q3] . [q3]
```
### Example 3: `abc$`
```
<q0> a <q1> . <q0>
<q1> b <q2> a <q1> . <q0>
<q2> c [q3] a <q1> . <q0>
[q3] . <q1>
<q0> a <q1> . <q0>
<q1> b <q2> a <q1> . <q0>
<q2> c [q3] a <q1> . <q0>
[q3] . <q1>
```
### Example 4: `^(abc)*$`
```
[q0] a <q1>
<q1> b <q2>
<q2> c [q0]
[q0] a <q1>
<q1> b <q2>
<q2> c [q0]
```
### Example 5: `^[ab][cd][ef]$`
```
<q0> ab <q1>
<q1> cd <q2>
<q2> ef [q3]
[q3]
<q0> ab <q1>
<q1> cd <q2>
<q2> ef [q3]
[q3]
```
### Example 6: `^(abc|efg)$`
```
<q0> a <q1> e <q3>
<q1> b <q2>
<q2> c [q5]
<q3> f <q4>
<q4> g [q5]
[q5]
<q0> a <q1> e <q3>
<q1> b <q2>
<q2> c [q5]
<q3> f <q4>
<q4> g [q5]
[q5]
```
With the automaton specification in `filename`, invoke the program by
typing
```sh
./adrian filename
./adrian filename
```
@@ -152,7 +152,7 @@ occurs if your automaton has more than 257 states.
Running:
```sh
./adrian from < your_mailbox
./adrian from < your_mailbox
```
will perform a function similar to that of the unix `from` command.
@@ -164,13 +164,13 @@ changed to `__FILE__`.) In this case, the program will search for matches to
the regular expression:
```
^.[^|C][^w[Q]*(Q|[w[]c).*|^.[C|]$
^.[^|C][^w[Q]*(Q|[w[]c).*|^.[C|]$
```
I suggest using `adrian.c` as input, and storing the output in `adwc.c`:
```sh
./adrian < adrian.c > adwc.c
./adrian < adrian.c > adwc.c
```
Compiling the new file, `adwc.c`, yields a clone of the unix `wc` command. It
@@ -182,19 +182,19 @@ Another possibly interesting automaton can be created by slightly
adjusting the `adrian.c` file. Change the first line to read
```c
/* . echo| . */
/* . echo| . */
```
and repeat the process above
```sh
./adrian <adrian.c > adecho.c
./adrian <adrian.c > adecho.c
```
The new file now contains all lines which match
```
^.[^5|m^]*[m^]([e=p,;]|[^e=+p,;].*)$
^.[^5|m^]*[m^]([e=p,;]|[^e=+p,;].*)$
```
Compile and run. This is an `echo(1)` clone. Note the efficient algorithm
@@ -205,13 +205,13 @@ Two other adjustments to the first line also yield useful results. By
changing it to
```c
/* . head; . */
/* . head; . */
```
you can search for matches to
```
^.[^W]*W..*$
^.[^W]*W..*$
```
By some freak happenstance, lines of `adrian.c` which match this regular
@@ -222,14 +222,14 @@ specified (again this was changed to `__FILE__`).
By setting the first line to
```c
/* . basename . */
/* . basename . */
```
a clone of the unix `basename(1)` command can be unearthed. The automaton will
search for
```
^.[^j]*jr.*$
^.[^j]*jr.*$
```
on standard input. And the program which results by running `adrian.c`
@@ -241,13 +241,13 @@ The resulting base name is printed to stdout.
Lastly, by setting the first line to
```c
/* . sleep . */
/* . sleep . */
```
you can search for
```
^.[^(~][^s]*sl.*$
^.[^(~][^s]*sl.*$
```
Filtering `adrian.c` through this search yields a clone of the `sleep(1)`
+45 -46
View File
@@ -132,8 +132,7 @@
<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>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,16 +141,16 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> all</span></code></pre></div>
<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>
<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
STATUS: INABIAF - please **DO NOT** fix</code></pre>
<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>
<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>
<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>
<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">./adsleep</span> 32767</span></code></pre></div>
<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">./adsleep</span> 32767</span></code></pre></div>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>Once you get past the obfuscation, you have an opportunity to learn
about regular expressions and state machines.</p>
@@ -171,51 +170,51 @@ 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>&lt;state&gt; chars1 &lt;dest1&gt; chars2 &lt;dest2&gt; ...</code></pre>
<pre><code> &lt;state&gt; chars1 &lt;dest1&gt; chars2 &lt;dest2&gt; ...</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>&lt;dest1&gt;</code>. <code>&lt;dest1&gt;</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>&lt;q0&gt; a &lt;q1&gt; The first state to appear is the start state
&lt;q1&gt; b &lt;q2&gt;
&lt;q2&gt; c [q3]
[q3]</code></pre>
<pre><code> &lt;q0&gt; a &lt;q1&gt; The first state to appear is the start state
&lt;q1&gt; b &lt;q2&gt;
&lt;q2&gt; 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>
<h3 id="example-2-abc">Example 2: <code>^abc</code></h3>
<pre><code>&lt;q0&gt; a &lt;q1&gt;
&lt;q1&gt; b &lt;q2&gt;
&lt;q2&gt; c [q3]
[q3] . [q3]</code></pre>
<pre><code> &lt;q0&gt; a &lt;q1&gt;
&lt;q1&gt; b &lt;q2&gt;
&lt;q2&gt; c [q3]
[q3] . [q3]</code></pre>
<h3 id="example-3-abc">Example 3: <code>abc$</code></h3>
<pre><code>&lt;q0&gt; a &lt;q1&gt; . &lt;q0&gt;
&lt;q1&gt; b &lt;q2&gt; a &lt;q1&gt; . &lt;q0&gt;
&lt;q2&gt; c [q3] a &lt;q1&gt; . &lt;q0&gt;
[q3] . &lt;q1&gt;</code></pre>
<pre><code> &lt;q0&gt; a &lt;q1&gt; . &lt;q0&gt;
&lt;q1&gt; b &lt;q2&gt; a &lt;q1&gt; . &lt;q0&gt;
&lt;q2&gt; c [q3] a &lt;q1&gt; . &lt;q0&gt;
[q3] . &lt;q1&gt;</code></pre>
<h3 id="example-4-abc">Example 4: <code>^(abc)*$</code></h3>
<pre><code>[q0] a &lt;q1&gt;
&lt;q1&gt; b &lt;q2&gt;
&lt;q2&gt; c [q0]</code></pre>
<pre><code> [q0] a &lt;q1&gt;
&lt;q1&gt; b &lt;q2&gt;
&lt;q2&gt; c [q0]</code></pre>
<h3 id="example-5-abcdef">Example 5: <code>^[ab][cd][ef]$</code></h3>
<pre><code>&lt;q0&gt; ab &lt;q1&gt;
&lt;q1&gt; cd &lt;q2&gt;
&lt;q2&gt; ef [q3]
[q3]</code></pre>
<pre><code> &lt;q0&gt; ab &lt;q1&gt;
&lt;q1&gt; cd &lt;q2&gt;
&lt;q2&gt; ef [q3]
[q3]</code></pre>
<h3 id="example-6-abcefg">Example 6: <code>^(abc|efg)$</code></h3>
<pre><code>&lt;q0&gt; a &lt;q1&gt; e &lt;q3&gt;
&lt;q1&gt; b &lt;q2&gt;
&lt;q2&gt; c [q5]
&lt;q3&gt; f &lt;q4&gt;
&lt;q4&gt; g [q5]
[q5]</code></pre>
<pre><code> &lt;q0&gt; a &lt;q1&gt; e &lt;q3&gt;
&lt;q1&gt; b &lt;q2&gt;
&lt;q2&gt; c [q5]
&lt;q3&gt; f &lt;q4&gt;
&lt;q4&gt; 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>
<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
@@ -226,52 +225,52 @@ being processed is printed. Error <code>no_destination</code> occurs if you spec
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">&lt;</span> your_mailbox</span></code></pre></div>
<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">&lt;</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>
<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">&lt;</span> adrian.c <span class="op">&gt;</span> adwc.c</span></code></pre></div>
<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">&lt;</span> adrian.c <span class="op">&gt;</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>
<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>
<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">&lt;</span>adrian.c <span class="op">&gt;</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">&lt;</span>adrian.c <span class="op">&gt;</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>
<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>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>
<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>
<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 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>
<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>
<pre><code>^.[^j]*jr.*$</code></pre>
<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>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>
<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>
<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>
+19 -19
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
@@ -13,7 +13,7 @@ An [alternate version](#alternate-code) exists that fixes a bug.
The current status of this entry is:
```
STATUS: known bug - please help us fix
STATUS: known bug - please help us fix
```
For more detailed information see [1992 albert bugs](../../bugs.html#1992_albert).
@@ -22,14 +22,14 @@ For more detailed information see [1992 albert bugs](../../bugs.html#1992_albert
## To use:
```sh
./albert number
./albert number
```
## Try:
```sh
./try.sh
./try.sh
```
@@ -40,20 +40,20 @@ Leo Broukhis, before he was an IOCCC judge, sent the IOCCC
judges this Email message:
```
From: leo _at_ zycad -dot- com (Leo Broukhis)
Date: Tue, 30 Jan 96 17:37:51 PST
To: judges _at_ toad -dot- com
Subject: IOCCC 1992 - a bug
From: leo _at_ zycad -dot- com (Leo Broukhis)
Date: Tue, 30 Jan 96 17:37:51 PST
To: judges _at_ toad -dot- com
Subject: IOCCC 1992 - a bug
Dear Judges,
Dear Judges,
albert.c (even in its fixed form) still has a bug. Although I don't
remember the number that exposed the bug (afair, resulting in coredump)
in albert.orig.c that has been fixed in albert.c,
albert.c (even in its fixed form) still has a bug. Although I don't
remember the number that exposed the bug (afair, resulting in coredump)
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.
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.
```
The [albert.alt.c](albert.c) file is the fixed file, whereas the
@@ -65,7 +65,7 @@ The [albert.alt.c](albert.c) file is the fixed file, whereas the
To compile this alternate version:
```sh
make alt
make alt
```
@@ -77,7 +77,7 @@ Use `albert.alt` as you would `albert` above.
### Alternate try:
```sh
./try.alt.sh
./try.alt.sh
```
@@ -107,7 +107,7 @@ Or you may type `./albert <some-number>`
A nice one is also (30 ones):
```sh
./albert 111111111111111111111111111111
./albert 111111111111111111111111111111
```
Apart from the foregoing there are no special execution instructions.
@@ -115,7 +115,7 @@ Apart from the foregoing there are no special execution instructions.
To customize the program into a factorizer of a fixed number, use
```sh
cc albert.c -o 4294967297
cc albert.c -o 4294967297
```
or some such.
+20 -21
View File
@@ -132,8 +132,7 @@
<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>
Location: <a href="../../location.html#NL">NL</a> - <em>Kingdom of the Netherlands</em> (<em>Netherlands</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,43 +141,43 @@ Location: <a href="../../location.html#NL">NL</a> - <em>Kingdom of the Netherlan
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> all</span></code></pre></div>
<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>
<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>
<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>
<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>
<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>
<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>
<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
Subject: IOCCC 1992 - a bug
<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
Subject: IOCCC 1992 - a bug
Dear Judges,
Dear Judges,
albert.c (even in its fixed form) still has a bug. Although I don&#39;t
remember the number that exposed the bug (afair, resulting in coredump)
in albert.orig.c that has been fixed in albert.c,
albert.c (even in its fixed form) still has a bug. Although I don&#39;t
remember the number that exposed the bug (afair, resulting in coredump)
in albert.orig.c that has been fixed in albert.c,
I&#39;ve found a number exposing another bug: 10000000001 (that&#39;s 9 0&#39;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>
I&#39;ve found a number exposing another bug: 10000000001 (that&#39;s 9 0&#39;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>
<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>
<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>
<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>
<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
@@ -195,10 +194,10 @@ multiplication, until the candidate factor no longer fits in a signed long.</p>
if you want to factor Fermat’s 4th number. Then just run it.</p>
<p>Or you may type <code>./albert &lt;some-number&gt;</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>
<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>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>
<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>
+4 -4
View File
@@ -1,16 +1,16 @@
## To build:
```sh
make all
make all
```
## To use:
```sh
./ant Makefile
./ant Makefile
./ant Makefile rule
./ant Makefile rule
```
where `Makefile` is a Makefile to use and `rule` is an optional rule to use.
@@ -19,7 +19,7 @@ where `Makefile` is a Makefile to use and `rule` is an optional rule to use.
## Try:
```sh
./try.sh
./try.sh
```
+5 -6
View File
@@ -132,8 +132,7 @@
<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>
Location: <a href="../../location.html#CA">CA</a> - <em>Canada</em></li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,14 +141,14 @@ Location: <a href="../../location.html#CA">CA</a> - <em>Canada</em>
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> all</span></code></pre></div>
<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>
<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">./ant</span> Makefile</span>
<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>
<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>
<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>
<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>
+39 -41
View File
@@ -1,22 +1,21 @@
## To build:
```sh
make all
make all
```
## To use:
```sh
./buzzard.1 num num
./buzzard.1 num num
```
## Try:
```sh
./try.sh
./try.sh
```
@@ -25,8 +24,8 @@ make all
To see good C Preprocessor buzzard.1, try:
```sh
make babble.cppcb
cat babble.cppcb
make babble.cppcb
cat babble.cppcb
```
Notice how many statements it takes to do anything useful?
@@ -56,19 +55,19 @@ short strings.
arguments.
```sh
./buzzard.1 0 <num>
./buzzard.1 0 <num>
```
will print out the factorial of `<num>`.
```sh
./buzzard.1 <num1> <num2>
./buzzard.1 <num1> <num2>
```
will print out the largest common factor of `num1` and `num2`.
```sh
./buzzard.1 1 <num2>
./buzzard.1 1 <num2>
```
will print out a factor of `num2` if it's composite, or else
@@ -127,37 +126,36 @@ place to site some references on the AE, but I don't have any.
[Don't read this unless you're stumped!]
```
MACRO FUNCTION MNEMONIC
MACRO FUNCTION MNEMONIC
V begin variable declarations Variable
C begin program Code
V begin variable declarations Variable
C begin program Code
Q(b,a) let b = a eQuals
A(c,a,b) let c = a + b Add
S(c,a,b) let c = a - b Subtract
D(c,a,b) let c = a / b, where b is a *constant* Divide
U(c,a,b) let c = a / b, where b is anything Unknown
M(c,a,b) let c = a * b Multiply
Q(b,a) let b = a eQuals
A(c,a,b) let c = a + b Add
S(c,a,b) let c = a - b Subtract
D(c,a,b) let c = a / b, where b is a *constant* Divide
U(c,a,b) let c = a / b, where b is anything Unknown
M(c,a,b) let c = a * b Multiply
O(c,a,b) let c = a boolean-or b (a,b are 0 or 1) Or
B(b, a) let b = boolean value of a Boolean
P(b, a) let b = 1 if a>0, else 0. Positive
O(c,a,b) let c = a boolean-or b (a,b are 0 or 1) Or
B(b, a) let b = boolean value of a Boolean
P(b, a) let b = 1 if a>0, else 0. Positive
l emit next sequential label Label
J(x) goto label #x Jump
l emit next sequential label Label
J(x) goto label #x Jump
Z(a,d) if a is 0 goto d (a is 0 or 1) Zero
E(a,d) if a is 1 goto d (a is 0 or 1) Else
Z(a,d) if a is 0 goto d (a is 0 or 1) Zero
E(a,d) if a is 1 goto d (a is 0 or 1) Else
H halt Haly
H halt Haly
K(x) let x = number of cmd line arguments Kount
G(x,y) let x = the value if the yth argument Get argument
K(x) let x = number of cmd line arguments Kount
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
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
```
You can figure out the other macros yourself. In the sample program, I've
@@ -174,26 +172,26 @@ Since all you can do in the given operation output set is
assignment, we implement "conditional assignment":
```c
if (x) y = z;
if (x) y = z;
```
To implement this, we constrain `x` to be either 0 or 1, and
simply compute:
```c
y = (z * x) + (y * (1-x));
y = (z * x) + (y * (1-x));
```
This is more obscured by factoring out common terms and restricting
ourselves to two operand operations:
```c
temp = z; (temp == z)
temp -= y; (temp == z-y)
temp *= x; (temp == (z-y)*x)
y += temp; (y == (z-y)*x + y)
( == z*x - y*x + y)
( == z*x + y*(1-x))
temp = z; (temp == z)
temp -= y; (temp == z-y)
temp *= x; (temp == (z-y)*x)
y += temp; (y == (z-y)*x + y)
( == z*x - y*x + y)
( == z*x + y*(1-x))
```
Next we imagine we have a [pc](https://en.wikipedia.org/wiki/Program_counter).
@@ -202,7 +200,7 @@ 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:
```c
if (pc == some_constant) y = z;
if (pc == some_constant) y = z;
```
To combine this with other operations, we simply multiply by our
+40 -42
View File
@@ -132,8 +132,7 @@
<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></li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,15 +141,15 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> all</span></code></pre></div>
<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>
<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">./buzzard.1</span> num num</span></code></pre></div>
<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">./buzzard.1</span> num num</span></code></pre></div>
<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>
<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>To see good C Preprocessor buzzard.1, 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> babble.cppcb</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> babble.cppcb</span></code></pre></div>
<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> babble.cppcb</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> babble.cppcb</span></code></pre></div>
<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>
@@ -163,11 +162,11 @@ 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>
<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">&lt;</span>num<span class="op">&gt;</span></span></code></pre></div>
<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">&lt;</span>num<span class="op">&gt;</span></span></code></pre></div>
<p>will print out the factorial of <code>&lt;num&gt;</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">&lt;</span>num1<span class="op">&gt;</span> <span class="op">&lt;</span>num2<span class="op">&gt;</span></span></code></pre></div>
<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">&lt;</span>num1<span class="op">&gt;</span> <span class="op">&lt;</span>num2<span class="op">&gt;</span></span></code></pre></div>
<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">&lt;</span>num2<span class="op">&gt;</span></span></code></pre></div>
<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">&lt;</span>num2<span class="op">&gt;</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
@@ -206,37 +205,36 @@ 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
<pre><code> MACRO FUNCTION MNEMONIC
V begin variable declarations Variable
C begin program Code
V begin variable declarations Variable
C begin program Code
Q(b,a) let b = a eQuals
A(c,a,b) let c = a + b Add
S(c,a,b) let c = a - b Subtract
D(c,a,b) let c = a / b, where b is a *constant* Divide
U(c,a,b) let c = a / b, where b is anything Unknown
M(c,a,b) let c = a * b Multiply
Q(b,a) let b = a eQuals
A(c,a,b) let c = a + b Add
S(c,a,b) let c = a - b Subtract
D(c,a,b) let c = a / b, where b is a *constant* Divide
U(c,a,b) let c = a / b, where b is anything Unknown
M(c,a,b) let c = a * b Multiply
O(c,a,b) let c = a boolean-or b (a,b are 0 or 1) Or
B(b, a) let b = boolean value of a Boolean
P(b, a) let b = 1 if a&gt;0, else 0. Positive
O(c,a,b) let c = a boolean-or b (a,b are 0 or 1) Or
B(b, a) let b = boolean value of a Boolean
P(b, a) let b = 1 if a&gt;0, else 0. Positive
l emit next sequential label Label
J(x) goto label #x Jump
l emit next sequential label Label
J(x) goto label #x Jump
Z(a,d) if a is 0 goto d (a is 0 or 1) Zero
E(a,d) if a is 1 goto d (a is 0 or 1) Else
Z(a,d) if a is 0 goto d (a is 0 or 1) Zero
E(a,d) if a is 1 goto d (a is 0 or 1) Else
H halt Haly
H halt Haly
K(x) let x = number of cmd line arguments Kount
G(x,y) let x = the value if the yth argument Get argument
K(x) let x = number of cmd line arguments Kount
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>
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
@@ -246,23 +244,23 @@ BCD, so it can be output by the hexadecimal output statement.</p>
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>
<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>
<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>
<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>
<div class="sourceCode" id="cb11"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a>temp <span class="op">=</span> z<span class="op">;</span> <span class="op">(</span>temp <span class="op">==</span> z<span class="op">)</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a>temp <span class="op">-=</span> y<span class="op">;</span> <span class="op">(</span>temp <span class="op">==</span> z<span class="op">-</span>y<span class="op">)</span></span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a>temp <span class="op">*=</span> x<span class="op">;</span> <span class="op">(</span>temp <span class="op">==</span> <span class="op">(</span>z<span class="op">-</span>y<span class="op">)*</span>x<span class="op">)</span></span>
<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>
<div class="sourceCode" id="cb11"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> temp <span class="op">=</span> z<span class="op">;</span> <span class="op">(</span>temp <span class="op">==</span> z<span class="op">)</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> temp <span class="op">-=</span> y<span class="op">;</span> <span class="op">(</span>temp <span class="op">==</span> z<span class="op">-</span>y<span class="op">)</span></span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> temp <span class="op">*=</span> x<span class="op">;</span> <span class="op">(</span>temp <span class="op">==</span> <span class="op">(</span>z<span class="op">-</span>y<span class="op">)*</span>x<span class="op">)</span></span>
<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>
<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>
<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
+19 -19
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
There is an alternate version of this program. See [Alternate
@@ -14,29 +14,29 @@ First, you must make sure that `first` is made first (even though `make all`
should make first first :-) ):
```sh
make first
make first
```
Second:
```sh
# get help:
echo help | cat third help.th - | ./first
# get help:
echo help | cat third help.th - | ./first
# try out a demo:
cat third demo5.th | ./first
# try out a demo:
cat third demo5.th | ./first
```
Third:
```sh
cat third help.th - | ./first
cat third help.th - | ./first
```
NOTE: Wait until 'Ok' is printed and the type:
```
2 3 + . cr
2 3 + . cr
```
Yes you should really type the 2 letters: `cr`.
@@ -44,14 +44,14 @@ Yes you should really type the 2 letters: `cr`.
Fourth:
```
Sorry, this is third!
Sorry, this is third!
```
## Try:
```sh
./try.sh
./try.sh
```
@@ -64,7 +64,7 @@ fix that the author notes in their remarks.
### Alternate build:
```sh
make alt
make alt
```
@@ -76,7 +76,7 @@ Use `buzzard.2.alt` as you would `buzzard.2` above.
### Alternate try:
```sh
./try.alt.sh
./try.alt.sh
```
@@ -126,7 +126,7 @@ To do something interesting, you need to feed `first` the file
[third](third) first. In unix, you can do
```sh
cat third help.th - | ./first
cat third help.th - | ./first
```
to do this. Hopefully most operating systems will provide a way to do this. It
@@ -227,7 +227,7 @@ you in a normal way. It only prints `'Ok.'` after you define a word).
```sh
2 3 + . cr
2 3 + . cr
```
(which adds 2 and 3, and print the result and a newline.)
@@ -235,20 +235,20 @@ you in a normal way. It only prints `'Ok.'` after you define a word).
THIRD responds:
```
5
5
```
Now try:
```
: test 11 1 do i . loop cr ;
test
: test 11 1 do i . loop cr ;
test
```
and THIRD responds
```
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
```
@@ -256,7 +256,7 @@ When in `THIRD`, you can see how much space you're currently
using by typing:
```
here .
here .
```
The number THIRD replies with is the number of machine words (`int`s) that the
+374 -378
View File
@@ -188,64 +188,64 @@ when they are used. Normal instructions compile a pointer to their
executable part onto the end of the dictionary. As we will see, this
means that by default FIRST simply compiles things.</p>
<h4 id="integer-operations">Integer Operations</h4>
<pre><code>SYMBOL NAME FUNCTION
<pre><code> SYMBOL NAME FUNCTION
- binary minus pop top 2 elements of stack, subtract, push
- binary minus pop top 2 elements of stack, subtract, push
* multiply pop top 2 elements of stack, multiply, push
* multiply pop top 2 elements of stack, multiply, push
/ divide pop top 2 elements of stack, divide, push
/ divide pop top 2 elements of stack, divide, push
&lt;0 less than 0 pop top element of stack, push 1 if &lt; 0 else 0</code></pre>
&lt;0 less than 0 pop top element of stack, push 1 if &lt; 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>&lt;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
<pre><code> SYMBOL NAME FUNCTION
@ fetch pop top of stack, treat as address to push contents of
@ fetch pop top of stack, treat as address to push contents of
! store top of stack is address, 2nd is value; store to memory
and pop both off the stack</code></pre>
! store top of stack is address, 2nd is value; store to memory
and pop both off the stack</code></pre>
<h4 id="inputoutput-operations">Input/Output Operations</h4>
<pre><code>NAME FUNCTION
<pre><code> NAME FUNCTION
echo output top of stack through C&#39;s putchar()
echo output top of stack through C&#39;s putchar()
key push C&#39;s getchar() onto top of stack
key push C&#39;s getchar() onto top of stack
_read read a space-delimited word, find it in the
dictionary, and compile a pointer to
that word&#39;s code pointer onto the
current end of the dictionary</code></pre>
_read read a space-delimited word, find it in the
dictionary, and compile a pointer to
that word&#39;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>
<h4 id="execution-operations">Execution Operations</h4>
<pre><code>NAME FUNCTION
<pre><code> NAME FUNCTION
exit leave the current function: pop the return stack
into the program counter</code></pre>
exit leave the current function: pop the return stack
into the program counter</code></pre>
<h4 id="immediate-compilation-operations">Immediate (compilation) Operations</h4>
<pre><code>SYMBOL NAME FUNCTION
<pre><code> SYMBOL NAME FUNCTION
: define read in the next space-delimited word, add it to
the end of our string storage, and generate
a header for the new word so that when it
is typed it compiles a pointer to itself
so that it can be executed.
: define read in the next space-delimited word, add it to
the end of our string storage, and generate
a header for the new word so that when it
is typed it compiles a pointer to itself
so that it can be executed.
immediate immediate when used immediately after a name following a &#39;:&#39;,
it makes the word being defined run whenever
it is typed.</code></pre>
immediate immediate when used immediately after a name following a &#39;:&#39;,
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>
<h4 id="stack-operations">Stack Operations</h4>
<pre><code>NAME FUNCTION
<pre><code> NAME FUNCTION
pick pop top of stack, use as index into stack and copy up
that element</code></pre>
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>
@@ -264,16 +264,16 @@ word internally that it executes as its main loop. This word calls
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
<pre><code> WORD DESCRIPTION
- * / binary integer operations on the stack
&lt;0 is top of stack less than 0?
@ ! read from or write to memory
echo key output or input one character
_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>
- * / binary integer operations on the stack
&lt;0 is top of stack less than 0?
@ ! read from or write to memory
echo key output or input one character
_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
@@ -286,33 +286,33 @@ differently if you wanted.</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 @ ! - * / &lt;0 exit echo key _pick
<pre><code> ( Our first line gives the symbols for the built-ins )
: immediate _read @ ! - * / &lt;0 exit echo key _pick
( now we define a simple word that will print out a couple characters )
( now we define a simple word that will print out a couple characters )
: L ( define a word named &#39;L&#39; )
108 echo ( output an ascii &#39;l&#39; )
exit
: L ( define a word named &#39;L&#39; )
108 echo ( output an ascii &#39;l&#39; )
exit
: hello ( define a word named &#39;hello&#39;)
72 echo ( output an ascii &#39;H&#39; )
101 echo ( output an ascii &#39;e&#39; )
111 ( push ascii &#39;o&#39; onto the stack )
L L ( output two ascii &#39;l&#39;s )
echo ( output the &#39;o&#39; we pushed on the stack before )
10 echo ( print a newline )
exit ( stop running this routine )
: hello ( define a word named &#39;hello&#39;)
72 echo ( output an ascii &#39;H&#39; )
101 echo ( output an ascii &#39;e&#39; )
111 ( push ascii &#39;o&#39; onto the stack )
L L ( output two ascii &#39;l&#39;s )
echo ( output the &#39;o&#39; we pushed on the stack before )
10 echo ( print a newline )
exit ( stop running this routine )
: test immediate ( define a word named &#39;test&#39; that runs whenever typed )
hello ( call hello )
exit
: test immediate ( define a word named &#39;test&#39; that runs whenever typed )
hello ( call hello )
exit
test
test
( The result of running this program should be:
Hello
)</code></pre>
( The result of running this program should be:
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
@@ -350,47 +350,46 @@ be <code>0</code>–it’s a fake dictionary entry that means <code>pushint</cod
<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>
<pre><code>: immediate _read @ ! - * / &lt; exit echo key _pick</code></pre>
<pre><code> : immediate _read @ ! - * / &lt; 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>
<pre><code>: r 1 exit</code></pre>
<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>
<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>
<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>Now let’s get compile running.</p>
<pre><code>: main immediate ]
main</code></pre>
<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>
<pre><code>: &#39;&quot;&#39; 34 exit
: &#39;)&#39; 41 exit
: &#39;\n&#39; 10 exit
: &#39;space&#39; 32 exit
: &#39;0&#39; 48 exit
: &#39;-&#39; 45 exit
<pre><code> : &#39;&quot;&#39; 34 exit
: &#39;)&#39; 41 exit
: &#39;\n&#39; 10 exit
: &#39;space&#39; 32 exit
: &#39;0&#39; 48 exit
: &#39;-&#39; 45 exit
: cr &#39;\n&#39; echo exit</code></pre>
: cr &#39;\n&#39; 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>
<pre><code>: _x 3 @ exit
: _x! 3 ! exit
: _y 4 @ exit
: _y! 4 ! exit
</code></pre>
<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
@@ -399,41 +398,39 @@ command-mode handler. We don’t have one, so all we want
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>
<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>
<pre><code>: +
0 swap -
-
exit
</code></pre>
<pre><code> : +
0 swap -
-
exit</code></pre>
<p>Create a copy of the top of stack.</p>
<pre><code>: dup _x! _x _x exit</code></pre>
<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>
<pre><code>: h 0 exit</code></pre>
<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>
<pre><code>: inc
dup @ Get another copy of the address, and get the value
so now we have value, address on top of stack.
1 + Add one to the value
swap Swap to put the address on top of the stack
! exit Write it to memory
</code></pre>
<pre><code> : inc
dup @ Get another copy of the address, and get the value
so now we have value, address on top of stack.
1 + Add one to the value
swap Swap to put the address on top of the stack
! exit Write it to memory</code></pre>
<p><code>,</code> is a standard FORTH word. It should write the top of
stack into the dictionary, and advance the pointer</p>
<pre><code>: ,
h @ Get the value of the dictionary pointer
! Write the top of stack there
h inc And increment the dictionary pointer
exit</code></pre>
<pre><code> : ,
h @ Get the value of the dictionary pointer
! Write the top of stack there
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
@@ -442,30 +439,29 @@ 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>: &#39;
r @ Get the address of the top of return stack
We currently have a pointer to the top of return stack
@ Get the value from there
We currently have a pointer to the instruction stream
dup Get another copy of it--the bottom copy will stick
around until the end of this word
1 + Increment the pointer, pointing to the NEXT instruction
r @ ! Write it back onto the top of the return stack
We currently have our first copy of the old pointer
to the instruction stream
@ Get the value there--the address of the &quot;next word&quot;
exit
</code></pre>
<pre><code> : &#39;
r @ Get the address of the top of return stack
We currently have a pointer to the top of return stack
@ Get the value from there
We currently have a pointer to the instruction stream
dup Get another copy of it--the bottom copy will stick
around until the end of this word
1 + Increment the pointer, pointing to the NEXT instruction
r @ ! Write it back onto the top of the return stack
We currently have our first copy of the old pointer
to the instruction stream
@ Get the value there--the address of the &quot;next word&quot;
exit</code></pre>
<p>Now we’re set. <code>;</code> should be an immediate word that pushes
the address of <code>exit</code> onto the stack, then writes it out.</p>
<pre><code>: ; immediate
&#39; exit Get the address of exit
, Compile it
exit And we should return</code></pre>
<pre><code> : ; immediate
&#39; exit Get the address of exit
, Compile it
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>
<pre><code> : drop 0 * + ;</code></pre>
<p>Since we have <code>inc</code>, we ought to make <code>dec</code>:</p>
<pre><code>: dec dup @ 1 - swap ! ;</code></pre>
<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
@@ -478,22 +474,22 @@ 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
swap Bring the value to be pushed to the top of stack
r @ ! Write it over the current top of return stack
r @ 1 + r ! Increment the return stack pointer--but can&#39;t use inc
r @ ! Store our return address back on the return stack
;</code></pre>
<pre><code> : tor
r @ @ Get the value off the top of the return stack
swap Bring the value to be pushed to the top of stack
r @ ! Write it over the current top of return stack
r @ 1 + r ! Increment the return stack pointer--but can&#39;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>
<pre><code>: fromr
r @ @ Save old value
r @ 1 - r ! Decrement pointer
r @ @ Get value that we want off
swap Bring return address to top
r @ ! Store it and return
;</code></pre>
<pre><code> : fromr
r @ @ Save old value
r @ 1 - r ! Decrement pointer
r @ @ Get value that we want off
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
@@ -503,324 +499,324 @@ 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>
<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>
<p><code>minus</code> gives us unary negation.</p>
<pre><code>: minus 0 swap - ;</code></pre>
<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>
<pre><code> : bnot 1 swap - ;</code></pre>
<p>To compare two numbers, subtract and compare to <code>0</code>.</p>
<pre><code>: &lt; - &lt;0 ;</code></pre>
<pre><code> : &lt; - &lt;0 ;</code></pre>
<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 &lt; 1 if &lt; 0, 0 otherwise
swap minus Swap number back up, and take negative
0 &lt; 1 if original was &gt; 0, 0 otherwise
+ Add them up--has to be 0 or 1!
;</code></pre>
<pre><code> : logical
dup Get two copies of it
0 &lt; 1 if &lt; 0, 0 otherwise
swap minus Swap number back up, and take negative
0 &lt; 1 if original was &gt; 0, 0 otherwise
+ Add them up--has to be 0 or 1!
;</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>
<pre><code> : not logical bnot ;</code></pre>
<p>We can test equality by subtracting and comparing to <code>0</code>.</p>
<pre><code>: = - not ;</code></pre>
<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>
<pre><code>: branch
r @ Address of top of return stack
@ Our return address
@ Value from there: the branch offset
r @ @ Our return address again
+ The address we want to execute at
r @ ! Store it back onto the return stack
;</code></pre>
<pre><code> : branch
r @ Address of top of return stack
@ Our return address
@ Value from there: the branch offset
r @ @ Our return address again
+ 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>
<pre><code>: computebranch 1 - * 1 + ;</code></pre>
<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
not
r @ @ @ Get the branch offset
computebranch Adjust as necessary
r @ @ + Calculate the new address
r @ ! Store it
;</code></pre>
<pre><code> : notbranch
not
r @ @ @ Get the branch offset
computebranch Adjust as necessary
r @ @ + Calculate the new address
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>
<pre><code>: here h @ ;</code></pre>
<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>
<pre><code>: if immediate
&#39; notbranch , Compile notbranch
here Save the current dictionary address
0 , Compile a dummy value
;</code></pre>
<pre><code> : if immediate
&#39; 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>
<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>
<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>
<pre><code>: find-)
key Read in a character
&#39;)&#39; = Compare it to close parentheses
not if If it&#39;s not equal
tail find-) repeat (popping R stack)
then Otherwise branch here and exit
;
<pre><code> : find-)
key Read in a character
&#39;)&#39; = Compare it to close parentheses
not if If it&#39;s not equal
tail find-) repeat (popping R stack)
then Otherwise branch here and exit
;
: ( immediate
find-)
;
: ( immediate
find-)
;
( we should be able to do FORTH-style comments now )
( we should be able to do FORTH-style comments now )
( now that we&#39;ve got comments, we can comment the rest of the code
in a legitimate [self parsing] fashion. Note that you can&#39;t
nest parentheses... )
( now that we&#39;ve got comments, we can comment the rest of the code
in a legitimate [self parsing] fashion. Note that you can&#39;t
nest parentheses... )
: else immediate
&#39; branch , ( compile a definite branch )
here ( push the backpatching address )
0 , ( compile a dummy offset for branch )
swap ( bring old backpatch address to top )
dup here swap - ( calculate the offset from old address )
swap ! ( put the address on top and store it )
;
: else immediate
&#39; branch , ( compile a definite branch )
here ( push the backpatching address )
0 , ( compile a dummy offset for branch )
swap ( bring old backpatch address to top )
dup here swap - ( calculate the offset from old address )
swap ! ( put the address on top and store it )
;
: over _x! _y! _y _x _y ;
: over _x! _y! _y _x _y ;
: add
_x! ( save the pointer in a temp variable )
_x @ ( get the value pointed to )
+ ( add the incremement from on top of the stack )
_x ! ( and save it )
;
: add
_x! ( save the pointer in a temp variable )
_x @ ( get the value pointed to )
+ ( add the incremement from on top of the stack )
_x ! ( and save it )
;
: allot h add ;
: allot h add ;
: maybebranch
logical ( force the TOS to be 0 or 1 )
r @ @ @ ( load the branch offset )
computebranch ( calculate the condition offset [either TOS or 1])
r @ @ + ( add it to the return address )
r @ ! ( store it to our return address and return )
;
: maybebranch
logical ( force the TOS to be 0 or 1 )
r @ @ @ ( load the branch offset )
computebranch ( calculate the condition offset [either TOS or 1])
r @ @ + ( add it to the return address )
r @ ! ( store it to our return address and return )
;
: mod _x! _y! ( get x then y off of stack )
_y _y _x / _x * ( y - y / x * x )
-
;
: mod _x! _y! ( get x then y off of stack )
_y _y _x / _x * ( y - y / x * x )
-
;
: printnum
dup
10 mod &#39;0&#39; +
swap 10 / dup
if
printnum
echo
else
drop
echo
then
;
: printnum
dup
10 mod &#39;0&#39; +
swap 10 / dup
if
printnum
echo
else
drop
echo
then
;
: .
dup 0 &lt;
if
&#39;-&#39; echo minus
then
printnum
&#39;space&#39; echo
;
: .
dup 0 &lt;
if
&#39;-&#39; echo minus
then
printnum
&#39;space&#39; echo
;
: debugprint dup . cr ;
: debugprint dup . cr ;
( the following routine takes a pointer to a string, and prints it,
except for the trailing quote. returns a pointer to the next word
after the trailing quote )
( the following routine takes a pointer to a string, and prints it,
except for the trailing quote. returns a pointer to the next word
after the trailing quote )
: _print
dup 1 +
swap @
dup &#39;&quot;&#39; =
if
drop exit
then
echo
tail _print
;
: _print
dup 1 +
swap @
dup &#39;&quot;&#39; =
if
drop exit
then
echo
tail _print
;
: print _print ;
: print _print ;
( print the next thing from the instruction stream )
: immprint
r @ @
print
r @ !
;
( print the next thing from the instruction stream )
: immprint
r @ @
print
r @ !
;
: find-&quot;
key dup ,
&#39;&quot;&#39; =
if
exit
then
tail find-&quot;
;
: find-&quot;
key dup ,
&#39;&quot;&#39; =
if
exit
then
tail find-&quot;
;
: &quot; immediate
key drop
&#39; immprint ,
find-&quot;
;
: &quot; immediate
key drop
&#39; immprint ,
find-&quot;
;
: do immediate
&#39; swap , ( compile &#39;swap&#39; to swap the limit and start )
&#39; tor , ( compile to push the limit onto the return stack )
&#39; tor , ( compile to push the start on the return stack )
here ( save this address so we can branch back to it )
;
: do immediate
&#39; swap , ( compile &#39;swap&#39; to swap the limit and start )
&#39; tor , ( compile to push the limit onto the return stack )
&#39; tor , ( compile to push the start on the return stack )
here ( save this address so we can branch back to it )
;
: i r @ 1 - @ ;
: j r @ 3 - @ ;
: i r @ 1 - @ ;
: j r @ 3 - @ ;
: &gt; swap &lt; ;
: &lt;= 1 + &lt; ;
: &gt;= swap &lt;= ;
: &gt; swap &lt; ;
: &lt;= 1 + &lt; ;
: &gt;= swap &lt;= ;
: inci
r @ 1 - ( get the pointer to i )
inc ( add one to it )
r @ 1 - @ ( find the value again )
r @ 2 - @ ( find the limit value )
&lt;=
if
r @ @ @ r @ @ + r @ ! exit ( branch )
then
fromr 1 +
fromr drop
fromr drop
tor
;
: inci
r @ 1 - ( get the pointer to i )
inc ( add one to it )
r @ 1 - @ ( find the value again )
r @ 2 - @ ( find the limit value )
&lt;=
if
r @ @ @ r @ @ + r @ ! exit ( branch )
then
fromr 1 +
fromr drop
fromr drop
tor
;
: loop immediate &#39; inci @ here - , ;
: loop immediate &#39; inci @ here - , ;
: loopexit
: loopexit
fromr drop ( pop off our return address )
fromr drop ( pop off i )
fromr drop ( pop off the limit of i )
; ( and return to the caller&#39;s caller routine )
fromr drop ( pop off our return address )
fromr drop ( pop off i )
fromr drop ( pop off the limit of i )
; ( and return to the caller&#39;s caller routine )
: execute
8 !
&#39; exit 9 !
8 tor
;
: execute
8 !
&#39; exit 9 !
8 tor
;
: :: ; ( :: is going to be a word that does &#39;:&#39; at runtime )
: :: ; ( :: is going to be a word that does &#39;:&#39; at runtime )
: fix-:: immediate 3 &#39; :: ! ;
fix-::
: fix-:: immediate 3 &#39; :: ! ;
fix-::
( Override old definition of &#39;:&#39; with a new one that invokes ] )
: : immediate :: ] ;
( Override old definition of &#39;:&#39; with a new one that invokes ] )
: : immediate :: ] ;
: command
here 5 ! ( store dict pointer in temp variable )
_read ( compile a word )
( if we get control back: )
here 5 @
= if
tail command ( we didn&#39;t compile anything )
then
here 1 - h ! ( decrement the dictionary pointer )
here 5 @ ( get the original value )
= if
here @ ( get the word that was compiled )
execute ( and run it )
else
here @ ( else it was an integer constant, so push it )
here 1 - h ! ( and decrement the dictionary pointer again )
then
tail command
;
: command
here 5 ! ( store dict pointer in temp variable )
_read ( compile a word )
( if we get control back: )
here 5 @
= if
tail command ( we didn&#39;t compile anything )
then
here 1 - h ! ( decrement the dictionary pointer )
here 5 @ ( get the original value )
= if
here @ ( get the word that was compiled )
execute ( and run it )
else
here @ ( else it was an integer constant, so push it )
here 1 - h ! ( and decrement the dictionary pointer again )
then
tail command
;
: make-immediate ( make a word just compiled immediate )
here 1 - ( back up a word in the dictionary )
dup dup ( save the pointer to here )
h ! ( store as the current dictionary pointer )
@ ( get the run-time code pointer )
swap ( get the dict pointer again )
1 - ( point to the compile-time code pointer )
! ( write run-time code pointer on compile-time pointer )
;
: make-immediate ( make a word just compiled immediate )
here 1 - ( back up a word in the dictionary )
dup dup ( save the pointer to here )
h ! ( store as the current dictionary pointer )
@ ( get the run-time code pointer )
swap ( get the dict pointer again )
1 - ( point to the compile-time code pointer )
! ( write run-time code pointer on compile-time pointer )
;
: &lt;build immediate
make-immediate ( make the word compiled so far immediate )
&#39; :: , ( compile &#39;::&#39;, so we read next word )
2 , ( compile &#39;pushint&#39; )
here 0 , ( write out a 0 but save address for does&gt; )
&#39; , , ( compile a push that address onto dictionary )
;
: &lt;build immediate
make-immediate ( make the word compiled so far immediate )
&#39; :: , ( compile &#39;::&#39;, so we read next word )
2 , ( compile &#39;pushint&#39; )
here 0 , ( write out a 0 but save address for does&gt; )
&#39; , , ( compile a push that address onto dictionary )
;
: does&gt; immediate
&#39; command , ( jump back into command mode at runtime )
here swap ! ( backpatch the build&gt; to point to here )
2 , ( compile run-code primitive so we look like a word )
&#39; fromr , ( compile fromr, which leaves var address on stack )
;
: does&gt; immediate
&#39; command , ( jump back into command mode at runtime )
here swap ! ( backpatch the build&gt; to point to here )
2 , ( compile run-code primitive so we look like a word )
&#39; fromr , ( compile fromr, which leaves var address on stack )
;
: _dump ( dump out the definition of a word, sort of )
dup &quot; (&quot; . &quot; , &quot;
dup @ ( save the pointer and get the contents )
dup &#39; exit
= if
&quot; ;)&quot; cr exit
then
. &quot; ), &quot;
1 +
tail _dump
;
: _dump ( dump out the definition of a word, sort of )
dup &quot; (&quot; . &quot; , &quot;
dup @ ( save the pointer and get the contents )
dup &#39; exit
= if
&quot; ;)&quot; cr exit
then
. &quot; ), &quot;
1 +
tail _dump
;
: dump _dump ;
: dump _dump ;
: # . cr ;
: # . cr ;
: var &lt;build , does&gt; ;
: constant &lt;build , does&gt; @ ;
: array &lt;build allot does&gt; + ;
: var &lt;build , does&gt; ;
: constant &lt;build , does&gt; @ ;
: array &lt;build allot does&gt; + ;
: [ immediate command ;
: _welcome &quot; Welcome to THIRD.
Ok.
&quot; ;
: [ immediate command ;
: _welcome &quot; Welcome to THIRD.
Ok.
&quot; ;
: ; immediate &#39; exit , command exit
: ; immediate &#39; exit , command exit
[
[
_welcome</code></pre>
_welcome</code></pre>
<!--
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
File diff suppressed because it is too large. Load diff
+20 -21
View File
@@ -132,8 +132,7 @@
<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></li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,37 +141,37 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> all</span></code></pre></div>
<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>
<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>
<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>
<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>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> help <span class="kw">|</span> <span class="fu">cat</span> third help.th <span class="at">-</span> <span class="kw">|</span> <span class="ex">./first</span></span>
<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>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> help <span class="kw">|</span> <span class="fu">cat</span> third help.th <span class="at">-</span> <span class="kw">|</span> <span class="ex">./first</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="co"># try out a demo:</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> third demo5.th <span class="kw">|</span> <span class="ex">./first</span></span></code></pre></div>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="co"># try out a demo:</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> third demo5.th <span class="kw">|</span> <span class="ex">./first</span></span></code></pre></div>
<p>Third:</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">cat</span> third help.th <span class="at">-</span> <span class="kw">|</span> <span class="ex">./first</span></span></code></pre></div>
<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">cat</span> third help.th <span class="at">-</span> <span class="kw">|</span> <span class="ex">./first</span></span></code></pre></div>
<p>NOTE: Wait until ‘Ok’ is printed and the type:</p>
<pre><code>2 3 + . cr</code></pre>
<pre><code> 2 3 + . cr</code></pre>
<p>Yes you should really type the 2 letters: <code>cr</code>.</p>
<p>Fourth:</p>
<pre><code>Sorry, this is third!</code></pre>
<pre><code> Sorry, this is third!</code></pre>
<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>
<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>
<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>
<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>
<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>
<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>
@@ -205,7 +204,7 @@ 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>
<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
@@ -284,18 +283,18 @@ take a significant amount of time in THIRD.</p>
<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>
<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>
<pre><code> 5</code></pre>
<p>Now try:</p>
<pre><code>: test 11 1 do i . loop cr ;
test</code></pre>
<pre><code> : test 11 1 do i . loop cr ;
test</code></pre>
<p>and THIRD responds</p>
<pre><code>1 2 3 4 5 6 7 8 9 10</code></pre>
<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>
<pre><code>here .</code></pre>
<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
+19 -19
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
NOTE: we DISABLE the optimiser because having it enabled causes some invocations
@@ -13,7 +13,7 @@ to crash in some systems.
The current status of this entry is:
```
STATUS: uses gets() - change to fgets() if possible
STATUS: uses gets() - change to fgets() if possible
```
For more detailed information see [1992 gson bugs](../../bugs.html#1992_gson).
@@ -22,14 +22,14 @@ For more detailed information see [1992 gson bugs](../../bugs.html#1992_gson).
## To use:
```sh
./ag word word2 word3 < /path/to/dictionary
./ag word word2 word3 < /path/to/dictionary
```
## Try:
```sh
./try.sh
./try.sh
```
This script will determine (or try and determine) where your system dictionary
@@ -37,22 +37,22 @@ 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:
```
/usr/share/dict/words
/usr/share/lib/spell/words
/usr/ucblib/dict/words
/dev/null # <-- for machines with nothing to say
/usr/share/dict/words
/usr/share/lib/spell/words
/usr/ucblib/dict/words
/dev/null # <-- for machines with nothing to say
```
Then using the proper dictionary file it does:
```sh
./ag free software foundation < /usr/share/dict/words
./ag obfuscated c contest < /usr/share/dict/words
./ag unix international < /usr/share/dict/words
./ag george bush < /usr/share/dict/words
./ag bill clinton < /usr/share/dict/words
./ag ross perot < /usr/share/dict/words
./ag paul e tsongas < /usr/share/dict/words
./ag free software foundation < /usr/share/dict/words
./ag obfuscated c contest < /usr/share/dict/words
./ag unix international < /usr/share/dict/words
./ag george bush < /usr/share/dict/words
./ag bill clinton < /usr/share/dict/words
./ag ross perot < /usr/share/dict/words
./ag paul e tsongas < /usr/share/dict/words
```
where `/usr/share/dict/words` is the dictionary file.
@@ -74,7 +74,7 @@ The author provided an obfuscated script that can be used to construct
dictionaries which has been put in as [mkdict.sh](mkdict.sh). To use try:
```sh
cat README.md | ./mkdict.sh > words
cat README.md | ./mkdict.sh > words
```
Then try using the program as shown above with the file `words`.
@@ -104,8 +104,8 @@ hundred of your favourite Usenet articles and piping them through the following
obfuscated shell script:
```sh
#!/bin/sh
z=a-z];tr [A-Z\] \[$z|sed s/[\^$z[\^$z*/_/g|tr _ \\012|grep ..|sort -u
#!/bin/sh
z=a-z];tr [A-Z\] \[$z|sed s/[\^$z[\^$z*/_/g|tr _ \\012|grep ..|sort -u
```
Using articles from alt.folklore.computers is likely to make
@@ -259,7 +259,7 @@ program prints all those 16-bit integers that contain zeroes in all
even bit positions:
```c
main(){int i=0,s=0xAAAA;do{printf("%04x\t",i);}while(i=((i|~s)+1)&s);}
main(){int i=0,s=0xAAAA;do{printf("%04x\t",i);}while(i=((i|~s)+1)&s);}
```
AG uses a similar method but works in the opposite direction, finding
+20 -21
View File
@@ -132,8 +132,7 @@
<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>
Location: <a href="../../location.html#FI">FI</a> - <em>Republic of Finland </em> (<em>Finland</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,32 +141,32 @@ Location: <a href="../../location.html#FI">FI</a> - <em>Republic of Finland </em
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> all</span></code></pre></div>
<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>
<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>
<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>
<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">&lt;</span> /path/to/dictionary</span></code></pre></div>
<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">&lt;</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>
<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>
<pre><code>/usr/share/dict/words
/usr/share/lib/spell/words
/usr/ucblib/dict/words
/dev/null # &lt;-- for machines with nothing to say</code></pre>
<pre><code> /usr/share/dict/words
/usr/share/lib/spell/words
/usr/ucblib/dict/words
/dev/null # &lt;-- for machines with nothing to say</code></pre>
<p>Then using the proper dictionary file it 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="ex">./ag</span> free software foundation <span class="op">&lt;</span> /usr/share/dict/words</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./ag</span> obfuscated c contest <span class="op">&lt;</span> /usr/share/dict/words</span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./ag</span> unix international <span class="op">&lt;</span> /usr/share/dict/words</span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a><span class="ex">./ag</span> george bush <span class="op">&lt;</span> /usr/share/dict/words</span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a><span class="ex">./ag</span> bill clinton <span class="op">&lt;</span> /usr/share/dict/words</span>
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a><span class="ex">./ag</span> ross perot <span class="op">&lt;</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">&lt;</span> /usr/share/dict/words</span></code></pre></div>
<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">./ag</span> free software foundation <span class="op">&lt;</span> /usr/share/dict/words</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./ag</span> obfuscated c contest <span class="op">&lt;</span> /usr/share/dict/words</span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./ag</span> unix international <span class="op">&lt;</span> /usr/share/dict/words</span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./ag</span> george bush <span class="op">&lt;</span> /usr/share/dict/words</span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">./ag</span> bill clinton <span class="op">&lt;</span> /usr/share/dict/words</span>
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">./ag</span> ross perot <span class="op">&lt;</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">&lt;</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
@@ -180,7 +179,7 @@ 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">&gt;</span> words</span></code></pre></div>
<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">&gt;</span> words</span></code></pre></div>
<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>
@@ -196,8 +195,8 @@ natural language of your choice, one word on each line. If your machine doesn’
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>
<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>AG must be run with the dictionary file as standard input.</p>
@@ -324,7 +323,7 @@ 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">&quot;</span><span class="sc">%04x\t</span><span class="st">&quot;</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">)&amp;</span>s<span class="op">);}</span></span></code></pre></div>
<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">&quot;</span><span class="sc">%04x\t</span><span class="st">&quot;</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">)&amp;</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
+19 -19
View File
@@ -1,17 +1,17 @@
## To build:
```sh
make all
make all
```
## To use:
```sh
# text mode
./imc -text
# text mode
./imc -text
./imc
./imc
```
@@ -20,7 +20,7 @@ make all
To see a number of options and configurations:
```sh
./try.sh
./try.sh
```
@@ -125,26 +125,26 @@ raster size; not a good idea!).
The options of this program are:
```
-centre x y (float x,y) Centre the picture at x+iy in the complex
plane (default x=0 y=0)
-centre x y (float x,y) Centre the picture at x+iy in the complex
plane (default x=0 y=0)
-factor f (float f) Use f pixels per unit of the plane (default
f=x/4 where x is the width)
-factor f (float f) Use f pixels per unit of the plane (default
f=x/4 where x is the width)
-julia x y (float x,y) Draw a julia set. Use x+iy as the constant
to add after squaring (default x=0 y=0)
-julia x y (float x,y) Draw a julia set. Use x+iy as the constant
to add after squaring (default x=0 y=0)
-limit l (int l) Use l iterations maximum (default l=128)
-limit l (int l) Use l iterations maximum (default l=128)
-mask m (int m) Use m as a mask in deciding the colour of each
pixel (see below) (default m=1)
-mask m (int m) Use m as a mask in deciding the colour of each
pixel (see below) (default m=1)
-size x y (int x,y) Produce an x-by-y output (default for raster
x=768 y=768; default for text x=63 y=23)
-size x y (int x,y) Produce an x-by-y output (default for raster
x=768 y=768; default for text x=63 y=23)
-text Produce text instead of raster.
-text Produce text instead of raster.
```
The colour of each point is determined by taking the bitwise AND of the
@@ -165,8 +165,8 @@ standard error to indicate its progress (one dot per pixel line).
Here are a couple of good pictures to draw:
```sh
./imc -s 512,512 -f 600000 -l 512 -m 16 -c.00805,.74274 > screen1.ras
./imc -s512,512 -j-.523,-.535 > screen2.ras
./imc -s 512,512 -f 600000 -l 512 -m 16 -c.00805,.74274 > screen1.ras
./imc -s512,512 -j-.523,-.535 > screen2.ras
```
+20 -21
View File
@@ -132,8 +132,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>)
<br><br></li>
Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom of Great Britain and Northern Ireland</em> (<em>United Kingdom</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,15 +141,15 @@ Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom of Great
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> all</span></code></pre></div>
<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>
<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="co"># text mode</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./imc</span> <span class="at">-text</span></span>
<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="co"># text mode</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./imc</span> <span class="at">-text</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="ex">./imc</span></span></code></pre></div>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./imc</span></span></code></pre></div>
<h2 id="try">Try:</h2>
<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>
<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
@@ -231,26 +230,26 @@ appears before <code>t</code>, specifying an option without numbers has no effec
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
plane (default x=0 y=0)
<pre><code> -centre x y (float x,y) Centre the picture at x+iy in the complex
plane (default x=0 y=0)
-factor f (float f) Use f pixels per unit of the plane (default
f=x/4 where x is the width)
-factor f (float f) Use f pixels per unit of the plane (default
f=x/4 where x is the width)
-julia x y (float x,y) Draw a julia set. Use x+iy as the constant
to add after squaring (default x=0 y=0)
-julia x y (float x,y) Draw a julia set. Use x+iy as the constant
to add after squaring (default x=0 y=0)
-limit l (int l) Use l iterations maximum (default l=128)
-limit l (int l) Use l iterations maximum (default l=128)
-mask m (int m) Use m as a mask in deciding the colour of each
pixel (see below) (default m=1)
-mask m (int m) Use m as a mask in deciding the colour of each
pixel (see below) (default m=1)
-size x y (int x,y) Produce an x-by-y output (default for raster
x=768 y=768; default for text x=63 y=23)
-size x y (int x,y) Produce an x-by-y output (default for raster
x=768 y=768; default for text x=63 y=23)
-text Produce text instead of raster.</code></pre>
-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
(1-bit) if the result is zero, white otherwise. For text, the result of
@@ -264,8 +263,8 @@ bits (e.g. 8).</p>
standard error to indicate its progress (one dot per pixel line).</p>
<h3 id="example-pictures-to-try">Example pictures to try</h3>
<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">&gt;</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">&gt;</span> screen2.ras</span></code></pre></div>
<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">&gt;</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">&gt;</span> screen2.ras</span></code></pre></div>
<!--
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
+2 -2
View File
@@ -179,8 +179,8 @@ 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>
<pre><code>...!{sun,pacbell,uunet,pyramid}!hoptoad!judges
judges@toad.com</code></pre>
<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>
<h2 id="final-comments">Final Comments</h2>
+8 -8
View File
@@ -3,7 +3,7 @@
If your machine support the X Window System, Version 11:
```sh
make alt
make alt
```
We recommend that you try the alt version first so you can get a better idea of
@@ -16,7 +16,7 @@ original should you wish to see what we mean.
The current status of this entry is:
```
STATUS: known bug - please help us fix
STATUS: known bug - please help us fix
```
For more detailed information see [1992 kivinen bugs](../../bugs.html#1992_kivinen).
@@ -25,11 +25,11 @@ For more detailed information see [1992 kivinen bugs](../../bugs.html#1992_kivin
## To use:
```sh
./kivinen.alt
./kivinen.alt
./kivinen.alt a
./kivinen.alt a
./kivinen.alt a b
./kivinen.alt a b
```
See also the author's remarks for other variations.
@@ -42,9 +42,9 @@ change the `usleep(3)` value to `30000` from `20000`, try:
```sh
make clobber SLEEP=30000 alt # make it slower
make clobber SLEEP=30000 alt # make it slower
make clobber SLEEP=10000 alt # make it faster
make clobber SLEEP=10000 alt # make it faster
```
Then use the same syntax as above and described by the author.
@@ -60,7 +60,7 @@ code.
### Original build:
```sh
make all
make all
```
+9 -10
View File
@@ -132,8 +132,7 @@
<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>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -143,34 +142,34 @@ Location: <a href="../../location.html#FI">FI</a> - <em>Republic of Finland </em
<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>
<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>
<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>
<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>
<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>
<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>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./kivinen.alt</span> a</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./kivinen.alt</span> a</span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a></span>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
+3 -3
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
@@ -10,7 +10,7 @@ make all
The current status of this entry is:
```
STATUS: doesn't work with some compilers - please provide alternative code or fix for more compilers
STATUS: doesn't work with some compilers - please provide alternative code or fix for more compilers
```
For more detailed information see [1992 lush bugs](../../bugs.html#1992_lush).
@@ -19,7 +19,7 @@ For more detailed information see [1992 lush bugs](../../bugs.html#1992_lush).
## To use:
```sh
./lush.sh
./lush.sh
```
+4 -5
View File
@@ -132,8 +132,7 @@
<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>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,13 +141,13 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> all</span></code></pre></div>
<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>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code>STATUS: doesn&#39;t work with some compilers - please provide alternative code or fix for more compilers</code></pre>
<pre><code> STATUS: doesn&#39;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>
<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>
<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>
<p>The program uses error messages issued by the C Preprocessor to
generate its message to the world. One program’s error is another
+2 -2
View File
@@ -1,14 +1,14 @@
## To build:
```sh
make all
make all
```
## To use:
```sh
./marangon
./marangon
```
+3 -4
View File
@@ -132,8 +132,7 @@
<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>
Location: <a href="../../location.html#IT">IT</a> - <em>Italian Republic</em> (<em>Italy</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,9 +141,9 @@ Location: <a href="../../location.html#IT">IT</a> - <em>Italian Republic</em> (<
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> all</span></code></pre></div>
<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>
<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>
<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
+6 -6
View File
@@ -1,15 +1,15 @@
## To build:
```sh
make all
make all
```
## To use:
```sh
./nathan
# enter some text
./nathan
# enter some text
```
@@ -18,7 +18,7 @@ make all
To see some other fun uses:
```sh
./try.sh
./try.sh
```
@@ -59,8 +59,8 @@ 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:
```sh
make nathan
./nathan
make nathan
./nathan
```
to learn how to get a copy of the code.
+7 -8
View File
@@ -132,8 +132,7 @@
<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>
Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom of Great Britain and Northern Ireland</em> (<em>United Kingdom</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,13 +141,13 @@ Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom of Great
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> all</span></code></pre></div>
<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>
<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">./nathan</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="co"># enter some text</span></span></code></pre></div>
<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">./nathan</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="co"># enter some text</span></span></code></pre></div>
<h2 id="try">Try:</h2>
<p>To see some other fun uses:</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>
<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
@@ -174,8 +173,8 @@ 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>
<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>
+12 -12
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
@@ -10,7 +10,7 @@ make all
The current status of this entry is:
```
STATUS: INABIAF - please **DO NOT** fix
STATUS: INABIAF - please **DO NOT** fix
```
For more detailed information see [1992 vern bugs](../../bugs.html#1992_vern).
@@ -19,7 +19,7 @@ For more detailed information see [1992 vern bugs](../../bugs.html#1992_vern).
## To use:
```sh
./vern 3 # <-- default is 2
./vern 3 # <-- default is 2
```
@@ -28,10 +28,10 @@ For more detailed information see [1992 vern bugs](../../bugs.html#1992_vern).
You might start off by giving the following input:
```
63 43
76 55
71 52
67 57 # <-- this may take a while
63 43
76 55
71 52
67 57 # <-- this may take a while
```
@@ -43,10 +43,10 @@ suggested above. :-)
For a real quick game try:
```sh
./vern
./vern
65 55
66 46
65 55
66 46
```
NOTE: Move values must be restricted to the range 00 to 77.
@@ -125,8 +125,8 @@ initial source is gloriously difficult to peruse. In particular, the Makefile
does:
```sh
sed <vern.c 's/{ /(/g;s/} /)/g;s/; /#define /' | \
sed 's/} /=/g;s/{ /i/g' >vern.tmp.c
sed <vern.c 's/{ /(/g;s/} /)/g;s/; /#define /' | \
sed 's/} /=/g;s/{ /i/g' >vern.tmp.c
```
and compiles `vern.tmp.c`.
+13 -14
View File
@@ -132,8 +132,7 @@
<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>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,27 +141,27 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> all</span></code></pre></div>
<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>
<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>
<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>
<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"># &lt;-- default is 2</span></span></code></pre></div>
<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"># &lt;-- default is 2</span></span></code></pre></div>
<h2 id="try">Try:</h2>
<p>You might start off by giving the following input:</p>
<pre><code>63 43
76 55
71 52
67 57 # &lt;-- this may take a while</code></pre>
<pre><code> 63 43
76 55
71 52
67 57 # &lt;-- this may take a while</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>The judges assume no responsibility for the obfuscated opening
suggested above. :-)</p>
<p>For a real quick game try:</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">./vern</span></span>
<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">./vern</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a></span>
<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>
<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>
@@ -226,8 +225,8 @@ 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">&lt;</span>vern.c <span class="st">&#39;s/{ /(/g;s/} /)/g;s/; /#define /&#39;</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">&#39;s/} /=/g;s/{ /i/g&#39;</span> <span class="op">&gt;</span>vern.tmp.c</span></code></pre></div>
<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">&lt;</span>vern.c <span class="st">&#39;s/{ /(/g;s/} /)/g;s/; /#define /&#39;</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">&#39;s/} /=/g;s/{ /i/g&#39;</span> <span class="op">&gt;</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
+16 -17
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
@@ -10,8 +10,8 @@ make all
The current status of this entry is:
```
STATUS: INABIAF - please **DO NOT** fix
STATUS: known bug - please help us fix
STATUS: INABIAF - please **DO NOT** fix
STATUS: known bug - please help us fix
```
For more detailed information see [1992 westley bugs](../../bugs.html#1992_westley).
@@ -23,7 +23,7 @@ If lost:
```sh
./whereami.sh lat long
./whereami.sh lat long
```
Where `lat` and `long` correspond to your latitude and longitude.
@@ -37,7 +37,7 @@ should just use the `westley` and `westley.alt` programs directly.
## Try:
```sh
./try.sh
./try.sh
```
@@ -49,15 +49,14 @@ The author provided a version for the US which we added. To build:
### Alternate build:
```sh
make alt
make alt
```
### Alternate use:
```sh
./whereami.alt.sh lat long
./whereami.alt.sh lat long
```
NOTE: this alternative version also needs a terminal with at least 80 columns.
@@ -69,7 +68,7 @@ The [try.sh](try.sh) script uses both the original entry and the alternate code
so one can try the same script for both:
```sh
./try.sh
./try.sh
```
@@ -78,10 +77,10 @@ so one can try the same script for both:
To find the approximate place where this entry was judged, type:
```sh
./whereami 37 -122 # NOTE: - means west of meridian
./whereami 37 -122 # NOTE: - means west of meridian
# or if you don't have curses installed:
./westley 37 -122 # NOTE: - means west of meridian
# or if you don't have curses installed:
./westley 37 -122 # NOTE: - means west of meridian
```
@@ -166,17 +165,17 @@ is reasonably accurate.
For a domestic (US) version with higher resolution, try:
```c
main(l,a,n,d)char**a;{for(d=atoi(a[1])/2*80-atoi(a[2])-2043;
n="bnaBCOCXdBBHGYdAP[A M E R I C A].AqandkmavX|ELC}BOCd"
[l++-3];)for(;n-->64;)putchar(!d+++33^l&1);}
main(l,a,n,d)char**a;{for(d=atoi(a[1])/2*80-atoi(a[2])-2043;
n="bnaBCOCXdBBHGYdAP[A M E R I C A].AqandkmavX|ELC}BOCd"
[l++-3];)for(;n-->64;)putchar(!d+++33^l&1);}
```
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:
```c
main(l,a,n,d)...
[A M E R I C A]...
main(l,a,n,d)...
[A M E R I C A]...
```
...going down the left edge if your terminal auto-wraps at 80 characters.
+17 -18
View File
@@ -132,8 +132,7 @@
<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>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,39 +141,39 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> all</span></code></pre></div>
<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>
<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
STATUS: known bug - please help us fix</code></pre>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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">./whereami</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>
<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">./whereami</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>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="co"># or if you don&#39;t have curses installed:</span></span>
<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>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="co"># or if you don&#39;t have curses installed:</span></span>
<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 &amp; longitude as integer
arguments; it will produce a map made up of <code>'!'</code> with the given
@@ -244,13 +243,13 @@ is reasonably accurate.</p>
<li>Tokyo 36 140</li>
</ul>
<p>For a domestic (US) version with higher resolution, try:</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>l<span class="op">,</span>a<span class="op">,</span>n<span class="op">,</span>d<span class="op">)</span><span class="dt">char</span><span class="op">**</span>a<span class="op">;{</span><span class="cf">for</span><span class="op">(</span>d<span class="op">=</span>atoi<span class="op">(</span>a<span class="op">[</span><span class="dv">1</span><span class="op">])/</span><span class="dv">2</span><span class="op">*</span><span class="dv">80</span><span class="op">-</span>atoi<span class="op">(</span>a<span class="op">[</span><span class="dv">2</span><span class="op">])-</span><span class="dv">2043</span><span class="op">;</span></span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a>n<span class="op">=</span><span class="st">&quot;bnaBCOCXdBBHGYdAP[A M E R I C A].AqandkmavX|ELC}BOCd&quot;</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">--&gt;</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">&amp;</span><span class="dv">1</span><span class="op">);}</span></span></code></pre></div>
<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>l<span class="op">,</span>a<span class="op">,</span>n<span class="op">,</span>d<span class="op">)</span><span class="dt">char</span><span class="op">**</span>a<span class="op">;{</span><span class="cf">for</span><span class="op">(</span>d<span class="op">=</span>atoi<span class="op">(</span>a<span class="op">[</span><span class="dv">1</span><span class="op">])/</span><span class="dv">2</span><span class="op">*</span><span class="dv">80</span><span class="op">-</span>atoi<span class="op">(</span>a<span class="op">[</span><span class="dv">2</span><span class="op">])-</span><span class="dv">2043</span><span class="op">;</span></span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> n<span class="op">=</span><span class="st">&quot;bnaBCOCXdBBHGYdAP[A M E R I C A].AqandkmavX|ELC}BOCd&quot;</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">--&gt;</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">&amp;</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>
<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>
<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>
<!--