-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
pops.e
1679 lines (1586 loc) · 82.1 KB
/
pops.e
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
--
-- pops.e
--
-- Phix opcodes
--
--
--DEV This is overdue for a complete rewrite. Most of the "careful ordering" stuff
-- has been replaced with explicit declarations in psym.e, and optable.e seems to
-- cope quite effectively with any reordering. The distinction between "real" and
-- "virtual" opcodes is no longer important. Only {opInt,opAtom,opSq,opStr,opObj}
-- still require any ordering, according to a quick test 23/10/15 (see pmain.e). [now gone as per update below]
-- It really deserves enum/nxt()/columnize, and some of the calling conventions
-- shown below may now be out of date (see pilx86.e|builtins/VM for the gospel).
-- Obviously, leave this as-is, create a pops2.e, toggle the include statement
-- in p.exw to test, and only properly overwrite once fully tested. I expect it
-- will need to be ~300 lines before it compiles cleanly.
-- UPDATE: my first attempt at pops2.e was an abject failure. I have however
-- applied a few lessons learnt here (deleted a few things, including maxNVop,
-- and opIres/opNres/opSres/opPres/opOres). I think we can suffer a few append,
-- but constant opMove=1 is probably just about worth it over opMove=nxtOP():
-- it makes editing this painful, but gives pilx86 a proper fixed jump table.
-- (I may even have finally killed the 255 limit, but don't quote me on that.)
-- I suppose the best thing would be to add entries for all opcodes to Phix.chm,
-- and leave this looking rather sparse/clean.
--
-- Opcodes are used to locate entry points in the Virtual Machine, and hence the
-- following definitions must exactly match the equivalent table in the assembly
-- back-end [VMep]. Hence when/if Phix gets an "enum", this is probably the last
-- place you'd want to use it. [DEV VMep vanished quite some time ago...]
-- It may help to consider the VM as similar in theory to clib, with the compiler
-- electing to inline/emit machine code directly for as many trivial/common cases
--- as possible, but some things such as puts, s[i][j][k]=t, etc., are always
-- performed by the VM. (If you want a look at the actual code in the VM, see
-- the constant dumpVM in plist.e.)
--
-- Opcodes also inherently define the intermediate code, as emitted by the parser,
-- which is carefuly analysed before emitting the final x86 machine code.
--
-- At the end of this file I have replicated the calling conventions [DEV!]
--
-- (TIP: inserting and/or removing entries can be tricky:
-- if "p -cp" fails, try "p p -cp" instead.)
--
without trace
integer opUsed
opUsed=0
procedure opName(sequence label, integer chk, integer skip)
opUsed += 1
if opUsed!=chk then opUsed = 9/0 end if
opNames[opUsed] = label
opSkip[opUsed] = skip
end procedure
global constant
--
opMove = 1, -- p1 = p2 (p3=onDeclaraion, p4=srcInit, p5=srcLtype)
-- verifies p2 has been assigned a value, also when needed deallocates p1 & increfs p2
-- nb VMep[opMove] is NULL
-- optimised forms of opMove, when the compiler knows, for certain, that source, target or
-- both are (initialised) integer. These are virtual opcodes/always inlined.
opMovbi = 2, -- opMove when both are integer, and source init.
--DEV opStoreFlt = 2, [and make opMovbi a proper virtual opcode!]
-- no need to incref/dealloc either -- nb VMep[opMovbi] is StoreFlt (was AllocSeq)
opMovsi = 3, -- opMove when source is init integer (p3=onDeclaration)
-- no need to incref src -- nb VMep[opMovsi] is deallocX
opMovti = 4, -- opMove when target is integer
-- no need to dealloc target -- nb VMep[opMovti] is unassigned/TchkFail
--
-- The following opcodes have fixed literal int as first param (up to opCallOnce):
--
-- opStat = 5, -- opstats[opcode]+=1 (for development/analysis use)
-- [NB may be broken/not tested prior to any release]
--DEV/SUG replace with opLn,line,flags (flags of 0=>opLn, 1=>opLnt, 2=>opLnp, 3=> opLnpt)??
--DEV better order is: opLn=1..opLnpt=4,opTchk=5,opTcFail=6,opMove=7..opMovti=10, opStat elsewhere
-- (oh, forgot about the fixed literal int thing...)
opLnt = 6, -- traceable line number
-- output under "with trace" only.
-- prior to a trace(1) call, has no effect, else calls show_trace(). See pTrace.e
opLnp = 7, -- profile line number
-- output under "with profile" only.
-- after a profile(0) call, has no effect, else updates ptab. See pProfile.e
opLnpt = 8, -- profile_time line number
-- output under "with profile_time" only.
-- after a profile(0) call, has no effect, else updates ptab. See pProfile.e
--opLnpclone profile_clone line number
--opLnpcover profile_coverage line number
opTchk = 9, -- type_check(symtab[p1])
-- call the user defined type routine after assignment has occurred.
-- Builtin types are inlined/use opTcFail
opTcFail = 10, -- error: typecheck (builtin), See also opTchk.
opBadRetf = 11, -- code should not reach this!
-- emitted at the end of every function and type as a safety measure
opUnassigned = 12,
-- usage: (only) when we cannot be sure a variable is assigned, so
-- have to test, and the test fails! See notes below.
--DEV to go (only used in <=pfileio4.e)
-- opAllocStr = 13,
opCallOnceYeNot = 13,
-- Used at the start of many builtin\VM sources, albeit in the form
-- "jmp :!opCallOnceYeNot". An include inc1.e statement, where inc1.e
-- begins with puts(1,"started\n"), issues an opCallOnce so that the
-- puts (or whatever) is executed as expected. However, if there is
-- no top-level code (or it is just "jmp :%opRetf", which pulls off
-- exactly the same trick as "jmp :!opCallOnceYeNot") then obviously
-- no opCallOnce is either needed or wanted. Given there are 40-odd
-- source files in builtins\VM, we want to keep numbers down a bit.
-- Of course :!opCallOnceYeNot is a real error, and can be triggered
-- if you add initialisation code to a builtins\VM source code file,
-- but forget about changing over to a "jmp :%opRetf". I decided to
-- use :!opCallOnceYeNot instead of :%opRetf as both the intent is
-- clearer, and it triggers should I accidentally add such code.
--opTchk2 = 13,
--opTcFail2 = 14,
-- opWithJS = 14,
opDeSeq = 14, -- (re)set ma_ip flag in pRepeN.e
-- 15,16 spare
--
-- opFor,init,ctl,step,limit,tgt/x86loc
-- opFor checks control var/init/limit/step are integer and sets C flag if
-- loop should be iterated zero times. For most loops, opFor should only
-- generate code for "i:=init"; init/limit/step may need to be opUnassigned
-- and the backend code is only called when they may be floats or it does
-- not know the sign of step at compile time. Note that in Phix, any float
-- is automatically an error, by design, since they are deeply unreliable.
-- (eg on RDS Eu/OpenEuphoria,
-- for i=0 to 1 by 0.1 do iterates 11 times
-- but for i=1 to 2 by 0.1 do iterates 10 times. Try it and see.)
--
--DEV to go...
-- opFor = 16,
opFrame = 17, -- create a call frame (save vars)
-- opFrame is routine no, first, last [DEV: LIAR]
-- saves parameters, local variables, and temporaries first..last, and
-- clears them all to "unassigned".
opCallOnce = 18, -- call tls once
-- if I have main.exw which includes misc.exw, then there will be two tls
-- (top level subroutine) entries, one for main [==symtab[T_maintls]] and
-- one for misc; opCallOnce is emitted at the include statement to perform
-- includee tls, or before a forward (auto-include) call to ensure any
-- initialisation gets done. Multiple opCallOnce to same tls have no effect.
--DEV may yet be required:
-- opCalli = opCode("opCalli",1?2), -- call tls if rqd, then routine ("")
--end of first param fixed (plus skip <0, ie opMkSq..opSubss).
opRetf = 19, -- return from frame
-- used for procedures, functions, and types
--
-- opMkSq is n (literal length), res, en,...,e2,e1
--
opMkSq = 20, -- res={e1,e2,..en}
--
-- opMkSqi is an optimised version of opMkSq, when res is known to be
-- a sequence of integer (/not/ just that e1..en are ints);
-- hence res can be reused (if long enough, refcount of 1 and
-- without a delete_routine) without deallocating contents.
-- [opMkSqi is never emitted in il]
--
opMkSqi = 21, -- res={e1,e2,..en}
--
-- opRepe is n (noofsubscripts), ref, rep, idx1..idxn -- ref[idx1][idx2]~[idxn] := rep
--erm...
-- opRepe is n (noofsubscripts), rep, idxn..idx1, ref
-- see also opRepe1
--
opRepe = 22,
--
-- opReps is n (noofsubscripts), ref, idx1..n, sliceend, rep -- ref[idx1]~[idxn..sliceend] := rep
--
opReps = 23,
--
-- opSubse is N, ref, idx1..idxN, res -- res := ref[idx1][idx2]~[idxN]
--
opSubse = 24,
--
-- opSubss is N, ref, idx1..idxN, sliceend, res -- res := ref[idx1]~[idxN..sliceend]
--
opSubss = 25,
--
-- opConcatN is N, res, ref1..refN -- res := ref1&ref2..&refN
--
opConcatN = 26,
--
-- opRepe1 is ref, idx, rep
-- optimised form of opRepe for the single subscript case (common cases are inlined)
--
opRepe1 = 27, -- ref[idx] := rep
opRepe1ip = 28, -- "", when ref is T_Dsq of integer
-- dropped 26/07/14, resurrected 9/10/14:
opRepe1is = 29, -- "", when ref is string
--
-- opSubsss is ref, slicestart, sliceend, res -- res := ref[slicestart..sliceend]
--
opSubsss = 30, -- s = t[i..j], when s,t are strings
-- opSubssp = 31??
-- 31,32 spare
--
-- opSubse1 is res, ref, idx, isInit[ref and idx], isCompound:
-- res:=ref[idx], aka N=p1[p2].
-- optimised forms of opSubse for the single subscript case (common cases are inlined)
--
opSubse1 = 33, -- res := ref[idx]
opSubse1i = 34, -- res := ref[idx], when res is integer
opSubse1is = 35, -- res := ref[idx], "" and ref is string
opSubse1ip = 36, -- res := ref[idx], "" "" T_Dsq of integer
--DEV/SUG:
-- opSubse1tp = ??, -- res := ref[idx], when res is <t> and ref is T_Dsq of <t> (t!=T_integer)
-- 37 spare
--
-- Conditional tests on initialised integers are always inlined; these
-- opcodes handle floating point, string and nested sequence comparison,
-- unassigned errors, etc. Behind the scenes, the VM (virtual machine)
-- actually only implements three (real) opcodes for the following eight
-- (which are virtual/il opcodes), being opJif(=opJnot), opJccE (eq/ne),
-- and opJcc (ge/lt/gt/le). For example:
--
-- "if a>=b then"
-- is this in il:
-- opJlt,a,b,<end if>
-- and this in asm:
-- mov edi,[b]
-- mov eax,[a]
-- call opJcc
-- jl <end if>
--
-- (more often than not hll conditions generate inverted machine jumps)
-- Note: "fred"=1 is simply false (ie 0), rather than {0,0,0,0} or the
-- infamous "true/false condition must be an ATOM" - though that
-- error can still occur via opJif/opJnot[x].
--
opJif = 38, -- if b then \ inlined if
opJnot = 39, -- if not b then / b is atom
opJge = 40, -- if b>=c then \ inlined if
opJlt = 41, -- if b<c then / both int
opJeq = 42, -- if b=c then \ inlined if
opJne = 43, -- if b!=c then / either int
opJgt = 44, -- if b>c then \ inlined if
opJle = 45, -- if b<=c then / both int
--DEV14: dead (see invert on opJnotx)
-- opJifx = 46, -- if b[c] then
opJnotx = 47, -- if not b[c] then
--
-- Set cc opcodes are similar to opJcc, except first param is bool result
--
opSge = 48, -- a = (b>=c)
opSlt = 49, -- a = (b<c)
opSeq = 50, -- a = (b=c) aka a = equal(b,c) -- NB a=sequence(b) is opSq.
opSne = 51, -- a = (b!=c)
opSgt = 52, -- a = (b>c)
opSle = 53, -- a = (b<=c)
-- (nb keep opSge..Sle mappable to/from opJge..opJle)
opScmp = 54, -- a = compare(b,c) [see also cmap() in pmain.e]
-- opFind = 55, -- a = find(b,c[,from])
-- opMatch = 56, -- a = match(b,c[,from])
opXor = 57, -- a = b xor c (a is set to 1 or 0)
-- btw "and", "or" are always short-circuited: opAnd, opOr simply do not exist at all.
-- builtins which return an integer (to opIres):
opInt = 58, -- a = integer(b)
opAtom = 59, -- a = atom(b)
opSq = 60, -- a = sequence(b) -- NB opSeq is a=(b=c).
opStr = 61, -- a = string(b)
opObj = 62, -- a = object(b) [always 1] [DEV]
-- opInt..Str are only called when the result (a) is non-integer and may need deallocating,
-- or b is not init/may need an unassigned error. opObj is not called at all.
opInt0 = 63, -- \
opAtom0 = 64, -- \ optimised forms (the 0/1 result is just left)
opSq0 = 65, -- / used by opJtyp (in edx, not stored anywhere)
opStr0 = 66, -- /
opLen = 67, -- a = length(b)
opNot = 68, -- a = not b -- NB b must be atom (see sq_not)
opOpen = 69, -- a = open(b,c)
opGetc = 70, -- a = getc(b)
opGetKey = 71, -- a = get_key()
opWaitKey = 72, -- a = wait_key()
opSeek = 73, -- a = seek(b,c)
opWhere = 74, -- a = where(b)
opLock = 75, -- a = lock_file(b,c,d) -- 55
opUnLock = 76, -- unlock_file(a,b) --DEV??
opRand = 77, -- a = rand(b) -- NB b must be atom (see sq_rand)
-- opChDir = 78, -- a = chdir(b)
-- 78 spare
--DEV broken on newEmit? (reorder??)
opPeeki = 79, -- a = peek(b) where a is integer
-->>5)
-->> put 2 spare here
-- 80,81 spare
-- opIres = 81,
-- builtins which return an atom (to opNres):
opAdd = 82, -- a = b+c -- NB b,c must be atoms (see sq_add etc)
opAddi = 83, -- a = b+c -- when a is integer
opAddiii = 84, -- a = b+c -- .. and b,c init ints (:%e01tcfAddiii)
opSub = 85, -- a = b-c -- ""
opSubi = 86, -- a = b-c -- ""
opSubiii = 87, -- a = b-c -- "" (:%e01tcfAddiii)
opMul = 88, -- a = b*c -- ""
opMuli = 89, -- a = b*c -- ""
opMuliii = 90, -- a = b*c -- "" (:%e01tcfediMul)
opDiv = 91, -- a = b/c -- ""
opDivi = 92, -- a = b/c -- ""
opDiviii = 93, -- a = b/c -- "" (:%e01tcfediDiv)
opDiv2 = 94, -- a = b/2 -- b is init int, a is atom or int
opDivi2 = 95, -- a = b/2 -- b is init int, a is integer
opDivf = 96, -- a = floor(b/c) -- a,b are atom or int
opDivf2 = 97, -- a = floor(b/2) -- b is init int, a is atom or int
-- nb VMep[opDivf2] is e02atdb0 (not for newEmit)
--
-- opAdd is the general purpose opcode, a,b,c can be ints or atoms (see sq_add)
-- opAddi is used when a is an integer, meaning no dealloc rqd, has built-in typecheck
-- opAddiii is used when a is int, and b, c are known to be initialised integers (fastest of all)
-- opAddiii is in fact always inlined, the VMep is an error handler (overflow), likewise +/*/div. (newEmit)
-- Ditto for Sub/Mul/Div, the latter has extra forms:
-- opDiv2 is used when b is init integer (and obviously c=2). result (a) can be int or atom.
-- opDivi2 is used when the result must be an integer, has built-in typecheck.
-- opDivf is general purpose, a,b,c can be ints or atoms. (see sq_floor_div)
-- (nb result may be atom, eg floor(1e308) is 1e308)
-- opDivf2 is only used when b is an init integer, and result will therefore be an integer.
--
--6)
-->> put 2 spare here
-- 98,99,100 spare
--DEV no longer used:
--DEV opLen0?
-- oXpInc = 101, -- a += 1 -- a must be init integer
-- 28/11/09 hijacked, see below:
-- oXpDec = 102, -- a -= 1 -- ""
-- if a is atom, or not known to be initialised, then opAdd/Sub a,a,1 is used instead of Inc/Dec.
-- The VMep entries for opInc and opDec are in fact error handlers (overflow) [opInc/Dec no longer used]
-->>move me (this becomes spare):
-- oXpCatsi = 102, -- p1 &= p2, when p1 is a gvar-scan-proven sequence of integer
opFloor = 103, -- a = floor(b) -- NB b must be atom (see sq_floor)
-- nb: while most times floor() yields an integer, eg floor(1e308) yields 1e308, ie an atom.
opRmdr = 104, -- a = remainder(b,c) -- NB b,c must be atom|int (see sq_rmdr)
opUminus = 105, -- a = -b -- "" (see sq_uminus)
opAndBits = 106, -- a = and_bits(b,c) -- b,c must not exceed 32 bits
opOrBits = 107, -- a = or_bits(b,c) -- ""
opXorBits = 108, -- a = xor_bits(b,c) -- ""
opNotBits = 109, -- a = not_bits(b) -- ""
opPow = 110, -- a = power(b,c) -- NB b,c must be atoms (see sq_pow)
opTime = 111, -- a = time()
opAlloc = 112, -- a = allocate(b)
opCos = 113, -- a = cos(b) -- b must be atom, see sq_cos etc
opSin = 114, -- a = sin(b) -- ""
opTan = 115, -- a = tan(b) -- ""
opArcTan = 116, -- a = arctan(b) -- ""
opLog = 117, -- a = log(b) -- ""
opSqrt = 118, -- a = sqrt(b) -- ""
-- op32toA = 119, -- a = float32_to_atom(b)
-- op64toA = 120, -- a = float64_to_atom(b)
opCallFunc = 119, -- o = call_func(rid,params)
opCallProc = 120, -- call_proc(rid,params)
--DEV?
opOpenDLL = 121, -- a = open_dll(s) -- (:%opOpenDLL in pcfunc.e) [DEV togo]
opDcfunc = 122, -- i = define_c_func(l,n,a,r) -- (:%opDcfunc "")
opDcvar = 123, -- i = define_c_var(l,n) -- (:%opDcvar "")
opInstance = 124, -- a = instance()
--DEV?
opCallback = 125, -- a = call_back(id) -- (:%opCallback "")
opCallA = 126, -- call(addr)
opCfunc = 127, -- a = c_func(rid,params)
opCproc = 128, -- c_proc(rid,params)
opGpct = 129, -- call :%opGpct (prev3/[edi] = fget_pcfunc_tables())
opRpct = 130, -- call :%opRpct (frestore_pcfunc_tables(prev3/[esi]))
opCbHandler = 131, -- call :%cbhandler (for dll use only)
-- 126,127 spare
-- opNres = 127,
-- builtins which return a string (to opSres):
-- opCurrDir = 128, -- a = current_dir()
----DEV delete for newEBP (or rewrite)
-- opCatsi = 129, -- p1 &= p2, when p1 is a gvar-scan-proven sequence of integer
-- 130,131 spare
-- opSres = 131,
opApnd = 132, -- a = append(b,c)
opPpnd = 133, -- a = prepend(b,c)
opConcat = 134, -- a = b&c, see also opConcatN
-- opRepeat = 135, -- a = repeat(b,c)
opCurrDir = 136, -- a = current_dir()
--DEV delete for newEBP (or rewrite)
opCatsi = 137, -- p1 &= p2, when p1 is a gvar-scan-proven sequence of integer
-- opAto32 = 136, -- a = atom_to_float32(b)
-- opAto64 = 137, -- a = atom_to_float64(b)
-- opDate = opCode("opDate",1), -- a = date() -- now in pdate.e
--DEV
-- oXpGSCh = 138, -- a = get_screen_char(b,c)
opGetRand = 138, -- (opposite of opSetRand)
opGetPos = 139, -- s = get_position() --DEV newEmit (now just a standard routine in pfileioN.e [BLUFF!])
-- 140,141 spare
-- opPres = 141,
-- builtins which return an object (to opOres):
-- opUpper = opCode("opUpper",2), -- a = upper(b) -- now in pcase.e
-- opLower = opCode("opLower",2), -- a = lower(b) -- ""
--DEV reorder as below...
opPeek = 142, -- a = peek(b) -- (returns integer if b is atom, string if b is sequence)
opPeek4s = 143, -- a = peek4s(b) -- (returns atom if b is atom, sequence if b is sequence)
opPeek4u = 144, -- a = peek4u(b) -- (returns atom if b is atom, sequence if b is sequence)
opGets = 145, -- a = gets(b) -- (returns string or -1, ie T_IS)
opGetText = 146, -- op-- -- 146 spare
-- opMoveFRes = 147, -- a = get_function_result_for_routine_no(b)
-- 147,148 spare
--DEV this should be named say lastObjRes, likewise things above
-- opOres = 148,
-- builtin procedures:
-- opCallA = 150, -- call(a) NB opCall (paired with opFrame) is the normal/usual routine call
--DEV togo
-- opCallProc = 151, -- call_proc(a,b)
--DEV reorder..
opPokeN = 149, --DEV newEmit opPokeN,addr,value,size
opPoke1 = 150,
opPoke2 = 151,
opPoke8 = 152,
opClrScrn = 153, -- clear_screen()
opFreeCons = 154, -- free_console()
opFree = 155, -- free(a)
opMemCopy = 156, -- mem_copy(a,b,c)
opMemSet = 157, -- mem_set(a,b,c)
-- opPixel = opCode("opPixel",2), -- pixel(a,b) --DOS!
--DEV becomes opPoke1 for newEmit:
opPoke = 158, -- poke(a,b)
opPoke4 = 159, -- poke4(a,b)
opPosition = 160, -- position(a,b)
opPuts = 161, -- puts(a,b)
--DEV
-- oXpPSCh = 162, -- put_screen_char(a,b,c)
-- opGetProcA = 162, -- (see pcfunc.e)
opFlush = 163, -- flush(a)
opClose = 164, -- close(a)
opSetRand = 165, -- set_rand(a)
opSleep = 166, -- sleep(a)
opTxtClr = 167, -- text_color(a)
opBkClr = 168, -- bk_color(a)
opTrace = 169, -- trace(a)
opProfile = 170, -- profile(a)
opProfout = 171, -- profile_dump()
-- internals:
opClrDbg = 172, -- clear debug screen (notes below)
-- opTrap = 173, -- temp (debug aid)
--DEV to go:
opRTErn = 174, -- internal, pdiag.e/eg pprntf.e. Trigger error by number.
--DEV to go(?):
opGetST = 175, -- internal, a=symtab (NB 32-bit!), b=flag/crashmsg, c=crashfile.
--opGetSP = 176,
--opSetSP = 177,
opDelRtn = 176, -- see %opDelRtn in pDeleteN.e
opDelete = 177, -- see %opDelete in pDeleteN.e
-- opGetVMep = 176, -- internal, p1=VMep,p2=debugleak see pemit.e/t97mleak
-->>12)
-- opReadVM = 177,
--no longer used
-- opPokeRef = 178, -- internal, [p2]=p1, see pemit.e
--DEV no longer used??
-- opGetRaw = 179, -- internal, [p2]=raw(p1), (debug aid) see pemit.e/t97mleak
--newEmit
-- opLicence = 180, -- internal, see pemit.e
-- opSetDbg = 181, -- internal, see pexec.e/pdebug.e
-- opCrshRtn = 182, -- internal, see pexec.e/pdiag.e
--newEmit
-- opRbldIds = 183, -- internal, see pemit.e/calling convention below.
-- opCrshMsg = 184, -- implements crash_message() [see pDiagN.e]
--DEV togo/newEmit:
-- opDelRtn = 185, -- internal, see pdelete.e/calling covention below.
-- opCrshFile = 186, -- implements crash_file()
-- opInterp = 187, -- interpret(symtab,CSvaddr,DSvaddr,opstat,ptab,errorcode) [internal routine]
-- opCrshRtn = 188, -- implements crash_routine(rid) [see pDiagN.e]
opAbort = 178, -- abort(a)
--newEmit
-- opCleanUp = 189, -- internal, for debugleak check
-- opCleanUp1 = 190, -- internal, for debugleak check
-->>13)
-->> (becomes 7 spare)
--newEmit
-- opGetRRC = 191,
-- opSetBatchMode = 192,
--DEV???
--newEmit
-- opLichk = 193,
-- opDelRef = 194,
-- opCrsh = 195, -- implements crash()
--opInterp2 = 195,
--spare:
-- opSq0 = 196,
--DEV to go *2:
--opHeapAlloc = 196,
-- opStr0 = 197,
--opTlsGetValue = 197,
-- maxNVop = 197 -- max non-virtual opcode (checked against VM table in pemit.e)
-- maxNVop = 0 -- max non-virtual opcode (checked against VM table in pemit.e)
--$
opLoadMint = 179, -- edx:eax := int64(eax)
opStoreMint = 180, -- [edi] := eax, as float if rqd
--EXCEPT
opTry = 181,
opTryend = 182,
opCatch = 183,
opThrow = 184,
--DEV newEmit...
-- virtual opcodes (ie no actual code in the VM for these)
-- (technically, opMovbi/opMovsi/opMovti/opAddiii/opSubiii/opMuliii/opDiviii
-- are also kinda virtual, with VMep[i] being an error handler or somesuch.
-- Also opObj should probably really be here rather than above, I think.)
--global constant
opCall = 201,
opFrst = 202, -- "Frame ReSTore"; used between opFrame and opCall, where all
-- local vars must be retrieved from the old stack frame.
--NESTEDFUNC (DEV/SUG:)
-- -- (opFrst is also used in nested functions (one level deep!?)
--opFstr = 209 -- "Frame Store"; used in nested functions...
-- -- (may not be much use for subscripting etc...)
--<<opJcci? (above 8)
--
-- opMov0 = 166, -- instead of incref, do decref(tgt), tgt=src, src=0.
-- opMov0nd = 167, -- "" w/o the decref (as onDeclaration)
-- opMovnd = 168, -- normal opMove, w/o decref (as onDeclaration)
-- opMovncd = 169, -- as opMovnd but no need to cmp h4 (as src is init seq/str)
-- [DEV this may be better as just src is init, opMovndsi]
-- opMovsind = 170 -- as opMovsi [DEV do I mean opMovbi?]
opJmp = 203,
opJtyp = 204,
opJbits = 205,
opJlen = 206,
opLabel = 207, -- opLabel,mergeSet,0/x86loc,link
opNop = 208,
--DEV unused:
-- opNopN = 209,
opLoopTop = 210, -- opLoopTop,lmask,gmask,end
opEndFor = 211,
opAsm = 212, -- opAsm,len/loc,next,jlink
opLn = 213,
opGchk = 214, -- implements #isginfo{} checks (no final code emitted)
opLchk = 215, -- implements #istype{} checks (no final code emitted)
opCtrl = 216, -- opCtrl,stmt,link,emitline
-- where stmt is one of IF/ELSIF/ELSE/END+IF/LOOP/END+LOOP
-- and link joins them all up, reverse-circle-wise.
-- emitline is for switch(/if) error reporting only
opInit = 217, -- initialise system/heap/stack/diag/etc
opDealloc = 218, -- used to link to :%pDealloc in VM\pHeap.e, should never actually occur in IL [same for opFrame [DEV]]
--DEV to go*4: (when ilasm->ilASM completed)
-- opLoadMem = 217, -- opLoadMem,reg,var (in ilasm only)
-- opLeaMov = 218, -- opLeaMov,reg,var (in ilasm only)
-- opStoreMem = 219, -- opStoreMem,reg,var (in ilasm only)
-- opFildMem = 220, -- opFildMem,reg,var (in ilasm only)
-- opObort = 219, -- test/temp
--219 spare
-- opRepCh = 220,
opFor2 = 221,
--DEV not in use*2:
-- opPushEax = 222, -- \ used in saveFunctionResultVars from paramList (only)
-- opPopVar = 223, -- / " " " "
--DEV temp[?]
opRunCleanup = 222,
opLogPos = 224, -- implements global labels (save the x86 offset)
--temp/test:
-- opMalloc = 225, -- opMalloc,dest,size
-- opMfree = 226, -- opMfree,addr
-- opTestN = 227, -- opTestN,lblidx
-- opTestM = 228, -- opTestM,lblidx
opPlatform = 225, -- implements platform() [resolved in pmain.e]
opMachine = 226, -- implements machine_bits() [resolved in pmain.e]
opDiv0 = 227, -- mapped to :%e02atdb0 in VM\\pDiagN.e (fatal error)
--DEV reorder...
-- opPeek = 142, -- a = peek(b) -- (returns integer if b is atom, string if b is sequence)
-- opPeek4s = 143, -- a = peek4s(b) -- (returns atom if b is atom, sequence if b is sequence)
-- opPeek4u = 144, -- a = peek4u(b) -- (returns atom if b is atom, sequence if b is sequence)
opPeek1s = 228, -- \
opPeek1u = 229, -- \\
opPeek2s = 230, -- } all done via :%opPeekNx,
opPeek2u = 231, -- } in builtins\VM\pMem.e
opPeek8s = 232, -- //
opPeek8u = 233, -- /
opPeekNS = 234, --/
opInitCS = 235, -- opInitCS,dest
opDeleteCS = 236, -- opDeleteCS,src [DEV ,init]
opEnterCS = 237, -- opEnterCS,src(/T_const0) [,init]
opTryCS = 238, -- opTryCS,dest,src [,init]
opLeaveCS = 239, -- opLeaveCS,src(/T_const0) [,init]
-- (the last 4 currently rely on opUnassigned, but will accept varno in esi, if that helps any)
opCrashMsg = 240, -- opCrashMsg,cm
-- opCrash = 241, -- opCrash,fmt,data
-- opCrash1 = 242, -- opCrash,fmt
opCrashFile = 242, -- opCrashFile,file_path
opCrashRtn = 243, -- opCrashRtn,rid
opWrap = 244, -- opWrap,flag
opScroll = 245, -- opScroll,amount,top,bottom
opTextRows = 246, -- opTextRows,res,lines
opVersion = 247, -- implements version() [resolved in pmain.e]
--??
--opDcfp = 247, -- define_c_func/proc
maxVop = 247
opNames = repeat(0,maxVop)
opSkip = repeat(-20000,maxVop) -- instruction lengths (mostly)
sqAble = repeat(0,maxVop) -- eg sqAble[opXor] -> "sq_xor_bits"
opEfct = repeat(0,maxVop) -- does opcode have side effects?
-- these next three should remain 0 for <=T_Bin and >T_Asm:
aatidx = repeat(0,maxVop) -- ttidx of glabels
aasydx = repeat(0,maxVop) -- corresponding symtab index
aartypes = repeat(0,maxVop) -- return types
opName("opMove",opMove,6)
opName("opMovbi",opMovbi,4)
opName("opMovsi",opMovsi,5)
opName("opMovti",opMovti,4)
-- opName("opStat",opStat,0) -- DEV??
opUsed += 1
opName("opLnt",opLnt,2)
opName("opLnp",opLnp,2)
opName("opLnpt",opLnpt,2)
opName("opTchk",opTchk,4) -- opTchk,varno,wasOptTypeCheck,default
opName("opTcFail",opTcFail,0)
opName("opBadRetf",opBadRetf,0)
opName("opUnassigned",opUnassigned,2)
-- opName("opCallOnceYeNot",opCallOnceYeNot,0)
-- opName("opAllocStr",opAllocStr,2) -- opAllocStr,res,len (only called from ilASM, so far)
-- opUsed += 4 -- spare/opCallOnceYeNot?
opUsed += 1 -- spare/opCallOnceYeNot?
opName("opDeSeq",opDeSeq,2)
-- opName("opWithJS",opWithJS,1)
opUsed += 2 -- spare
-- opName("opFor",opFor,6) -- opFor,init,ctl,step,limit,tgt/x86loc (see notes below)
-- (29/12/2011: "end" on the opLoopTop should now be used
-- in place of tgt, since that gets clobbered
-- with x86loc on the last pass.)
opName("opFrame",opFrame,0) -- opFrame,routineNo (0==handled separately)
opName("opCallOnce",opCallOnce,2)
opName("opRetf",opRetf,0)
opName("opMkSq",opMkSq,-3)
opName("opMkSqi",opMkSqi,-3)
opName("opRepe",opRepe,-4)
opName("opReps",opReps,-5)
opName("opSubse",opSubse,-4)
opName("opSubss",opSubss,-5)
opName("opConcatN",opConcatN,-3)
opName("opRepe1",opRepe1,4)
opName("opRepe1ip",opRepe1ip,0) --??
opName("opRepe1is",opRepe1is,0) --??
-- opUsed += 1 -- spare
opName("opSubsss",opSubsss,0) --??
opUsed += 2 -- spare
opName("opSubse1",opSubse1,6)
opName("opSubse1i",opSubse1i,6)
opName("opSubse1is",opSubse1is,6)
opName("opSubse1ip",opSubse1ip,0) --?? -- ""
opUsed += 1 -- spare
opName("opJif",opJif,7)
opName("opJnot",opJnot,7)
opName("opJge",opJge,8)
opName("opJlt",opJlt,8)
opName("opJeq",opJeq,8)
opName("opJne",opJne,8)
opName("opJgt",opJgt,8)
opName("opJle",opJle,8)
-- opName("opJifx",opJifx,7) -- ??
opUsed += 1 -- spare
opName("opJnotx",opJnotx,7)
opName("opSge",opSge,7)
opName("opSlt",opSlt,7)
opName("opSeq",opSeq,7)
opName("opSne",opSne,7)
opName("opSgt",opSgt,7)
opName("opSle",opSle,7)
opName("opScmp",opScmp,4)
-- opName("opFind",opFind,5)
-- opName("opMatch",opMatch,5)
opUsed += 2 -- spare
opName("opXor",opXor,4)
opName("opInt",opInt,4)
opName("opAtom",opAtom,4)
opName("opSq",opSq,4)
opName("opStr",opStr,4)
opName("opObj",opObj,4) --DEV??
-- opUsed += 4 -- (reserved for opInt0 etc)
-- sub-opcodes for opJtyp:
-- (these exist in the backend, and "-list" will show calls to them,
-- but they do not occur in the intermediate code, but are instead
-- generated off non-init opJtyp il opcodes)
opName("opInt0",opInt0,0)
opName("opAtom0",opAtom0,0)
opName("opSq0",opSq0,0)
opName("opStr0",opStr0,0)
opName("opLen",opLen,5)
opName("opNot",opNot,3)
opName("opOpen",opOpen,4)
opName("opGetc",opGetc,3) -- opGetc,res,fn
opName("opGetKey",opGetKey,2)
opName("opWaitKey",opWaitKey,2)
opName("opSeek",opSeek,4)
opName("opWhere",opWhere,4)
opName("opLock",opLock,5)
opName("opUnLock",opUnLock,3)
opName("opRand",opRand,4)
-- opName("opChDir",opChDir,4)
opUsed += 1 -- spare
opName("opPeeki",opPeeki,4)
opUsed += 2 -- spare
opName("opAdd",opAdd,4)
opName("opAddi",opAddi,4)
opName("opAddiii",opAddiii,4)
opName("opSub",opSub,4)
opName("opSubi",opSubi,4)
opName("opSubiii",opSubiii,4)
opName("opMul",opMul,4)
opName("opMuli",opMuli,4)
opName("opMuliii",opMuliii,4)
opName("opDiv",opDiv,4)
opName("opDivi",opDivi,4)
opName("opDiviii",opDiviii,4)
opName("opDiv2",opDiv2,3)
opName("opDivi2",opDivi2,3)
opName("opDivf",opDivf,4)
opName("opDivf2",opDivf2,4)
-- opUsed += 3 -- spare
opUsed += 5 -- spare
-- opName("oXpInc",oXpInc,2) --DEV no longer used
-- opName("oXpDec",oXpDec,2) -- ""
--opName("oXpCatsi",oXpCatsi,2)
opName("opFloor",opFloor,3)
opName("opRmdr",opRmdr,5)
opName("opUminus",opUminus,3)
opName("opAndBits",opAndBits,5)
opName("opOrBits",opOrBits,5)
opName("opXorBits",opXorBits,5)
opName("opNotBits",opNotBits,4)
opName("opPow",opPow,5)
opName("opTime",opTime,2)
opName("opAlloc",opAlloc,4)
opName("opCos",opCos,3)
opName("opSin",opSin,3)
opName("opTan",opTan,3)
opName("opArcTan",opArcTan,3)
opName("opLog",opLog,3)
opName("opSqrt",opSqrt,3)
-- opName("op32toA",op32toA,4)
-- opName("op64toA",op64toA,4)
-- opUsed += 2 -- spare
opName("opCallFunc",opCallFunc,4) -- opCallFunc,res,rid,params
opName("opCallProc",opCallProc,3) -- opCallProc,rid,params
--DEV?
opName("opOpenDLL",opOpenDLL,3)
opName("opDcfunc",opDcfunc,6) -- opDcfunc,res,lib,name,args,rtyp
opName("opDcvar",opDcvar,4) -- opDcvar,res,lib,name
opName("opInstance",opInstance,2)
opName("opCallback",opCallback,3) -- opCallback,res,id
-- opUsed += 4 -- spare
-- opName("opCurrDir",opCurrDir,2)
-- opName("opCatsi",opCatsi,2)
-- opUsed += 2 -- spare
opName("opCallA",opCallA,2)
opName("opCfunc",opCfunc,4)
opName("opCproc",opCproc,3)
opName("opGpct",opGpct,0) -- no opSkip/should not occur in il/#ilasm only
opName("opRpct",opRpct,0) -- no opSkip/should not occur in il/#ilasm only
opUsed += 1 -- spare
opName("opApnd",opApnd,4)
opName("opPpnd",opPpnd,4)
opName("opConcat",opConcat,4)
-- opName("opRepeat",opRepeat,4)
opUsed += 1
-- opName("opAto32",opAto32,3)
-- opName("opAto64",opAto64,3)
-- opUsed += 2 -- spare
opName("opCurrDir",opCurrDir,2)
opName("opCatsi",opCatsi,2)
-- opName("opGSCh",opGSCh,0) -- ??!!! [DEV]
opName("opGetRand",opGetRand,0) -- no opSkip/should not occur in il/#ilasm only
opName("opGetPos",opGetPos,2)
opUsed += 2 -- spare
opName("opPeek",opPeek,3)
opName("opPeek4s",opPeek4s,3)
opName("opPeek4u",opPeek4u,3)
opName("opGets",opGets,4)
opName("opGetText",opGetText,4) -- opGetText,res,fn,option
-- opName("opMoveFRes",opMoveFRes,3)
opUsed += 2 -- spare
-- opUsed += 3 -- spare
-- opName("opPokeN",opPokeN,5) -- opPokeN,Nflag,base,offset,value
opName("opPokeN",opPokeN,4) -- opPokeN,addr,value,size
--DEV togo
-- opName("opCallA",opCallA,2)
-- opName("opCallProc",opCallProc,3)
-- opUsed += 3 -- spare
opName("opPoke1",opPoke1,3)
opName("opPoke2",opPoke2,3)
opName("opPoke8",opPoke8,3)
opName("opClrScrn",opClrScrn,1)
opName("opFreeCons",opFreeCons,1)
opName("opFree",opFree,2)
opName("opMemCopy",opMemCopy,4)
opName("opMemSet",opMemSet,4)
opName("opPoke",opPoke,3)
opName("opPoke4",opPoke4,3)
opName("opPosition",opPosition,3)
opName("opPuts",opPuts,3)
-- opName("oXpPSCh",oXpPSCh,0) -- ??!!!! [DEV]
-- opName("opGetProcA",opGetProcA,0) -- (#ilasm only, see pcfunc.e) [to go?]
opUsed += 1
opName("opFlush",opFlush,2)
opName("opClose",opClose,2)
opName("opSetRand",opSetRand,2)
opName("opSleep",opSleep,2)
opName("opTxtClr",opTxtClr,2)
opName("opBkClr",opBkClr,2)
opName("opTrace",opTrace,2)
opName("opProfile",opProfile,2)
-- opUsed += 1 -- spare
opName("opProfout",opProfout,1)
opName("opClrDbg",opClrDbg,0)
-- opName("opTrap",opTrap,0) -- ?? -- untested/ buried in #ilasm block and hence
opUsed += 1
opName("opRTErn",opRTErn,0) -- ?? -- there is no need for opSkip handling.
--DEV to go:
opName("opGetST",opGetST,0) -- ?? -- ""
--if newEmit then
-- opName("opGetSP",opGetSP,0) -- ?? -- ""
-- opName("opSetSP",opSetSP,0) -- ?? -- ""
--else
-- opUsed += 2
opName("opDelRtn",opDelRtn,4) -- ?? -- ""
opName("opDelete",opDelete,2) -- ?? -- ""
opName("opAbort",opAbort,2)
-- opName("opGetVMep",opGetVMep,0) --??
-- opName("opReadVM",opReadVM,0) --??
--end if
-- opName("opPokeRef",opPokeRef,0) -- ??
-- opName("opGetRaw",opGetRaw,0) --??
opUsed += 2
-- opUsed += 20
--DEV::
--EXCEPT
opName("opTry",opTry,4) -- opTry,tmp,tgt,esp4
opName("opTryend",opTryend,5) -- opTryend,mergeSet(0),tgt,link,tlnk
opName("opCatch",opCatch,3) -- opCatch,tlnk,e
opName("opThrow",opThrow,3) -- opThrow,e,user
opUsed += 16
-- opName("opLicence",opLicence,0) -- (#ilASM only, see pemit.e)
-- opName("opSetDbg",opSetDbg,0) --??
-- opName("opCrshRtn",opCrshRtn,0) --??
-- opName("opRbldIds",opRbldIds,0) --??
-- opName("opCrshMsg",opCrshMsg,2)
-- opUsed += 2
-- opName("opDelRtn",opDelRtn,0) --??
-- opName("opCrshFile",opCrshFile,2)
-- opUsed += 2
-- opName("opInterp",opInterp,0) --??
-- opName("opAbort",opAbort,2)
-- opUsed += 3
-- opName("opCleanUp",opCleanUp,0) --??
-- opName("opCleanUp1",opCleanUp1,0) --??
-- opUsed += 7
-- opName("opGetRRC",opGetRRC,0) -- (#ilASM only, see pgui.exw)
-- opName("opSetBatchMode",opSetBatchMode,0)
-- opName("opLichk",opLichk,0) -- (#ilASM only, TEMP!)
-- opName("opDelRef",opDelRef,0)
-- opName("opCrsh",opCrsh,0)
--opName("opInterp2",opInterp2,0)
--opName("opHeapAlloc",opHeapAlloc,0) -- (#ilASM only) [TEMP, to go]
--opName("opTlsGetValue",opTlsGetValue,0) -- (#ilASM only) [TEMP, to go]
-- opUsed += 4
-- opUsed += 2
-- opUsed += 3
-- virtual opcodes:
opName("opCall",opCall,1) -- opCall (routine to call is left on stack by opFrame)
opName("opFrst",opFrst,5)
opName("opJmp",opJmp,4) -- opJmp,mergeSet,tgt,link\n"
opName("opJtyp",opJtyp,10)
opName("opJbits",opJbits,8)
opName("opJlen",opJlen,8)
opName("opLabel",opLabel,4)
opName("opNop",opNop,1)
-- opName("opNopN",opNopN,-1)
opUsed += 1
opName("opLoopTop",opLoopTop,4) -- opLoopTop,lmask,gmask,end
opName("opEndFor",opEndFor,3) -- opEndFor,ctnr,bpFor
opName("opAsm",opAsm,-4)
opName("opLn",opLn,2)
opName("opGchk",opGchk,10) -- opGchk,N,typ,min,max,etyp,len,tokline,tokcol,fileno
opName("opLchk",opLchk,6) -- opLchk,N,typ,tokline,tokcol,fileno
opName("opCtrl",opCtrl,4) -- opCtrl,stmt,link[,emitline] (see ltCtrl in pltype.e)
-- (emitline is for switch(/if) error reporting only)
opName("opInit",opInit,1)
-- opName("opDealloc",opDealloc,1) -- used to link to :%pDealloc in VM\pHeap.e, should never actually occur in IL
opUsed += 2
-- opName("opObort",opObort,2) -- opObort,N
-- opName("opRepCh",opRepCh,4) -- opRepCh,dest,item,count
opUsed += 1
--DEV to go?
-- opName("opLoadMem",opLoadMem,5) -- opLoadMem,reg,var (see loadMem in pilx86.e)
-- opName("opLeaMov",opLeaMov,5) -- opLeaMov,reg,var (see leamov in pilx86.e)
-- opName("opStoreMem",opStoreMem,5) -- opStoreMem,reg,var (see storeMem in pilx86.e)
-- opName("opFildMem",opFildMem,5) -- opFildMem,reg,var (see fildMem in pilx86.e)
-- opUsed += 3
opName("opFor2",opFor2,7) -- opFor,flags,init,ctl,step,limit,tgt/x86loc
--DEV (spotted in passing) Are these used? 'cos they cannot possibly be right...
-- opName("opPushEax",opPushEax,0) -- opPushEax
-- opName("opPopVar",opPopVar,1) -- opPopVar,N
-- opUsed += 2
opName("opRunCleanup",opRunCleanup,0)
opUsed += 1
opName("opLogPos",opLogPos,2) -- opLogPos,N
--DEV (test)
-- opName("opMalloc",opMalloc,3) -- opMalloc,dest,size
-- opName("opMfree",opMfree,2) -- opMfree,addr
-- opName("opTestN",opTestN,2) -- opTestN,lblidx
-- opName("opTestM",opTestM,2) -- opTestM,lblidx
opName("opPlatform",opPlatform,0)
opName("opMachine",opMachine,0)
opName("opDiv0",opDiv0,0)
opName("opPeek1s",opPeek1s,3) -- opPeek1s,res,addr
opName("opPeek1u",opPeek1u,3)
opName("opPeek2s",opPeek2s,3)
opName("opPeek2u",opPeek2u,3)
opName("opPeek8s",opPeek8s,3)
opName("opPeek8u",opPeek8u,3)
opName("opPeekNS",opPeekNS,5) -- opPeekNS,res,addr,size,sign
opName("opInitCS",opInitCS,2)
opName("opDeleteCS",opDeleteCS,2)
opName("opEnterCS",opEnterCS,2)
opName("opTryCS",opTryCS,3)
opName("opLeaveCS",opLeaveCS,2)
opName("opCrashMsg",opCrashMsg,2)
-- opName("opCrash",opCrash,3)
--DEV??
-- opName("opCrash1",opCrash1,2)
opUsed += 1
opName("opCrashFile",opCrashFile,2)
opName("opCrashRtn",opCrashRtn,2)
opName("opWrap",opWrap,2)
opName("opScroll",opScroll,4)
opName("opTextRows",opTextRows,3)
opName("opVersion",opVersion,0)
--DEV move this to the help text, and fill in any gaps
-- The anonymous label (@@:) can be used with @f (forward) and @b (backward) jumps:
--
-- cmp eax,h4
-- jle @f
-- add dword[ebx+eax*4-12],1 -- incref
-- @@:
-- lodsd
-- cmp al,'\n'