-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathThe_Micron_Intermediate_Language_Specification.html
3326 lines (3326 loc) · 154 KB
/
The_Micron_Intermediate_Language_Specification.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
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 PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head><title>2024-02-16 The Micron Intermediate Language</title>
<style type="text/css" media="screen, projection, print">
body{font-family:Arial,sans-serif;font-size:small;orphans:2;widows:2;}
h1,h2,h3,h4{background-color:#F5F5F5;padding:0.3em;page-break-after:avoid;margin:0;border-style:solid;border-color:white #F5F5F5 #F5F5F5 #F5F5F5;border-width:thin;}
span.label{position:absolute;top:auto;left:0;margin-top:0.2em;font-size:smaller;color:darkblue; }
span.ident{background-color:aliceblue;font-weight:bold;padding:0 0.2em 0 0.2em;}
a[href^="#"]{text-decoration:none;font-weight:normal;color:darkblue;background-color:#F5F5F5;}
div{border-style:none solid solid solid;border-width:thin;border-color:#F5F5F5;margin:0;padding:0.3em;}
ol,ul{margin:0;}
</style>
</head><body>
<h4 style="margin-left:9px"><span class="label"><a name="14944">1</a></span>
Front Matter</h4>
<h4 style="margin-left:27px"><span class="label"><a name="14946">1.1</a></span>
Title</h4>
<div style="margin-left:45px"><span class="label"><a name="14947">1.1.1</a></span>
The Micron Intermediate Language Specification</div>
<h4 style="margin-left:27px"><span class="label"><a name="14948">1.2</a></span>
Version</h4>
<div style="margin-left:45px"><span class="label"><a name="14949">1.2.1</a></span>
2024-12-15, work in progress</div>
<h4 style="margin-left:27px"><span class="label"><a name="14950">1.3</a></span>
Author</h4>
<div style="margin-left:45px"><span class="label"><a name="14951">1.3.1</a></span>
[email protected]</div>
<h4 style="margin-left:27px"><span class="label"><a name="15158">1.4</a></span>
<b>Additional Credits</b></h4>
<div style="margin-left:45px"><span class="label"><a name="15160">1.4.1</a></span>
This specification was derived from the ECMA-335 standard (3rd edition 2005).</div>
<h4 style="margin-left:27px"><span class="label"><a name="14952">1.5</a></span>
License</h4>
<div style="margin-left:45px"><span class="label"><a name="14953">1.5.1</a></span>
<i>Permission under Ecma’s and Rochus Keller's copyright to copy, modify, prepare derivative works of, and distribute this work, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the work or portions thereof, including modifications:</i>
<br><i>(i) The full text of this COPYRIGHT NOTICE AND COPYRIGHT LICENSE in a location viewable to users of the redistributed or derivative work.</i>
<br><i>(ii) Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the Ecma alternative copyright notice should be included.</i>
<br><i>(iii) Notice of any changes or modifications, through a copyright statement on the document such as “This document includes material copied from or derived from ECMA-335, 3rd Edition.</i><br /><i>Copyright © Ecma International.”</i></div>
<div style="margin-left:45px"><span class="label"><a name="15161">1.5.2</a></span>
<i><b>Disclaimers</b></i>
<br><i>THIS WORK IS PROVIDED “AS IS,” AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.</i>
<br><i>COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT.</i></div>
<h4 style="margin-left:27px"><span class="label"><a name="15601">1.6</a></span>
<b>Table of Contents</b></h4>
<div style="margin-left:45px"><span class="label"><a name="15603">1.6.1</a></span>
<a href="#14944">1 Front Matter</a></div>
<div style="margin-left:63px"><span class="label"><a name="15604">1.6.1.1</a></span>
<a href="#14946">1.1 Title</a></div>
<div style="margin-left:63px"><span class="label"><a name="15605">1.6.1.2</a></span>
<a href="#14948">1.2 Version</a></div>
<div style="margin-left:63px"><span class="label"><a name="15606">1.6.1.3</a></span>
<a href="#14950">1.3 Author</a></div>
<div style="margin-left:63px"><span class="label"><a name="15607">1.6.1.4</a></span>
<a href="#15158">1.4 Additional Credits</a></div>
<div style="margin-left:63px"><span class="label"><a name="15608">1.6.1.5</a></span>
<a href="#14952">1.5 License</a></div>
<div style="margin-left:63px"><span class="label"><a name="15609">1.6.1.6</a></span>
<a href="#15601">1.6 Table of Contents</a></div>
<div style="margin-left:45px"><span class="label"><a name="15610">1.6.2</a></span>
<a href="#14954">2 Language Specification</a></div>
<div style="margin-left:63px"><span class="label"><a name="15611">1.6.2.1</a></span>
<a href="#14955">2.1 Overview</a></div>
<div style="margin-left:63px"><span class="label"><a name="15612">1.6.2.2</a></span>
<a href="#14959">2.2 Representations</a></div>
<div style="margin-left:63px"><span class="label"><a name="15613">1.6.2.3</a></span>
<a href="#14976">2.3 Declarations and scope rules</a></div>
<div style="margin-left:63px"><span class="label"><a name="15614">1.6.2.4</a></span>
<a href="#14956">2.4 Types</a></div>
<div style="margin-left:63px"><span class="label"><a name="15615">1.6.2.5</a></span>
<a href="#14960">2.5 Expressions</a></div>
<div style="margin-left:63px"><span class="label"><a name="15616">1.6.2.6</a></span>
<a href="#15447">2.6 Constants</a></div>
<div style="margin-left:63px"><span class="label"><a name="15617">1.6.2.7</a></span>
<a href="#15500">2.7 Variables</a></div>
<div style="margin-left:63px"><span class="label"><a name="15618">1.6.2.8</a></span>
<a href="#14965">2.8 Procedures</a></div>
<div style="margin-left:63px"><span class="label"><a name="15619">1.6.2.9</a></span>
<a href="#14961">2.9 Statements</a></div>
<div style="margin-left:63px"><span class="label"><a name="15620">1.6.2.10</a></span>
<a href="#14957">2.10 Modules</a></div>
<div style="margin-left:45px"><span class="label"><a name="15621">1.6.3</a></span>
<a href="#15512">3 Complete syntax of the textual representation</a></div>
<div style="margin-left:45px"><span class="label"><a name="15622">1.6.4</a></span>
<a href="#14962">4 References</a></div>
<h4 style="margin-left:9px"><span class="label"><a name="14954">2</a></span>
<b>Language Specification</b></h4>
<h4 style="margin-left:27px"><span class="label"><a name="14955">2.1</a></span>
<b>Overview</b></h4>
<div style="margin-left:45px"><span class="label"><a name="15325">2.1.1</a></span>
The Micron Intermediate Languae (MIL) uses a subset of the ECMA-335 Common Intermediate Language (CIL) without managed types, and with manual memory management, and extended by explicit control-flow syntax. Because of the latter no explicit branch instructions are required, and different types of analyses, as well as translations to high-level languages like C or lower-level representations like CIL or LLVM IR are straight-forward.</div>
<div style="margin-left:45px"><span class="label"><a name="15327">2.1.2</a></span>
In contrast to CIL, MIL targets the feature set of languages like Micron or C. The OO features of CIL are not supported, but could be implemented on top of MIL if required. MIL is designed for direct compatibility with the C ABI of all supported architectures.</div>
<h4 style="margin-left:27px"><span class="label"><a name="14959">2.2</a></span>
<b>Representations</b></h4>
<div style="margin-left:45px"><span class="label"><a name="15326">2.2.1</a></span>
MIL exists in two equivalent representations: a human-readable textual representation, and an efficient binary representation. Both map to a common structure.</div>
<h4 style="margin-left:45px"><span class="label"><a name="14971">2.2.2</a></span>
Textual Representation</h4>
<div style="margin-left:63px"><span class="label"><a name="15369">2.2.2.1</a></span>
The MIL textual representation is a string of characters encoded using the UTF-8 variable-width encoding as defined in ISO/IEC 10646. Identifiers, numbers, operators, and delimiters are represented using the ASCII character set; strings and comments can be either represented in the ASCII or Latin-1 (as defined in ISO/IEC 8859-1) character set.</div>
<h4 style="margin-left:63px"><span class="label"><a name="15561">2.2.2.2</a></span>
<a href=""><b>S</b></a><b>yntax</b></h4>
<div style="margin-left:81px"><span class="label"><a name="15562">2.2.2.2.1</a></span>
An extended Backus-Naur Formalism (EBNF) is used to describe the textual syntax of MIL:</div>
<div style="margin-left:99px"><span class="label"><a name="15563">2.2.2.2.1.1</a></span>
Alternatives are separated by <b>|</b>.</div>
<div style="margin-left:99px"><span class="label"><a name="15564">2.2.2.2.1.2</a></span>
Brackets <b>[</b> and <b>]</b> denote optionality of the enclosed expression.</div>
<div style="margin-left:99px"><span class="label"><a name="15565">2.2.2.2.1.3</a></span>
Braces <b>{</b> and <b>}</b> denote its repetition (possibly 0 times).</div>
<div style="margin-left:99px"><span class="label"><a name="15566">2.2.2.2.1.4</a></span>
Syntactic entities (non-terminal symbols) are denoted by English words expressing their intuitive meaning.</div>
<div style="margin-left:99px"><span class="label"><a name="15567">2.2.2.2.1.5</a></span>
Symbols of the language vocabulary (terminal symbols) are denoted by strings formatted in bold face.</div>
<h4 style="margin-left:63px"><span class="label"><a name="15370">2.2.2.3</a></span>
Identifiers</h4>
<div style="margin-left:81px"><span class="label"><a name="15371">2.2.2.3.1</a></span>
Identifiers are sequences of letters, digits and dollar signs. The first character cannot be a digit.</div>
<div style="margin-left:81px"><span class="label"><a name="15372">2.2.2.3.2</a></span>
Syntax:</div>
<div style="margin-left:99px"><span class="label"><a name="15373">2.2.2.3.2.1</a></span>
<pre><code>ident = ( letter | '_' | '$' ) { letter | digit | '_' | '$' }</code></pre>
<pre><code>letter = 'A' ... 'Z' | 'a' ... 'z'</code></pre>
<pre><code>digit = '0' ... '9'</code></pre></div>
<h4 style="margin-left:63px"><span class="label"><a name="15376">2.2.2.4</a></span>
Numbers</h4>
<div style="margin-left:81px"><span class="label"><a name="15377">2.2.2.4.1</a></span>
Number literals are optionaly signed integer or real constants. </div>
<div style="margin-left:81px"><span class="label"><a name="15379">2.2.2.4.2</a></span>
If the literal is specified with the suffix 'H', the representation is hexadecimal, if it is specified with suffix 'O', the representation is ocal, or if it is specified with suffic 'B', the representation is binary, otherwise the representation is decimal. </div>
<div style="margin-left:81px"><span class="label"><a name="15383">2.2.2.4.3</a></span>
A real number always contains a decimal point and at least one digit before the point. Optionally it may also contain a decimal scale factor. The letter 'E' means <i>times ten to the power of</i>. </div>
<div style="margin-left:81px"><span class="label"><a name="15386">2.2.2.4.4</a></span>
Syntax:</div>
<div style="margin-left:99px"><span class="label"><a name="15387">2.2.2.4.4.1</a></span>
<pre><code>unsigned = (digit {digit} ['O'|'B' | digit {hexDigit} 'H')<br />integer = ['+' | '-'] unsigned</code></pre>
<pre><code>real = ['+' | '-'] digit {digit} '.' {digit} [Exponent]</code></pre>
<pre><code>Exponent = 'E' ['+' | '-'] digit {digit}</code></pre>
<pre><code>hexDigit = digit | 'A' ... 'F'</code></pre>
<pre><code>digit = '0' ... '9'</code></pre></div>
<div style="margin-left:81px"><span class="label"><a name="15388">2.2.2.4.5</a></span>
Even though only the upper-case version is shown here, also the lower-case versions of the suffices and scale factor letters are supported.</div>
<h4 style="margin-left:63px"><span class="label"><a name="15391">2.2.2.5</a></span>
Characters</h4>
<div style="margin-left:81px"><span class="label"><a name="15392">2.2.2.5.1</a></span>
Character constants are denoted by the ordinal number of the character in hexadecimal notation followed by the letter <code>X</code> (or <code>x</code>).</div>
<div style="margin-left:81px"><span class="label"><a name="15393">2.2.2.5.2</a></span>
Syntax:</div>
<div style="margin-left:99px"><span class="label"><a name="15394">2.2.2.5.2.1</a></span>
<pre><code>character = digit {hexDigit} ('X' | 'x')</code></pre></div>
<div style="margin-left:81px"><span class="label"><a name="15395">2.2.2.5.3</a></span>
A character is encoded as a 8-bit code value using the ISO/IEC 8859-1 Latin-1 encoding scheme.</div>
<h4 style="margin-left:63px"><span class="label"><a name="15396">2.2.2.6</a></span>
Strings</h4>
<div style="margin-left:81px"><span class="label"><a name="15397">2.2.2.6.1</a></span>
Strings are sequences of printable characters enclosed in single (') or double (") quote marks. The opening quote must be the same as the closing quote and must not occur within the string. A string must not extend over the end of a line. The number of characters in a string is called its length. A string of length 1 can be used wherever a character constant is allowed and vice versa.</div>
<div style="margin-left:81px"><span class="label"><a name="15398">2.2.2.6.2</a></span>
Syntax:</div>
<div style="margin-left:99px"><span class="label"><a name="15399">2.2.2.6.2.1</a></span>
<pre><code>string = ''' {character} ''' | '"' {character} '"'</code></pre></div>
<h4 style="margin-left:81px"><span class="label"><a name="15402">2.2.2.6.3</a></span>
Hex Strings</h4>
<div style="margin-left:99px"><span class="label"><a name="15403">2.2.2.6.3.1</a></span>
Hex strings are sequences of bytes encoded in hexadecimal format and enclosed in hash signs. The number of hex digits in the string must be even, two hex digits per byte. The number of bytes encoded in a hex string is called its length. Line breaks and other white space between the hash signs is ignored. Both upper and lower-case hex digits are supported. </div>
<div style="margin-left:99px"><span class="label"><a name="15973">2.2.2.6.3.2</a></span>
When a hex string is used in place of a string literal, the terminating zero has to be explicit.</div>
<div style="margin-left:99px"><span class="label"><a name="15404">2.2.2.6.3.3</a></span>
Syntax:</div>
<div style="margin-left:117px"><span class="label"><a name="15405">2.2.2.6.3.3.1</a></span>
<pre><code>hexstring = '#' {hexDigit} '#'</code></pre></div>
<h4 style="margin-left:63px"><span class="label"><a name="15411">2.2.2.7</a></span>
Reserved Words</h4>
<div style="margin-left:81px"><span class="label"><a name="15978">2.2.2.7.1</a></span>
The MIL textual representation has only the following reserved words:</div>
<div style="margin-left:99px"><span class="label"><a name="15980">2.2.2.7.1.1</a></span>
BEGIN</div>
<div style="margin-left:99px"><span class="label"><a name="15981">2.2.2.7.1.2</a></span>
END</div>
<div style="margin-left:99px"><span class="label"><a name="15982">2.2.2.7.1.3</a></span>
IMPORT</div>
<div style="margin-left:99px"><span class="label"><a name="15983">2.2.2.7.1.4</a></span>
PROC</div>
<div style="margin-left:99px"><span class="label"><a name="15984">2.2.2.7.1.5</a></span>
PROCEDURE</div>
<div style="margin-left:99px"><span class="label"><a name="15985">2.2.2.7.1.6</a></span>
TYPE</div>
<div style="margin-left:99px"><span class="label"><a name="15986">2.2.2.7.1.7</a></span>
VAR</div>
<div style="margin-left:81px"><span class="label"><a name="15987">2.2.2.7.2</a></span>
A lot of identifiers have dedicated meanings in a specific context of the source code, which usually doesn't interfere with field, parameter and variable naming.</div>
<h4 style="margin-left:63px"><span class="label"><a name="15414">2.2.2.8</a></span>
Comments</h4>
<div style="margin-left:81px"><span class="label"><a name="15415">2.2.2.8.1</a></span>
Comments are arbitrary character sequences opened by the bracket <code>(*</code> and closed by <code>*)</code>. Comments may be nested. They do not affect the meaning of a program. Oberon+ also supports line comments; text starting with <code>//</code> up to a line break is considered a comment.</div>
<h4 style="margin-left:45px"><span class="label"><a name="14972">2.2.3</a></span>
Binary Representation</h4>
<div style="margin-left:63px"><span class="label"><a name="15418">2.2.3.1</a></span>
TODO</div>
<h4 style="margin-left:27px"><span class="label"><a name="14976">2.3</a></span>
<b>Declarations and scope rules</b></h4>
<div style="margin-left:45px"><span class="label"><a name="14977">2.3.1</a></span>
Every identifier occurring in a program must be introduced by a declaration, unless it is a predeclared identifier. Declarations also specify certain permanent properties of an object, such as whether it is a constant, a type, a variable, or a procedure. The identifier is then used to refer to the associated object.</div>
<div style="margin-left:45px"><span class="label"><a name="15479">2.3.2</a></span>
The <i>scope</i> of an object <i>x</i> extends textually from the point of its declaration to the end of the block (module, procedure, struct, or union) to which the declaration belongs and hence to which the object is <i>local</i>. </div>
<div style="margin-left:63px"><span class="label"><a name="15480">2.3.2.1</a></span>
No identifier may denote more than one object within a given scope; </div>
<div style="margin-left:63px"><span class="label"><a name="15482">2.3.2.2</a></span>
A type<i>T</i> of the form POINTER TO <i>T1</i> can be declared at a point where <i>T1</i> is still unknown. The declaration of <i>T1</i> must follow in the same block to which <i>T</i> is local; </div>
<div style="margin-left:45px"><span class="label"><a name="15484">2.3.3</a></span>
An identifier declared in a module block may be followed by an export mark ("*") in its declaration to indicate that it is exported. An identifier <i>x</i> exported by a module <i>M</i> may be used in other modules, if they import <i>M</i>. The identifier is then denoted as <i>M.x</i> in these modules and is called a <i>qualified identifier</i>. </div>
<div style="margin-left:45px"><span class="label"><a name="15451">2.3.4</a></span>
Syntax of textual representation:</div>
<div style="margin-left:63px"><span class="label"><a name="15452">2.3.4.1</a></span>
<code>qualident = [ident '!'] ident<br />trident = qualident '.' ident</code>
<br><code>identdef = ident ['*']</code></div>
<h4 style="margin-left:27px"><span class="label"><a name="14956">2.4</a></span>
Types</h4>
<div style="margin-left:45px"><span class="label"><a name="15339">2.4.1</a></span>
A data type determines the set of values which variables of that type may assume, and the operators that are applicable. A type declaration associates an identifier with a type. In the case of structured types (arrays, structs and unions) it also defines the structure of variables of this type. A structured type cannot contain itself.</div>
<div style="margin-left:45px"><span class="label"><a name="15430">2.4.2</a></span>
Syntax of textual representation:</div>
<div style="margin-left:63px"><span class="label"><a name="15431">2.4.2.1</a></span>
<pre><code>TypeDeclaration = identdef '=' type</code></pre>
<pre><code>type = NamedType | ArrayType | StructUnionType | PointerType | ProcedureType</code></pre></div>
<h4 style="margin-left:45px"><span class="label"><a name="14966">2.4.3</a></span>
<b>Basic types</b></h4>
<div style="margin-left:63px"><span class="label"><a name="15421">2.4.3.1</a></span>
The basic types are denoted by predeclared identifiers. Either all capital or all lower case identifiers are supported (only lower case versions shown). </div>
<div style="margin-left:63px"><span class="label"><a name="15419">2.4.3.2</a></span>
<table border=1 cellspacing=0 CELLPADDING=3 >
<tr>
<td>
<b>Name </b></td>
<td>
<br><b>Description</b> </td></tr>
<tr>
<td>
<br>bool </td>
<td>
<br>true (1) / false (0) value (equals uint8)</td></tr>
<tr>
<td>
<br>char </td>
<td>
<br>Latin-1 8-bit char (equals uint8)</td></tr>
<tr>
<td>
<br>float32 </td>
<td>
<br>IEC 60559:1989 32-bit float </td></tr>
<tr>
<td>
<br>float64 </td>
<td>
<br>IEC 60559:1989 64-bit float </td></tr>
<tr>
<td>
<br>int8 </td>
<td>
<br>Signed 8-bit integer </td></tr>
<tr>
<td>
<br>int16 </td>
<td>
<br>Signed 16-bit integer </td></tr>
<tr>
<td>
<br>int32 </td>
<td>
<br>Signed 32-bit integer </td></tr>
<tr>
<td>
<br>int64 </td>
<td>
<br>Signed 64-bit integer </td></tr>
<tr>
<td>
<br>intptr </td>
<td>
<br>Signed integer address, native size </td></tr>
<tr>
<td>
<br>uint8 </td>
<td>
<br>Unsigned 8-bit integer </td></tr>
<tr>
<td>
<br>uint16 </td>
<td>
<br>Unsigned 16-bit integer </td></tr>
<tr>
<td>
<br>uint32 </td>
<td>
<br>Unsigned 32-bit integer </td></tr>
<tr>
<td>
<br>uint64 </td>
<td>
<br>Unsigned 64-bit integer </td></tr></table></div>
<h4 style="margin-left:45px"><span class="label"><a name="15438">2.4.4</a></span>
<b>Alias types</b></h4>
<div style="margin-left:63px"><span class="label"><a name="15443">2.4.4.1</a></span>
A type can be an alias of another type. The other type is referenced with a qualident. If the other type is in another module, it must be exported. A type is considered the same type as its alias.</div>
<div style="margin-left:63px"><span class="label"><a name="15777">2.4.4.2</a></span>
Syntax of textual representation:</div>
<div style="margin-left:81px"><span class="label"><a name="15778">2.4.4.2.1</a></span>
<code>NamedType = qualident</code></div>
<h4 style="margin-left:45px"><span class="label"><a name="14967">2.4.5</a></span>
<b>Structured types</b></h4>
<h4 style="margin-left:63px"><span class="label"><a name="14968">2.4.5.1</a></span>
<b>Array types</b></h4>
<div style="margin-left:81px"><span class="label"><a name="14980">2.4.5.1.1</a></span>
An array is a structure consisting of a number of elements which are all of the same type, called the element type. The number of elements of an array is called its length. The length is a positive integer (uint32). The elements of the array are designated by indices, which are integers between 0 and the length minus 1. </div>
<div style="margin-left:81px"><span class="label"><a name="15422">2.4.5.1.2</a></span>
Syntax of textual representation:</div>
<div style="margin-left:99px"><span class="label"><a name="15423">2.4.5.1.2.1</a></span>
<code>ArrayType = ARRAY [ length ] OF NamedType | '[' [ length ] ']' NamedType</code>
<br><code>length = unsigned</code></div>
<div style="margin-left:81px"><span class="label"><a name="15424">2.4.5.1.3</a></span>
Arrays declared without length are called <i>open arrays</i>. They are restricted to pointer base types, and element types of open array types.</div>
<h4 style="margin-left:63px"><span class="label"><a name="14969">2.4.5.2</a></span>
<b>Struct and union types</b></h4>
<div style="margin-left:81px"><span class="label"><a name="15429">2.4.5.2.1</a></span>
MIL struct and union types correspond to the ones of the C programming language, including alignment and layout rules.</div>
<div style="margin-left:81px"><span class="label"><a name="14978">2.4.5.2.2</a></span>
A struct type is a structure consisting of a fixed number of elements, called fields, with possibly different types. The struct type declaration specifies the name and type of each field. The scope of the field identifiers extends from the point of their declaration to the end of the struct type, but they are also visible within designators referring to elements of struct variables. If a struct type is exported, field identifiers that are to be visible outside the declaring module must be marked. They are called public fields; unmarked elements are called private fields.</div>
<div style="margin-left:81px"><span class="label"><a name="15428">2.4.5.2.3</a></span>
A union type is declared like a struct type, but in contrast to the latter all fields reside at the same memory position. A union can be pictured as a chunk of memory that is used to store variables of different data types. Once a new value is assigned to a field, the existing data is overwritten with the new data.</div>
<div style="margin-left:81px"><span class="label"><a name="15426">2.4.5.2.4</a></span>
Syntax of textual representation:</div>
<div style="margin-left:99px"><span class="label"><a name="15427">2.4.5.2.4.1</a></span>
<code>StructUnionType = (STRUCT | UNION) { FieldList [';'] } END</code>
<br><code>FieldList = IdentList ':' NamedType</code>
<br><code>IdentList = identdef { [','] identdef }</code></div>
<h4 style="margin-left:45px"><span class="label"><a name="15432">2.4.6</a></span>
<b>Pointer types</b></h4>
<div style="margin-left:63px"><span class="label"><a name="15434">2.4.6.1</a></span>
Variables of a pointer type P assume as values pointers to variables of some type T. T is called the pointer base type of P and can be of any type. </div>
<div style="margin-left:63px"><span class="label"><a name="15435">2.4.6.2</a></span>
Syntax of textual representation:</div>
<div style="margin-left:81px"><span class="label"><a name="15436">2.4.6.2.1</a></span>
<pre><code>PointerType = ( POINTER TO | '^' ) NamedType</code></pre></div>
<div style="margin-left:63px"><span class="label"><a name="15437">2.4.6.3</a></span>
Any pointer variable or parameter may assume the value NIL, which points to no variable at all. </div>
<h4 style="margin-left:45px"><span class="label"><a name="15433">2.4.7</a></span>
<b>Procedure types</b></h4>
<div style="margin-left:63px"><span class="label"><a name="15439">2.4.7.1</a></span>
Variables of a procedure type T have a pointer to a procedure (or NIL) as value. If a procedure P is assigned to a variable of type T, the formal parameter lists and result types of P and T must <i>match.</i></div>
<div style="margin-left:63px"><span class="label"><a name="15440">2.4.7.2</a></span>
Syntax of textual representation:</div>
<div style="margin-left:81px"><span class="label"><a name="15441">2.4.7.2.1</a></span>
<pre><code>ProcedureType = (PROCEDURE|PROC) [FormalParameters]</code></pre></div>
<h4 style="margin-left:27px"><span class="label"><a name="14960">2.5</a></span>
Expressions</h4>
<div style="margin-left:45px"><span class="label"><a name="15552">2.5.1</a></span>
Expressions are calculated using a conceptual evaluation stack. The actual implementation is not supposed to be stack based. The conceptual evaluation stack is made up of conceptual slots that can hold any data type.</div>
<div style="margin-left:45px"><span class="label"><a name="15553">2.5.2</a></span>
An expression consists of a sequence of instructions which push or pop values of a specified type to and from the evaluation stack. </div>
<div style="margin-left:45px"><span class="label"><a name="15554">2.5.3</a></span>
The evaluation stack is empty upon procedure entry. Its contents are entirely local to a procedure and are preserved across <i>call</i> instructions. Arguments to other procedures and their return values are also placed on the evaluation stack. The evaluation stack is not addressable. At all times it is possible to deduce which one of a reduced set of types is stored in any stack location at a specific point in the instruction stream.</div>
<div style="margin-left:45px"><span class="label"><a name="15555">2.5.4</a></span>
While MIL, in general, supports the full set of types described in <a href="#14956">2.4 Types</a>, MIL only requires that values be one of:</div>
<div style="margin-left:63px"><span class="label"><a name="15556">2.5.4.1</a></span>
int64 , an 8-byte signed integer</div>
<div style="margin-left:63px"><span class="label"><a name="15557">2.5.4.2</a></span>
int32 , a 4-byte signed integer</div>
<div style="margin-left:63px"><span class="label"><a name="15558">2.5.4.3</a></span>
intptr, a signed integer of either 4 or 8 bytes, whichever is more convenient for the target architecture</div>
<div style="margin-left:63px"><span class="label"><a name="15559">2.5.4.4</a></span>
F , a floating point value (float32 , float64 , or other representation supported by the underlying hardware)</div>
<div style="margin-left:63px"><span class="label"><a name="15560">2.5.4.5</a></span>
a user-defined value type</div>
<div style="margin-left:45px"><span class="label"><a name="15549">2.5.5</a></span>
Syntax of textual representation:</div>
<div style="margin-left:63px"><span class="label"><a name="15550">2.5.5.1</a></span>
<code>Expression = { ExpInstr }</code>
<br><code>ExpInstr = 'add' | 'and' | ('call' | 'calli') qualident | 'castptr' qualident</code>
<br><code>| 'ceq' | 'cgt' | 'cgt_un' | 'clt' | 'clt_un' </code>
<br><code>| 'conv_i1' | 'conv_i2' | 'conv_i4' | 'conv_i8' | 'conv_r4' | 'conv_r8'</code>
<br><code>| 'conv_u1' | 'conv_u2' | 'conv_u4' | 'conv_u8' | 'conv_ip'</code>
<br><code>| 'div' | 'div_un' | 'dup' | 'initobj' qualident | ('ldarg'|'ldarg_s') (unsigned|ident) </code>
<br><code>| 'ldarg_0' | 'ldarg_1' | 'ldarg_2' | 'ldarg_3'</code>
<br><code>| ('ldarga'|'ldarga_s') (unsigned|ident)</code>
<br><code>| ('ldc_i4'|'ldc_i8'|'ldc_i4_s') integer | ('ldc_r4'|'ldc_r8') (real | integer)</code>
<br><code>| 'ldc_i4_0' | 'ldc_i4_1' | 'ldc_i4_2' | 'ldc_i4_3' | 'ldc_i4_4' | 'ldc_i4_5'</code>
<br><code>| 'ldc_i4_6' | 'ldc_i4_7' | 'ldc_i4_8' | 'ldc_i4_m1' | 'ldc_obj' constructor</code>
<br><code>| ('ldelem'|'ldelema') qualident | 'ldelem_i1' | 'ldelem_i2'</code>
<br><code>| 'ldelem_i4' | 'ldelem_i8' | 'ldelem_u1' | 'ldelem_u2' </code>
<br><code>| 'ldelem_u4' | 'ldelem_u8' | 'ldelem_r4' | 'ldelem_r8' | 'ldelem_ip'</code>
<br><code>| ('ldfld'|'ldflda') trident </code>
<br><code>| 'ldind_i1' | 'ldind_i2' | 'ldind_i4' | 'ldind_i8' | 'ldind_u1' | 'ldind_u2'</code>
<br><code>| 'ldind_u4' | 'ldind_r4' | 'ldind_u8' | 'ldind_r8' | 'ldind_ip'</code>
<br><code>| ('ldloc'|'ldloc_s'|'ldloca'|'ldloca_s')(unsigned|ident)</code>
<br><code>| 'ldloc_0' | 'ldloc_1' | 'ldloc_2' | 'ldloc_3' | 'ldnull' </code>
<br><code>| 'ldobj' [qualident] | 'ldproc' qualident | 'ldstr' (string|hexstring)</code>
<br><code>| ('ldvar'|'ldvara') qualident | 'mul' | 'neg' </code>
<br><code>| ('newarr'|'newvla'|'newobj') qualident </code>
<br><code>| 'not' | 'or' | 'rem' | 'rem_un' | 'shl' | 'shr' | 'shr_un' <br /><br />| 'sizeof' qualident | 'sub' | 'xor' | 'ptroff' qualident | 'nop'</code></div>
<div style="margin-left:63px"><span class="label"><a name="15733">2.5.5.2</a></span>
<code>ConstExpression = qualident | integer | real | string | hexstring </code></div>
<div style="margin-left:45px"><span class="label"><a name="15340">2.5.6</a></span>
TODO: keep designators to ease alias analysis.</div>
<h4 style="margin-left:45px"><span class="label"><a name="15734">2.5.7</a></span>
Constructors</h4>
<div style="margin-left:63px"><span class="label"><a name="15735">2.5.7.1</a></span>
With constructors, struct, union, array and pointer literals can be declared. </div>
<div style="margin-left:63px"><span class="label"><a name="15736">2.5.7.2</a></span>
Syntax of textual representation:</div>
<div style="margin-left:81px"><span class="label"><a name="15737">2.5.7.2.1</a></span>
<code>constructor = NamedType component_list<br />component_list = '{' [ component {[','] component} ] '}' <br />component = [ident '='] ( ConstExpression | component_list )</code></div>
<div style="margin-left:63px"><span class="label"><a name="15738">2.5.7.3</a></span>
A constructor consists of an explicit type and a list of either named or anonymous components. Named and anonymous components cannot be mixed in the list.</div>
<div style="margin-left:63px"><span class="label"><a name="15739">2.5.7.4</a></span>
If NamedType is a struct type, then there is either an anonymous component for each field of the struct in the order of declaration, or there is a named component for each field in arbitrary order. For union types, only named components can be used, and only one option of the union can be initialized in the constructor.</div>
<div style="margin-left:63px"><span class="label"><a name="15740">2.5.7.5</a></span>
If NamedType is an array type, then there is an anonymous componend for each element of the array. The array type may be an open array in which case the number of elements is determined by the number of components.</div>
<div style="margin-left:63px"><span class="label"><a name="15741">2.5.7.6</a></span>
If NamedType is a pointer type, then there is exactly one anonymous component which is an unsigned integer type constant representing the address. </div>
<div style="margin-left:63px"><span class="label"><a name="15742">2.5.7.7</a></span>
For each field or element which is of struct, union, array or pointer type, an embedded constructor is required. Since the exact type of the field or element is known, the NamedType prefix is not required.</div>
<h4 style="margin-left:45px"><span class="label"><a name="14964">2.5.8</a></span>
<b>add</b></h4>
<div style="margin-left:63px"><span class="label"><a name="15067">2.5.8.1</a></span>
<table border=1 cellspacing=0 CELLPADDING=3 >
<tr>
<td>
<b>Binary</b> </td>
<td>
<br><b>Text Format</b> </td>
<td>
<br><b>Description</b> </td></tr>
<tr>
<td>
<br>58 </td>
<td>
<br>add </td>
<td>
<br>Add two values, returning a new value. </td></tr></table></div>
<div style="margin-left:63px"><span class="label"><a name="14982">2.5.8.2</a></span>
<code>…, value1, value2 -> …, result</code></div>
<div style="margin-left:63px"><span class="label"><a name="14983">2.5.8.3</a></span>
The add instruction adds <i>value2 </i>to<i> value1 </i>and pushes the result on the stack. Overflow is not detected for integral operations; floating-point overflow returns +inf or -inf.</div>
<div style="margin-left:63px"><span class="label"><a name="14984">2.5.8.4</a></span>
The acceptable operand types and their corresponding result data type are encapsulated as follows:</div>
<div style="margin-left:81px"><span class="label"><a name="14996">2.5.8.4.1</a></span>
<table border=1 cellspacing=0 CELLPADDING=3 ><thead>
<tr>
<td rowspan="2">
<b>A's Type</b> </td>
<td colspan="5">
<br><b>B's Type</b> </td></tr></thead>
<tr>
<td>
<br><b>int32</b> </td>
<td>
<br><b>int64</b> </td>
<td>
<br><b>intptr</b> </td>
<td>
<br><b>F</b> </td>
<td>
<br><br /></td></tr>
<tr>
<td>
<br><b>int32 </b></td>
<td>
<br>int32 </td>
<td>
<br>x </td>
<td>
<br>intptr</td>
<td>
<br>x </td>
<td>
<br><br /></td></tr>
<tr>
<td>
<br><b>int64 </b></td>
<td>
<br>x </td>
<td>
<br>int64 </td>
<td>
<br>x </td>
<td>
<br>x </td>
<td>
<br><br /></td></tr>
<tr>
<td>
<br><b>intptr </b></td>
<td>
<br>intptr </td>
<td>
<br>x </td>
<td>
<br>intptr</td>
<td>
<br>x </td>
<td>
<br><br /></td></tr>
<tr>
<td>
<br><b>F </b></td>
<td>
<br>x</td>
<td>
<br>x</td>
<td>
<br>x </td>
<td>
<br>F </td>
<td>
<br><br /></td></tr></table></div>
<h4 style="margin-left:45px"><span class="label"><a name="14987">2.5.9</a></span>
and – bitwise AND </h4>
<div style="margin-left:63px"><span class="label"><a name="15068">2.5.9.1</a></span>
<table border=1 cellspacing=0 CELLPADDING=3 >
<tr>
<td>
<b>Binary</b> </td>
<td>
<br><b>Text Format</b> </td>
<td>
<br><b>Description</b> </td></tr>
<tr>
<td>
<br>5F </td>
<td>
<br>and </td>
<td>
<br>Bitwise and of two integral values, returns an integral value. </td></tr></table></div>
<div style="margin-left:63px"><span class="label"><a name="14988">2.5.9.2</a></span>
<code>…, value1, value2 -> …, result</code></div>
<div style="margin-left:63px"><span class="label"><a name="14989">2.5.9.3</a></span>
The and instruction computes the bitwise and of <i>value1</i> and <i>value2 </i>and pushes the result on the stack. The acceptable operand types and their corresponding result data type are encapsulated as follows:</div>
<div style="margin-left:81px"><span class="label"><a name="14997">2.5.9.3.1</a></span>
<table border=1 cellspacing=0 CELLPADDING=3 ><thead>
<tr>
<td>
<br /></td>
<td>
<br><b>int32</b> </td>
<td>
<br><b>int64</b> </td>
<td>
<br><b>intptr</b></td>
<td>
<br><b>F</b> </td></tr></thead>
<tr>
<td>
<br><b>int32</b> </td>
<td>
<br>int32 </td>
<td>
<br>x </td>
<td>
<br>intptr </td>
<td>
<br>x </td></tr>
<tr>
<td>
<br><b>int64</b> </td>
<td>
<br>x</td>
<td>
<br>int64 </td>
<td>
<br>x </td>
<td>
<br>x </td></tr>
<tr>
<td>
<br><b>intptr</b> </td>
<td>
<br>intptr </td>
<td>
<br>x </td>
<td>
<br>intptr </td>
<td>
<br>x </td></tr>
<tr>
<td>
<br><b>F</b> </td>
<td>
<br>x </td>
<td>
<br>x </td>
<td>
<br>x </td>
<td>
<br>x </td></tr></table></div>
<h4 style="margin-left:45px"><span class="label"><a name="14991">2.5.10</a></span>
<b>call – call a function </b></h4>
<div style="margin-left:63px"><span class="label"><a name="15069">2.5.10.1</a></span>
<table border=1 cellspacing=0 CELLPADDING=3 >
<tr>
<td>
<b>Binary</b> </td>
<td>
<br><b>Text</b> <b>Format</b></td>
<td>
<br><b>Description</b> </td></tr>
<tr>
<td>
<br>28 <<i>T</i>> </td>
<td>
<br>call <i>function</i> </td>
<td>
<br>Call function described by <i>function.</i> </td></tr></table></div>
<div style="margin-left:63px"><span class="label"><a name="14999">2.5.10.2</a></span>
<code>…, arg1, arg2 … argN -> …, retVal</code></div>
<div style="margin-left:63px"><span class="label"><a name="15006">2.5.10.3</a></span>
<code>…, arg1, arg2 … argN -> …</code></div>
<div style="margin-left:63px"><span class="label"><a name="15000">2.5.10.4</a></span>
The call instruction calls the function indicated by the descriptor. The latter indicates the function to call, and the number, type, and order of the arguments that have been placed on the stack to be passed to that function, or possibly returned from the function. The arguments are placed on the stack in left-to-right order. That is, the first argument is computed and placed on the stack, then the second argument, and so on. If the method has a return value, it is pushed on the stack upon method completion.</div>
<div style="margin-left:63px"><span class="label"><a name="15001">2.5.10.5</a></span>
TODO: tail calls</div>
<h4 style="margin-left:45px"><span class="label"><a name="15008">2.5.11</a></span>
<b>calli – indirect function call </b></h4>
<div style="margin-left:63px"><span class="label"><a name="15070">2.5.11.1</a></span>
<table border=1 cellspacing=0 CELLPADDING=3 >
<tr>
<td>
<b>Binary</b> </td>
<td>
<br><b>Text Format</b> </td>
<td>
<br><b>Description</b> </td></tr>
<tr>
<td>
<br>29 <<i>T</i>> </td>
<td>
<br>calli <i>function</i> </td>
<td>
<br>Call function indicated on the stack with arguments described by <i>function</i>. </td></tr></table></div>
<div style="margin-left:63px"><span class="label"><a name="15010">2.5.11.2</a></span>
<code>…, arg1, arg2 … argN, ftn -> …, retVal</code></div>
<div style="margin-left:63px"><span class="label"><a name="15009">2.5.11.3</a></span>
<code>…, arg1, arg2 … argN, ftn -> …</code></div>
<div style="margin-left:63px"><span class="label"><a name="15011">2.5.11.4</a></span>
The calli instruction calls <i>ftn</i> (a pointer to a procedure entry point) with the arguments arg1 … argN. The types of these arguments, and a possible return type, are described by the signature. The <i>ftn</i> argument is assumed to be a pointer to native code (of the target machine) that can be legitimately called with the arguments described by the signature. Such a pointer can be created using the ldproc instruction, or could have been passed in from external code. The arguments are placed on the stack in left-to-right order. That is, the first argument is computed and placed on the stack, then the second argument, and so on. If the method has a return value, it is pushed on the stack upon method completion.</div>
<div style="margin-left:63px"><span class="label"><a name="15012">2.5.11.5</a></span>
TODO: tail calls</div>
<h4 style="margin-left:45px"><span class="label"><a name="15233">2.5.12</a></span>
<b>castptr – cast a pointer to a type </b></h4>
<div style="margin-left:63px"><span class="label"><a name="15234">2.5.12.1</a></span>
<table border=1 cellspacing=0 CELLPADDING=3 >
<tr>
<td>
<b>Binary</b> </td>
<td>
<br><b>Text Format</b> </td>
<td>
<br><b>Description</b> </td></tr>
<tr>
<td>
<br>74 <<i>T</i>> </td>
<td>
<br>castptr <i>type </i></td>
<td>
<br>Cast pointer <i>ptr</i> to <i>type</i></td></tr></table></div>
<div style="margin-left:81px"><span class="label"><a name="15235">2.5.12.1.1</a></span>
<code>…, ptr -> …, ptr2</code></div>
<div style="margin-left:81px"><span class="label"><a name="15236">2.5.12.1.2</a></span>
The castptr instruction reinterprets the pointer to type1 on the stack as a pointer to type2. </div>
<div style="margin-left:81px"><span class="label"><a name="15237">2.5.12.1.3</a></span>
If <i>ptr</i> is null, castptr succeeds and returns null.</div>
<h4 style="margin-left:45px"><span class="label"><a name="15014">2.5.13</a></span>
<b>ceq – compare equal</b></h4>
<div style="margin-left:63px"><span class="label"><a name="15071">2.5.13.1</a></span>
<table border=1 cellspacing=0 CELLPADDING=3 >
<tr>
<td>
<b>Binary</b> </td>
<td>
<br><b>Text Format</b> </td>
<td>
<br><b>Description</b> </td></tr>
<tr>
<td>
<br>FE 01 </td>
<td>
<br>ceq </td>
<td>
<br>Push 1 (of type int32) if <i>value1</i> equals <i>value2</i>, else push 0. </td></tr></table></div>
<div style="margin-left:63px"><span class="label"><a name="15015">2.5.13.2</a></span>
<code>…, value1, value2 -> …, result</code></div>
<div style="margin-left:63px"><span class="label"><a name="15016">2.5.13.3</a></span>
The ceq instruction compares <i>value</i>1 and <i>value</i>2. If <i>value</i>1 is equal to <i>value</i>2, then 1 (of type int32) is pushed on the stack. Otherwise, 0 (of type int32) is pushed on the stack. For floating-point numbers, ceq will return 0 if the numbers are unordered (either or both are NaN). The infinite values are equal to themselves.</div>
<div style="margin-left:63px"><span class="label"><a name="15017">2.5.13.4</a></span>
The acceptable operand types are encapsulated as follows:</div>
<div style="margin-left:81px"><span class="label"><a name="15018">2.5.13.4.1</a></span>
<table border=1 cellspacing=0 CELLPADDING=3 >
<tr>
<td>
<br /></td>
<td>
<br><b>int32</b> </td>
<td>
<br><b>int64</b> </td>
<td>
<br><b>intptr</b> </td>
<td>
<br><b>F</b> </td></tr>
<tr>
<td>
<br><b>int32</b> </td>
<td>
<br>ok</td>
<td>
<br>x</td>
<td>
<br>ok</td>
<td>
<br>x</td></tr>
<tr>
<td>
<br><b>int64</b> </td>
<td>
<br>x</td>
<td>
<br>ok</td>
<td>
<br>x</td>
<td>
<br>x</td></tr>
<tr>
<td>
<br><b>intptr</b> </td>
<td>
<br>ok</td>
<td>
<br>x</td>
<td>
<br>ok</td>
<td>
<br>x</td></tr>
<tr>
<td>
<br><b>F</b> </td>
<td>
<br>x</td>
<td>
<br>x</td>
<td>
<br>x</td>
<td>
<br>ok</td></tr></table></div>
<h4 style="margin-left:45px"><span class="label"><a name="15019">2.5.14</a></span>
<b>cgt – compare greater than</b></h4>
<div style="margin-left:63px"><span class="label"><a name="15072">2.5.14.1</a></span>
<table border=1 cellspacing=0 CELLPADDING=3 >
<tr>
<td>
<b>Binary</b> </td>
<td>
<br><b>Text Format</b> </td>
<td>
<br><b>Description</b> </td></tr>
<tr>
<td>
<br>FE 02 </td>
<td>
<br>cgt </td>
<td>
<br>Push 1 (of type int32) if <i>value1</i> > <i>value2</i>, else push 0. </td></tr></table></div>
<div style="margin-left:63px"><span class="label"><a name="15020">2.5.14.2</a></span>
The cgt instruction compares <i>value1</i> and <i>value2</i>. If <i>value1</i> is strictly greater than <i>value2</i>, then 1 (of type int32) is pushed on the stack. Otherwise, 0 (of type int32) is pushed on the stack. For floating-point numbers, cgt returns 0 if the numbers are unordered (that is, if one or both of the arguments are NaN). As with IEC 60559:1989, infinite values are ordered with respect to normal numbers (e.g., +infinity > 5.0 > -infinity).</div>
<div style="margin-left:63px"><span class="label"><a name="15021">2.5.14.3</a></span>
The acceptable operand types are encapsulated in table <a href="#15018">2.5.13.4.1</a>.</div>
<h4 style="margin-left:45px"><span class="label"><a name="15022">2.5.15</a></span>
<b>cgt_un – compare greater than, unsigned or unordered</b></h4>
<div style="margin-left:63px"><span class="label"><a name="15073">2.5.15.1</a></span>
<table border=1 cellspacing=0 CELLPADDING=3 >
<tr>
<td>
<b>Binary</b> </td>
<td>
<br><b>Text Format</b> </td>
<td>
<br><b>Description</b> </td></tr>
<tr>
<td>
<br>FE 03 </td>
<td>
<br>cgt_un </td>
<td>
<br>Push 1 (of type int32) if <i>value1</i> > <i>value2</i>, unsigned or unordered, else push 0. </td></tr></table></div>
<div style="margin-left:63px"><span class="label"><a name="15023">2.5.15.2</a></span>
<code>…, value1, value2 -> …, result</code></div>
<div style="margin-left:63px"><span class="label"><a name="15024">2.5.15.3</a></span>
The cgt.un instruction compares <i>value1</i> and <i>value2</i>. A value of 1 (of type int32) is pushed on the stack if</div>
<div style="margin-left:81px"><span class="label"><a name="15025">2.5.15.3.1</a></span>
for floating-point numbers, either value1 is strictly greater than value2, or value1 is not ordered with respect to value2. </div>
<div style="margin-left:81px"><span class="label"><a name="15026">2.5.15.3.2</a></span>
for integer values, value1 is strictly greater than value2 when considered as unsigned numbers. Otherwise, 0 (of type int32) is pushed on the stack. </div>
<div style="margin-left:63px"><span class="label"><a name="15027">2.5.15.4</a></span>
As per IEC 60559:1989, infinite values are ordered with respect to normal numbers (e.g., +infinity > 5.0 > -infinity). </div>
<div style="margin-left:63px"><span class="label"><a name="15029">2.5.15.5</a></span>
The acceptable operand types are encapsulated in table <a href="#15018">2.5.13.4.1</a>.</div>
<h4 style="margin-left:45px"><span class="label"><a name="15028">2.5.16</a></span>
clt – compare less than</h4>
<div style="margin-left:63px"><span class="label"><a name="15074">2.5.16.1</a></span>
<table border=1 cellspacing=0 CELLPADDING=3 >
<tr>
<td>
<b>Binary</b> </td>
<td>
<br><b>Text Format</b> </td>
<td>
<br><b>Description</b> </td></tr>
<tr>
<td>
<br>FE 04 </td>
<td>
<br>clt </td>
<td>
<br>Push 1 (of type int32) if <i>value1</i> < <i>value2</i>, else push 0. </td></tr></table></div>
<div style="margin-left:63px"><span class="label"><a name="15030">2.5.16.2</a></span>
<code>…, value1, value2 -> …, result</code></div>
<div style="margin-left:63px"><span class="label"><a name="15031">2.5.16.3</a></span>
The clt instruction compares <i>value1</i> and <i>value2</i>. If <i>value1</i> is strictly less than <i>value2</i>, then 1 (of type int32) is pushed on the stack. Otherwise, 0 (of type int32) is pushed on the stack. For floating-point numbers, clt will return 0 if the numbers are unordered (that is, one or both of the arguments are NaN). As per IEC 60559:1989, infinite values are ordered with respect to normal numbers (e.g., +infinity > 5.0 > -infinity).</div>
<div style="margin-left:63px"><span class="label"><a name="15032">2.5.16.4</a></span>
The acceptable operand types are encapsulated in table <a href="#15018">2.5.13.4.1</a>.</div>
<h4 style="margin-left:45px"><span class="label"><a name="15033">2.5.17</a></span>
<b>clt_un – compare less than, unsigned or unordered</b></h4>
<div style="margin-left:63px"><span class="label"><a name="15075">2.5.17.1</a></span>
<table border=1 cellspacing=0 CELLPADDING=3 >
<tr>
<td>
<b>Binary</b> </td>
<td>
<br><b>Text Format</b> </td>
<td>
<br><b>Description</b> </td></tr>
<tr>
<td>
<br>FE 05 </td>
<td>
<br>clt_un </td>
<td>
<br>Push 1 (of type int32) if <i>value1</i> < <i>value2</i>, unsigned or unordered, else push 0. </td></tr></table></div>
<div style="margin-left:63px"><span class="label"><a name="15034">2.5.17.2</a></span>
<code>…, value1, value2 -> …, result</code></div>
<div style="margin-left:63px"><span class="label"><a name="15035">2.5.17.3</a></span>
The clt.un instruction compares <i>value1</i> and <i>value2</i>. A value of 1 (of type int32) is pushed on the stack if </div>
<div style="margin-left:81px"><span class="label"><a name="15036">2.5.17.3.1</a></span>
for floating-point numbers, either value1 is strictly less than value2, or value1 is not ordered with respect to value2.</div>
<div style="margin-left:81px"><span class="label"><a name="15037">2.5.17.3.2</a></span>
for integer values, value1 is strictly less than value2 when considered as unsigned numbers. Otherwise, 0 (of type int32) is pushed on the stack.</div>
<div style="margin-left:63px"><span class="label"><a name="15038">2.5.17.4</a></span>
As per IEC 60559:1989, infinite values are ordered with respect to normal numbers (e.g., +infinity > 5.0 > -infinity).</div>
<div style="margin-left:63px"><span class="label"><a name="15039">2.5.17.5</a></span>
The acceptable operand types are encapsulated in table <a href="#15018">2.5.13.4.1</a>.</div>
<h4 style="margin-left:45px"><span class="label"><a name="15040">2.5.18</a></span>
<b>conv – data conversion</b></h4>
<div style="margin-left:63px"><span class="label"><a name="15076">2.5.18.1</a></span>
<table border=1 cellspacing=0 CELLPADDING=3 >
<tr>
<td>
<b>Binary</b> </td>
<td>
<br><b>Text Format</b> </td>
<td>
<br><b>Description</b> </td></tr>
<tr>
<td>
<br>67 </td>
<td>
<br>conv_i1 </td>
<td>
<br>Convert to int8, pushing int32 on stack. </td></tr>
<tr>
<td>
<br>68 </td>
<td>
<br>conv_i2 </td>
<td>
<br>Convert to int16, pushing int32 on stack. </td></tr>
<tr>
<td>
<br>69 </td>
<td>
<br>conv_i4 </td>
<td>
<br>Convert to int32, pushing int32 on stack. </td></tr>
<tr>
<td>
<br>6A </td>
<td>
<br>conv_i8 </td>
<td>
<br>Convert to int64, pushing int64 on stack. </td></tr>
<tr>
<td>
<br>6B </td>
<td>
<br>conv_r4 </td>
<td>
<br>Convert to float32, pushing F on stack. </td></tr>
<tr>
<td>
<br>6C </td>
<td>
<br>conv_r8 </td>
<td>
<br>Convert to float64, pushing F on stack. </td></tr>
<tr>
<td>
<br>D2 </td>
<td>
<br>conv_u1 </td>
<td>
<br>Convert to unsigned int8, pushing int32 on stack. </td></tr>
<tr>
<td>
<br>D1 </td>
<td>
<br>conv_u2 </td>
<td>
<br>Convert to unsigned int16, pushing int32 on stack. </td></tr>
<tr>
<td>
<br>6D </td>
<td>
<br>conv_u4 </td>
<td>
<br>Convert to unsigned int32, pushing int32 on stack. </td></tr>
<tr>
<td>
<br>6E </td>
<td>
<br>conv_u8 </td>
<td>
<br>Convert to unsigned int64, pushing int64 on stack. </td></tr>
<tr>
<td>
<br>D3 </td>
<td>
<br>conv_ip</td>
<td>
<br>Convert to intptr, pushing intptr on stack. </td></tr></table></div>
<div style="margin-left:63px"><span class="label"><a name="15041">2.5.18.2</a></span>
<code>…, value -> …, result</code></div>
<div style="margin-left:63px"><span class="label"><a name="15043">2.5.18.3</a></span>
Convert the value on top of the stack to the type specified in the opcode, and leave that converted value on the top of the stack. Note that integer values of less than 4 bytes are extended to int32 (not intptr) when they are loaded onto the evaluation stack, and floating-point values are converted to the F type.</div>
<div style="margin-left:63px"><span class="label"><a name="15044">2.5.18.4</a></span>
Conversion from floating-point numbers to integral values truncate the number toward zero. When converting from a float64 to a float32, precision might be lost. If <i>value </i>is too large to fit in a float32, the IEC 60559:1989 positive infinity (if <i>value</i> is positive) or IEC 60559:1989 negative infinity (if <i>value</i> is negative) is returned. If overflow occurs when converting one integer type to another, the high-order bits are silently truncated. If the result is smaller than an int32, then the value is sign-extended to fill the slot.</div>
<div style="margin-left:63px"><span class="label"><a name="15045">2.5.18.5</a></span>
If overflow occurs converting a floating-point type to an integer, or if the floating-point value being converted to an integer is a NaN, the value returned is unspecified. </div>
<div style="margin-left:63px"><span class="label"><a name="15046">2.5.18.6</a></span>
The acceptable operand types and their corresponding result data type is encapsulated as follows:</div>
<div style="margin-left:81px"><span class="label"><a name="15047">2.5.18.6.1</a></span>
<table border=1 cellspacing=0 CELLPADDING=3 ><thead>
<tr>
<td rowspan="2">
<b>Convert-To</b> </td>
<td colspan="5">
<br><b>Input (from evaluation stack)</b> </td></tr></thead>
<tr>
<td>
<br><b>int32</b> </td>
<td>
<br><b>int64</b> </td>
<td>
<br><b>intptr</b> </td>
<td>
<br><b>F</b> </td>
<td></td></tr>
<tr>
<td>
<br><b>int8<br />uint8<br />int16<br />uint16</b> </td>
<td>
<br>Truncate<sup>1</sup> </td>
<td>
<br>Truncate<sup>1</sup> </td>
<td>
<br>Truncate<sup>1</sup> </td>
<td>
<br>Truncate to zero<sup>2</sup> </td>
<td></td></tr>
<tr>
<td>
<br><b>int32<br />uint32</b> </td>
<td>
<br>Nop </td>
<td>
<br>Truncate<sup>1</sup> </td>
<td>
<br>Truncate<sup>1</sup> </td>
<td>
<br>Truncate to zero<sup>2</sup> </td>
<td></td></tr>
<tr>
<td>
<br><b>int64</b> </td>
<td>