-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstartup.shtml
1508 lines (1508 loc) · 196 KB
/
startup.shtml
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
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252"><meta name="viewport" content="width=device-width"><title>https://iulg.sitehost.iu.edu/trm/startup.shtml</title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span>
<span id="line2"></span></span><span class="error doctype" title="Quirky doctype. Expected “<!DOCTYPE html>”."><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"></span><span>
<span id="line3"></span></span><span><<span class="start-tag">html</span>></span><span>
<span id="line4"></span></span><span><<span class="start-tag">font</span> <span class="attribute-name">face</span>="<a class="attribute-value">Verdana</a>"></span><span>
<span id="line5"></span></span><span class="error" title="Stray start tag “head”."><<span class="start-tag">head</span>></span><span>
<span id="line6"></span></span><span><<span class="start-tag">TITLE</span>></span><span>Getting Started with 1#</span><span></<span class="end-tag">TITLE</span>></span><span>
<span id="line7"></span></span><span><<span class="start-tag">META</span> <span class="attribute-name">content</span>=<a class="attribute-value">noindex,nofollow</a> <span class="attribute-name">name</span>=<a class="attribute-value">robots</a>></span><span>
<span id="line8"></span></span><span><<span class="start-tag">meta</span> <span class="attribute-name">http-equiv</span>="<a class="attribute-value">Content-Type</a>" <span class="attribute-name">content</span>="<a class="attribute-value">text/html; charset=iso-8859-1</a>"></span><span>
<span id="line9"></span></span><span><<span class="start-tag">link</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/iubdep.css">iubdep.css</a>" <span class="attribute-name">rel</span>="<a class="attribute-value">stylesheet</a>" <span class="attribute-name">type</span>="<a class="attribute-value">text/css</a>"></span><span>
<span id="line10"></span></span><span><<span class="start-tag">META</span> <span class="attribute-name">content</span>="<a class="attribute-value">
<span id="line11"></span><span class="entity"><span>&</span>#10;</span>homepage.
<span id="line12"></span>You will find information on text register machines
<span id="line13"></span>and the language 1#.</a>" <span class="attribute-name">name</span>=<a class="attribute-value">description</a>></span><span>
<span id="line14"></span></span><span><<span class="start-tag">META</span> <span class="attribute-name">content</span>="<a class="attribute-value">Text Register Machines, 1#</a>" <span class="attribute-name">name</span>=<a class="attribute-value">keywords</a>></span><span>
<span id="line15"></span></span><span class="error" title="Stray end tag “head”."></<span class="end-tag">head</span>></span><span>
<span id="line16"></span></span><span class="error" title="Start tag “body” seen but an element of the same type was already open."><<span class="start-tag">body</span> <span class="attribute-name">background</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/bg.jpg">bg.jpg</a>"></span><span>
<span id="line17"></span></span><span class="comment"><!--header start--></span><span>
<span id="line18"></span> </span><span><<span class="start-tag">script</span> <span class="attribute-name">language</span>="<a class="attribute-value">JavaScript</a>"></span><span>
<span id="line19"></span></span><span><!</span><span>--
<span id="line20"></span>function reloadPage(init) { //reloads the window if Nav4 resized
<span id="line21"></span> if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
<span id="line22"></span> document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; }}
<span id="line23"></span> else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
<span id="line24"></span>}
<span id="line25"></span>reloadPage(true);
<span id="line26"></span>// -->
<span id="line27"></span></span><span></<span class="end-tag">script</span>></span><span>
<span id="line28"></span> </span><span class="comment"><!--
<span id="line29"></span><div class="homeheadpos">
<span id="line30"></span>--></span><span>
<span id="line31"></span>
<span id="line32"></span> </span><span><<span class="start-tag">table</span> <span class="attribute-name">width</span>="<a class="attribute-value">800</a>" <span class="attribute-name">border</span>="<a class="attribute-value">0</a>" <span class="attribute-name">cellspacing</span>="<a class="attribute-value">0</a>" <span class="attribute-name">cellpadding</span>="<a class="attribute-value">0</a>"></span><span>
<span id="line33"></span> </span><span><<span class="start-tag">tr</span>></span><span>
<span id="line34"></span> </span><span><<span class="start-tag">td</span> <span class="attribute-name">width</span>="<a class="attribute-value">150</a>" <span class="attribute-name">valign</span>="<a class="attribute-value">top</a>"></span><span></span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/index.shtml">index.shtml</a>"></span><span></span><span><<span class="start-tag">img</span> <span class="attribute-name">src</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/harp.jpg">harp.jpg</a>" <span class="attribute-name">alt</span>="<a class="attribute-value">IU Relief</a>" <span class="attribute-name">width</span>="<a class="attribute-value">150</a>" <span class="attribute-name">height</span>="<a class="attribute-value">165</a>" <span class="attribute-name">border</span>="<a class="attribute-value">0</a>"></span><span></span><span></<span class="end-tag">a</span>></span><span></span><span></<span class="end-tag">td</span>></span><span>
<span id="line35"></span> </span><span><<span class="start-tag">td</span> <span class="attribute-name">width</span>="<a class="attribute-value">100%</a>" <span class="attribute-name">valign</span>="<a class="attribute-value">top</a>"></span><span>
<span id="line36"></span>
<span id="line37"></span> </span><span><<span class="start-tag">table</span> <span class="attribute-name">width</span>="<a class="attribute-value">100%</a>" <span class="attribute-name">border</span>="<a class="attribute-value">0</a>" <span class="attribute-name">cellspacing</span>="<a class="attribute-value">0</a>" <span class="attribute-name">cellpadding</span>="<a class="attribute-value">0</a>"></span><span>
<span id="line38"></span> </span><span><<span class="start-tag">tr</span>></span><span>
<span id="line39"></span> </span><span><<span class="start-tag">td</span>></span><span> </span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/startup.shtml#SkipNavigation">#SkipNavigation</a>"></span><span></span><span><<span class="start-tag">img</span> <span class="attribute-name">src</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/spacer.gif">spacer.gif</a>" <span class="attribute-name">width</span>="<a class="attribute-value">1</a>" <span class="attribute-name">height</span>="<a class="attribute-value">28</a>" <span class="attribute-name">alt</span>="<a class="attribute-value">Skip Navigation</a>" <span class="attribute-name">border</span>="<a class="attribute-value">0</a>"></span><span></span><span></<span class="end-tag">a</span>></span><span></span><span></<span class="end-tag">td</span>></span><span>
<span id="line40"></span> </span><span></<span class="end-tag">tr</span>></span><span>
<span id="line41"></span> </span><span><<span class="start-tag">tr</span>></span><span>
<span id="line42"></span> </span><span><<span class="start-tag">td</span> <span class="attribute-name">bgcolor</span>="<a class="attribute-value">#990000</a>"></span><span></span><span><<span class="start-tag">div</span> <span class="attribute-name">align</span>="<a class="attribute-value">center</a>"></span><span></span><span><<span class="start-tag">img</span> <span class="attribute-name">src</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/spacer.gif">spacer.gif</a>" <span class="attribute-name">alt</span>="<a class="attribute-value">1#: A Text Register Introduction to Computability Theory</a>" <span class="attribute-name">width</span>="<a class="attribute-value">471</a>" <span class="attribute-name">height</span>="<a class="attribute-value">72</a>" <span class="attribute-name">border</span>="<a class="attribute-value">0</a>"></span><span></span><span></<span class="end-tag">div</span>></span><span></span><span></<span class="end-tag">td</span>></span><span>
<span id="line43"></span> </span><span></<span class="end-tag">tr</span>></span><span>
<span id="line44"></span> </span><span><<span class="start-tag">tr</span>></span><span>
<span id="line45"></span> </span><span><<span class="start-tag">td</span>></span><span></span><span><<span class="start-tag">img</span> <span class="attribute-name">src</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/spacer.gif">spacer.gif</a>" <span class="attribute-name">width</span>="<a class="attribute-value">1</a>" <span class="attribute-name">height</span>="<a class="attribute-value">31</a>" <span class="attribute-name">alt</span>="<a class="attribute-value"></a>" <span class="attribute-name">border</span>="<a class="attribute-value">0</a>"></span><span></span><span></<span class="end-tag">td</span>></span><span>
<span id="line46"></span> </span><span></<span class="end-tag">tr</span>></span><span>
<span id="line47"></span> </span><span></<span class="end-tag">table</span>></span><span>
<span id="line48"></span>
<span id="line49"></span> </span><span></<span class="end-tag">td</span>></span><span>
<span id="line50"></span> </span><span></<span class="end-tag">tr</span>></span><span>
<span id="line51"></span> </span><span></<span class="end-tag">table</span>></span><span>
<span id="line52"></span>
<span id="line53"></span>
<span id="line54"></span>
<span id="line55"></span>
<span id="line56"></span></span><span class="comment"><!--header end--></span><span>
<span id="line57"></span></span><span><<span class="start-tag">table</span> <span class="attribute-name">width</span>=<a class="attribute-value">800</a> <span class="attribute-name">border</span>="<a class="attribute-value">0</a>" <span class="attribute-name">cellpadding</span>="<a class="attribute-value">0</a>" <span class="attribute-name">cellspacing</span>="<a class="attribute-value">0</a>" <span class="attribute-name">align</span>="<a class="attribute-value">left</a>"></span><span>
<span id="line58"></span> </span><span><<span class="start-tag">tr</span>></span><span>
<span id="line59"></span> </span><span><<span class="start-tag">td</span> <span class="attribute-name">width</span>="<a class="attribute-value">150</a>" <span class="attribute-name">rowspan</span>="<a class="attribute-value">2</a>" <span class="attribute-name">valign</span>="<a class="attribute-value">top</a>"></span><span> </span><span><<span class="start-tag">table</span> <span class="attribute-name">width</span>="<a class="attribute-value">149</a>" <span class="attribute-name">border</span>="<a class="attribute-value">0</a>" <span class="attribute-name">cellpadding</span>="<a class="attribute-value">0</a>" <span class="attribute-name">cellspacing</span>="<a class="attribute-value">0</a>"></span><span>
<span id="line60"></span> </span><span><<span class="start-tag">tr</span>></span><span>
<span id="line61"></span> </span><span><<span class="start-tag">td</span> <span class="attribute-name">width</span>="<a class="attribute-value">149</a>"></span><span>
<span id="line62"></span>
<span id="line63"></span>
<span id="line64"></span> </span><span class="error" title="Stray start tag “head”."><<span class="start-tag">head</span>></span><span>
<span id="line65"></span></span><span><<span class="start-tag">SCRIPT</span> <span class="attribute-name">TYPE</span>="<a class="attribute-value">text/javascript</a>"></span><span>
<span id="line66"></span></span><span><!</span><span>--
<span id="line67"></span>function popup(mylink, windowname)
<span id="line68"></span>{
<span id="line69"></span>if (! window.focus)return true;
<span id="line70"></span>var href;
<span id="line71"></span>if (typeof(mylink) == 'string')
<span id="line72"></span> href=mylink;
<span id="line73"></span>else
<span id="line74"></span> href=mylink.href;
<span id="line75"></span>window.open(href, windowname,
<span id="line76"></span>'width=700,height=380,scrollbars=no');
<span id="line77"></span>return false;
<span id="line78"></span>}
<span id="line79"></span>//-->
<span id="line80"></span></span><span></<span class="end-tag">SCRIPT</span>></span><span>
<span id="line81"></span></span><span class="error" title="Stray end tag “head”."></<span class="end-tag">head</span>></span><span>
<span id="line82"></span>
<span id="line83"></span>
<span id="line84"></span>
<span id="line85"></span></span><span><<span class="start-tag">table</span> <span class="attribute-name">width</span>="<a class="attribute-value">165</a>" <span class="attribute-name">border</span>="<a class="attribute-value">0</a>" <span class="attribute-name">cellpadding</span>="<a class="attribute-value">0</a>" <span class="attribute-name">cellspacing</span>="<a class="attribute-value">0</a>"></span><span>
<span id="line86"></span> </span><span><<span class="start-tag">tr</span>></span><span>
<span id="line87"></span>
<span id="line88"></span> </span><span class="error" title="Start tag “p” seen in “table”."><<span class="start-tag">P</span>></span><span>
<span id="line89"></span> </span><span><<span class="start-tag">tr</span>></span><span>
<span id="line90"></span> </span><span><<span class="start-tag">td</span>></span><span></span><span><<span class="start-tag">img</span> <span class="attribute-name">src</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/spacer.gif">spacer.gif</a>" <span class="attribute-name">alt</span>="<a class="attribute-value"></a>" <span class="attribute-name">height</span>="<a class="attribute-value">10</a>" <span class="attribute-name">width</span>="<a class="attribute-value">10</a>"></span><span></span><span></<span class="end-tag">td</span>></span><span>
<span id="line91"></span> </span><span><<span class="start-tag">td</span>></span><span>
<span id="line92"></span>
<span id="line93"></span> </span><span><<span class="start-tag">td</span>></span><span></span><span><<span class="start-tag">img</span> <span class="attribute-name">src</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/spacer.gif">spacer.gif</a>" <span class="attribute-name">alt</span>="<a class="attribute-value"></a>" <span class="attribute-name">height</span>="<a class="attribute-value">1</a>" <span class="attribute-name">width</span>="<a class="attribute-value">10</a>"></span><span></span><span></<span class="end-tag">td</span>></span><span>
<span id="line94"></span> </span><span><<span class="start-tag">td</span> <span class="attribute-name">valign</span>="<a class="attribute-value">top</a>"></span><span>
<span id="line95"></span>
<span id="line96"></span>
<span id="line97"></span></span><span class="comment"><!--left navigation bar--></span><span>
<span id="line98"></span>
<span id="line99"></span>
<span id="line100"></span> </span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span> </span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/index.shtml">index.shtml</a>"
<span id="line101"></span><span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span>1# Home</span><span></<span class="end-tag">a</span>></span><span> </span><span></<span class="end-tag">div</span>></span><span>
<span id="line102"></span>
<span id="line103"></span>
<span id="line104"></span></span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">leftnavhr</a>"></span><span></span><span><<span class="start-tag">img</span> <span class="attribute-name">src</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/iured.gif">iured.gif</a>" <span class="attribute-name">alt</span>="<a class="attribute-value">red horizontal line</a>" <span class="attribute-name">width</span>="<a class="attribute-value">110</a>" <span class="attribute-name">height</span>="<a class="attribute-value">2</a>"></span><span></span><span></<span class="end-tag">div</span>></span><span>
<span id="line105"></span></span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">nav</a>"></span><span>Lessons</span><span></<span class="end-tag">div</span>></span><span>
<span id="line106"></span></span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span></span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/startup.shtml">startup.shtml</a>" <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span>Getting Started</span><span></<span class="end-tag">a</span>></span><span></span><span></<span class="end-tag">div</span>></span><span>
<span id="line107"></span></span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span></span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/arith.shtml">arith.shtml</a>" <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span>Arithmetic</span><span></<span class="end-tag">a</span>></span><span></span><span></<span class="end-tag">div</span>></span><span>
<span id="line108"></span></span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span></span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/programs.shtml">programs.shtml</a>" <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span>Programs for Programs</span><span></<span class="end-tag">a</span>></span><span></span><span></<span class="end-tag">div</span>></span><span>
<span id="line109"></span></span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span></span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/self.shtml">self.shtml</a>" <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span>Self-Replication</span><span></<span class="end-tag">a</span>></span><span></span><span></<span class="end-tag">div</span>></span><span>
<span id="line110"></span></span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span></span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/recursion.shtml">recursion.shtml</a>" <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span>Recursion Theorems</span><span></<span class="end-tag">a</span>></span><span></span><span></<span class="end-tag">div</span>></span><span>
<span id="line111"></span></span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span></span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/universal.shtml">universal.shtml</a>" <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span>Universal Programs</span><span></<span class="end-tag">a</span>></span><span></span><span></<span class="end-tag">div</span>></span><span>
<span id="line112"></span>
<span id="line113"></span></span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">leftnavhr</a>"></span><span></span><span><<span class="start-tag">img</span> <span class="attribute-name">src</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/iured.gif">iured.gif</a>" <span class="attribute-name">alt</span>="<a class="attribute-value">red horizontal line</a>" <span class="attribute-name">width</span>="<a class="attribute-value">110</a>" <span class="attribute-name">height</span>="<a class="attribute-value">2</a>"></span><span></span><span></<span class="end-tag">div</span>></span><span>
<span id="line114"></span>
<span id="line115"></span></span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">leftnavhr</a>"></span><span></span><span><<span class="start-tag">img</span> <span class="attribute-name">src</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/img/iured.gif">img/iured.gif</a>" <span class="attribute-name">alt</span>="<a class="attribute-value">red horizontal line</a>"
<span id="line116"></span><span class="attribute-name">width</span>="<a class="attribute-value">110</a>" <span class="attribute-name">height</span>="<a class="attribute-value">2</a>"></span><span></span><span></<span class="end-tag">div</span>></span><span>
<span id="line117"></span>
<span id="line118"></span>
<span id="line119"></span> </span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span>
<span id="line120"></span></span><span><<span class="start-tag">A</span>
<span id="line121"></span> <span class="attribute-name">HREF</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/nutshell.shtml">nutshell.shtml</a>" <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"
<span id="line122"></span> <span class="attribute-name">onClick</span>="<a class="attribute-value">return popup(this, 'nutshell')</a>"></span><span>1# in a nutshell</span><span></<span class="end-tag">A</span>></span><span>
<span id="line123"></span> </span><span></<span class="end-tag">div</span>></span><span>
<span id="line124"></span>
<span id="line125"></span> </span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span> </span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/progindex.shtml">progindex.shtml</a>"
<span id="line126"></span><span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span>Index of Programs</span><span></<span class="end-tag">a</span>></span><span> </span><span></<span class="end-tag">div</span>></span><span>
<span id="line127"></span>
<span id="line128"></span> </span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span> </span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/terms.shtml">terms.shtml</a>"
<span id="line129"></span><span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span>Definitions of Terms</span><span></<span class="end-tag">a</span>></span><span> </span><span></<span class="end-tag">div</span>></span><span>
<span id="line130"></span>
<span id="line131"></span> </span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span> </span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/credits.shtml">credits.shtml</a>"
<span id="line132"></span><span class="attribute-name">class</span>="<a class="attribute-value">navsmall</a>"></span><span>Credits</span><span></<span class="end-tag">a</span>></span><span> </span><span></<span class="end-tag">div</span>></span><span>
<span id="line133"></span>
<span id="line134"></span>
<span id="line135"></span></span><span class="comment"><!--end of left navigation bar--></span><span>
<span id="line136"></span>
<span id="line137"></span></span><span class="comment"><!-- <div class="leftnavhr"> <img src="img/iured.gif" alt="" width="110" height="2"></div>
<span id="line138"></span>
<span id="line139"></span> <div class="nav">Optional Heading2</a></div>
<span id="line140"></span> <div class="navsmall"><a href="#" class="navsmall">Page4</a></div>
<span id="line141"></span> <div class="navsmall"> <a href="#" class="navsmall">Page5</a> </div>
<span id="line142"></span>
<span id="line143"></span> <div class="leftnavhr"> <img src="iured.gif" alt=" "
<span id="line144"></span>width="110" height="2"></div>
<span id="line145"></span>
<span id="line146"></span> <div class="navsmall"><a href="./" class="navsmall">Department Home</a></div>
<span id="line147"></span>
<span id="line148"></span>
<span id="line149"></span> <a name="SkipNavigation" tabindex="1"></a>
<span id="line150"></span>
<span id="line151"></span>
<span id="line152"></span>
<span id="line153"></span> </td>
<span id="line154"></span>--></span><span>
<span id="line155"></span>
<span id="line156"></span>
<span id="line157"></span> </span><span><<span class="start-tag">td</span>></span><span></span><span><<span class="start-tag">img</span> <span class="attribute-name">src</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/img/spacer.gif">img/spacer.gif</a>" <span class="attribute-name">alt</span>="<a class="attribute-value"></a>" <span class="attribute-name">height</span>="<a class="attribute-value">1</a>" <span class="attribute-name">width</span>="<a class="attribute-value">20</a>"></span><span></span><span></<span class="end-tag">td</span>></span><span>
<span id="line158"></span> </span><span></<span class="end-tag">tr</span>></span><span>
<span id="line159"></span></span><span></<span class="end-tag">table</span>></span><span>
<span id="line160"></span></span><span><<span class="start-tag">IMG</span> <span class="attribute-name">ALIGN</span> = <a class="attribute-value">middle</a> <span class="attribute-name">SRC</span> = <a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/cello.jpg">cello.jpg</a> <span class="attribute-name">width</span>=<a class="attribute-value">150</a> <span class="attribute-name">height</span>=<a class="attribute-value">150</a> <span class="attribute-name">border</span>=<a class="attribute-value">0</a>></span><span>
<span id="line161"></span>
<span id="line162"></span>
<span id="line163"></span>
<span id="line164"></span> </span><span></<span class="end-tag">td</span>></span><span>
<span id="line165"></span> </span><span></<span class="end-tag">tr</span>></span><span>
<span id="line166"></span> </span><span></<span class="end-tag">table</span>></span><span></span><span></<span class="end-tag">td</span>></span><span>
<span id="line167"></span> </span><span><<span class="start-tag">td</span> <span class="attribute-name">width</span>="<a class="attribute-value">90%</a>" <span class="attribute-name">colspan</span>="<a class="attribute-value">2</a>" <span class="attribute-name">rowspan</span>="<a class="attribute-value">2</a>" <span class="attribute-name">valign</span>="<a class="attribute-value">top</a>"></span><span>
<span id="line168"></span>
<span id="line169"></span> </span><span class="comment"><!-- main body --></span><span>
<span id="line170"></span>
<span id="line171"></span>
<span id="line172"></span>
<span id="line173"></span></span><span><<span class="start-tag">center</span>></span><span>
<span id="line174"></span> </span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">depnamebig</a>"></span><span>
<span id="line175"></span> Getting Started with 1#</span><span></<span class="end-tag">div</span>></span><span>
<span id="line176"></span></span><span><<span class="start-tag">P</span>></span><span>
<span id="line177"></span>
<span id="line178"></span>
<span id="line179"></span>
<span id="line180"></span>
<span id="line181"></span></span><span><<span class="start-tag">table</span> <span class="attribute-name">cellpadding</span>="<a class="attribute-value">0</a>" <span class="attribute-name">cellspacing</span>="<a class="attribute-value">0</a>" <span class="attribute-name">ALIGN</span>="<a class="attribute-value">TOP</a>" ></span><span>
<span id="line182"></span> </span><span><<span class="start-tag">tr</span>></span><span></span><span><<span class="start-tag">td</span>></span><span>
<span id="line183"></span> </span><span><<span class="start-tag">img</span> <span class="attribute-name">width</span>=<a class="attribute-value">300</a> <span class="attribute-name">height</span>=<a class="attribute-value">300</a> <span class="attribute-name">src</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/pianotrumpet.jpg">pianotrumpet.jpg</a>"></span><span>
<span id="line184"></span> </span><span></<span class="end-tag">td</span>></span><span>
<span id="line185"></span> </span><span><<span class="start-tag">td</span>></span><span>
<span id="line186"></span> </span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">height</span>=<a class="attribute-value">300</a> ></span><span>
<span id="line187"></span></span><span><<span class="start-tag">TR</span>></span><span>
<span id="line188"></span></span><span><<span class="start-tag">TD</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">TOP</a>"
<span id="line189"></span><span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span></span><span><<span class="start-tag">A</span> <span class="attribute-name">HREF</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/startup.shtml">startup.shtml</a>"></span><span>LESSON One</span><span></<span class="end-tag">A</span>></span><span></span><span><<span class="start-tag">BR</span>></span><span>
<span id="line190"></span></span><span><<span class="start-tag">BR</span>></span><span></span><span><<span class="start-tag">P</span>></span><span></span><span><<span class="start-tag">BR</span>></span><span>
<span id="line191"></span></span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/startup.shtml#running">#running</a>"></span><span>Using the interpreter</span><span></<span class="end-tag">A</span>></span><span>
<span id="line192"></span></span><span><<span class="start-tag">BR</span>></span><span></span><span><<span class="start-tag">P</span>></span><span></span><span><<span class="start-tag">BR</span>></span><span>
<span id="line193"></span></span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/startup.shtml#adding">#adding</a>"></span><span>The 1# instruction set</span><span class="error" title="Start tag “a” seen but an element of the same type was already open."><<span class="start-tag">A</span>></span><span>
<span id="line194"></span></span><span><<span class="start-tag">BR</span>></span><span></span><span class="error" title="End tag “p” implied, but there were open elements."><<span class="start-tag">P</span>></span><span></span><span><<span class="start-tag">BR</span>></span><span>
<span id="line195"></span></span><span class="error" title="Start tag “a” seen but an element of the same type was already open."><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/startup.shtml#moving">#moving</a>"></span><span>Programs to move registers</span><span></<span class="end-tag">A</span>></span><span>
<span id="line196"></span></span><span><<span class="start-tag">BR</span>></span><span></span><span><<span class="start-tag">P</span>></span><span></span><span><<span class="start-tag">BR</span>></span><span>
<span id="line197"></span></span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/startup.shtml#copy">#copy</a>"></span><span>Programs to copy registers</span><span></<span class="end-tag">A</span>></span><span>
<span id="line198"></span></span><span><<span class="start-tag">BR</span>></span><span></span><span><<span class="start-tag">P</span>></span><span></span><span><<span class="start-tag">BR</span>></span><span>
<span id="line199"></span></span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/startup.shtml#functions">#functions</a>"></span><span>Functions defined by programs</span><span></<span class="end-tag">A</span>></span><span>
<span id="line200"></span></span><span><<span class="start-tag">BR</span>></span><span></span><span><<span class="start-tag">P</span>></span><span></span><span><<span class="start-tag">BR</span>></span><span>
<span id="line201"></span></span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/startup.shtml#full">#full</a>"></span><span>The full 1# instruction set</span><span></<span class="end-tag">A</span>></span><span>
<span id="line202"></span></span><span></<span class="end-tag">TABLE</span>></span><span></span><span class="error" title="Stray end tag “h3”."></<span class="end-tag">H3</span>></span><span>
<span id="line203"></span> </span><span></<span class="end-tag">td</span>></span><span>
<span id="line204"></span> </span><span></<span class="end-tag">tr</span>></span><span>
<span id="line205"></span></span><span class="error error" title="Stray end tag “center”.
Stray end tag “center”."></<span class="end-tag">center</span>></span><span>
<span id="line206"></span></span><span></<span class="end-tag">table</span>></span><span>
<span id="line207"></span></span><span></<span class="end-tag">center</span>></span><span>
<span id="line208"></span>
<span id="line209"></span>
<span id="line210"></span>
<span id="line211"></span>
<span id="line212"></span> </span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">depname</a>"></span><span> Welcome</span><span></<span class="end-tag">div</span>></span><span>
<span id="line213"></span>
<span id="line214"></span></span><span><<span class="start-tag">BR</span>></span><span>
<span id="line215"></span>Welcome to our first tutorial lesson on 1#.
<span id="line216"></span>You will learn the basics of the language here and also see some
<span id="line217"></span>small programs.
<span id="line218"></span>
<span id="line219"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line220"></span>It is not absolutely necessary to have the intepreter open
<span id="line221"></span>as you work through this lesson. But it probably will help.
<span id="line222"></span>If you do not have an interpreter, you should begin with
<span id="line223"></span></span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/startup.shtml#adding">#adding</a>"></span><span>the 1# instruction set</span><span class="error" title="Start tag “a” seen but an element of the same type was already open."><<span class="start-tag">A</span>></span><span>.
<span id="line224"></span>Those with an interpreter will enjoy the section on
<span id="line225"></span></span><span class="error" title="Start tag “a” seen but an element of the same type was already open."><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/startup.shtml#running">#running</a>"></span><span>using the interpreter</span><span></<span class="end-tag">A</span>></span><span>.
<span id="line226"></span>
<span id="line227"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line228"></span>This lesson is written on a lower level than the lessons which
<span id="line229"></span>come after it. The only abstract concept comes at the end,
<span id="line230"></span>as does the only
<span id="line231"></span>and mathematical notation. The rest of the lesson is a concrete
<span id="line232"></span>introduction to 1#.
<span id="line233"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line234"></span>If you are familiar with any machine model in the theory
<span id="line235"></span>of computations, such as Turing Machines, or classical register machines,
<span id="line236"></span>you probably will want to skim through this lesson quickly.
<span id="line237"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line238"></span>But this introductory lesson is really intended for people with
<span id="line239"></span>no background on these matters. If this is you, please
<span id="line240"></span>work slowly, doing the exercises as you go.
<span id="line241"></span>
<span id="line242"></span>
<span id="line243"></span></span><span><<span class="start-tag">hr</span>></span><span>
<span id="line244"></span>
<span id="line245"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line246"></span> </span><span><<span class="start-tag">img</span> <span class="attribute-name">width</span>=<a class="attribute-value">200</a> <span class="attribute-name">height</span>=<a class="attribute-value">200</a> <span class="attribute-name">src</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/drum.jpg">drum.jpg</a>"></span><span>
<span id="line247"></span> </span><span><<span class="start-tag">br</span>></span><span>
<span id="line248"></span>
<span id="line249"></span></span><span><<span class="start-tag">a</span> <span class="attribute-name">name</span>="<a class="attribute-value">running</a>"></span><span></span><span></<span class="end-tag">a</span>></span><span>
<span id="line250"></span>
<span id="line251"></span>
<span id="line252"></span></span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">depname</a>"></span><span>Using the interpreter</span><span></<span class="end-tag">div</span>></span><span>
<span id="line253"></span>
<span id="line254"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line255"></span>Please copy the following program of 1# into the
<span id="line256"></span>program window in the middle of the interpreter.
<span id="line257"></span></span><span><<span class="start-tag">CENTER</span>></span><span>
<span id="line258"></span></span><span><<span class="start-tag">TABLE</span>></span><span>
<span id="line259"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line260"></span></span><span><<span class="start-tag">td</span>></span><span>11#####111111###111###1##1111####1#111111####</span><span></<span class="end-tag">td</span>></span><span></span><span></<span class="end-tag">TR</span>></span><span>
<span id="line261"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line262"></span></span><span></<span class="end-tag">CENTER</span>></span><span>
<span id="line263"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line264"></span>A note on copying from the web page (or from text files)
<span id="line265"></span>to the interpreter: With most current browsers, you should
<span id="line266"></span>be able to copy and paste as usual. For other browsers,
<span id="line267"></span>things are harder. For example, using Safari, one would
<span id="line268"></span>highlight the area to be copied, click on it, hold down the
<span id="line269"></span>clicker and then drag the image to the 1# Interpreter.
<span id="line270"></span>I would be interested to hear of others' experiences with
<span id="line271"></span>copying to the interpreter.
<span id="line272"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line273"></span>Now enter some words in the input registers on the left.
<span id="line274"></span>At first, it will be best to only enter words in the first two registers,
<span id="line275"></span> R1 and R2. You must enter words composed of the symbols 1 and #,
<span id="line276"></span>such as 11###11#1 and #1###1###111#11.
<span id="line277"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line278"></span>Next, run your program by clicking on one of the two buttons at the
<span id="line279"></span>bottom. You can either run the interpreter in fast or slow mode.
<span id="line280"></span>You should try out the two buttons to be able to tell which is
<span id="line281"></span>which, and also you should try running the program very slowly
<span id="line282"></span>by moving the indicator on the bottom right corner and by clicking
<span id="line283"></span>the middle button of the three control buttons at the bottom.
<span id="line284"></span>
<span id="line285"></span>
<span id="line286"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line287"></span>You should then clear the input and output registers,
<span id="line288"></span>and then enter some new words in R1 and R2.
<span id="line289"></span>You might now enter some words in R3, R4, etc. to see what difference
<span id="line290"></span>(if any) they make.
<span id="line291"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line292"></span>
<span id="line293"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line294"></span>What you should find after doing this is that the output in R1
<span id="line295"></span>at the end is the input in R1 followed by the input in R2.
<span id="line296"></span>And as a result of the same computation, R2 is emptied out.
<span id="line297"></span>We usually will say </span><span><<span class="start-tag">i</span>></span><span>concatenated</span><span></<span class="end-tag">i</span>></span><span> instead of
<span id="line298"></span></span><span><<span class="start-tag">i</span>></span><span>followed by.</span><span></<span class="end-tag">i</span>></span><span>
<span id="line299"></span>
<span id="line300"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line301"></span>The overall point is that the program
<span id="line302"></span>11#####111111###111###1##1111####1#111111####
<span id="line303"></span>may be run on words which are input in the registers.
<span id="line304"></span>This program does not change when we run it, but the
<span id="line305"></span>contents of the registers does change. Our first
<span id="line306"></span>order of business is to understand programs like the one we've just seen.
<span id="line307"></span>It turns out that this program is composed of seven
<span id="line308"></span></span><span><<span class="start-tag">i</span>></span><span>instructions.</span><span></<span class="end-tag">i</span>></span><span> We'll get to the instructions soon,
<span id="line309"></span>but first we have an exercise for you to try.
<span id="line310"></span>
<span id="line311"></span>
<span id="line312"></span></span><span><<span class="start-tag">H3</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">LEFT</a>"></span><span>
<span id="line313"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span>="<a class="attribute-value">3</a>" <span class="attribute-name">CELLPADDING</span>="<a class="attribute-value">3</a>" <span class="attribute-name">width</span>="<a class="attribute-value">100%</a>"></span><span>
<span id="line314"></span></span><span><<span class="start-tag">TR</span>></span><span>
<span id="line315"></span></span><span><<span class="start-tag">TD</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">Left</a>" <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#99FF99</a>"></span><span>
<span id="line316"></span></span><span><<span class="start-tag">strong</span>></span><span>Exercise 1</span><span></<span class="end-tag">strong</span>></span><span>
<span id="line317"></span>Here is another 1# program. It takes its input from the first
<span id="line318"></span>two registers. Enter some words in R1 and R2 input boxes,
<span id="line319"></span>and then run the program. Your job is to try to figure out what
<span id="line320"></span>the program does.
<span id="line321"></span></span><span><<span class="start-tag">Br</span>></span><span>
<span id="line322"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line323"></span></span><span><<span class="start-tag">CENTER</span>></span><span>
<span id="line324"></span></span><span><<span class="start-tag">TABLE</span>></span><span>
<span id="line325"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line326"></span></span><span><<span class="start-tag">td</span>></span><span>
<span id="line327"></span>1##### 11111111### 1111### 111## 1111## 11111#### 111# 1111# 11111111####
<span id="line328"></span>111##### 111111### 111### 1## 1111#### 1# 111111####
<span id="line329"></span>1111##### 111111### 111### 1## 1111#### 1# 111111####
<span id="line330"></span>11##### 111111### 111### 1## 1111#### 1#
<span id="line331"></span> 111111####
<span id="line332"></span></span><span></<span class="end-tag">td</span>></span><span></span><span></<span class="end-tag">TR</span>></span><span>
<span id="line333"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line334"></span></span><span></<span class="end-tag">CENTER</span>></span><span>
<span id="line335"></span></span><span></<span class="end-tag">table</span>></span><span>
<span id="line336"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line337"></span>
<span id="line338"></span>
<span id="line339"></span>
<span id="line340"></span>
<span id="line341"></span>
<span id="line342"></span>
<span id="line343"></span>
<span id="line344"></span></span><span><<span class="start-tag">hr</span>></span><span>
<span id="line345"></span>
<span id="line346"></span>
<span id="line347"></span>
<span id="line348"></span>
<span id="line349"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line350"></span> </span><span><<span class="start-tag">img</span> <span class="attribute-name">width</span>=<a class="attribute-value">200</a> <span class="attribute-name">height</span>=<a class="attribute-value">200</a> <span class="attribute-name">src</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/drum.jpg">drum.jpg</a>"></span><span>
<span id="line351"></span> </span><span><<span class="start-tag">br</span>></span><span>
<span id="line352"></span>
<span id="line353"></span></span><span><<span class="start-tag">a</span> <span class="attribute-name">name</span>="<a class="attribute-value">adding</a>"></span><span></span><span></<span class="end-tag">a</span>></span><span>
<span id="line354"></span>
<span id="line355"></span></span><span class="error" title="Heading cannot be a child of another heading."><<span class="start-tag">h3</span>></span><span>
<span id="line356"></span> </span><span><<span class="start-tag">div</span> <span class="attribute-name">class</span>="<a class="attribute-value">depname</a>"></span><span>
<span id="line357"></span> The 1# instruction set</span><span></<span class="end-tag">div</span>></span><span>
<span id="line358"></span></span><span></<span class="end-tag">h3</span>></span><span>
<span id="line359"></span>
<span id="line360"></span>
<span id="line361"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line362"></span>So far, we have seen two programs of 1#. Programs are composed of
<span id="line363"></span></span><span><<span class="start-tag">i</span>></span><span>instructions</span><span></<span class="end-tag">i</span>></span><span>. In fact, programs are just sequences of instructions.
<span id="line364"></span>The instructions could be written on separate lines, but they could
<span id="line365"></span>also simply be run together to form a long word. At this point,
<span id="line366"></span>we want to look at the five types of 1# instructions.
<span id="line367"></span>
<span id="line368"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line369"></span>We begin our journey with the first two types of instructions
<span id="line370"></span>of the language.
<span id="line371"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line372"></span></span><span><<span class="start-tag">CENTER</span>></span><span>
<span id="line373"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">width</span>=<a class="attribute-value">75%</a>></span><span>
<span id="line374"></span></span><span class="error" title="“td” start tag in table body."><<span class="start-tag">td</span>></span><span>
<span id="line375"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span> ></span><span>
<span id="line376"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line377"></span> </span><span><<span class="start-tag">TH</span>></span><span>Instruction</span><span></<span class="end-tag">TH</span>></span><span> </span><span><<span class="start-tag">TH</span>></span><span>Meaning</span><span></<span class="end-tag">TH</span>></span><span>
<span id="line378"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line379"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line380"></span> </span><span><<span class="start-tag">TD</span>></span><span>1#</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Add 1 to R1</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line381"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line382"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line383"></span> </span><span><<span class="start-tag">TD</span>></span><span>11#</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Add 1 to R2</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line384"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line385"></span> </span><span class="error" title="Stray end tag “tr”."></<span class="end-tag">TR</span>></span><span>
<span id="line386"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line387"></span> </span><span><<span class="start-tag">TD</span>></span><span>111#</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Add 1 to R3</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line388"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line389"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line390"></span> </span><span><<span class="start-tag">TD</span>></span><span>1111#</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Add 1 to R4</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line391"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line392"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line393"></span></span><span></<span class="end-tag">td</span>></span><span>
<span id="line394"></span></span><span><<span class="start-tag">td</span>></span><span> </span><span><<span class="start-tag">img</span> <span class="attribute-name">width</span>=<a class="attribute-value">10</a> <span class="attribute-name">height</span>=<a class="attribute-value">5</a> <span class="attribute-name">src</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/space.gif">space.gif</a>"></span><span></span><span><<span class="start-tag">td</span>></span><span>
<span id="line395"></span></span><span><<span class="start-tag">td</span>></span><span>
<span id="line396"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span> ></span><span>
<span id="line397"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line398"></span> </span><span><<span class="start-tag">TH</span>></span><span>Instruction</span><span></<span class="end-tag">TH</span>></span><span> </span><span><<span class="start-tag">TH</span>></span><span>Meaning</span><span></<span class="end-tag">TH</span>></span><span>
<span id="line399"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line400"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line401"></span> </span><span><<span class="start-tag">TD</span>></span><span>1##</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Add # to R1</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line402"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line403"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line404"></span> </span><span><<span class="start-tag">TD</span>></span><span>11##</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Add # to R2</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line405"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line406"></span> </span><span class="error" title="Stray end tag “tr”."></<span class="end-tag">TR</span>></span><span>
<span id="line407"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line408"></span> </span><span><<span class="start-tag">TD</span>></span><span>111##</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Add # to R3</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line409"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line410"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line411"></span> </span><span><<span class="start-tag">TD</span>></span><span>1111##</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Add # to R4</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line412"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line413"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line414"></span></span><span></<span class="end-tag">td</span>></span><span>
<span id="line415"></span></span><span></<span class="end-tag">table</span>></span><span>
<span id="line416"></span></span><span></<span class="end-tag">center</span>></span><span>
<span id="line417"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line418"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line419"></span>The group on the left are instructions that add a 1 to the
<span id="line420"></span>end of the word in the specified register.
<span id="line421"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line422"></span>The ones on the right add a # to the end (the right side)
<span id="line423"></span> of
<span id="line424"></span>the word in the specified register.
<span id="line425"></span>
<span id="line426"></span>
<span id="line427"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line428"></span>The programs of 1# are just sequences of instructions run together.</span><span><<span class="start-tag">p</span>></span><span>
<span id="line429"></span>There is no punctuation between the instructions. However, we do have
<span id="line430"></span>an important comment.
<span id="line431"></span>
<span id="line432"></span></span><span><<span class="start-tag">hr</span>></span><span>
<span id="line433"></span>
<span id="line434"></span>
<span id="line435"></span></span><span><<span class="start-tag">h3</span>></span><span>Spaces and Comments</span><span></<span class="end-tag">h3</span>></span><span>
<span id="line436"></span>
<span id="line437"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line438"></span>The interpreter ignores all spaces.
<span id="line439"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line440"></span>In addition, if you have a semicolon (;) in a line,
<span id="line441"></span>the rest of that line is simply ignored. This way, you can add
<span id="line442"></span>comments to programs.
<span id="line443"></span>
<span id="line444"></span></span><span><<span class="start-tag">hr</span>></span><span>
<span id="line445"></span>
<span id="line446"></span>
<span id="line447"></span>
<span id="line448"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line449"></span>For example, here is a program which we'll call p:
<span id="line450"></span></span><span><<span class="start-tag">CENTER</span>></span><span>
<span id="line451"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">CELLPADDING</span>="<a class="attribute-value">3</a>"></span><span>
<span id="line452"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line453"></span></span><span><<span class="start-tag">td</span>></span><span>1#11##11##111##</span><span></<span class="end-tag">td</span>></span><span></span><span></<span class="end-tag">TR</span>></span><span>
<span id="line454"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line455"></span></span><span></<span class="end-tag">CENTER</span>></span><span>
<span id="line456"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line457"></span>(We call this one p just to have a name for it;
<span id="line458"></span>the letter stands for ``program.'')
<span id="line459"></span>Programs of 1# are hard to read.
<span id="line460"></span>But fortunately, there's an easy way to </span><span><<span class="start-tag">i</span>></span><span>parse</span><span></<span class="end-tag">i</span>></span><span> them into instructions.
<span id="line461"></span>Everytime we see a # followed by a 1 we have the end of one instruction
<span id="line462"></span>and the beginning of the next.
<span id="line463"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line464"></span>Going back to the program p above, we see that it parses into a sequence
<span id="line465"></span>of four instructions:
<span id="line466"></span></span><span><<span class="start-tag">P</span>></span><span>
<span id="line467"></span></span><span><<span class="start-tag">CENTER</span>></span><span>
<span id="line468"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">CELLPADDING</span>=<a class="attribute-value">3</a> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span> </span><span class="error" title="Start tag “border=10” seen in “table”."><<span class="start-tag">BORDER=10</span>></span><span>
<span id="line469"></span> </span><span><<span class="start-tag">TR</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span> 1#
<span id="line470"></span> </span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span> 11##
<span id="line471"></span></span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span> 11##
<span id="line472"></span></span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span> 111##
<span id="line473"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line474"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line475"></span></span><span></<span class="end-tag">CENTER</span>></span><span>
<span id="line476"></span></span><span><<span class="start-tag">P</span>></span><span>
<span id="line477"></span>Here is an explanation of what this program p does:
<span id="line478"></span></span><span><<span class="start-tag">ol</span>></span><span>
<span id="line479"></span></span><span><<span class="start-tag">li</span>></span><span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line480"></span>The first instruction, 1#, adds a 1 to R1.
<span id="line481"></span></span><span><<span class="start-tag">li</span>></span><span></span><span><<span class="start-tag">p</span>></span><span> Then 11##
<span id="line482"></span>adds a # to R2
<span id="line483"></span></span><span><<span class="start-tag">li</span>></span><span></span><span><<span class="start-tag">p</span>></span><span> Then the third instruction again adds a # to R2.
<span id="line484"></span></span><span><<span class="start-tag">li</span>></span><span></span><span><<span class="start-tag">p</span>></span><span> Finally, 111##
<span id="line485"></span>adds a # to R3.
<span id="line486"></span></span><span></<span class="end-tag">ol</span>></span><span>
<span id="line487"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line488"></span>Notice also that no other registers are affected.
<span id="line489"></span>
<span id="line490"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line491"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line492"></span>For example, suppose we start
<span id="line493"></span>with 1 in R1 and R2, 1# in R3,
<span id="line494"></span>and the other registers empty.
<span id="line495"></span>If we run our program p from above, we would end up with
<span id="line496"></span>11 in R1, ## R2, #1# in R3,
<span id="line497"></span>and the other registers empty.
<span id="line498"></span>
<span id="line499"></span>
<span id="line500"></span>
<span id="line501"></span>
<span id="line502"></span>
<span id="line503"></span></span><span><<span class="start-tag">H3</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">LEFT</a>"></span><span>
<span id="line504"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span>="<a class="attribute-value">3</a>" <span class="attribute-name">CELLPADDING</span>="<a class="attribute-value">3</a>" <span class="attribute-name">width</span>="<a class="attribute-value">100%</a>"></span><span>
<span id="line505"></span></span><span><<span class="start-tag">TR</span>></span><span>
<span id="line506"></span></span><span><<span class="start-tag">TD</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">Left</a>" <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#99FF99</a>"></span><span>
<span id="line507"></span></span><span><<span class="start-tag">strong</span>></span><span>Exercise 2</span><span></<span class="end-tag">strong</span>></span><span>
<span id="line508"></span>Again, start with 1 in R1 and R2, 1# in R3,
<span id="line509"></span>and the other registers empty.
<span id="line510"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line511"></span>What happens in each register if we run
<span id="line512"></span>111##?
<span id="line513"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line514"></span>You can try to figure this out for yourself,
<span id="line515"></span>and then check your work by actually running the program.
<span id="line516"></span></span><span></<span class="end-tag">TABLE</span>></span><span></span><span></<span class="end-tag">H3</span>></span><span>
<span id="line517"></span>
<span id="line518"></span>
<span id="line519"></span>
<span id="line520"></span>
<span id="line521"></span>
<span id="line522"></span>
<span id="line523"></span></span><span><<span class="start-tag">H3</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">LEFT</a>"></span><span>
<span id="line524"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span>="<a class="attribute-value">3</a>" <span class="attribute-name">CELLPADDING</span>="<a class="attribute-value">3</a>" <span class="attribute-name">width</span>="<a class="attribute-value">100%</a>"></span><span>
<span id="line525"></span></span><span><<span class="start-tag">TR</span>></span><span>
<span id="line526"></span></span><span><<span class="start-tag">TD</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">Left</a>" <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#99FF99</a>"></span><span>
<span id="line527"></span></span><span><<span class="start-tag">strong</span>></span><span>Exercise 3</span><span></<span class="end-tag">strong</span>></span><span>
<span id="line528"></span>As before, start with 1 in R1 and R2, 1# in R3,
<span id="line529"></span>and the other registers empty.
<span id="line530"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line531"></span>What happens in each register if we run the same program p from above?
<span id="line532"></span></span><span></<span class="end-tag">TABLE</span>></span><span></span><span></<span class="end-tag">H3</span>></span><span>
<span id="line533"></span>
<span id="line534"></span></span><span><<span class="start-tag">H3</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">LEFT</a>"></span><span>
<span id="line535"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span>="<a class="attribute-value">3</a>" <span class="attribute-name">CELLPADDING</span>="<a class="attribute-value">3</a>" <span class="attribute-name">width</span>="<a class="attribute-value">100%</a>"></span><span>
<span id="line536"></span></span><span><<span class="start-tag">TR</span>></span><span>
<span id="line537"></span></span><span><<span class="start-tag">TD</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">Left</a>" <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#99FF99</a>"></span><span>
<span id="line538"></span></span><span><<span class="start-tag">strong</span>></span><span>Exercise 4</span><span></<span class="end-tag">strong</span>></span><span>
<span id="line539"></span>Write a program which, when started with all registers empty,
<span id="line540"></span>gives 1 in R1 and R2, 1# in R3,
<span id="line541"></span>and the other registers empty.
<span id="line542"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line543"></span></span><span></<span class="end-tag">TABLE</span>></span><span></span><span></<span class="end-tag">H3</span>></span><span>
<span id="line544"></span>
<span id="line545"></span>
<span id="line546"></span>
<span id="line547"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line548"></span>The instructions in our two tables above
<span id="line549"></span>were just samples. If you want to add a # to R15, you would use
<span id="line550"></span></span><span><<span class="start-tag">P</span>></span><span>
<span id="line551"></span></span><span><<span class="start-tag">CENTER</span>></span><span>
<span id="line552"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">CELLPADDING</span>=<a class="attribute-value">3</a> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span> </span><span class="error" title="Start tag “border=10” seen in “table”."><<span class="start-tag">BORDER=10</span>></span><span>
<span id="line553"></span> </span><span><<span class="start-tag">TR</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span> 111111111111111##
<span id="line554"></span> </span><span></<span class="end-tag">TD</span>></span><span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line555"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line556"></span></span><span></<span class="end-tag">CENTER</span>></span><span>
<span id="line557"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line558"></span>(Incidentally, most of the instructions in this tutorial use only the first
<span id="line559"></span>four registers. But you should know how to the meaning all of the
<span id="line560"></span>instructions in the language.)
<span id="line561"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line562"></span>To state the instructions in a general way, we need a notational agreement.
<span id="line563"></span></span><span><<span class="start-tag">H3</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">LEFT</a>"></span><span>
<span id="line564"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span>="<a class="attribute-value">3</a>" <span class="attribute-name">CELLPADDING</span>="<a class="attribute-value">3</a>" <span class="attribute-name">width</span>="<a class="attribute-value">100%</a>"></span><span>
<span id="line565"></span></span><span><<span class="start-tag">TR</span>></span><span>
<span id="line566"></span></span><span><<span class="start-tag">TD</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">Left</a>" <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">FF9999</a>"></span><span> "n in unary" and
<span id="line567"></span>1</span><span><<span class="start-tag">sup</span>></span><span>n</span><span></<span class="end-tag">sup</span>></span><span> both
<span id="line568"></span> mean n 1s in a row.
<span id="line569"></span></span><span></<span class="end-tag">TABLE</span>></span><span></span><span></<span class="end-tag">H3</span>></span><span>
<span id="line570"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line571"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line572"></span>So the succinct statement of the instructions to add symbols
<span id="line573"></span>to the ends of registers is
<span id="line574"></span>
<span id="line575"></span></span><span><<span class="start-tag">P</span>></span><span>
<span id="line576"></span></span><span><<span class="start-tag">CENTER</span>></span><span>
<span id="line577"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span> </span><span class="error" title="Start tag “border=10” seen in “table”."><<span class="start-tag">BORDER=10</span>></span><span>
<span id="line578"></span> </span><span><<span class="start-tag">TR</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Add 1 to Rn </span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span> Add # to Rn</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line579"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line580"></span> </span><span><<span class="start-tag">TR</span>></span><span>
<span id="line581"></span> </span><span><<span class="start-tag">TR</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>1</span><span><<span class="start-tag">sup</span>></span><span>n</span><span></<span class="end-tag">sup</span>></span><span># </span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span> 1</span><span><<span class="start-tag">sup</span>></span><span>n</span><span></<span class="end-tag">sup</span>></span><span>##</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line582"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line583"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line584"></span></span><span></<span class="end-tag">CENTER</span>></span><span>
<span id="line585"></span></span><span><<span class="start-tag">P</span>></span><span>
<span id="line586"></span>
<span id="line587"></span>
<span id="line588"></span>
<span id="line589"></span>
<span id="line590"></span>
<span id="line591"></span>
<span id="line592"></span></span><span><<span class="start-tag">H3</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">LEFT</a>"></span><span>
<span id="line593"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span>="<a class="attribute-value">3</a>" <span class="attribute-name">CELLPADDING</span>="<a class="attribute-value">3</a>" <span class="attribute-name">width</span>="<a class="attribute-value">100%</a>"></span><span>
<span id="line594"></span></span><span><<span class="start-tag">TR</span>></span><span>
<span id="line595"></span></span><span><<span class="start-tag">TD</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">Left</a>" <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">FF9999</a>"></span><span></span><span><<span class="start-tag">strong</span>></span><span>Please remember</span><span></<span class="end-tag">strong</span>></span><span>:
<span id="line596"></span> all adding is done on the right ends of the registers.
<span id="line597"></span></span><span></<span class="end-tag">TABLE</span>></span><span></span><span></<span class="end-tag">H3</span>></span><span>
<span id="line598"></span>
<span id="line599"></span> </span><span><<span class="start-tag">hr</span>></span><span>
<span id="line600"></span>
<span id="line601"></span>
<span id="line602"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line603"></span></span><span><<span class="start-tag">h3</span>></span><span>
<span id="line604"></span>Transfer Instructions</span><span></<span class="end-tag">h3</span>></span><span>
<span id="line605"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line606"></span>
<span id="line607"></span>
<span id="line608"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line609"></span>Our next instructions move us around in a program.
<span id="line610"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line611"></span>Here is what they look like:
<span id="line612"></span></span><span><<span class="start-tag">CENTER</span>></span><span>
<span id="line613"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">width</span>=<a class="attribute-value">75%</a>></span><span>
<span id="line614"></span></span><span class="error" title="“td” start tag in table body."><<span class="start-tag">td</span>></span><span>
<span id="line615"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span>></span><span>
<span id="line616"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line617"></span> </span><span><<span class="start-tag">TH</span>></span><span>Instruction</span><span></<span class="end-tag">TH</span>></span><span> </span><span><<span class="start-tag">TH</span>></span><span>Meaning</span><span></<span class="end-tag">TH</span>></span><span>
<span id="line618"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line619"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line620"></span> </span><span><<span class="start-tag">TD</span>></span><span>1###</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Go forward 1</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line621"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line622"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line623"></span> </span><span><<span class="start-tag">TD</span>></span><span>11###</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Go forward 2</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line624"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line625"></span> </span><span class="error" title="Stray end tag “tr”."></<span class="end-tag">TR</span>></span><span>
<span id="line626"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line627"></span> </span><span><<span class="start-tag">TD</span>></span><span>111###</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Go forward 3</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line628"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line629"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line630"></span> </span><span><<span class="start-tag">TD</span>></span><span>1111###</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Go forward 4</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line631"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line632"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line633"></span></span><span></<span class="end-tag">td</span>></span><span>
<span id="line634"></span></span><span><<span class="start-tag">td</span>></span><span> </span><span><<span class="start-tag">img</span> <span class="attribute-name">width</span>=<a class="attribute-value">20</a> <span class="attribute-name">height</span>=<a class="attribute-value">5</a> <span class="attribute-name">src</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/space.gif">space.gif</a>"></span><span></span><span><<span class="start-tag">td</span>></span><span>
<span id="line635"></span></span><span><<span class="start-tag">td</span>></span><span>
<span id="line636"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span>></span><span>
<span id="line637"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line638"></span> </span><span><<span class="start-tag">TH</span>></span><span>Instruction</span><span></<span class="end-tag">TH</span>></span><span> </span><span><<span class="start-tag">TH</span>></span><span>Meaning</span><span></<span class="end-tag">TH</span>></span><span>
<span id="line639"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line640"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line641"></span> </span><span><<span class="start-tag">TD</span>></span><span>1####</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Go backward 1</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line642"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line643"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line644"></span> </span><span><<span class="start-tag">TD</span>></span><span>11####</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Go backward 2</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line645"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line646"></span> </span><span class="error" title="Stray end tag “tr”."></<span class="end-tag">TR</span>></span><span>
<span id="line647"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line648"></span> </span><span><<span class="start-tag">TD</span>></span><span>111####</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Go backward 3</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line649"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line650"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line651"></span> </span><span><<span class="start-tag">TD</span>></span><span>1111####</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Go backward 4</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line652"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line653"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line654"></span></span><span></<span class="end-tag">td</span>></span><span>
<span id="line655"></span></span><span></<span class="end-tag">table</span>></span><span>
<span id="line656"></span></span><span></<span class="end-tag">center</span>></span><span>
<span id="line657"></span>
<span id="line658"></span>
<span id="line659"></span>
<span id="line660"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line661"></span>As before, you should understand the tables
<span id="line662"></span>as providing examples:
<span id="line663"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line664"></span>in general we would write n in unary followed by ### to transfer forward n instructions,
<span id="line665"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line666"></span>and n in unary followed by #### to transfer backward n instructions.
<span id="line667"></span>
<span id="line668"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line669"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line670"></span>Here is how this all works. Let's consider a sample program like
<span id="line671"></span></span><span><<span class="start-tag">CENTER</span>></span><span>
<span id="line672"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">CELLPADDING</span>="<a class="attribute-value">3</a>" ></span><span>
<span id="line673"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line674"></span></span><span><<span class="start-tag">td</span>></span><span>11#1111###1#11#11###111####</span><span></<span class="end-tag">td</span>></span><span></span><span></<span class="end-tag">TR</span>></span><span>
<span id="line675"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line676"></span></span><span></<span class="end-tag">CENTER</span>></span><span>
<span id="line677"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line678"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line679"></span>We'll call this program q.
<span id="line680"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line681"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line682"></span>Just as before, we start by parsing q as a list of instructions:
<span id="line683"></span></span><span><<span class="start-tag">CENTER</span>></span><span>
<span id="line684"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">CELLPADDING</span>="<a class="attribute-value">3</a>" ></span><span>
<span id="line685"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line686"></span> </span><span><<span class="start-tag">TD</span>></span><span>11#</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Add 1 to R2</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line687"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line688"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line689"></span> </span><span><<span class="start-tag">TD</span>></span><span>1111### </span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Go forward 4</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line690"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line691"></span> </span><span class="error" title="Stray end tag “tr”."></<span class="end-tag">TR</span>></span><span>
<span id="line692"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line693"></span> </span><span><<span class="start-tag">TD</span>></span><span>1#</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Add 1 to R1</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line694"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line695"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line696"></span> </span><span><<span class="start-tag">TD</span>></span><span>11#</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Add 1 to R2</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line697"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line698"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line699"></span> </span><span><<span class="start-tag">TD</span>></span><span>11###</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Go forward 2</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line700"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line701"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line702"></span> </span><span><<span class="start-tag">TD</span>></span><span>111####</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Go backward 3</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line703"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line704"></span> </span><span class="error" title="Stray end tag “tr”."></<span class="end-tag">TR</span>></span><span>
<span id="line705"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line706"></span></span><span></<span class="end-tag">CENTER</span>></span><span>
<span id="line707"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line708"></span> </span><span><<span class="start-tag">p</span>></span><span>
<span id="line709"></span>The first instruction
<span id="line710"></span>of q adds a 1 to the end of whatever is in R2.
<span id="line711"></span></span><span><<span class="start-tag">br</span>></span><span> The second then transfers us to the </span><span><<span class="start-tag">i</span>></span><span>sixth</span><span></<span class="end-tag">i</span>></span><span> instruction,
<span id="line712"></span>which transfers us back to the </span><span><<span class="start-tag">i</span>></span><span>third</span><span></<span class="end-tag">i</span>></span><span>.
<span id="line713"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line714"></span>Then we add 1 to R1. After this we add 1 to R2.
<span id="line715"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line716"></span>Then we arrive at the fifth instruction. This sends us
<span id="line717"></span>forward 2, beyond the end of q.
<span id="line718"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line719"></span>As we'll soon see, this last point indicates that our
<span id="line720"></span>program q </span><span><<span class="start-tag">i</span>></span><span>halts.</span><span></<span class="end-tag">i</span>></span><span>
<span id="line721"></span>
<span id="line722"></span>
<span id="line723"></span></span><span><<span class="start-tag">H3</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">LEFT</a>"></span><span>
<span id="line724"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span>="<a class="attribute-value">3</a>" <span class="attribute-name">CELLPADDING</span>="<a class="attribute-value">3</a>" <span class="attribute-name">width</span>="<a class="attribute-value">100%</a>"></span><span>
<span id="line725"></span></span><span><<span class="start-tag">TR</span>></span><span>
<span id="line726"></span></span><span><<span class="start-tag">TD</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">Left</a>" <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">FF9999</a>"></span><span></span><span><<span class="start-tag">strong</span>></span><span>Please remember</span><span></<span class="end-tag">strong</span>></span><span>:
<span id="line727"></span> transfers in a program count either
<span id="line728"></span>forward or backward from the current instruction.
<span id="line729"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line730"></span>For forward transfers, start a count with 1 being the next
<span id="line731"></span>instruction.
<span id="line732"></span></span><span><<span class="start-tag">br</span>></span><span> For backward transfers,
<span id="line733"></span>start with 1 being the previous instruction.
<span id="line734"></span></span><span></<span class="end-tag">TABLE</span>></span><span></span><span></<span class="end-tag">H3</span>></span><span>
<span id="line735"></span>
<span id="line736"></span>
<span id="line737"></span></span><span><<span class="start-tag">hr</span>></span><span>
<span id="line738"></span>
<span id="line739"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line740"></span></span><span><<span class="start-tag">h3</span>></span><span>
<span id="line741"></span>Infinite loops</span><span></<span class="end-tag">h3</span>></span><span>
<span id="line742"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line743"></span>
<span id="line744"></span>
<span id="line745"></span>Here's a simple 1# program: 1###1####.
<span id="line746"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line747"></span>It has two instructions.
<span id="line748"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line749"></span>The first instruction is to transfer ahead one instruction, and the second
<span id="line750"></span>is to go back one instruction.
<span id="line751"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line752"></span>Executing this program puts the machine in an </span><span><<span class="start-tag">i</span>></span><span>infinite loop</span><span></<span class="end-tag">i</span>></span><span>.
<span id="line753"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line754"></span>You can try to run this program yourself on the simulator.
<span id="line755"></span>Note that it catches this loop. But for bigger ones, the simulator
<span id="line756"></span>will not detect the loop.
<span id="line757"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line758"></span>Can you think of other programs that would go into infinite loops?
<span id="line759"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line760"></span>
<span id="line761"></span>
<span id="line762"></span>
<span id="line763"></span>
<span id="line764"></span>
<span id="line765"></span>
<span id="line766"></span></span><span><<span class="start-tag">H3</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">LEFT</a>"></span><span>
<span id="line767"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span>="<a class="attribute-value">3</a>" <span class="attribute-name">CELLPADDING</span>="<a class="attribute-value">3</a>" <span class="attribute-name">width</span>="<a class="attribute-value">100%</a>"></span><span>
<span id="line768"></span></span><span><<span class="start-tag">TR</span>></span><span>
<span id="line769"></span></span><span><<span class="start-tag">TD</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">Left</a>" <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">FF9999</a>"></span><span></span><span><<span class="start-tag">strong</span>></span><span>Please remember</span><span></<span class="end-tag">strong</span>></span><span>:
<span id="line770"></span> there is a stop button on the interpreter!</span><span></<span class="end-tag">TABLE</span>></span><span></span><span></<span class="end-tag">H3</span>></span><span>
<span id="line771"></span>
<span id="line772"></span>
<span id="line773"></span></span><span><<span class="start-tag">hr</span>></span><span>
<span id="line774"></span>
<span id="line775"></span></span><span><<span class="start-tag">h3</span>></span><span>How programs halt</span><span></<span class="end-tag">h3</span>></span><span>
<span id="line776"></span>
<span id="line777"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line778"></span>We have just seen programs with infinite loops.
<span id="line779"></span>Such programs never finish. For all of our purposes in
<span id="line780"></span>this tutorial, we are mainly interested in programs which
<span id="line781"></span></span><span><<span class="start-tag">i</span>></span><span>do</span><span></<span class="end-tag">i</span>></span><span> finish. Actually, we are interested in programs
<span id="line782"></span>which finish in a special way.
<span id="line783"></span>
<span id="line784"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line785"></span>We say that a program p </span><span><<span class="start-tag">i</span>></span><span>halts</span><span></<span class="end-tag">i</span>></span><span> if at some point during
<span id="line786"></span>the execution of p, the control transfers to right below the
<span id="line787"></span>last instruction of p. In more detail, suppose that p has n instructions.
<span id="line788"></span>The formal definition is given
<span id="line789"></span></span><span><<span class="start-tag">a</span> <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/startup.shtml#halt">#halt</a>"></span><span>below</span><span></<span class="end-tag">a</span>></span><span>, after we discuss the remaining
<span id="line790"></span>types of instructions.
<span id="line791"></span>
<span id="line792"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line793"></span>In contrast, we say that p </span><span><<span class="start-tag">i</span>></span><span>stops improperly</span><span></<span class="end-tag">i</span>></span><span>
<span id="line794"></span>if
<span id="line795"></span>at some point during
<span id="line796"></span>the execution of p, the control tranfers
<span id="line797"></span>either to a point before the beginning of p
<span id="line798"></span>or to points more than one instruction beyond the
<span id="line799"></span>last instruction of p.
<span id="line800"></span>
<span id="line801"></span>
<span id="line802"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line803"></span>To see the difference, consider the following two programs:
<span id="line804"></span></span><span><<span class="start-tag">CENTER</span>></span><span>
<span id="line805"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">width</span>=<a class="attribute-value">75%</a>></span><span>
<span id="line806"></span></span><span class="error" title="“td” start tag in table body."><<span class="start-tag">td</span>></span><span>
<span id="line807"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span>></span><span>
<span id="line808"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line809"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line810"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line811"></span> </span><span><<span class="start-tag">TD</span>></span><span>11###</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Go forward 2</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line812"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line813"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line814"></span> </span><span><<span class="start-tag">TD</span>></span><span>1#</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Add 1 to R1</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line815"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line816"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line817"></span></span><span></<span class="end-tag">td</span>></span><span>
<span id="line818"></span></span><span><<span class="start-tag">td</span>></span><span> </span><span><<span class="start-tag">img</span> <span class="attribute-name">src</span>="<a class="attribute-value" href="view-source:https://iulg.sitehost.iu.edu/trm/space.gif">space.gif</a>"></span><span></span><span><<span class="start-tag">td</span>></span><span>
<span id="line819"></span></span><span><<span class="start-tag">td</span>></span><span>
<span id="line820"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span>></span><span>
<span id="line821"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line822"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line823"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line824"></span> </span><span><<span class="start-tag">TD</span>></span><span>111###</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Go forward 3</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line825"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line826"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line827"></span> </span><span><<span class="start-tag">TD</span>></span><span>1#</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Add 1 to R1</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line828"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line829"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line830"></span></span><span></<span class="end-tag">td</span>></span><span>
<span id="line831"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line832"></span></span><span></<span class="end-tag">center</span>></span><span>
<span id="line833"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line834"></span>The program on the left halts, while the one on the right stops improperly.
<span id="line835"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line836"></span>
<span id="line837"></span></span><span><<span class="start-tag">H3</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">LEFT</a>"></span><span>
<span id="line838"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span>="<a class="attribute-value">3</a>" <span class="attribute-name">CELLPADDING</span>="<a class="attribute-value">3</a>" <span class="attribute-name">width</span>="<a class="attribute-value">100%</a>"></span><span>
<span id="line839"></span></span><span><<span class="start-tag">TR</span>></span><span>
<span id="line840"></span></span><span><<span class="start-tag">TD</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">Left</a>" <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#99FF99</a>"></span><span>
<span id="line841"></span></span><span><<span class="start-tag">strong</span>></span><span>Exercise 5</span><span></<span class="end-tag">strong</span>></span><span>
<span id="line842"></span>Which of the following programs halt? Which stop improperly?
<span id="line843"></span></span><span><<span class="start-tag">ol</span>></span><span>
<span id="line844"></span></span><span><<span class="start-tag">li</span>></span><span> 11###111###1####
<span id="line845"></span></span><span><<span class="start-tag">li</span>></span><span> 11###111###11####
<span id="line846"></span></span><span><<span class="start-tag">li</span>></span><span> 11###111###111####
<span id="line847"></span></span><span><<span class="start-tag">li</span>></span><span> 1111###1111###1####11###11####
<span id="line848"></span></span><span></<span class="end-tag">ol</span>></span><span>
<span id="line849"></span>[It would be better to try to solve this problem
<span id="line850"></span>without running the programs.]
<span id="line851"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line852"></span></span><span></<span class="end-tag">TABLE</span>></span><span></span><span></<span class="end-tag">H3</span>></span><span>
<span id="line853"></span>
<span id="line854"></span>
<span id="line855"></span>
<span id="line856"></span></span><span><<span class="start-tag">H3</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">LEFT</a>"></span><span>
<span id="line857"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span>="<a class="attribute-value">3</a>" <span class="attribute-name">CELLPADDING</span>="<a class="attribute-value">3</a>" <span class="attribute-name">width</span>="<a class="attribute-value">100%</a>"></span><span>
<span id="line858"></span></span><span><<span class="start-tag">TR</span>></span><span>
<span id="line859"></span></span><span><<span class="start-tag">TD</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">Left</a>" <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">FF9999</a>"></span><span></span><span><<span class="start-tag">strong</span>></span><span>Please remember</span><span></<span class="end-tag">strong</span>></span><span>:
<span id="line860"></span>the only way for a program
<span id="line861"></span>p to halt
<span id="line862"></span>is when control is transferred to just after the last instruction of p.
<span id="line863"></span></span><span></<span class="end-tag">TABLE</span>></span><span></span><span></<span class="end-tag">H3</span>></span><span>
<span id="line864"></span>
<span id="line865"></span>
<span id="line866"></span>
<span id="line867"></span></span><span><<span class="start-tag">hr</span>></span><span>
<span id="line868"></span>
<span id="line869"></span></span><span><<span class="start-tag">h3</span>></span><span>Case instructions</span><span></<span class="end-tag">h3</span>></span><span>
<span id="line870"></span>
<span id="line871"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line872"></span>We now come to the last type of instructions in our little language 1#.
<span id="line873"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line874"></span>These are the most complicated instructions of all.
<span id="line875"></span>But this means that after you learn about them, you've mastered the whole
<span id="line876"></span>language.
<span id="line877"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line878"></span>Here are examples of what the case instructions
<span id="line879"></span>look like:
<span id="line880"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line881"></span></span><span><<span class="start-tag">CENTER</span>></span><span>
<span id="line882"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span>></span><span>
<span id="line883"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line884"></span> </span><span><<span class="start-tag">TH</span>></span><span>Instruction</span><span></<span class="end-tag">TH</span>></span><span> </span><span><<span class="start-tag">TH</span>></span><span>Meaning</span><span></<span class="end-tag">TH</span>></span><span>
<span id="line885"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line886"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line887"></span> </span><span><<span class="start-tag">TD</span>></span><span>1#####</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Cases on R1</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line888"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line889"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line890"></span> </span><span><<span class="start-tag">TD</span>></span><span>11#####</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Cases on R2</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line891"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line892"></span> </span><span class="error" title="Stray end tag “tr”."></<span class="end-tag">TR</span>></span><span>
<span id="line893"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line894"></span> </span><span><<span class="start-tag">TD</span>></span><span>111#####</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Cases on R3</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line895"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line896"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line897"></span> </span><span><<span class="start-tag">TD</span>></span><span>1111#####</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Cases on R4</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line898"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line899"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line900"></span></span><span></<span class="end-tag">CENTER</span>></span><span>
<span id="line901"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line902"></span></span><span><<span class="start-tag">p</span>></span><span> The general idea behind them is that
<span id="line903"></span> one whatever register is mentioned.
<span id="line904"></span>Either it is empty, or the first symbol is 1,
<span id="line905"></span>or the first symbol is #. We then
<span id="line906"></span>continue the program according to which alternative holds.
<span id="line907"></span>
<span id="line908"></span>Here is how case instructions work:
<span id="line909"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line910"></span>
<span id="line911"></span>
<span id="line912"></span>
<span id="line913"></span></span><span><<span class="start-tag">H3</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">LEFT</a>"></span><span>
<span id="line914"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">BORDER</span>="<a class="attribute-value">3</a>" <span class="attribute-name">CELLPADDING</span>="<a class="attribute-value">3</a>" <span class="attribute-name">width</span>="<a class="attribute-value">100%</a>"></span><span>
<span id="line915"></span></span><span><<span class="start-tag">TR</span>></span><span>
<span id="line916"></span></span><span><<span class="start-tag">TD</span> <span class="attribute-name">ALIGN</span>="<a class="attribute-value">Left</a>" <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">FF9999</a>"></span><span>
<span id="line917"></span>If Rn is empty, we go to the very next instruction.
<span id="line918"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line919"></span>If the first symbol of Rn is 1, we delete that symbol
<span id="line920"></span>and go to the second instruction after the case instruction.
<span id="line921"></span></span><span><<span class="start-tag">br</span>></span><span>
<span id="line922"></span>If the first symbol of Rn is #, we delete that symbol
<span id="line923"></span>and go to the third instruction after the case instruction.
<span id="line924"></span></span><span></<span class="end-tag">TABLE</span>></span><span></span><span></<span class="end-tag">H3</span>></span><span>
<span id="line925"></span>
<span id="line926"></span>
<span id="line927"></span></span><span><<span class="start-tag">hr</span>></span><span>
<span id="line928"></span>
<span id="line929"></span></span><span><<span class="start-tag">a</span> <span class="attribute-name">name</span>="<a class="attribute-value">halt</a>"></span><span></span><span></<span class="end-tag">a</span>></span><span>
<span id="line930"></span></span><span><<span class="start-tag">h3</span>></span><span>Halting: the formal definitions</span><span></<span class="end-tag">h3</span>></span><span>
<span id="line931"></span>
<span id="line932"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line933"></span>
<span id="line934"></span>There are five ways that p could halt.
<span id="line935"></span></span><span><<span class="start-tag">ol</span>></span><span>
<span id="line936"></span></span><span><<span class="start-tag">li</span>></span><span> Instruction n of p (the last instruction) is of the form
<span id="line937"></span>1</span><span><<span class="start-tag">sup</span>></span><span>k</span><span></<span class="end-tag">sup</span>></span><span># or 1</span><span><<span class="start-tag">sup</span>></span><span>k</span><span></<span class="end-tag">sup</span>></span><span>##, and at some point in
<span id="line938"></span>the run of p, we reach this last instruction.
<span id="line939"></span></span><span><<span class="start-tag">li</span>></span><span> Some instruction of p, say instruction number i, is of the form
<span id="line940"></span>1</span><span><<span class="start-tag">sup</span>></span><span>k</span><span></<span class="end-tag">sup</span>></span><span>###; and also i + k = n + 1; and finally that
<span id="line941"></span> at some point in
<span id="line942"></span>the run of p, we reach instruction i.
<span id="line943"></span></span><span><<span class="start-tag">li</span>></span><span>
<span id="line944"></span> Instruction n of p (the last instruction) is of the form
<span id="line945"></span>form 1</span><span><<span class="start-tag">sup</span>></span><span>k</span><span></<span class="end-tag">sup</span>></span><span>#####,
<span id="line946"></span>and at some point in
<span id="line947"></span>the run of p, we reach this last instruction with Rk empty.
<span id="line948"></span></span><span><<span class="start-tag">li</span>></span><span> Instruction n-1 of p (the next-to-last instruction) is of the form
<span id="line949"></span>form 1</span><span><<span class="start-tag">sup</span>></span><span>k</span><span></<span class="end-tag">sup</span>></span><span>#####,
<span id="line950"></span>and at some point in
<span id="line951"></span>the run of p, we reach this instruction with Rk containing a word beginning
<span id="line952"></span>with 1.
<span id="line953"></span></span><span><<span class="start-tag">li</span>></span><span> Instruction n-2 of p (the second-to-last instruction) is of the form
<span id="line954"></span>form 1</span><span><<span class="start-tag">sup</span>></span><span>k</span><span></<span class="end-tag">sup</span>></span><span>#####,
<span id="line955"></span>and at some point in
<span id="line956"></span>the run of p, we reach this instruction with Rk containing a word beginning
<span id="line957"></span>with #.
<span id="line958"></span></span><span></<span class="end-tag">ol</span>></span><span>
<span id="line959"></span>
<span id="line960"></span>
<span id="line961"></span></span><span><<span class="start-tag">hr</span>></span><span>
<span id="line962"></span>
<span id="line963"></span></span><span><<span class="start-tag">h3</span>></span><span>Programs to pop the first element off of registers</span><span></<span class="end-tag">h3</span>></span><span>
<span id="line964"></span>
<span id="line965"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line966"></span>We now turn to some simple example programs.
<span id="line967"></span>This topic is pursued more deeply in the lessons on arithmetic
<span id="line968"></span>and programs which write programs.
<span id="line969"></span>
<span id="line970"></span></span><span><<span class="start-tag">br</span>></span><span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line971"></span>One of the simplest programs is </span><span><<span class="start-tag">i</span>></span><span>pop</span><span></<span class="end-tag">i</span>></span><span></span><span><<span class="start-tag">sub</span>></span><span>1</span><span></<span class="end-tag">sub</span>></span><span>,
<span id="line972"></span>a program to pop the first symbol from the word in R1.
<span id="line973"></span>The remaining word will remain in R1.
<span id="line974"></span>(If R1 is empty, the program will not do anything.)
<span id="line975"></span></span><span><<span class="start-tag">br</span>></span><span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line976"></span></span><span><<span class="start-tag">P</span>></span><span>
<span id="line977"></span></span><span><<span class="start-tag">CENTER</span>></span><span>
<span id="line978"></span></span><span><<span class="start-tag">TABLE</span> <span class="attribute-name">CELLPADDING</span>="<a class="attribute-value">3</a>"></span><span>
<span id="line979"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line980"></span> </span><span><<span class="start-tag">TD</span>></span><span>1#####</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Cases on R1</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line981"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line982"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line983"></span> </span><span><<span class="start-tag">TD</span>></span><span>1###</span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Go forward 1 </span><span></<span class="end-tag">TD</span>></span><span>
<span id="line984"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line985"></span> </span><span class="error" title="Stray end tag “tr”."></<span class="end-tag">TR</span>></span><span>
<span id="line986"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line987"></span> </span><span><<span class="start-tag">TD</span>></span><span>1### </span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Go forward 1</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line988"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line989"></span> </span><span><<span class="start-tag">TR</span> <span class="attribute-name">BGCOLOR</span>="<a class="attribute-value">#FFFFCC</a>"></span><span>
<span id="line990"></span> </span><span><<span class="start-tag">TD</span>></span><span>1### </span><span></<span class="end-tag">TD</span>></span><span> </span><span><<span class="start-tag">TD</span>></span><span>Go forward 1</span><span></<span class="end-tag">TD</span>></span><span>
<span id="line991"></span> </span><span></<span class="end-tag">TR</span>></span><span>
<span id="line992"></span></span><span></<span class="end-tag">TABLE</span>></span><span>
<span id="line993"></span></span><span></<span class="end-tag">CENTER</span>></span><span>
<span id="line994"></span></span><span><<span class="start-tag">p</span>></span><span>
<span id="line995"></span>The program above does what we want. There are other
<span id="line996"></span>ways to do the same thing. For example, the last instruction
<span id="line997"></span>1### is not really needed. (Please think about this.)