-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIVO.java
2896 lines (2543 loc) · 97.4 KB
/
IVO.java
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
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.rms.*; // really needed?
import java.io.*;
import javax.microedition.io.*;
public class IVO extends MIDlet implements CommandListener {
private Display display;
private Form form = new Form("1V0");
private Command exit = new Command("EXIT", Command.EXIT, 1);
private Command submit = new Command("ENTER", Command.SCREEN, 1);
private Command reentry = new Command("INIT", Command.SCREEN, 1);
private Command runcode = new Command("RUN", Command.SCREEN, 1);
private Command setvalue = new Command("SET", Command.SCREEN, 1);
private Command previouscommand;
private TextField cmdfield = new TextField("CMDA:", "0", 4, TextField.NUMERIC); // 3 OR 4
private TextField oprfield = new TextField("OPER:", "0", 3, TextField.NUMERIC);
private TextField d1_field = new TextField("ADR1:", "1", 4, TextField.NUMERIC);
private TextField d2_field = new TextField("ADR2:", "1", 4, TextField.NUMERIC);
private TextField rl_field = new TextField("NEW RUNLIMIT:", "32767", 5, TextField.NUMERIC);
private TextField flofield = new TextField("NUM:", "0", 15, TextField.DECIMAL); // Make the text "00" on fixedpoint!
private TextField intfield = new TextField("INT:", "0", 11, TextField.NUMERIC);
private String ephemeral = ""; // I CAN DECLARE HERE ANYTHING AND USE THE STUFF BELOW LIKE GOSUBS
private String rlstring = "";
private String trace1s = "";
private int entryflag = 0;
private int DATAMEM = 8001; // 8191 is the addressable space
private int EXECMEM = 2001; // ANYTHING YOU LIKE, BUT OTHERWISE YOU WAIT TOO LONG FOR THE END IF YOU DID NOT SPECIFY A JUMP BACK
private short tracer = 0;
private int instr = 0;
/* instruction format: */
/* operator, data address 1 (=result), data address 2 */
/* every operator is at a command address. */
private int cmdadr = 0;
private int opr = 0;
private int datadr1 = 0;
private int datadr2 = 0;
private int pc = 0;
private int h = 0; /* beware: h & k are used for "transcendental" instructions ... */
private int i = 0; /* i & j are auxiliary looping variables */
private int j = 0;
private int k = 0; /* ... so ZERO THEM OUT after non-transcendental usage */
private int xx;
private int yy;
private int zz;
private int[] instruction = new int[EXECMEM];
private int runlimit = 0;
/* If this is 0, run unlimited, else break when it becomes 1. */
/* This is a sort of "safety", to prevent infinite looping. */
private float f = 0.0f; /* f & g are auxiliary floating point temporary storage */
private float g = 0.0f;
private float TOLERANCE = 0.0001f;
private float PI = 3.14159265358979323846f;
private float[] datum = new float[DATAMEM];
private static float sqrt(float num) {
num = absvalu(num);
float guess = num / 4;
int maxrun = 1;
while(absvalu(guess * guess - num) >= 0.0001f) {
guess = (num/guess + guess) / 2.0f;
maxrun++;
if (maxrun > 200) {
break;
}
}
return guess;
}
private static float cbrt(float num) {
float guess = num / 2;
int maxrun = 1;
while(absvalu(guess * guess * guess - num) >= 0.0001f) {
guess = (num/guess + guess) / 2.0f;
maxrun++;
if (maxrun > 200) {
break;
}
}
return guess;
}
private static double pwr(double base, int expo) {
double ff = 1.0;
int ij;
if (expo > 1) {
for (ij = 1; ij <= expo; ij++) {
ff = ff * base;
}
} else if (expo < 1) {
expo = -expo;
for (ij = 1; ij <= expo; ij++) {
ff = ff / base;
}
} else {
ff = 1.0;
}
return ff;
}
/* OMITTED - DYSFUNCTIONAL
public static double lgr(double x) {
long l = Double.doubleToLongBits(x);
long expo = ((0x7ff0000000000000L & l) >> 52) - 1023;
double man = (0x000fffffffffffffL & l) / (double)0x10000000000000L + 1.0;
double lnm = 0.0;
double a = (man - 1) / (man + 1);
for( int n = 1; n < 7; n += 2) {
lnm += pwr(a, n) / n;
}
return 2 * lnm + expo * 0.69314718055994530941723212145818;
}
public static float log(float x) {
return ((float) lgr((double) x));
}
*/
private static float pow(float base, float expo) {
return ((float) pwr((double) base, (int) expo));
}
private static float exp(float expo) {
return ((float) pwr(2.71828182845904523536, (int) expo));
}
private static float absvalu(float x) {
if (x < 0.0f) {
return -x;
} else {
return x;
}
}
public IVO() {
// Better do stuff BEFORE showing controls.
for (i=0; i<EXECMEM; i++) {
instruction[i] = 0;
}
for (i=0; i<DATAMEM; i++) {
datum[i] = 0.0f;
}
runlimit = 5 * EXECMEM;
display = Display.getDisplay(this);
form.append("WELCOME TO 1V0: -1show_instructions -2show_data -4enter_data 0NOOP 1JUMP 2IADR 5SADR 6SVAL 7IAAS 8IVAS 9PLUS 10MINS 11MULS 12DIVS 13POXY 14IFRA 15REMN 17AMNT 19PCNT 20SWAP 21FACT 22COPY 23FRIS 24MNMX 25SORT 26CORS 27TURN 28SUMR 29SUSQ 30IXTH 31ABSR 32SQRT 33SQUA 34CBRT 35CUBE 37EXPR 38RADE 39DERA 40SIND 41COSD 42TAND 46MSTD 47ZERO 49RUND 50CEIL 53PLUR 54MINR 55MULR 56DIVR 57PLUN 58MINN 59MULN 60DIVN");
form.addCommand(exit);
form.addCommand(reentry);
form.setCommandListener(this);
}
public void startApp() {
display.setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command command, Displayable displayable) {
if (command == submit) {
previouscommand = command;
// TESTME2 IS MUTABLE HERE AND "REMEMBERS" BEING CHANGED!
// ephemeral = cmdfield.getString() + oprfield.getString() + d1_field.getString() + d2_field.getString();
ephemeral = cmdfield.getString(); // Turn the field strings into numbers.
cmdadr = java.lang.Integer.parseInt(ephemeral);
ephemeral = oprfield.getString();
opr = java.lang.Integer.parseInt(ephemeral);
ephemeral = d1_field.getString();
datadr1 = java.lang.Integer.parseInt(ephemeral);
ephemeral = d2_field.getString();
datadr2 = java.lang.Integer.parseInt(ephemeral);
form.removeCommand(submit); // cycle the available commands
form.deleteAll(); // CLS at first safe place
if (cmdadr > 0) {
form.deleteAll(); // CLS at first safe place
// THIS WORKS:
ephemeral = Integer.toString(cmdadr) + " " + Integer.toString(opr) + " " + Integer.toString(datadr1) + " " + Integer.toString(datadr2);
form.append(ephemeral);
if ((datadr1 >= DATAMEM) || (datadr2 >= DATAMEM) ||
(datadr1 < 0) || (datadr1 < 0) || (cmdadr >= EXECMEM)) {
form.append(" CORRECTING RANGE. DATA 0 ... " + (DATAMEM - 1) + ", COMMANDS 0 ... " + (EXECMEM - 1));
}
/* only positive data addresses - and 0 - are allowed: */
datadr1 = (int) absvalu(datadr1);
datadr2 = (int) absvalu(datadr2);
/* force everything to be within range: */
if (cmdadr >= EXECMEM) {
cmdadr = EXECMEM - 1;
}
if (datadr1 >= DATAMEM) {
datadr1 = DATAMEM - 1;
}
if (datadr2 >= DATAMEM) {
datadr2 = DATAMEM - 1;
}
/* Having read the instruction, compose it and save it. */
xx = opr & 63;
yy = datadr1 & 8191;
zz = datadr2 & 8191;
instr = (xx << 26) | (yy << 13) | zz;
instruction[cmdadr] = instr;
ephemeral = " ";
ephemeral = ephemeral + cmdadr + ":" + opr;
ephemeral = ephemeral + "=";
if (opr == 0) {
ephemeral = ephemeral + "NOOP";
} else if (opr == 1) {
ephemeral = ephemeral + "JUMP";
} else if (opr == 2) {
ephemeral = ephemeral + "IADR";
} else if (opr == 3) {
ephemeral = ephemeral + "OUTP";
} else if (opr == 4) {
ephemeral = ephemeral + "INPT";
} else if (opr == 5) {
ephemeral = ephemeral + "SADR";
} else if (opr == 6) {
ephemeral = ephemeral + "SVAL";
} else if (opr == 7) {
ephemeral = ephemeral + "IAAS";
} else if (opr == 8) {
ephemeral = ephemeral + "IVAS";
} else if (opr == 9) {
ephemeral = ephemeral + "PLUS";
} else if (opr == 10) {
ephemeral = ephemeral + "MINS";
} else if (opr == 11) {
ephemeral = ephemeral + "MULS";
} else if (opr == 12) {
ephemeral = ephemeral + "DIVS";
} else if (opr == 13) {
ephemeral = ephemeral + "POXY";
} else if (opr == 14) {
ephemeral = ephemeral + "LOXY";
} else if (opr == 15) {
ephemeral = ephemeral + "IFRA";
} else if (opr == 16) {
ephemeral = ephemeral + "REMN";
} else if (opr == 17) {
ephemeral = ephemeral + "AMNT";
} else if (opr == 18) {
ephemeral = ephemeral + "PERD";
} else if (opr == 19) {
ephemeral = ephemeral + "PCNT";
} else if (opr == 20) {
ephemeral = ephemeral + "SWAP";
} else if (opr == 21) {
ephemeral = ephemeral + "FACT";
} else if (opr == 22) {
ephemeral = ephemeral + "COPY";
} else if (opr == 23) {
ephemeral = ephemeral + "FRIS";
} else if (opr == 24) {
ephemeral = ephemeral + "MNMX";
} else if (opr == 25) {
ephemeral = ephemeral + "SORT";
} else if (opr == 26) {
ephemeral = ephemeral + "CORS";
} else if (opr == 27) {
ephemeral = ephemeral + "TURN";
} else if (opr == 28) {
ephemeral = ephemeral + "SUMR";
} else if (opr == 29) {
ephemeral = ephemeral + "SUSQ";
} else if (opr == 30) {
ephemeral = ephemeral + "IXTH";
} else if (opr == 31) {
ephemeral = ephemeral + "ABSR";
} else if (opr == 32) {
ephemeral = ephemeral + "SQRT";
} else if (opr == 33) {
ephemeral = ephemeral + "SQUA";
} else if (opr == 34) {
ephemeral = ephemeral + "CBRT";
} else if (opr == 35) {
ephemeral = ephemeral + "CUBE";
} else if (opr == 36) {
ephemeral = ephemeral + "LNRN";
} else if (opr == 37) {
ephemeral = ephemeral + "EXPR";
} else if (opr == 38) {
ephemeral = ephemeral + "RADE";
} else if (opr == 39) {
ephemeral = ephemeral + "DERA";
} else if (opr == 40) {
ephemeral = ephemeral + "SIND";
} else if (opr == 41) {
ephemeral = ephemeral + "COSD";
} else if (opr == 42) {
ephemeral = ephemeral + "TAND";
} else if (opr == 43) {
ephemeral = ephemeral + "ASND";
} else if (opr == 44) {
ephemeral = ephemeral + "ACSD";
} else if (opr == 45) {
ephemeral = ephemeral + "ATND";
} else if (opr == 46) {
ephemeral = ephemeral + "MSTD";
} else if (opr == 47) {
ephemeral = ephemeral + "ZERO";
} else if (opr == 48) {
ephemeral = ephemeral + "RAND";
} else if (opr == 49) {
ephemeral = ephemeral + "RUND";
} else if (opr == 50) {
ephemeral = ephemeral + "CEIL";
} else if (opr == 51) {
ephemeral = ephemeral + "TANH";
} else if (opr == 52) {
ephemeral = ephemeral + "DTNH";
} else if (opr == 53) {
ephemeral = ephemeral + "PLUR";
} else if (opr == 54) {
ephemeral = ephemeral + "MINR";
} else if (opr == 55) {
ephemeral = ephemeral + "MULR";
} else if (opr == 56) {
ephemeral = ephemeral + "DIVR";
} else if (opr == 57) {
ephemeral = ephemeral + "PLUN";
} else if (opr == 58) {
ephemeral = ephemeral + "MINN";
} else if (opr == 59) {
ephemeral = ephemeral + "MULN";
} else if (opr == 60) {
ephemeral = ephemeral + "DIVN";
} else if (opr == 61) {
ephemeral = ephemeral + "PROB";
} else if (opr == 62) {
ephemeral = ephemeral + "STDD";
} else if (opr == 63) {
ephemeral = ephemeral + "USER";
} else {
/* Such an "else" MAY come into existence if not ALL possible */
/* instructions have been implemented, either theoretically, or */
/* practically - simply due to a lack of flash space. */
ephemeral = ephemeral + "NOKO";
}
ephemeral = ephemeral + ":";
ephemeral = ephemeral + datadr1 + ">" + datum[datadr1];
if ((datum[datadr1] > -1 * DATAMEM) && (datum[datadr1] < DATAMEM)) {
j = (int) absvalu((int)(datum[datadr1]));
ephemeral = ephemeral + ">" + datum[j];
}
ephemeral = ephemeral + ":";
ephemeral = ephemeral + datadr2 + ">" + datum[datadr2];
if ((datum[datadr2] > -1 * DATAMEM) && (datum[datadr2] < DATAMEM)) {
j = (int) absvalu((int)(datum[datadr2]));
ephemeral = ephemeral + ">" + datum[j];
}
ephemeral = ephemeral + ":";
ephemeral = ephemeral + "DEC:" + instr;
form.append(ephemeral);
form.addCommand(reentry); // submit -> reentry
form.setCommandListener(this);
} else if (cmdadr == 0) {
form.deleteAll();
// THIS WORKS:
ephemeral = Integer.toString(cmdadr) + " " + Integer.toString(opr) + " " + Integer.toString(datadr1) + " " + Integer.toString(datadr2);
form.append(ephemeral);
if ((datadr1 >= DATAMEM) || (datadr2 >= DATAMEM) ||
(datadr1 < 0) || (datadr1 < 0) || (cmdadr >= EXECMEM)) {
form.append(" CORRECTING RANGE. DATA 0 ... " + (DATAMEM - 1) + ", COMMANDS 0 ... " + (EXECMEM - 1));
}
/* only positive data addresses - and 0 - are allowed: */
datadr1 = (int) absvalu(datadr1);
datadr2 = (int) absvalu(datadr2);
/* force everything to be within range: */
if (cmdadr >= EXECMEM) {
cmdadr = EXECMEM - 1;
}
if (datadr1 >= DATAMEM) {
datadr1 = DATAMEM - 1;
}
if (datadr2 >= DATAMEM) {
datadr2 = DATAMEM - 1;
}
/* Having read the instruction, compose it and save it. */
xx = opr & 63;
yy = datadr1 & 8191;
zz = datadr2 & 8191;
instr = (xx << 26) | (yy << 13) | zz;
cmdadr = 0;
instruction[cmdadr] = instr;
ephemeral = " ";
ephemeral = ephemeral + cmdadr + ":" + opr;
ephemeral = ephemeral + "=";
if (opr == 0) {
ephemeral = ephemeral + "NOOP";
} else if (opr == 1) {
ephemeral = ephemeral + "JUMP";
} else if (opr == 2) {
ephemeral = ephemeral + "IADR";
} else if (opr == 3) {
ephemeral = ephemeral + "OUTP";
} else if (opr == 4) {
ephemeral = ephemeral + "INPT";
} else if (opr == 5) {
ephemeral = ephemeral + "SADR";
} else if (opr == 6) {
ephemeral = ephemeral + "SVAL";
} else if (opr == 7) {
ephemeral = ephemeral + "IAAS";
} else if (opr == 8) {
ephemeral = ephemeral + "IVAS";
} else if (opr == 9) {
ephemeral = ephemeral + "PLUS";
} else if (opr == 10) {
ephemeral = ephemeral + "MINS";
} else if (opr == 11) {
ephemeral = ephemeral + "MULS";
} else if (opr == 12) {
ephemeral = ephemeral + "DIVS";
} else if (opr == 13) {
ephemeral = ephemeral + "POXY";
} else if (opr == 14) {
ephemeral = ephemeral + "LOXY";
} else if (opr == 15) {
ephemeral = ephemeral + "IFRA";
} else if (opr == 16) {
ephemeral = ephemeral + "REMN";
} else if (opr == 17) {
ephemeral = ephemeral + "AMNT";
} else if (opr == 18) {
ephemeral = ephemeral + "PERD";
} else if (opr == 19) {
ephemeral = ephemeral + "PCNT";
} else if (opr == 20) {
ephemeral = ephemeral + "SWAP";
} else if (opr == 21) {
ephemeral = ephemeral + "FACT";
} else if (opr == 22) {
ephemeral = ephemeral + "COPY";
} else if (opr == 23) {
ephemeral = ephemeral + "FRIS";
} else if (opr == 24) {
ephemeral = ephemeral + "MNMX";
} else if (opr == 25) {
ephemeral = ephemeral + "SORT";
} else if (opr == 26) {
ephemeral = ephemeral + "CORS";
} else if (opr == 27) {
ephemeral = ephemeral + "TURN";
} else if (opr == 28) {
ephemeral = ephemeral + "SUMR";
} else if (opr == 29) {
ephemeral = ephemeral + "SUSQ";
} else if (opr == 30) {
ephemeral = ephemeral + "IXTH";
} else if (opr == 31) {
ephemeral = ephemeral + "ABSR";
} else if (opr == 32) {
ephemeral = ephemeral + "SQRT";
} else if (opr == 33) {
ephemeral = ephemeral + "SQUA";
} else if (opr == 34) {
ephemeral = ephemeral + "CBRT";
} else if (opr == 35) {
ephemeral = ephemeral + "CUBE";
} else if (opr == 36) {
ephemeral = ephemeral + "LNRN";
} else if (opr == 37) {
ephemeral = ephemeral + "EXPR";
} else if (opr == 38) {
ephemeral = ephemeral + "RADE";
} else if (opr == 39) {
ephemeral = ephemeral + "DERA";
} else if (opr == 40) {
ephemeral = ephemeral + "SIND";
} else if (opr == 41) {
ephemeral = ephemeral + "COSD";
} else if (opr == 42) {
ephemeral = ephemeral + "TAND";
} else if (opr == 43) {
ephemeral = ephemeral + "ASND";
} else if (opr == 44) {
ephemeral = ephemeral + "ACSD";
} else if (opr == 45) {
ephemeral = ephemeral + "ATND";
} else if (opr == 46) {
ephemeral = ephemeral + "MSTD";
} else if (opr == 47) {
ephemeral = ephemeral + "ZERO";
} else if (opr == 48) {
ephemeral = ephemeral + "RAND";
} else if (opr == 49) {
ephemeral = ephemeral + "RUND";
} else if (opr == 50) {
ephemeral = ephemeral + "CEIL";
} else if (opr == 51) {
ephemeral = ephemeral + "TANH";
} else if (opr == 52) {
ephemeral = ephemeral + "DTNH";
} else if (opr == 53) {
ephemeral = ephemeral + "PLUR";
} else if (opr == 54) {
ephemeral = ephemeral + "MINR";
} else if (opr == 55) {
ephemeral = ephemeral + "MULR";
} else if (opr == 56) {
ephemeral = ephemeral + "DIVR";
} else if (opr == 57) {
ephemeral = ephemeral + "PLUN";
} else if (opr == 58) {
ephemeral = ephemeral + "MINN";
} else if (opr == 59) {
ephemeral = ephemeral + "MULN";
} else if (opr == 60) {
ephemeral = ephemeral + "DIVN";
} else if (opr == 61) {
ephemeral = ephemeral + "PROB";
} else if (opr == 62) {
ephemeral = ephemeral + "STDD";
} else if (opr == 63) {
ephemeral = ephemeral + "USER";
} else {
/* Such an "else" MAY come into existence if not ALL possible */
/* instructions have been implemented, either theoretically, or */
/* practically - simply due to a lack of flash space. */
ephemeral = ephemeral + "NOKO";
}
ephemeral = ephemeral + ":";
ephemeral = ephemeral + datadr1 + ">" + datum[datadr1];
if ((datum[datadr1] > -1 * DATAMEM) && (datum[datadr1] < DATAMEM)) {
j = (int) absvalu((int)(datum[datadr1]));
ephemeral = ephemeral + ">" + datum[j];
}
ephemeral = ephemeral + ":";
ephemeral = ephemeral + datadr2 + ">" + datum[datadr2];
if ((datum[datadr2] > -1 * DATAMEM) && (datum[datadr2] < DATAMEM)) {
j = (int) absvalu((int)(datum[datadr2]));
ephemeral = ephemeral + ">" + datum[j];
}
ephemeral = ephemeral + ":";
ephemeral = ephemeral + "DEC:" + instr;
form.append(ephemeral);
form.addCommand(runcode); // GO: submit -> runcode"SUBMIT TO RUN CODE EXIT TO CANCEL"
form.append(" ENTER TO RUN, EXIT TO ABORT");
form.setCommandListener(this);
} else if (cmdadr == -1) {
form.deleteAll();
form.append(d1_field);
form.append(d2_field);
form.append(" LIST INSTRUCTION RANGE");
form.addCommand(setvalue);
form.setCommandListener(this);
} else if (cmdadr == -2) {
form.deleteAll();
form.append(d1_field);
form.append(d2_field);
form.append(" LIST DATA RANGE");
form.addCommand(setvalue);
form.setCommandListener(this);
} else if (cmdadr == -3) {
form.deleteAll();
form.append(d1_field);
form.append(" ENTER INSTRUCTIONS FROM ADDRESS UP");
form.addCommand(setvalue);
form.setCommandListener(this);
} else if (cmdadr == -4) {
form.deleteAll();
form.append(d1_field);
form.append(d2_field);
form.append(" ENTER NUMBERS IN DATA RANGE");
form.addCommand(setvalue);
form.setCommandListener(this);
} else if (cmdadr == -5) {
form.deleteAll();
form.append(d1_field);
form.append(d2_field);
form.append(" CLEAR INSTRUCTION RANGE");
form.addCommand(setvalue);
form.setCommandListener(this);
} else if (cmdadr == -6) {
form.deleteAll();
form.append(d1_field);
form.append(d2_field);
form.append(" CLEAR DATA RANGE");
form.addCommand(setvalue);
form.setCommandListener(this);
} else if (cmdadr == -7) {
form.deleteAll();
form.addCommand(reentry);
form.setCommandListener(this);
form.append(" TRACE ON");
tracer = 1;
} else if (cmdadr == -8) {
form.addCommand(reentry);
form.setCommandListener(this);
form.append(" TRACE OFF");
tracer = 0;
} else if (cmdadr == -9) {
form.deleteAll();
form.append(rl_field);
form.addCommand(setvalue);
form.setCommandListener(this);
} else if (cmdadr == -10) {
form.deleteAll();
form.addCommand(reentry); // EJECT: -> reentry
form.setCommandListener(this);
form.append(" EXIT FROM INIT MENU");
} else {
form.deleteAll();
form.addCommand(reentry); // EJECT: -> reentry
form.setCommandListener(this);
form.append(" COMMAND NOT AVAILABLE");
}
} else if (command == reentry) {
previouscommand = command;
form.deleteAll(); // CLS at first safe place
form.removeCommand(reentry); // cycle the available commands
form.removeCommand(runcode); // cycle the available commands
// Better do stuff BEFORE showing controls.
pc = 0; // safety: nuke the program counter and the immediate instruction
instruction[0] = 0;
form.setCommandListener(this);
form.addCommand(submit); // reentry -> submit
form.append(cmdfield); // REDRAW EVERYTHING
form.append(oprfield);
form.append(d1_field);
form.append(d2_field);
form.setCommandListener(this);
cmdfield.setString("0");
oprfield.setString("0");
d1_field.setString("1");
d2_field.setString("1");
} else if (command == setvalue) {
previouscommand = setvalue;
form.removeCommand(setvalue);
if (entryflag == -3) {
form.deleteAll();
ephemeral = intfield.getString();
instr = java.lang.Integer.parseInt(ephemeral);
if ((instr == 67108863) || (datadr1 == EXECMEM)) { /* eject */
entryflag = 0;
form.addCommand(reentry);
form.setCommandListener(this);
form.append(" INSTRUCTION ENTRY DONE");
cmdadr = 0;
opr = 0;
datadr1 = 0;
datadr2 = 0;
} else {
instruction[datadr1] = instr;
form.append(intfield);
intfield.setString("0");
form.addCommand(setvalue);
form.setCommandListener(this);
form.append(" ADDRESS: " + datadr1 + ", OPERATION:" + instr + ", ENTER NEXT OPERATION OR 67108863");
datadr1++;
}
} else if (entryflag == -4) {
form.deleteAll();
ephemeral = flofield.getString();
f = java.lang.Float.parseFloat(ephemeral);
datum[datadr1] = f;
datadr1++;
if (datadr1 > datadr2) {
entryflag = 0;
form.addCommand(reentry);
form.setCommandListener(this);
form.append(" ADDRESS: " + (datadr1 - 1) + ", DATUM:" + f + ", DONE");
cmdadr = 0;
opr = 0;
datadr1 = 0;
datadr2 = 0;
} else {
form.append(flofield);
flofield.setString("0");
form.addCommand(setvalue);
form.setCommandListener(this);
form.append(" ADDRESS: " + (datadr1 - 1) + ", DATUM:" + f + ", ENTER NEXT DATUM");
}
} else if (cmdadr == -1) {
form.deleteAll();
ephemeral = d1_field.getString();
datadr1 = java.lang.Integer.parseInt(ephemeral);
ephemeral = d2_field.getString();
datadr2 = java.lang.Integer.parseInt(ephemeral);
if ((datadr1 < 0) || (datadr2 < 0)) { // fast eject - do nothing
form.append(" CANCELLED ON NEGATIVE RANGE");
} else {
if ((datadr1 == 0) && (datadr2 == 0)) {
/* print EVERYTHING */
datadr1 = 1;
datadr2 = DATAMEM - 1;
} else if (datadr2 == 0) {
datadr2 = datadr1; /* i.e. print only one datum */
}
/* Normalise ranges: low to high */
if (datadr2 < datadr1) {
k = datadr2;
datadr2 = datadr1;
datadr1 = k;
}
h = datadr1;
k = datadr2;
if (h < 1) { h = 1;}
if (k >= DATAMEM) { k = DATAMEM - 1; }
for (i = h; i <= k; i++) {
instr = instruction[i];
// EEPROM.get((INSTRUCTION_BYTE_LENGTH * (i - 0)) + ZERO_OFFSET, instr);
xx = (instr >> 26) & 63; /* 4095:255:24:12 or 8191:63:26:13 */
yy = (instr >> 13) & 8191;
zz = instr & 8191;
opr = xx;
datadr1 = yy;
datadr2 = zz;
ephemeral = " ";
ephemeral = ephemeral + i + ":" + opr;
ephemeral = ephemeral + "=";
if (opr == 0) {
ephemeral = ephemeral + "NOOP";
} else if (opr == 1) {
ephemeral = ephemeral + "JUMP";
} else if (opr == 2) {
ephemeral = ephemeral + "IADR";
} else if (opr == 3) {
ephemeral = ephemeral + "OUTP";
} else if (opr == 4) {
ephemeral = ephemeral + "INPT";
} else if (opr == 5) {
ephemeral = ephemeral + "SADR";
} else if (opr == 6) {
ephemeral = ephemeral + "SVAL";
} else if (opr == 7) {
ephemeral = ephemeral + "IAAS";
} else if (opr == 8) {
ephemeral = ephemeral + "IVAS";
} else if (opr == 9) {
ephemeral = ephemeral + "PLUS";
} else if (opr == 10) {
ephemeral = ephemeral + "MINS";
} else if (opr == 11) {
ephemeral = ephemeral + "MULS";
} else if (opr == 12) {
ephemeral = ephemeral + "DIVS";
} else if (opr == 13) {
ephemeral = ephemeral + "POXY";
} else if (opr == 14) {
ephemeral = ephemeral + "LOXY";
} else if (opr == 15) {
ephemeral = ephemeral + "IFRA";
} else if (opr == 16) {
ephemeral = ephemeral + "REMN";
} else if (opr == 17) {
ephemeral = ephemeral + "AMNT";
} else if (opr == 18) {
ephemeral = ephemeral + "PERD";
} else if (opr == 19) {
ephemeral = ephemeral + "PCNT";
} else if (opr == 20) {
ephemeral = ephemeral + "SWAP";
} else if (opr == 21) {
ephemeral = ephemeral + "FACT";
} else if (opr == 22) {
ephemeral = ephemeral + "COPY";
} else if (opr == 23) {
ephemeral = ephemeral + "FRIS";
} else if (opr == 24) {
ephemeral = ephemeral + "MNMX";
} else if (opr == 25) {
ephemeral = ephemeral + "SORT";
} else if (opr == 26) {
ephemeral = ephemeral + "CORS";
} else if (opr == 27) {
ephemeral = ephemeral + "TURN";
} else if (opr == 28) {
ephemeral = ephemeral + "SUMR";
} else if (opr == 29) {
ephemeral = ephemeral + "SUSQ";
} else if (opr == 30) {
ephemeral = ephemeral + "IXTH";
} else if (opr == 31) {
ephemeral = ephemeral + "ABSR";
} else if (opr == 32) {
ephemeral = ephemeral + "SQRT";
} else if (opr == 33) {
ephemeral = ephemeral + "SQUA";
} else if (opr == 34) {
ephemeral = ephemeral + "CBRT";
} else if (opr == 35) {
ephemeral = ephemeral + "CUBE";
} else if (opr == 36) {
ephemeral = ephemeral + "LNRN";
} else if (opr == 37) {
ephemeral = ephemeral + "EXPR";
} else if (opr == 38) {
ephemeral = ephemeral + "RADE";
} else if (opr == 39) {
ephemeral = ephemeral + "DERA";
} else if (opr == 40) {
ephemeral = ephemeral + "SIND";
} else if (opr == 41) {
ephemeral = ephemeral + "COSD";
} else if (opr == 42) {
ephemeral = ephemeral + "TAND";
} else if (opr == 43) {
ephemeral = ephemeral + "ASND";
} else if (opr == 44) {
ephemeral = ephemeral + "ACSD";
} else if (opr == 45) {
ephemeral = ephemeral + "ATND";
} else if (opr == 46) {
ephemeral = ephemeral + "MSTD";
} else if (opr == 47) {
ephemeral = ephemeral + "ZERO";
} else if (opr == 48) {
ephemeral = ephemeral + "RAND";
} else if (opr == 49) {
ephemeral = ephemeral + "RUND";
} else if (opr == 50) {
ephemeral = ephemeral + "CEIL";
} else if (opr == 51) {
ephemeral = ephemeral + "TANH";
} else if (opr == 52) {
ephemeral = ephemeral + "DTNH";
} else if (opr == 53) {
ephemeral = ephemeral + "PLUR";
} else if (opr == 54) {
ephemeral = ephemeral + "MINR";
} else if (opr == 55) {
ephemeral = ephemeral + "MULR";
} else if (opr == 56) {
ephemeral = ephemeral + "DIVR";
} else if (opr == 57) {
ephemeral = ephemeral + "PLUN";
} else if (opr == 58) {
ephemeral = ephemeral + "MINN";
} else if (opr == 59) {
ephemeral = ephemeral + "MULN";
} else if (opr == 60) {
ephemeral = ephemeral + "DIVN";
} else if (opr == 61) {
ephemeral = ephemeral + "PROB";
} else if (opr == 62) {
ephemeral = ephemeral + "STDD";
} else if (opr == 63) {
ephemeral = ephemeral + "USER";
} else {
/* Such an "else" MAY come into existence if not ALL possible */
/* instructions have been implemented, either theoretically, or */
/* practically - simply due to a lack of flash space. */
ephemeral = ephemeral + "NOKO";
}
ephemeral = ephemeral + ":";
ephemeral = ephemeral + datadr1 + ">" + datum[datadr1];
if ((datum[datadr1] > -1 * DATAMEM) && (datum[datadr1] < DATAMEM)) {
j = (int) absvalu((int)(datum[datadr1]));
ephemeral = ephemeral + ">" + datum[j];
}
ephemeral = ephemeral + ":";
ephemeral = ephemeral + datadr2 + ">" + datum[datadr2];
if ((datum[datadr2] > -1 * DATAMEM) && (datum[datadr2] < DATAMEM)) {
j = (int) absvalu((int)(datum[datadr2]));
ephemeral = ephemeral + ">" + datum[j];
}
ephemeral = ephemeral + ":";
ephemeral = ephemeral + "DEC:" + instr;
form.append(ephemeral);
}
h = 0;
k = 0;
i = 0;
}
} else if (cmdadr == -2) {
form.deleteAll();
ephemeral = d1_field.getString();
datadr1 = java.lang.Integer.parseInt(ephemeral);
ephemeral = d2_field.getString();
datadr2 = java.lang.Integer.parseInt(ephemeral);
if ((datadr1 < 0) || (datadr2 < 0)) { // fast eject - do nothing
form.append(" CANCELLED ON NEGATIVE RANGE");
} else {
if ((datadr1 == 0) && (datadr2 == 0)) {
/* print EVERYTHING */
datadr1 = 1;
datadr2 = DATAMEM - 1;
} else if (datadr2 == 0) {
datadr2 = datadr1; /* i.e. print only one datum */
}
/* Normalise ranges: low to high */
if (datadr2 < datadr1) {
k = datadr2;
datadr2 = datadr1;
datadr1 = k;
}
h = datadr1;
k = datadr2;
if (h < 1) { h = 1;}
if (k >= DATAMEM) { k = DATAMEM - 1; }
for (i = h; i <= k; i++) {