This repository was archived by the owner on Dec 30, 2024. It is now read-only.
forked from ioccc-src/winner
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
921 lines (791 loc) · 39.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@100..900&display=swap" rel="stylesheet">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>1984/mullender - Grand Prize</title>
<link rel="icon" type="image/x-icon" href="../../favicon.ico">
<meta name="description" content="1984 IOCCC entry mullender - Grand Prize">
<meta name="keywords" content="IOCCC, 1984, IOCCC 1984, IOCCC entry, mullender, Grand Prize">
</head>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- END: this line ends content from: inc/head.default.html -->
<!-- -->
<!-- This web page was formed via the tool: bin/readme2index.sh -->
<!-- The content of main section of this web page came from: 1984/mullender/README.md -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! Do not modify this web page, instead modify the file: 1984/mullender/README.md !!! -->
<!-- !!! Do not modify this web page, instead modify the file: 1984/mullender/README.md !!! -->
<!-- !!! Do not modify this web page, instead modify the file: 1984/mullender/README.md !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- Markdown content was converted into HTML via the tool: bin/md2html.sh -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/topbar.default.html -->
<div class="theader">
<nav class="topbar">
<div class="container">
<div class="logo">
<a href="../../index.html" class="logo-link">
IOCCC
</a>
</div>
<div class="topbar-items">
<div class="item">
<span class="item-header">
Entries
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../years.html" class="sub-item-link">
Winning entries
</a>
</div>
<div class="outfit-font">
<a href="../../authors.html" class="sub-item-link">
Winning authors
</a>
</div>
<div class="outfit-font">
<a href="../../location.html" class="sub-item-link">
Location of authors
</a>
</div>
<div class="outfit-font">
<a href="../../bugs.html" class="sub-item-link">
Bugs and (mis)features
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#fix_an_entry" class="sub-item-link">
Fixing entries
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#fix_author" class="sub-item-link">
Updating author info
</a>
</div>
</div>
</div>
<div class="item">
<span class="item-header">
Status
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../news.html" class="sub-item-link">
News
</a>
</div>
<div class="outfit-font">
<a href="../../status.html" class="sub-item-link">
Contest status
</a>
</div>
<div class="outfit-font">
<a href="../../next/index.html" class="sub-item-link">
Rules and guidelines
</a>
</div>
<div class="outfit-font">
<a href="../../markdown.html" class="sub-item-link">
Markdown guidelines
</a>
</div>
<div class="outfit-font">
<a href="../../SECURITY.html" class="sub-item-link">
Security policy
</a>
</div>
</div>
</div>
<div class="item">
<span class="item-header">
FAQ
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../faq.html" class="sub-item-link">
Frequently Asked Questions
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#enter" class="sub-item-link">
Enter the IOCCC
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#compiling" class="sub-item-link">
Compiling entries
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#running_entries" class="sub-item-link">
Running entries
</a>
</div>
<div class="outfit-font">
<a href="../../faq.html#help" class="sub-item-link">
How to help
</a>
</div>
</div>
</div>
<div class="item">
<span class="item-header">
About
</span>
<div class="sub-item">
<div class="outfit-font">
<a href="../../index.html" class="sub-item-link">
Home page
</a>
</div>
<div class="outfit-font">
<a href="../../about.html" class="sub-item-link">
About the IOCCC
</a>
</div>
<div class="outfit-font">
<a href="../../judges.html" class="sub-item-link">
The Judges
</a>
</div>
<div class="outfit-font">
<a href="../../thanks-for-help.html" class="sub-item-link">
Thanks for the help
</a>
</div>
<div class="outfit-font">
<a href="../../contact.html" class="sub-item-link">
Contact us
</a>
</div>
</div>
</div>
</div>
</div>
</nav>
<div class="header-mobile-menu">
<noscript>
<a href="../../nojs-menu.html" class="topbar-js-label">
Please Enable JavaScript
</a>
</noscript>
<button id="header-open-menu-button" class="topbar-mobile-menu">
<img
src="../../png/hamburger-icon-open.png"
alt="hamburger style menu icon - open state"
width=48
height=48>
</button>
<button id="header-close-menu-button" class="hide-content">
<img
src="../../png/hamburger-icon-closed.png"
alt="hamburger style menu icon - closed state"
width=48
height=48>
</button>
<div id="mobile-menu-panel" class="hide-content">
<div class="mobile-menu-container">
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
Entries
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../years.html">
Winning entries
</a>
<a class="mobile-submenu-item" href="../../authors.html">
Winning authors
</a>
<a class="mobile-submenu-item" href="../../location.html">
Location of authors
</a>
<a class="mobile-submenu-item" href="../../bugs.html">
Bugs and (mis)features
</a>
<a class="mobile-submenu-item" href="../../faq.html#fix_an_entry">
Fixing entries
</a>
<a class="mobile-submenu-item" href="../../faq.html#fix_author">
Updating author info
</a>
<a class="mobile-submenu-item" href="../../thanks-for-help.html">
Thanks for the help
</a>
</div>
</div>
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
Status
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../news.html">
News
</a>
<a class="mobile-submenu-item" href="../../status.html">
Contest status
</a>
<a class="mobile-submenu-item" href="../../next/index.html">
Rules and guidelines
</a>
<a class="mobile-submenu-item" href="../../markdown.html">
Markdown guidelines
</a>
<a class="mobile-submenu-item" href="../../SECURITY.html">
Security policy
</a>
</div>
</div>
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
FAQ
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../faq.html">
Frequently Asked Questions
</a>
<a class="mobile-submenu-item" href="../../faq.html#enter">
Enter the IOCCC
</a>
<a class="mobile-submenu-item" href="../../faq.html#compiling">
Compiling entries
</a>
<a class="mobile-submenu-item" href="../../faq.html#running_entries">
Running entries
</a>
<a class="mobile-submenu-item" href="../../faq.html#help">
How to help
</a>
</div>
</div>
<div class="mobile-menu-wrapper">
<div class="mobile-menu-item">
About
</div>
<div class="mobile-submenu-wrapper">
<a class="mobile-submenu-item" href="../../index.html">
Home page
</a>
<a class="mobile-submenu-item" href="../../about.html">
About the IOCCC
</a>
<a class="mobile-submenu-item" href="../../judges.html">
The Judges
</a>
<a class="mobile-submenu-item" href="../../contact.html">
Contact us
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
var headerOpenMenuButton = document.getElementById("header-open-menu-button");
var headerCloseMenuButton = document.getElementById("header-close-menu-button");
var mobileMenuPanel = document.getElementById("mobile-menu-panel");
headerOpenMenuButton.addEventListener("click", () => {
headerOpenMenuButton.classList.remove("topbar-mobile-menu");
headerOpenMenuButton.classList.add("hide-content");
headerCloseMenuButton.classList.remove("hide-content");
headerCloseMenuButton.classList.add("topbar-mobile-menu");
mobileMenuPanel.classList.remove("hide-content");
mobileMenuPanel.classList.add("topbar-mobile-panel");
});
headerCloseMenuButton.addEventListener("click", () => {
headerCloseMenuButton.classList.remove("topbar-mobile-menu");
headerCloseMenuButton.classList.add("hide-content");
mobileMenuPanel.classList.add("hide-content");
mobileMenuPanel.classList.remove("topbar-mobile-panel");
headerOpenMenuButton.classList.add("topbar-mobile-menu");
headerOpenMenuButton.classList.remove("hide-content");
});
</script>
<!-- END: this line ends content from: inc/topbar.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<a href="../../2011/zucker/index.html">
<img src="../../png/ioccc.png"
alt="IOCCC image by Matt Zucker"
width=300
height=110>
</a>
<h1>The International Obfuscated C Code Contest</h1>
<h2>1984/mullender - Grand Prize</h2>
<h3>hardcoded vax and pdp-11 code to move :-) across the screen</h3>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/navbar.mid.html -->
<div class="navbar">
<a class="Left" href="../laman/index.html">← 1984/laman</a>
<a class="Left" href="../index.html">↑ 1984 ↑</a>
<a class="Left" href="../../1985/applin/index.html">1985/applin →</a>
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/1984/mullender/mullender.c">C code</a>
<a class="Right" href="https://github.com/ioccc-src/winner/blob/master/1984/mullender/Makefile">Makefile</a>
<a class="Right" href="#inventory">Inventory</a>
<a class="Right" href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.ioccc.org%2F1984%2Fmullender%2Findex.html">✓</a>
</div>
<!-- END: this line ends content from: inc/navbar.mid.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<div class="content" id="content">
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
<!-- START: this line starts content generated by: bin/output-index-author.sh -->
<div id="author">
<h2 id="authors">Authors:</h2>
</div>
<ul>
<li>Name: <a href="../../authors.html#Robbert_van_Renesse">Robbert van Renesse</a><br>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
<br><br></li>
<li>Name: <a href="../../authors.html#Sjoerd_Mullender">Sjoerd Mullender</a><br>
Location: <a href="../../location.html#NL">NL</a> - <em>Kingdom of the Netherlands</em> (<em>Netherlands</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
<!-- END: this line ends content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- BEFORE: 1st line of markdown file: 1984/mullender/README.md -->
<h2 id="to-build">To build:</h2>
<pre><code> make alt</code></pre>
<p><strong>NOTE</strong>: the original code will not work on any system other than
<a href="https://en.wikipedia.org/wiki/VAX-11">VAX-11</a> and
<a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a> and this is why we encourage you
to use the alt version instead. See <a href="#original-code">original code</a> below for
the original version.</p>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<blockquote>
<p><strong>STATUS: INABIAF - please DO NOT fix</strong></p>
</blockquote>
<p>For more detailed information see <a href="../../bugs.html#1984_mullender">1984/mullender in bugs.html</a>.</p>
<h2 id="to-use">To use:</h2>
<pre><code> ./mullender.alt [microseconds]</code></pre>
<p>Hit ctrl-c/intr to exit the program.</p>
<p>The default microseconds is 190000 as this is approximately how long it slept in
the original entry but it can be no lower than 5000 as any lower doesn’t work
very well. This feature is so you can experiment with different speeds in
between writes. It can be useful if your CPU is too fast :-)</p>
<p>The author stated that the original version also had a delay but the difference
is it required one to hit enter for it to print another line; the alternate code will
start over once it times out or if one hits a key.</p>
<p>Note that the microseconds is argc and it uses <code>atoi()</code> which does NOT check for
overflow!</p>
<p><strong>BTW</strong>: is there such a thing as too fast a CPU ? :-) Actually yes for certain code
which is probably not as uncommon as you think :-).</p>
<h2 id="try">Try:</h2>
<pre><code> ./mullender.alt
./mullender.alt 5000 # wait for 5000 microseconds and see what happens
./mullender.alt 20000 # wait for 20000 microseconds and see what happens
./mullender.alt 100000 # wait for 100000 microseconds and see what happens</code></pre>
<p>What happens if you hit enter after it reaches the end of the line? Why? What
happens after some time of waiting?</p>
<h2 id="original-code">Original code:</h2>
<p>This original code will only execute correctly if your machine is a
<a href="https://en.wikipedia.org/wiki/VAX-11">VAX-11</a> or
<a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a>. In the following years, 1985 on,
machine dependent code was discouraged.</p>
<h3 id="original-build">Original build:</h3>
<pre><code> make all</code></pre>
<h3 id="original-use">Original use:</h3>
<pre><code> ./mullender</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>Without question, this C program is the one of the most obfuscated C program
that has ever been received! Like all great contest entries, it resulted in a
change of rules for the following year. To prevent a flood of similar programs,
the rules were changed, requesting non-machine specific code.</p>
<p>This program was selected for the 1987 t-shirt collection.</p>
<p>The C startup routine, via <a href="https://en.wikipedia.org/wiki/Crt0">crt0.o</a>,
transfers control to a location named <code>main</code>. In this case, <code>main</code> just happens
to be in the data area. The array of <code>short</code>s, which has been further
obfuscated by use of different data types, just happens to form a meaningful set
of <a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a> and
<a href="https://en.wikipedia.org/wiki/VAX">VAX</a> instructions.</p>
<p>The first word is a <a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a> branch
instruction that branches to the rest of the
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a> code.</p>
<p>On the VAX <code>main</code> is called with the <a href="https://jcsites.juniata.edu/faculty/rhodes/org/instr.htm#CALLS">calls
instruction</a>
which uses the first word of the subroutine as a mask of registers to be saved.
So on the VAX the first word can be anything. The real VAX code starts with the
second word.</p>
<p>This small program makes direct calls to the <code>write()</code> Unix system call to
produce a message on the screen. Can you guess what is printed? We knew you
couldn’t! :-)</p>
<p>What happens if you hit enter after it writes a line of output?</p>
<p><strong>BTW</strong>: to this day, 2023, this remains one of my (Landon Curt Noll’s) all time
favorite entries!</p>
<h3 id="gentab.c">gentab.c</h3>
<p>In 2023 remarks were discovered from <a href="../../authors.html#Sjoerd_Mullender">Sjoerd
Mullender</a>, one of the authors, and so was the
program that was used by the authors to generate the array that he referred to.
Because <a href="https://github.com/ioccc-src/winner/blob/master/1984/mullender/a.out.h">a.out.h</a>, which <a href="https://github.com/ioccc-src/winner/blob/master/1984/mullender/gentab.c">gentab.c</a> uses,
is not available in all systems (like macOS) and more importantly because we wanted it to be as
close to as the original as possible we used a copy of
<a href="https://raw.githubusercontent.com/dspinellis/unix-history-repo/Research-Release/usr/include/a.out.h" class="uri">https://raw.githubusercontent.com/dspinellis/unix-history-repo/Research-Release/usr/include/a.out.h</a>
in the <em>fabulous</em> <a href="https://github.com/dspinellis/unix-history-repo/tree/Research-Release">Unix History
Repo</a>.</p>
<h3 id="gentab-build">gentab build:</h3>
<p><code>gentab.c</code> can be built like:</p>
<pre><code> make gentab</code></pre>
<h3 id="gentab-use">gentab use:</h3>
<pre><code> ./gentab file</code></pre>
<h3 id="gentab-try">gentab try:</h3>
<pre><code> ./gentab gentab > g.c</code></pre>
<p><strong>NOTE</strong>: it is highly unlikely that you will be able to run the output of <code>gentab</code>
but it should at least compile.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="notes-from-the-judges">Notes from the judges:</h3>
<p>These remarks, found at
<a href="https://lainsystems.com/posts/exploring-mullender-dot-c/">https://lainsystems.com/posts/exploring-mullender-dot-c/</a>,
were provided by Sjoerd Mullender years later. We thank the author of the
article for the quote! For a more detailed analysis, taken from the book Obfuscated C
and Other Mysteries, see below. We hope that this is okay with the author of the
book. Considering that the analysis is entirely the authors’ comments we don’t
think this will be a problem. Unfortunately the excerpt was PDF and it did not
copy paste well. We had to go back and forth to type so it’s possible we made a
typo though we also fixed some typos found in the extract. As for the other
comments:</p>
<h3 id="remarks-from-the-author">Remarks from the author:</h3>
<p>I have never known a lot about the <a href="https://en.wikipedia.org/wiki/VAX">VAX</a>
<a href="https://en.wikipedia.org/wiki/Assembly_language">assembly</a>, so we used the C
compiler to create the VAX code. We didn’t write it ourselves from scratch as we
did with the <a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a>
code. This is the reason why the <a href="https://en.wikipedia.org/wiki/VAX">VAX</a> code
is more complex, including the extra data after the
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a> code.</p>
<p>Robbert and I were students at the <a href="https://vu.nl/en">VU (Free University in
Amsterdam)</a> at the time (mathematics with CS as our major
since there was no CS curriculum when we started). We had an assignment to
create a pair of programs for the computer networks course. The programs were
supposed to send data reliably from one program to the other over an unreliable
channel. This channel was simulated with a pair of
<a href="https://en.wikipedia.org/wiki/Pipeline_(software)">pipes</a>.</p>
<p>We decided for fun to create an
<a href="https://en.wikipedia.org/wiki/Obfuscation_(software)">obfuscated</a> set of
programs, only for the
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a>, to do this, but
circumventing the channel (i.e. cheating, hence the needed obfuscation). Our
programs worked and we handed them in.</p>
<p>Of course, the teacher had a good laugh and then rejected our submission. (We
knew him well, so we could get away with this.)</p>
<p>Then the <a href="https://www.ioccc.org">IOCCC</a> came along. I don’t remember how we
heard about it, but at the time there was a world-wide messaging network Usenet
where we read a bunch of newsgroups. I’m sure it was <a href="https://groups.google.com/g/net.lang.c/c/lx-TAuEyeRI/m/HdOOnNx6LC0J">announced
there</a> and we saw
it.</p>
<p>Since we had just recently created these <a href="https://en.wikipedia.org/wiki/Obfuscation_(software)">obfuscated
programs</a> we decided we could
use the same technique for an obfuscated C program. We upped the ante a bit by
making it “portable”.</p>
<p>To add to the
<a href="https://en.wikipedia.org/wiki/Obfuscation_(software)">obfuscation</a>, we used
different formats for the integers in the array: some in decimal, some in octal,
some in hexadecimal, and when the value would fit, some as an ASCII character.</p>
<p>The rest is history.</p>
<p>Since this was the first contest, we hadn’t seen any old entries, nor had any of
the other contestants. Of course we knew about <code>#define</code> and tricks you could do
with that, but we didn’t need that for this program. In fact, we made it as
“standard” as possible. At the time there was this program called <code>cb</code> or C
beautifier which would re-indent your program to make the layout look better.
Our program is idempotent under <code>cb</code>.</p>
<h3 id="more-detailed-analysis">More detailed analysis</h3>
<p>When this program is compiled, the compiler places the array somewhere in
memory, just like it places any compiled code somewhere in memory. Usually, the
C startup code, <a href="https://en.wikipedia.org/wiki/Crt0">crt0.o</a>, calls a routine
named <code>main()</code>. The loader fills in the address in the startup code, but at
least on the old systems where this program ran, it doesn’t know that the
<code>main()</code> in this program isn’t code but data!</p>
<p>When the program is run, the C startup code transfers control to the location
<code>main</code>. The contents of the array just happen to be machine instructions for
both a <a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a> and a
<a href="https://en.wikipedia.org/wiki/VAX">VAX</a>.</p>
<p>On the <a href="https://en.wikipedia.org/wiki/VAX">VAX</a>, the routine <code>main()</code> is called
with the <code>calls</code> instruction. This instruction uses the first (2-byte)
<a href="https://en.wikipedia.org/wiki/Word_(computer_architecture)">word</a> of the called
routine as a mask of
<a href="https://en.wikipedia.org/wiki/Processor_register">registers</a> that are to be
saved on the <a href="https://en.wikipedia.org/wiki/Call_stack">stack</a>.
In other words, on the VAX the first word can be anything. On the
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a>, the first word
is a <a href="https://en.wikipedia.org/wiki/Branch_(computer_science)">branch</a>
<a href="https://en.wikipedia.org/wiki/Instruction_set_architecture#Instructions">instruction</a>
that branches over the VAX code. The PDP and VAX codes are thus completely
separate.</p>
<p>The <a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a> and
<a href="https://en.wikipedia.org/wiki/VAX">VAX</a> codes implement the same algorithm:</p>
<pre><code> for (;;) {
write(1, " :-)\b\b\b\b", 9);
delay();
}</code></pre>
<p>The result is that the symbols <code>:-)</code> move across the screen. <code>delay</code> is
implemented differently on the
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a>, where we used a
nonexistent system call (<code>sys 55</code>), and on the
<a href="https://en.wikipedia.org/wiki/VAX">VAX</a> where we used a delay loop.</p>
<p>My co-author, Robbert, and I had earlier written a similar program for an
assignment on the <a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a>. <a href="https://groups.google.com/g/net.lang.c/c/lx-TAuEyeRI/m/HdOOnNx6LC0J">Along
came</a> the
first <a href="https://www.ioccc.org">Obfuscated C Code Contest</a>, and
we decided that we should write a program like this, but make it run on two
different <a href="https://en.wikipedia.org/wiki/Computer_architecture">architectures</a>.</p>
<p>We didn’t think long about what the program should do, so it does something very
simple.</p>
<p>We started with writing the
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a> code in assembly.
We both knew <a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a> assembly so that was
no problem. The assembly code we came up with is as follows:</p>
<pre><code> pdp:
mov pc,r4
tst -(r4)
sub $9, r4
mov r4,0f
mov $1, r0
sys 4; 0:0; 9
mov $1000, r2
1:
sys 55
sob r2,1b
br pdp</code></pre>
<p>This is not the code we originally wrote, but it is the code that we ultimately
used in the program. The string to be printed is shared by the
<a href="https://en.wikipedia.org/wiki/VAX">VAX</a> and the
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a>
code and is located between the two sections.</p>
<p>First, the program deals with figuring out the address of the string. Then the
<a href="https://en.wikipedia.org/wiki/Program_counter">program counter</a> is saved in a
scratch <a href="https://en.wikipedia.org/wiki/Processor_register">register</a>. Since the
program counter points at the second
<a href="https://en.wikipedia.org/wiki/Instruction_set_architecture#Instructions">instruction</a>,
we subtract 2 from the scratch register in the second instruction. Then we
subtract the length of the string and store the result in the location with
label <code>0</code>. This has to do with the calling sequence of <a href="https://en.wikipedia.org/wiki/System_call">system
calls</a> on the
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a>. Following the
<code>sys</code> instruction is the system call number (4 for <code>write()</code>), the address of
the buffer (pointed to by label <code>0</code>), and the length of the buffer (9). The <a href="https://en.wikipedia.org/wiki/File_descriptor">file
descriptor</a> is in register <code>r0</code>.
The rest of the code implements a delay loop. In each iteration, a non-existing
system call (55) slows things down.</p>
<p>We assembled this program and extracted the <a href="https://en.wikipedia.org/wiki/Machine_code">machine
code</a> from the resulting <a href="https://en.wikipedia.org/wiki/Object_file">object
file</a>. We used this code in the
<a href="https://en.wikipedia.org/wiki/VAX">VAX</a> part. Since neither of us were fluent in
VAX <a href="https://en.wikipedia.org/wiki/Assembly_language">assembly</a>, we wrote the
VAX code in C and massaged the
<a href="https://en.wikipedia.org/wiki/Compiler">compiler</a> output. The VAX assembly
program that we came up with is as follows:</p>
<pre><code> vax: .word 0400 + (pdp - vax) / 2 - 1
1:
pushl $9
pushal str
pushl $1
calls $3, write
cvtwl $32767, r2
2:
decl r2
jneq 2b
jbr 1b
write: .word 0
chmk $4
ret
str: .ascii " :-)\b\b\b\b"
pdp: .word 4548, 3044, 58820, 9, 4407, 6, 5568, 1, 35076, 0, 9, 5570, 512, 35117, 32386, 496</code></pre>
<p>The first word (after the label <code>vax</code>) is the
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a> <a href="https://en.wikipedia.org/wiki/Branch_(computer_science)">branch
instruction</a>.
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a> branch
instructions are octal <code>400</code> + the distance divided by <code>2</code>. The string that both
the <a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a> and
<a href="https://en.wikipedia.org/wiki/VAX">VAX</a>
programs use is after the <code>str</code> label, and the
<a href="https://en.wikipedia.org/wiki/Programmed_Data_Processor">PDP</a> code is after the
<code>pdp</code> label.</p>
<p>On the <a href="https://en.wikipedia.org/wiki/VAX">VAX</a>, the program
<a href="https://en.wikipedia.org/wiki/Stack_(abstract_data_type)">pushes</a> 9 (the length
of the string), the address of the string and 1, the <a href="https://en.wikipedia.org/wiki/File_descriptor">file
descriptor</a> on the
<a href="https://en.wikipedia.org/wiki/Stack_(abstract_data_type)">stack</a>, and calls
<code>write(2)</code>. Since we didn’t know the exact calling sequence for <a href="https://en.wikipedia.org/wiki/System_call">system
calls</a>, we just copied the source for
the <code>write(2)</code> system call stub into our program. After <code>write(2)</code> finishes, the
program executes a delay loop, after which it jumps back to the start of the
program.</p>
<p>We assembled this program, and extracted the <a href="https://en.wikipedia.org/wiki/Machine_code">machine
code</a> from the <a href="https://en.wikipedia.org/wiki/Object_file">object
file</a>. After this we only had to
convert the machine code to <a href="https://en.wikipedia.org/wiki/ASCII">ASCII</a> and
write a little bit of C to glue everything together. We wanted to use different
formats for each constant in the resulting array, and we wanted to choose the
format randomly. So we wrote a program to choose an appropriate format at
random. The program we wrote for that follows. This program actually also
extracted the machine code from the object file.</p>
<p>NOTE from judges: see <a href="https://github.com/ioccc-src/winner/blob/master/1984/mullender/gentab.c">gentab.c</a> for a copy of this file that can be
compiled in modern systems.</p>
<pre><code> #include <stdio.h>
#include <a.out.h>
main(argc, argv) char **argv;
{
register FILE *fp;
register short pos = 0, c, n;
register char *fmt;
if (argc != 2) {
fprintf (stderr, "Usage: %s file\n", argv[0]);
exit (1);
}
if ((fp = fopen(argv[1], "r")) == NULL) {
fprintf(stderr, "%s: can't open %s\n", argv[0], argv[1]);
exit(2);
}
fseek (fp, (long) sizeof (struct exec), 0);
printf("/* portable between VAX and PDP11 */\n\n");
printf ("short main[] = {\n");
for (;;) {
if (pos == 0)
printf("\t");
c=getc(fp) & 0377;
if (feof(fp)) break;
n = getc(fp) << 8|c;
switch (rand() % 5) {
case 0:
case 1:
fmt = "%d"; break;
case 2:
fmt = "%u"; break;
case 3:
fmt = "0%o"; break;
case 4:
fmt = "0x%x"; break;
}
if (32 <= n && n < 127 && (rand() % 4)) fmt = "'%c'";
printf(n < 8 ? "%d" : fmt, n);
printf(",");
if (pos++ == 8) {
printf("\n");
pos = 0;
}
else printf(" ");
printf("};\n");
}
}</code></pre>
<p>As can be seen, there is a slight preference for
<a href="https://en.wikipedia.org/wiki/Decimal">decimal</a>, and also a character
format is sometimes used, but only if the data is a printable ASCII character.</p>
<p>When we ran this program, we were almost completely satisfied with the result.
The only problem we had was that the program had chosen an
<a href="https://en.wikipedia.org/wiki/Octal">octal</a> representation for the first word.
Since everybody knows what a <a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a>
branch instruction looks like (everyone knows that the traditional magic word
for an executable, <code>0407</code>, is a <a href="https://en.wikipedia.org/wiki/PDP-11">PDP-11</a>
<a href="https://en.wikipedia.org/wiki/Branch_(computer_science)">branch</a>, we changed
that to <a href="https://en.wikipedia.org/wiki/Decimal">decimal</a>. After checking the
size of the resulting program we saw that it was one byte too long. The limit
was 512 bytes, and our program was 513 bytes. So we changed the word <code>and</code> in
the comment to <code>&&</code>.</p>
<!--
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
You are free to share and adapt this file under the terms of this license:
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
For more information, see:
https://creativecommons.org/licenses/by-sa/4.0/
-->
<!-- AFTER: last line of markdown file: 1984/mullender/README.md -->
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
<!-- START: this line starts content generated by: bin/output-index-inventory.sh -->
<div id="inventory">
<h1 id="inventory-for-1984mullender">Inventory for 1984/mullender</h1>
</div>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="https://github.com/ioccc-src/winner/blob/master/1984/mullender/mullender.c">mullender.c</a> - entry source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/1984/mullender/Makefile">Makefile</a> - entry Makefile</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/1984/mullender/mullender.alt.c">mullender.alt.c</a> - alternate source code that works with modern systems</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/1984/mullender/mullender.orig.c">mullender.orig.c</a> - original source code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/1984/mullender/gentab.c">gentab.c</a> - authors’ tool to generate code</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/1984/mullender/a.out.h">a.out.h</a> - gentab.c header file for compatibility with systems in 1984</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a href="1984_mullender.tar.bz2">1984_mullender.tar.bz2</a> - download entry tarball</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/1984/mullender/README.md">README.md</a> - markdown source for this web page</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/1984/mullender/.entry.json">.entry.json</a> - entry summary and manifest in JSON</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/1984/mullender/.gitignore">.gitignore</a> - list of files that should not be committed under git</li>
<li><a href="https://github.com/ioccc-src/winner/blob/master/1984/mullender/.path">.path</a> - directory path from top level directory</li>
<li><a href="index.html">index.html</a> - this web page</li>
</ul>
<hr style="width:10%;text-align:left;margin-left:0">
<h4>
Jump to: <a href="#">top</a>
</h4>
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
<!-- END: this line ends content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
</div>
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/footer.inventory.html -->
<!--
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
You are free to share and adapt this file under the terms of this license:
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
For more information, see:
https://creativecommons.org/licenses/by-sa/4.0/
-->
<div class="footer">
<div id="copyright"><h3>Copyright © 1984-2024 by Landon Curt Noll:
<a href="https://creativecommons.org/faq/#what-does-some-rights-reserved-mean"
target="_blank"
rel="license noopener noreferrer">Some Rights Reserved</a></h3>
<p>
This work is <b>licensed by Landon Curt Noll</b> under
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/?ref=chooser-v1"
target="_blank"
rel="license noopener noreferrer"
style="display:inline-block;">CC BY-SA 4.0</a></b>.
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
src="../../png/cc.png"
alt="cc inside circle symbol">
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
src="../../png/by.png"
alt="person inside circle symbol">
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
src="../../png/sa.png"
alt="arrow looping back on itself inside circle symbol"><br>
You should <b>carefully review</b> the
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode.en"
target="_blank"
rel="license noopener noreferrer">CC BY-SA 4.0 LEGAL CODE</a></b>
before using the licensed material.<br>
You may wish to review the
<b><a href="../../license.html"
target="_blank"
rel="license noopener noreferrer">highlights of some of the key features and terms</a></b>
of <b>CC BY-SA 4.0</b>.<br>
</p>
</div>
<div id="coda"><h3>Coda</h3>
<p>
<a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.ioccc.org%2F1984%2Fmullender%2Findex.html" rel="nofollow">Nu HTML check this web page</a><br>
<a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a><br>
</p>
</div>
</div>
<!-- END: this line ends content from: inc/footer.inventory.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->