forked from pmetras/nim0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOSG.html
1317 lines (1025 loc) · 95.1 KB
/
OSG.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
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- This file is generated by Nim. -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Favicon -->
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
<!-- Google fonts -->
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
<!-- CSS -->
<title>src/OSG</title>
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
<script type="text/javascript" src="dochack.js"></script>
<script type="text/javascript">
function main() {
var pragmaDots = document.getElementsByClassName("pragmadots");
for (var i = 0; i < pragmaDots.length; i++) {
pragmaDots[i].onclick = function(event) {
// Hide tease
event.target.parentNode.style.display = "none";
// Show actual
event.target.parentNode.nextElementSibling.style.display = "inline";
}
}
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
function switchTheme(e) {
if (e.target.checked) {
document.documentElement.setAttribute('data-theme', 'dark');
localStorage.setItem('theme', 'dark');
} else {
document.documentElement.setAttribute('data-theme', 'light');
localStorage.setItem('theme', 'light');
}
}
toggleSwitch.addEventListener('change', switchTheme, false);
const currentTheme = localStorage.getItem('theme') ? localStorage.getItem('theme') : null;
if (currentTheme) {
document.documentElement.setAttribute('data-theme', currentTheme);
if (currentTheme === 'dark') {
toggleSwitch.checked = true;
}
}
}
window.addEventListener('DOMContentLoaded', main);
</script>
</head>
<body>
<div class="document" id="documentId">
<div class="container">
<h1 class="title">src/OSG</h1>
<div class="row">
<div class="three columns">
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox" />
<div class="slider round"></div>
</label>
<em>Dark Mode</em>
</div>
<div id="global-links">
<ul class="simple">
<li>
<a href="theindex.html">Index</a>
</li>
</ul>
</div>
<div id="searchInputDiv">
Search: <input type="text" id="searchInput"
onkeyup="search()" />
</div>
<div>
Group by:
<select onchange="groupBy(this.value)">
<option value="section">Section</option>
<option value="type">Type</option>
</select>
</div>
<ul class="simple simple-toc" id="toc-list">
<li><a class="reference" id="nim0-language-in-nim_toc" href="#nim0-language-in-nim">Nim0 language in Nim</a></li>
<li>
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
<ul class="simple simple-toc-section">
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#7" id="57">Types</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#osgObject"
title="osgObject = ref osgObjDesc">osgObject</a></li>
<li><a class="reference" href="#osgType"
title="osgType = ref osgTypeDesc">osgType</a></li>
<li><a class="reference" href="#osgItem"
title="osgItem = object
mode*: int32 ## The addressing mode (direct, immediate or register) used
## to access the symbol [CC53].
lev*: int32 ## Level in included contexts.
typ*: osgType ## The type of the local symbol [CC54].
a*: int32 ## Additionnal attributes [CC53]. Following attributes `a`, `b` and `r`
## are used by Wirth to store many intermediate values depending on
## context and documenting them is difficult. Here are some explanations.
## The local value of the symbol if the item is a constant (`mode == Const`).
## Or the address offset to access the field if the item is an `object` [CC57].
## Value in memory at address `a`.
## Or the index if the item is an `array` [CC57].
## In case of `osgCond` mode, the fixup addresses (F-list) for `or` conditions [CC68].
## In case of `Proc` mode, contains the current value of `osgPc`, whci is the
## entry address of the procedure prologue [CC76].
b: int32 ## Another additional attribute like `a`.
## In case of `osgCond` mode, the fixup addresses (T-list) for `and` conditions [CC68].
r: int32 ## The register number where a value is temporarily stored (cached) [CC53].
## Instead of refering to memory, operations on register are
## faster. Value held in register `R[r]`.
## If the item is an `array`, register `R[r]` holds the index.
## In case of `osgCond` mode, it contains which relation is specified by the
## comparison [CC62].">osgItem</a></li>
<li><a class="reference" href="#osgObjDesc"
title="osgObjDesc = object
class*: int32 ## It indicates whether the identifier denotes a constant,
## a variable, a type or a procedure [CC39].
lev*: int32 ## Denotes the nesting level of the declared object [CC76].
next*: osgObject
dsc*: osgObject ## Link between scopes of procedure [CC76].
typ*: osgType ## The symbol type [CC39]
name*: string ## Name of the symbol [CC39]
val*: int32 ## Value of the symbol, if known at compile time [CC39]
## Or address of procedure in bytes.
nofpar*: int32 ## Number of formal parameters when object is a procedure.
comd*: bool ## The symbol is exported. In case of a `proc`, it means
## that it can be called from the RISC emulator.">osgObjDesc</a></li>
<li><a class="reference" href="#osgTypeDesc"
title="osgTypeDesc = object
form*: int32 ## Type form: bool/int/array/object. Differentiates between
## elementary types (`bool`, `int`) and structured types
## (`array`, `object` ) [CC40].
dsc*: osgObject
base*: osgType ## Base type of an array element [CC41].
size*: int32 ## Size of the type for memory allocation [CC42].
len*: int32 ## The number of elements in an array [CC41].
nofpar*: int32 ## Number of formal parameters?">osgTypeDesc</a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#8" id="58">Vars</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#osgBoolType"
title="osgBoolType: osgType">osgBoolType</a></li>
<li><a class="reference" href="#osgIntType"
title="osgIntType: osgType">osgIntType</a></li>
<li><a class="reference" href="#osgCharType"
title="osgCharType: osgType">osgCharType</a></li>
<li><a class="reference" href="#osgPc"
title="osgPc: int32">osgPc</a></li>
<li><a class="reference" href="#osgCode"
title="osgCode: array[osgMemSize, uint32]">osgCode</a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#10" id="60">Consts</a>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#osgWordSize"
title="osgWordSize = 4">osgWordSize</a></li>
<li><a class="reference" href="#osgMemSize"
title="osgMemSize = 8192'i32">osgMemSize</a></li>
<li><a class="reference" href="#osgHead"
title="osgHead = 0">osgHead</a></li>
<li><a class="reference" href="#osgConst"
title="osgConst = 1">osgConst</a></li>
<li><a class="reference" href="#osgVar"
title="osgVar = 2">osgVar</a></li>
<li><a class="reference" href="#osgPar"
title="osgPar = 3">osgPar</a></li>
<li><a class="reference" href="#osgFld"
title="osgFld = 4">osgFld</a></li>
<li><a class="reference" href="#osgTyp"
title="osgTyp = 5">osgTyp</a></li>
<li><a class="reference" href="#osgSProc"
title="osgSProc = 6">osgSProc</a></li>
<li><a class="reference" href="#osgSFunc"
title="osgSFunc = 7">osgSFunc</a></li>
<li><a class="reference" href="#osgProc"
title="osgProc = 8">osgProc</a></li>
<li><a class="reference" href="#osgNoTyp"
title="osgNoTyp = 9">osgNoTyp</a></li>
<li><a class="reference" href="#osgBoolean"
title="osgBoolean = 0">osgBoolean</a></li>
<li><a class="reference" href="#osgInteger"
title="osgInteger = 1">osgInteger</a></li>
<li><a class="reference" href="#osgCharacter"
title="osgCharacter = 2">osgCharacter</a></li>
<li><a class="reference" href="#osgArray"
title="osgArray = 3">osgArray</a></li>
<li><a class="reference" href="#osgRecord"
title="osgRecord = 4">osgRecord</a></li>
<li><a class="reference" href="#osgMOV"
title="osgMOV = 0">osgMOV</a></li>
<li><a class="reference" href="#osgLSL"
title="osgLSL = 1">osgLSL</a></li>
<li><a class="reference" href="#osgASR"
title="osgASR = 2">osgASR</a></li>
<li><a class="reference" href="#osgROR"
title="osgROR = 3">osgROR</a></li>
<li><a class="reference" href="#osgAND"
title="osgAND = 4">osgAND</a></li>
<li><a class="reference" href="#osgANN"
title="osgANN = 5">osgANN</a></li>
<li><a class="reference" href="#osgIOR"
title="osgIOR = 6">osgIOR</a></li>
<li><a class="reference" href="#osgXOR"
title="osgXOR = 7">osgXOR</a></li>
<li><a class="reference" href="#osgADD"
title="osgADD = 8">osgADD</a></li>
<li><a class="reference" href="#osgSUB"
title="osgSUB = 9">osgSUB</a></li>
<li><a class="reference" href="#osgCMP"
title="osgCMP = 9">osgCMP</a></li>
<li><a class="reference" href="#osgMUL"
title="osgMUL = 10">osgMUL</a></li>
<li><a class="reference" href="#osgDIV"
title="osgDIV = 11">osgDIV</a></li>
<li><a class="reference" href="#osgLDW"
title="osgLDW = 0">osgLDW</a></li>
<li><a class="reference" href="#osgSTW"
title="osgSTW = 2">osgSTW</a></li>
<li><a class="reference" href="#osgStdOpenInput"
title="osgStdOpenInput = 0x000FFFFF'u32">osgStdOpenInput</a></li>
<li><a class="reference" href="#osgStdReadInt"
title="osgStdReadInt = 0x000FFFFE'u32">osgStdReadInt</a></li>
<li><a class="reference" href="#osgStdEot"
title="osgStdEot = 0x000FFFFD'u32">osgStdEot</a></li>
<li><a class="reference" href="#osgStdWriteInt"
title="osgStdWriteInt = 0x000FFFFC'u32">osgStdWriteInt</a></li>
<li><a class="reference" href="#osgStdWriteChar"
title="osgStdWriteChar = 0x000FFFFB'u32">osgStdWriteChar</a></li>
<li><a class="reference" href="#osgStdWriteLine"
title="osgStdWriteLine = 0x000FFFFA'u32">osgStdWriteLine</a></li>
<li><a class="reference" href="#osgStdLED"
title="osgStdLED = 0x000FFFF9'u32">osgStdLED</a></li>
<li><a class="reference" href="#osgStdSwitch"
title="osgStdSwitch = 0x000FFFF8'u32">osgStdSwitch</a></li>
<li><a class="reference" href="#osgStdWriteBool"
title="osgStdWriteBool = 0x000FFFF7'u32">osgStdWriteBool</a></li>
<li><a class="reference" href="#osgStdRead"
title="osgStdRead = 0x000FFFF6'u32">osgStdRead</a></li>
</ul>
</li>
<li>
<a class="reference reference-toplevel" href="#12" id="62">Procs</a>
<ul class="simple simple-toc-section">
<ul class="simple nested-toc-section">osgMakeConstItem
<li><a class="reference" href="#osgMakeConstItem%2CosgItem%2CosgType%2Cint32"
title="osgMakeConstItem(x: var osgItem; typ: osgType; val: int32)">osgMakeConstItem(x: var osgItem; typ: osgType; val: int32)</a></li>
</ul>
<ul class="simple nested-toc-section">osgCall
<li><a class="reference" href="#osgCall%2CosgObject"
title="osgCall(obj: var osgObject)">osgCall(obj: var osgObject)</a></li>
</ul>
<ul class="simple nested-toc-section">osgWriteReg
<li><a class="reference" href="#osgWriteReg%2Cuint32%2CFile"
title="osgWriteReg(r: uint32; f: File = W)">osgWriteReg(r: uint32; f: File = W)</a></li>
</ul>
<ul class="simple nested-toc-section">osgAnd1
<li><a class="reference" href="#osgAnd1%2CosgItem"
title="osgAnd1(x: var osgItem)">osgAnd1(x: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgOpen
<li><a class="reference" href="#osgOpen"
title="osgOpen()">osgOpen()</a></li>
</ul>
<ul class="simple nested-toc-section">osgAddOp
<li><a class="reference" href="#osgAddOp%2Cint32%2CosgItem%2CosgItem"
title="osgAddOp(op: int32; x, y: var osgItem)">osgAddOp(op: int32; x, y: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgEnter
<li><a class="reference" href="#osgEnter%2Cint32%2Cint32%2Cbool"
title="osgEnter(parblksize, locblksize: int32; comd: bool)">osgEnter(parblksize, locblksize: int32; comd: bool)</a></li>
</ul>
<ul class="simple nested-toc-section">osgWriteLn
<li><a class="reference" href="#osgWriteLn"
title="osgWriteLn()">osgWriteLn()</a></li>
</ul>
<ul class="simple nested-toc-section">osgRelation
<li><a class="reference" href="#osgRelation%2Cint32%2CosgItem%2CosgItem"
title="osgRelation(op: int32; x, y: var osgItem)">osgRelation(op: int32; x, y: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgWriteDebugAsm
<li><a class="reference" href="#osgWriteDebugAsm%2Cint32%2CopenArray%5Buint32%5D%2CFile"
title="osgWriteDebugAsm(i: int32; code: openArray[uint32] = osgCode; f: File = W)">osgWriteDebugAsm(i: int32; code: openArray[uint32] = osgCode; f: File = W)</a></li>
</ul>
<ul class="simple nested-toc-section">osgSwitch
<li><a class="reference" href="#osgSwitch%2CosgItem"
title="osgSwitch(x: var osgItem)">osgSwitch(x: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgChr
<li><a class="reference" href="#osgChr%2CosgItem"
title="osgChr(x: var osgItem)">osgChr(x: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgField
<li><a class="reference" href="#osgField%2CosgItem%2CosgObject"
title="osgField(x: var osgItem; y: osgObject)">osgField(x: var osgItem; y: osgObject)</a></li>
</ul>
<ul class="simple nested-toc-section">osgCBJump
<li><a class="reference" href="#osgCBJump%2CosgItem%2Cint32"
title="osgCBJump(x: var osgItem; L: int32)">osgCBJump(x: var osgItem; L: int32)</a></li>
</ul>
<ul class="simple nested-toc-section">osgWriteInt
<li><a class="reference" href="#osgWriteInt%2CosgItem"
title="osgWriteInt(x: var osgItem)">osgWriteInt(x: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgDebugCode
<li><a class="reference" href="#osgDebugCode%2Cstring"
title="osgDebugCode(msg: string = "Code is now")">osgDebugCode(msg: string = "Code is now")</a></li>
</ul>
<ul class="simple nested-toc-section">osgCFJump
<li><a class="reference" href="#osgCFJump%2CosgItem"
title="osgCFJump(x: var osgItem)">osgCFJump(x: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgWriteBool
<li><a class="reference" href="#osgWriteBool%2CosgItem"
title="osgWriteBool(x: var osgItem)">osgWriteBool(x: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgHeader
<li><a class="reference" href="#osgHeader%2Cint32"
title="osgHeader(size: int32)">osgHeader(size: int32)</a></li>
</ul>
<ul class="simple nested-toc-section">osgStore
<li><a class="reference" href="#osgStore%2CosgItem%2CosgItem"
title="osgStore(x, y: var osgItem)">osgStore(x, y: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgOr1
<li><a class="reference" href="#osgOr1%2CosgItem"
title="osgOr1(x: var osgItem)">osgOr1(x: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgCheckRegs
<li><a class="reference" href="#osgCheckRegs"
title="osgCheckRegs()">osgCheckRegs()</a></li>
</ul>
<ul class="simple nested-toc-section">osgFJump
<li><a class="reference" href="#osgFJump%2Cint32"
title="osgFJump(L: var int32)">osgFJump(L: var int32)</a></li>
</ul>
<ul class="simple nested-toc-section">osgReturn
<li><a class="reference" href="#osgReturn%2Cint32"
title="osgReturn(size: int32)">osgReturn(size: int32)</a></li>
</ul>
<ul class="simple nested-toc-section">osgAnd2
<li><a class="reference" href="#osgAnd2%2CosgItem%2CosgItem"
title="osgAnd2(x, y: var osgItem)">osgAnd2(x, y: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgFixLink
<li><a class="reference" href="#osgFixLink%2Cint32"
title="osgFixLink(L: int32)">osgFixLink(L: int32)</a></li>
</ul>
<ul class="simple nested-toc-section">osgOpenInput
<li><a class="reference" href="#osgOpenInput"
title="osgOpenInput()">osgOpenInput()</a></li>
</ul>
<ul class="simple nested-toc-section">osgValueParam
<li><a class="reference" href="#osgValueParam%2CosgItem"
title="osgValueParam(x: var osgItem)">osgValueParam(x: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgNeg
<li><a class="reference" href="#osgNeg%2CosgItem"
title="osgNeg(x: var osgItem)">osgNeg(x: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgWriteChar
<li><a class="reference" href="#osgWriteChar%2CosgItem"
title="osgWriteChar(x: var osgItem)">osgWriteChar(x: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgClose
<li><a class="reference" href="#osgClose%2Cstring%2Cint32%2Cint32%2CosgObject"
title="osgClose(modid: string; key, datasize: int32; topScope: osgObject)">osgClose(modid: string; key, datasize: int32; topScope: osgObject)</a></li>
</ul>
<ul class="simple nested-toc-section">osgEot
<li><a class="reference" href="#osgEot%2CosgItem"
title="osgEot(x: var osgItem)">osgEot(x: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgReadInt
<li><a class="reference" href="#osgReadInt%2CosgItem"
title="osgReadInt(x: var osgItem)">osgReadInt(x: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgOrd
<li><a class="reference" href="#osgOrd%2CosgItem"
title="osgOrd(x: var osgItem)">osgOrd(x: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgNot
<li><a class="reference" href="#osgNot%2CosgItem"
title="osgNot(x: var osgItem)">osgNot(x: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgMulOp
<li><a class="reference" href="#osgMulOp%2CosgItem%2CosgItem"
title="osgMulOp(x, y: var osgItem)">osgMulOp(x, y: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgOr2
<li><a class="reference" href="#osgOr2%2CosgItem%2CosgItem"
title="osgOr2(x, y: var osgItem)">osgOr2(x, y: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgBJump
<li><a class="reference" href="#osgBJump%2Cint32"
title="osgBJump(L: int32)">osgBJump(L: int32)</a></li>
</ul>
<ul class="simple nested-toc-section">osgDecode
<li><a class="reference" href="#osgDecode"
title="osgDecode()">osgDecode()</a></li>
</ul>
<ul class="simple nested-toc-section">osgOpenArrayParam
<li><a class="reference" href="#osgOpenArrayParam%2CosgItem"
title="osgOpenArrayParam(x: var osgItem)">osgOpenArrayParam(x: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgMakeItem
<li><a class="reference" href="#osgMakeItem%2CosgItem%2CosgObject%2Cint32"
title="osgMakeItem(x: var osgItem; y: osgObject; curlev: int32)">osgMakeItem(x: var osgItem; y: osgObject; curlev: int32)</a></li>
</ul>
<ul class="simple nested-toc-section">osgIndex
<li><a class="reference" href="#osgIndex%2CosgItem%2CosgItem"
title="osgIndex(x, y: var osgItem)">osgIndex(x, y: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgDivOp
<li><a class="reference" href="#osgDivOp%2Cint32%2CosgItem%2CosgItem"
title="osgDivOp(op: int32; x, y: var osgItem)">osgDivOp(op: int32; x, y: var osgItem)</a></li>
</ul>
<ul class="simple nested-toc-section">osgVarParam
<li><a class="reference" href="#osgVarParam%2CosgItem%2CosgType"
title="osgVarParam(x: var osgItem; ftype: osgType)">osgVarParam(x: var osgItem; ftype: osgType)</a></li>
</ul>
<ul class="simple nested-toc-section">osgLED
<li><a class="reference" href="#osgLED%2CosgItem"
title="osgLED(x: var osgItem)">osgLED(x: var osgItem)</a></li>
</ul>
</ul>
</li>
</ul>
</div>
<div class="nine columns" id="content">
<div id="tocRoot"></div>
<p class="module-desc">
<h1><a class="toc-backref" id="nim0-language-in-nim" href="#nim0-language-in-nim">Nim0 language in Nim</a></h1><p>The code generator.</p>
<p>Emit RISC machine instructions.</p>
</p>
<div class="section" id="6">
<h1><a class="toc-backref" href="#6">Imports</a></h1>
<dl class="item">
<a class="reference external" href="OSS.html">OSS</a>
</dl></div>
<div class="section" id="7">
<h1><a class="toc-backref" href="#7">Types</a></h1>
<dl class="item">
<a id="osgObject"></a>
<dt><pre><a href="OSG.html#osgObject"><span class="Identifier">osgObject</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <a href="OSG.html#osgObjDesc"><span class="Identifier">osgObjDesc</span></a></pre></dt>
<dd>
Symbol entry
</dd>
<a id="osgType"></a>
<dt><pre><a href="OSG.html#osgType"><span class="Identifier">osgType</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <a href="OSG.html#osgTypeDesc"><span class="Identifier">osgTypeDesc</span></a></pre></dt>
<dd>
Type descriptor
</dd>
<a id="osgItem"></a>
<dt><pre><a href="OSG.html#osgItem"><span class="Identifier">osgItem</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Identifier">mode</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int32</span> <span class="Comment">## The addressing mode (direct, immediate or register) used</span>
<span class="Comment">## to access the symbol [CC53].</span>
<span class="Identifier">lev</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int32</span> <span class="Comment">## Level in included contexts.</span>
<span class="Identifier">typ</span><span class="Operator">*</span><span class="Other">:</span> <a href="OSG.html#osgType"><span class="Identifier">osgType</span></a> <span class="Comment">## The type of the local symbol [CC54].</span>
<span class="Identifier">a</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int32</span> <span class="Comment">## Additionnal attributes [CC53]. Following attributes `a`, `b` and `r`</span>
<span class="Comment">## are used by Wirth to store many intermediate values depending on</span>
<span class="Comment">## context and documenting them is difficult. Here are some explanations.</span>
<span class="Comment">## The local value of the symbol if the item is a constant (`mode == Const`).</span>
<span class="Comment">## Or the address offset to access the field if the item is an `object` [CC57].</span>
<span class="Comment">## Value in memory at address `a`.</span>
<span class="Comment">## Or the index if the item is an `array` [CC57].</span>
<span class="Comment">## In case of `osgCond` mode, the fixup addresses (F-list) for `or` conditions [CC68].</span>
<span class="Comment">## In case of `Proc` mode, contains the current value of `osgPc`, whci is the</span>
<span class="Comment">## entry address of the procedure prologue [CC76].</span>
<span class="Identifier">b</span><span class="Other">:</span> <span class="Identifier">int32</span> <span class="Comment">## Another additional attribute like `a`.</span>
<span class="Comment">## In case of `osgCond` mode, the fixup addresses (T-list) for `and` conditions [CC68].</span>
<span class="Identifier">r</span><span class="Other">:</span> <span class="Identifier">int32</span> <span class="Comment">## The register number where a value is temporarily stored (cached) [CC53].</span>
<span class="Comment">## Instead of refering to memory, operations on register are</span>
<span class="Comment">## faster. Value held in register `R[r]`.</span>
<span class="Comment">## If the item is an `array`, register `R[r]` holds the index.</span>
<span class="Comment">## In case of `osgCond` mode, it contains which relation is specified by the</span>
<span class="Comment">## comparison [CC62].</span>
</pre></dt>
<dd>
Item for delayed code generation [CC53]. Item objects are short-lived contextual objects and are generaly allocated on the stack: there's no need for <tt class="docutils literal"><span class="pre"><span class="Keyword">ref</span></span></tt>. Items are returned by the OSP parser procedures. You can understand an <tt class="docutils literal"><span class="pre"><span class="Identifier">osgItem</span></span></tt> as an instantiation of an <tt class="docutils literal"><span class="pre"><span class="Identifier">osgObject</span></span></tt> in a context.
</dd>
<a id="osgObjDesc"></a>
<dt><pre><a href="OSG.html#osgObjDesc"><span class="Identifier">osgObjDesc</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Identifier">class</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int32</span> <span class="Comment">## It indicates whether the identifier denotes a constant,</span>
<span class="Comment">## a variable, a type or a procedure [CC39].</span>
<span class="Identifier">lev</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int32</span> <span class="Comment">## Denotes the nesting level of the declared object [CC76].</span>
<span class="Identifier">next</span><span class="Operator">*</span><span class="Other">:</span> <a href="OSG.html#osgObject"><span class="Identifier">osgObject</span></a>
<span class="Identifier">dsc</span><span class="Operator">*</span><span class="Other">:</span> <a href="OSG.html#osgObject"><span class="Identifier">osgObject</span></a> <span class="Comment">## Link between scopes of procedure [CC76].</span>
<span class="Identifier">typ</span><span class="Operator">*</span><span class="Other">:</span> <a href="OSG.html#osgType"><span class="Identifier">osgType</span></a> <span class="Comment">## The symbol type [CC39]</span>
<span class="Identifier">name</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Comment">## Name of the symbol [CC39]</span>
<span class="Identifier">val</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int32</span> <span class="Comment">## Value of the symbol, if known at compile time [CC39]</span>
<span class="Comment">## Or address of procedure in bytes.</span>
<span class="Identifier">nofpar</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int32</span> <span class="Comment">## Number of formal parameters when object is a procedure.</span>
<span class="Identifier">comd</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">bool</span> <span class="Comment">## The symbol is exported. In case of a `proc`, it means</span>
<span class="Comment">## that it can be called from the RISC emulator.</span>
</pre></dt>
<dd>
Symbol descriptor in the table of symbols [CC39].
</dd>
<a id="osgTypeDesc"></a>
<dt><pre><a href="OSG.html#osgTypeDesc"><span class="Identifier">osgTypeDesc</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Identifier">form</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int32</span> <span class="Comment">## Type form: bool/int/array/object. Differentiates between</span>
<span class="Comment">## elementary types (`bool`, `int`) and structured types</span>
<span class="Comment">## (`array`, `object` ) [CC40].</span>
<span class="Identifier">dsc</span><span class="Operator">*</span><span class="Other">:</span> <a href="OSG.html#osgObject"><span class="Identifier">osgObject</span></a>
<span class="Identifier">base</span><span class="Operator">*</span><span class="Other">:</span> <a href="OSG.html#osgType"><span class="Identifier">osgType</span></a> <span class="Comment">## Base type of an array element [CC41].</span>
<span class="Identifier">size</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int32</span> <span class="Comment">## Size of the type for memory allocation [CC42].</span>
<span class="Identifier">len</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int32</span> <span class="Comment">## The number of elements in an array [CC41].</span>
<span class="Identifier">nofpar</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int32</span> <span class="Comment">## Number of formal parameters?</span>
</pre></dt>
<dd>
Data types of symbols [CC40]. Named types are represented in the symbol table by an entry of type <tt class="docutils literal"><span class="pre"><span class="Identifier">osgObjDesc</span></span></tt> which in turns refers to an element of type <tt class="docutils literal"><span class="pre"><span class="Identifier">osgTypeDesc</span></span></tt>.
</dd>
</dl></div>
<div class="section" id="8">
<h1><a class="toc-backref" href="#8">Vars</a></h1>
<dl class="item">
<a id="osgBoolType"></a>
<dt><pre><a href="OSG.html#osgBoolType"><span class="Identifier">osgBoolType</span></a><span class="Other">:</span> <a href="OSG.html#osgType"><span class="Identifier">osgType</span></a></pre></dt>
<dd>
A boolean type singleton object
</dd>
<a id="osgIntType"></a>
<dt><pre><a href="OSG.html#osgIntType"><span class="Identifier">osgIntType</span></a><span class="Other">:</span> <a href="OSG.html#osgType"><span class="Identifier">osgType</span></a></pre></dt>
<dd>
An integer type singleton object
</dd>
<a id="osgCharType"></a>
<dt><pre><a href="OSG.html#osgCharType"><span class="Identifier">osgCharType</span></a><span class="Other">:</span> <a href="OSG.html#osgType"><span class="Identifier">osgType</span></a></pre></dt>
<dd>
A character type singleton object
</dd>
<a id="osgPc"></a>
<dt><pre><a href="OSG.html#osgPc"><span class="Identifier">osgPc</span></a><span class="Other">:</span> <span class="Identifier">int32</span></pre></dt>
<dd>
Program Counter
</dd>
<a id="osgCode"></a>
<dt><pre><a href="OSG.html#osgCode"><span class="Identifier">osgCode</span></a><span class="Other">:</span> <span class="Identifier">array</span><span class="Other">[</span><span class="Identifier">osgMemSize</span><span class="Other">,</span> <span class="Identifier">uint32</span><span class="Other">]</span></pre></dt>
<dd>
The resulting code
</dd>
</dl></div>
<div class="section" id="10">
<h1><a class="toc-backref" href="#10">Consts</a></h1>
<dl class="item">
<a id="osgWordSize"></a>
<dt><pre><a href="OSG.html#osgWordSize"><span class="Identifier">osgWordSize</span></a> <span class="Other">=</span> <span class="DecNumber">4</span></pre></dt>
<dd>
int32(sizeof(uint32)) / int32(sizeof(int32))
</dd>
<a id="osgMemSize"></a>
<dt><pre><a href="OSG.html#osgMemSize"><span class="Identifier">osgMemSize</span></a> <span class="Other">=</span> <span class="DecNumber">8192'i32</span></pre></dt>
<dd>
Memory size in bytes. Negative addresses are used to call compiler standard procedures and functions (i.e. IO).
</dd>
<a id="osgHead"></a>
<dt><pre><a href="OSG.html#osgHead"><span class="Identifier">osgHead</span></a> <span class="Other">=</span> <span class="DecNumber">0</span></pre></dt>
<dd>
The object defines a new scope of identifiers in a record/object or in a procedure call [CC76].
</dd>
<a id="osgConst"></a>
<dt><pre><a href="OSG.html#osgConst"><span class="Identifier">osgConst</span></a> <span class="Other">=</span> <span class="DecNumber">1</span></pre></dt>
<dd>
The object is a contant / mode Const
</dd>
<a id="osgVar"></a>
<dt><pre><a href="OSG.html#osgVar"><span class="Identifier">osgVar</span></a> <span class="Other">=</span> <span class="DecNumber">2</span></pre></dt>
<dd>
The object is a variable / call by value procedure parameter [CC76].
</dd>
<a id="osgPar"></a>
<dt><pre><a href="OSG.html#osgPar"><span class="Identifier">osgPar</span></a> <span class="Other">=</span> <span class="DecNumber">3</span></pre></dt>
<dd>
The object is a call by <tt class="docutils literal"><span class="pre"><span class="Keyword">var</span></span></tt> (address) procedure parameter in a procedure call [CC76].
</dd>
<a id="osgFld"></a>
<dt><pre><a href="OSG.html#osgFld"><span class="Identifier">osgFld</span></a> <span class="Other">=</span> <span class="DecNumber">4</span></pre></dt>
<dd>
The object is an object/record field
</dd>
<a id="osgTyp"></a>
<dt><pre><a href="OSG.html#osgTyp"><span class="Identifier">osgTyp</span></a> <span class="Other">=</span> <span class="DecNumber">5</span></pre></dt>
<dd>
The object is a type
</dd>
<a id="osgSProc"></a>
<dt><pre><a href="OSG.html#osgSProc"><span class="Identifier">osgSProc</span></a> <span class="Other">=</span> <span class="DecNumber">6</span></pre></dt>
<dd>
The object is a standard procedure (magic procedure included in the system like readInt, writeInt) [CC80].
</dd>
<a id="osgSFunc"></a>
<dt><pre><a href="OSG.html#osgSFunc"><span class="Identifier">osgSFunc</span></a> <span class="Other">=</span> <span class="DecNumber">7</span></pre></dt>
<dd>
The object is a standard function name (magic system function like ord, endOfInput) [CC80]
</dd>
<a id="osgProc"></a>
<dt><pre><a href="OSG.html#osgProc"><span class="Identifier">osgProc</span></a> <span class="Other">=</span> <span class="DecNumber">8</span></pre></dt>
<dd>
The object is a procedure name [CC76]
</dd>
<a id="osgNoTyp"></a>
<dt><pre><a href="OSG.html#osgNoTyp"><span class="Identifier">osgNoTyp</span></a> <span class="Other">=</span> <span class="DecNumber">9</span></pre></dt>
<dd>
The object has no type (Not used)
</dd>
<a id="osgBoolean"></a>
<dt><pre><a href="OSG.html#osgBoolean"><span class="Identifier">osgBoolean</span></a> <span class="Other">=</span> <span class="DecNumber">0</span></pre></dt>
<dd>
Symbol is a boolean
</dd>
<a id="osgInteger"></a>
<dt><pre><a href="OSG.html#osgInteger"><span class="Identifier">osgInteger</span></a> <span class="Other">=</span> <span class="DecNumber">1</span></pre></dt>
<dd>
Symbol is an integer
</dd>
<a id="osgCharacter"></a>
<dt><pre><a href="OSG.html#osgCharacter"><span class="Identifier">osgCharacter</span></a> <span class="Other">=</span> <span class="DecNumber">2</span></pre></dt>
<dd>
Symbol is a character
</dd>
<a id="osgArray"></a>
<dt><pre><a href="OSG.html#osgArray"><span class="Identifier">osgArray</span></a> <span class="Other">=</span> <span class="DecNumber">3</span></pre></dt>
<dd>
Symbol is an array
</dd>
<a id="osgRecord"></a>
<dt><pre><a href="OSG.html#osgRecord"><span class="Identifier">osgRecord</span></a> <span class="Other">=</span> <span class="DecNumber">4</span></pre></dt>
<dd>
Symbol is an object/record
</dd>
<a id="osgMOV"></a>
<dt><pre><a href="OSG.html#osgMOV"><span class="Identifier">osgMOV</span></a> <span class="Other">=</span> <span class="DecNumber">0</span></pre></dt>
<dd>
</dd>
<a id="osgLSL"></a>
<dt><pre><a href="OSG.html#osgLSL"><span class="Identifier">osgLSL</span></a> <span class="Other">=</span> <span class="DecNumber">1</span></pre></dt>
<dd>
</dd>
<a id="osgASR"></a>
<dt><pre><a href="OSG.html#osgASR"><span class="Identifier">osgASR</span></a> <span class="Other">=</span> <span class="DecNumber">2</span></pre></dt>
<dd>
</dd>
<a id="osgROR"></a>
<dt><pre><a href="OSG.html#osgROR"><span class="Identifier">osgROR</span></a> <span class="Other">=</span> <span class="DecNumber">3</span></pre></dt>
<dd>
</dd>
<a id="osgAND"></a>
<dt><pre><a href="OSG.html#osgAND"><span class="Identifier">osgAND</span></a> <span class="Other">=</span> <span class="DecNumber">4</span></pre></dt>
<dd>
</dd>
<a id="osgANN"></a>
<dt><pre><a href="OSG.html#osgANN"><span class="Identifier">osgANN</span></a> <span class="Other">=</span> <span class="DecNumber">5</span></pre></dt>
<dd>
</dd>
<a id="osgIOR"></a>
<dt><pre><a href="OSG.html#osgIOR"><span class="Identifier">osgIOR</span></a> <span class="Other">=</span> <span class="DecNumber">6</span></pre></dt>
<dd>
</dd>
<a id="osgXOR"></a>
<dt><pre><a href="OSG.html#osgXOR"><span class="Identifier">osgXOR</span></a> <span class="Other">=</span> <span class="DecNumber">7</span></pre></dt>
<dd>
</dd>
<a id="osgADD"></a>
<dt><pre><a href="OSG.html#osgADD"><span class="Identifier">osgADD</span></a> <span class="Other">=</span> <span class="DecNumber">8</span></pre></dt>
<dd>
</dd>
<a id="osgSUB"></a>
<dt><pre><a href="OSG.html#osgSUB"><span class="Identifier">osgSUB</span></a> <span class="Other">=</span> <span class="DecNumber">9</span></pre></dt>
<dd>
</dd>
<a id="osgCMP"></a>
<dt><pre><a href="OSG.html#osgCMP"><span class="Identifier">osgCMP</span></a> <span class="Other">=</span> <span class="DecNumber">9</span></pre></dt>
<dd>
</dd>
<a id="osgMUL"></a>
<dt><pre><a href="OSG.html#osgMUL"><span class="Identifier">osgMUL</span></a> <span class="Other">=</span> <span class="DecNumber">10</span></pre></dt>
<dd>
</dd>
<a id="osgDIV"></a>
<dt><pre><a href="OSG.html#osgDIV"><span class="Identifier">osgDIV</span></a> <span class="Other">=</span> <span class="DecNumber">11</span></pre></dt>
<dd>
</dd>
<a id="osgLDW"></a>
<dt><pre><a href="OSG.html#osgLDW"><span class="Identifier">osgLDW</span></a> <span class="Other">=</span> <span class="DecNumber">0</span></pre></dt>
<dd>
</dd>
<a id="osgSTW"></a>
<dt><pre><a href="OSG.html#osgSTW"><span class="Identifier">osgSTW</span></a> <span class="Other">=</span> <span class="DecNumber">2</span></pre></dt>
<dd>
</dd>
<a id="osgStdOpenInput"></a>
<dt><pre><a href="OSG.html#osgStdOpenInput"><span class="Identifier">osgStdOpenInput</span></a> <span class="Other">=</span> <span class="DecNumber">0x000FFFFF'u32</span></pre></dt>
<dd>
OpenInput (not required in Nim0)
</dd>
<a id="osgStdReadInt"></a>
<dt><pre><a href="OSG.html#osgStdReadInt"><span class="Identifier">osgStdReadInt</span></a> <span class="Other">=</span> <span class="DecNumber">0x000FFFFE'u32</span></pre></dt>
<dd>
ReadInt from command line
</dd>
<a id="osgStdEot"></a>
<dt><pre><a href="OSG.html#osgStdEot"><span class="Identifier">osgStdEot</span></a> <span class="Other">=</span> <span class="DecNumber">0x000FFFFD'u32</span></pre></dt>
<dd>
End of text is reached (no more parameters in command line)
</dd>
<a id="osgStdWriteInt"></a>
<dt><pre><a href="OSG.html#osgStdWriteInt"><span class="Identifier">osgStdWriteInt</span></a> <span class="Other">=</span> <span class="DecNumber">0x000FFFFC'u32</span></pre></dt>
<dd>
Write integer to standard output
</dd>
<a id="osgStdWriteChar"></a>
<dt><pre><a href="OSG.html#osgStdWriteChar"><span class="Identifier">osgStdWriteChar</span></a> <span class="Other">=</span> <span class="DecNumber">0x000FFFFB'u32</span></pre></dt>
<dd>
Write <tt class="docutils literal"><span class="pre"><span class="Identifier">chr</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">)</span></span></tt> to standard output
</dd>
<a id="osgStdWriteLine"></a>
<dt><pre><a href="OSG.html#osgStdWriteLine"><span class="Identifier">osgStdWriteLine</span></a> <span class="Other">=</span> <span class="DecNumber">0x000FFFFA'u32</span></pre></dt>
<dd>
End line
</dd>
<a id="osgStdLED"></a>
<dt><pre><a href="OSG.html#osgStdLED"><span class="Identifier">osgStdLED</span></a> <span class="Other">=</span> <span class="DecNumber">0x000FFFF9'u32</span></pre></dt>
<dd>
Show <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt> on LED (not implemented)
</dd>
<a id="osgStdSwitch"></a>
<dt><pre><a href="OSG.html#osgStdSwitch"><span class="Identifier">osgStdSwitch</span></a> <span class="Other">=</span> <span class="DecNumber">0x000FFFF8'u32</span></pre></dt>
<dd>
Read state of switches
</dd>
<a id="osgStdWriteBool"></a>
<dt><pre><a href="OSG.html#osgStdWriteBool"><span class="Identifier">osgStdWriteBool</span></a> <span class="Other">=</span> <span class="DecNumber">0x000FFFF7'u32</span></pre></dt>
<dd>
Write a boolean value
</dd>
<a id="osgStdRead"></a>
<dt><pre><a href="OSG.html#osgStdRead"><span class="Identifier">osgStdRead</span></a> <span class="Other">=</span> <span class="DecNumber">0x000FFFF6'u32</span></pre></dt>
<dd>
Generic read from standard input
</dd>
</dl></div>
<div class="section" id="12">
<h1><a class="toc-backref" href="#12">Procs</a></h1>
<dl class="item">
<a id="osgWriteReg,uint32,File"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#osgWriteReg%2Cuint32%2CFile"><span class="Identifier">osgWriteReg</span></a><span class="Other">(</span><span class="Identifier">r</span><span class="Other">:</span> <span class="Identifier">uint32</span><span class="Other">;</span> <span class="Identifier">f</span><span class="Other">:</span> <span class="Identifier">File</span> <span class="Other">=</span> <span class="Identifier">W</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Write an anonymous or well-know register name.
</dd>
<a id="osgWriteDebugAsm,int32,openArray[uint32],File"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#osgWriteDebugAsm%2Cint32%2CopenArray%5Buint32%5D%2CFile"><span class="Identifier">osgWriteDebugAsm</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <span class="Identifier">int32</span><span class="Other">;</span> <span class="Identifier">code</span><span class="Other">:</span> <span class="Identifier">openArray</span><span class="Other">[</span><span class="Identifier">uint32</span><span class="Other">]</span> <span class="Other">=</span> <span class="Identifier">osgCode</span><span class="Other">;</span> <span class="Identifier">f</span><span class="Other">:</span> <span class="Identifier">File</span> <span class="Other">=</span> <span class="Identifier">W</span><span class="Other">)</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Write the RISC assembler corresponding to the memory location <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span></span></tt> in code. The procedure signature has been changed to be able to use it from the RISC emulator.
</dd>
<a id="osgDecode"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#osgDecode"><span class="Identifier">osgDecode</span></a><span class="Other">(</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Dump RISC object memory content.
</dd>
<a id="osgDebugCode,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#osgDebugCode%2Cstring"><span class="Identifier">osgDebugCode</span></a><span class="Other">(</span><span class="Identifier">msg</span><span class="Other">:</span> <span class="Identifier">string</span> <span class="Other">=</span> <span class="StringLit">"Code is now"</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Can be called when debugging compiler generation to dump the content of the last instructions in <tt class="docutils literal"><span class="pre"><span class="Identifier">osgCode</span></span></tt> memory. The header message is printed before the memory dump.
</dd>
<a id="osgCheckRegs"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#osgCheckRegs"><span class="Identifier">osgCheckRegs</span></a><span class="Other">(</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
After unstacking the registers stack, check that we don't underflow.
</dd>
<a id="osgFixLink,int32"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#osgFixLink%2Cint32"><span class="Identifier">osgFixLink</span></a><span class="Other">(</span><span class="Identifier">L</span><span class="Other">:</span> <span class="Identifier">int32</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Fix temporary branches locations replacing them with the final adresses. The <tt class="docutils literal"><span class="pre"><span class="Identifier">L</span></span></tt> parameter is the first of a chain. The next value in the chain has been temporarily stored in the offset value <tt class="docutils literal"><span class="pre"><span class="Identifier">off</span></span></tt> of the branch instruction. Note that branch instruction use addresses relative to the instruction location (PC-relative) therefore the value <tt class="docutils literal"><span class="pre"><span class="Identifier">osgPc</span> <span class="Operator">-</span> <span class="Identifier">L</span> <span class="Operator">-</span> <span class="DecNumber">1</span></span></tt> is used to fix it. Note also that this procedure, like many others in Wirth's code, use global variables, in that case <tt class="docutils literal"><span class="pre"><span class="Identifier">osgPc</span></span></tt>, and is very dependant of the location in the code where it is called.
</dd>
<a id="osgMakeConstItem,osgItem,osgType,int32"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#osgMakeConstItem%2CosgItem%2CosgType%2Cint32"><span class="Identifier">osgMakeConstItem</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="OSG.html#osgItem"><span class="Identifier">osgItem</span></a><span class="Other">;</span> <span class="Identifier">typ</span><span class="Other">:</span> <a href="OSG.html#osgType"><span class="Identifier">osgType</span></a><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <span class="Identifier">int32</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Create a constant <tt class="docutils literal"><span class="pre"><span class="Identifier">osgItem</span></span></tt> of type <tt class="docutils literal"><span class="pre"><span class="Identifier">typ</span></span></tt> from the given value <tt class="docutils literal"><span class="pre"><span class="Identifier">val</span></span></tt>.
</dd>
<a id="osgMakeItem,osgItem,osgObject,int32"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#osgMakeItem%2CosgItem%2CosgObject%2Cint32"><span class="Identifier">osgMakeItem</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="OSG.html#osgItem"><span class="Identifier">osgItem</span></a><span class="Other">;</span> <span class="Identifier">y</span><span class="Other">:</span> <a href="OSG.html#osgObject"><span class="Identifier">osgObject</span></a><span class="Other">;</span> <span class="Identifier">curlev</span><span class="Other">:</span> <span class="Identifier">int32</span><span class="Other">)</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Convert <tt class="docutils literal"><span class="pre"><span class="Identifier">y</span></span></tt> <tt class="docutils literal"><span class="pre"><span class="Identifier">osgObject</span></span></tt> into a corresponding <tt class="docutils literal"><span class="pre"><span class="Identifier">osgItem</span></span></tt> returned as <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt> [CC77]. Difference between the addressing of local and global variables should be taken into account. The handling of intermediate-level variables is not treated here.