-
Notifications
You must be signed in to change notification settings - Fork 0
/
Spin2_interpreter.spin2
2504 lines (2163 loc) · 83.3 KB
/
Spin2_interpreter.spin2
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
'************************************
'* Spin2 Interpreter - 2022.11.19 *
'************************************
'
CON bc_setup_reg_1D8_1F8 = $B0
bc_setup_var_0_15 = $C0
bc_setup_local_0_15 = $D0
bc_read_local_0_15 = $E0
bc_write_local_0_15 = $F0
'
'
' Set clock mode, clear first 16 hub longs and VAR space, then start interpreter
'
DAT org
mov y,clkmode_hub 'set clock mode
mov z,clkfreq_hub
call #clkset_init
setq #16-1 'clear $00..$3F in hub (this code space)
wrlong #0,#0
setq var_longs 'clear VAR space
wrlong #0,vbase_init
setq #2-1 'init stack with pbase/vbase
wrlong pbase_init,dbase_init
setq dbase_init 'restart cog 0 with interpreter
coginit #hubexec,##launch_spin
pbase_init long @test_pbase + 8 '$30 - compiler supplies initial pbase value, +8 without compiler
vbase_init long @test_vbase + 0 << 20 '$34 - compiler supplies initial vbase value, first pub in [31:20]
dbase_init long @test_dbase '$38 - compiler supplies initial dbase value
var_longs long (@test_dbase - @test_vbase) >> 2 '$3C - compiler supplies VAR longs to clear
clkmode_hub long %1_000000_0000001111_1111_10_11 '$40 - compiler supplies initial clkmode value
clkfreq_hub long 320_000_000 '$44 - compiler supplies initial clkfreq value
'
'
' Unaligned data
'
orgh
stopcog byte bc_cogid & $FF 'cogstop(cogid)
byte bc_cogstop & $FF
pri_sendb byte 0 'no locals PRI sendb(count,addr)
byte bc_read_local_0_15+0 'read count repeat count
.loop byte bc_setup_local_0_15+1 'setup addr send(byte[addr++])
byte bc_var_postinc_push & $FF 'addr++
byte bc_setup_byte_pa & $FF 'setup byte
byte bc_read & $FF 'read
byte bc_call_send & $FF 'call send
byte bc_djnz & $FF 'djnz
byte (.loop-$) & $7F 'loop address
byte bc_return_results & $FF 'return
'
'
' Hub bytecode vectors (up to $FE possible)
'
alignw 'word-align for vectors
bc_hubset word @hubset_ 'HUBSET(val) $54 miscellaneous routines
bc_clkset word @clkset_ 'CLKSET(clkmode,clkfreq) $56 (use ctrl-l to determine address)
bc_read_clkfreq word @read_clkfreq 'CLKFREQ (push) $58
bc_cogspin word @cogspin_ 'COGSPIN(cog,method(params),stackadr) $5A
bc_cogchk word @cogchk_ 'COGCHK(cog) (push) $5C
bc_inline word @inline 'inline pasm code $5E
bc_regexec word @regexec_ 'REGEXEC(hubadr) $60
bc_regload word @regload_ 'REGLOAD(hubadr) $62
bc_call word @call_ 'CALL(anyadr) $64
bc_getregs word @getregs_ 'GETREGS(hubadr,cogadr,longs) $66
bc_setregs word @getregs_ 'SETREGS(hubadr,cogadr,longs) $68
bc_bytemove word @bytemove_ 'BYTEMOVE(dst,src,cnt) $6A (+0, bit1=1)
bc_bytefill word @bytemove_ 'BYTEFILL(dst,val,cnt) $6C (+2, bit1=0)
bc_wordmove word @wordmove_ 'WORDMOVE(dst,src,cnt) $6E (+4, bit1=1)
bc_wordfill word @wordmove_ 'WORDFILL(dst,val,cnt) $70 (+6, bit1=0)
bc_longmove word @longmove_ 'LONGMOVE(dst,src,cnt) $72 (+8, bit1=1)
bc_longfill word @longmove_ 'LONGFILL(dst,val,cnt) $74 (+A, bit1=0)
bc_strsize word @strsize_ 'STRSIZE(adr) (push) $76
bc_strcomp word @strcomp_ 'STRCOMP(adra,adrb) (push) $78
bc_strcopy word @strcopy_ 'STRCOPY(dst,src,max) $7A
bc_getcrc word @getcrc_ 'GETCRC(ptr,poly,cnt) (push) $7C
bc_waitus word @waitus_ 'WAITUS(us) $7E
bc_waitms word @waitus_ 'WAITMS(ms) $80
bc_getms word @getms_ 'GETMS() (push) $82
bc_getsec word @getms_ 'GETSEC() (push) $84
bc_muldiv64 word @muldiv64_ 'MULDIV64(m1,m2,d) (push) $86
bc_qsin word @qsin_ 'QSIN(rho,theta,twopi) (push) $88
bc_qcos word @qsin_ 'QCOS(rho,theta,twopi) (push) $8A
bc_rotxy word @rotxy_ 'ROTXY(x,y,t) (push2) $8C (<bc_polxy)
bc_polxy word @polxy_ 'POLXY(r,t) (push2) $8E (=bc_polxy)
bc_xypol word @polxy_ 'XYPOL(x,y) (push2) $90 (>bc_polxy)
bc_nan word @nan_ 'NAN(float) (push) $92 floating-point routines
bc_fneg word @fneg_ '-. float (push) $94
bc_fabs word @fabs_ 'FABS(float) (push) $96
bc_fsqrt word @fsqrt_ 'FSQRT(float) (push) $98
bc_fadd word @fadd_ 'float +. float (push) $9A
bc_fsub word @fsub_ 'float -. float (push) $9C
bc_fmul word @fmul_ 'float *. float (push) $9E
bc_fdiv word @fdiv_ 'float /. float (push) $A0
bc_flt word @frel_ 'float <. float (push) $A2 (bit3..1=001)
bc_fgt word @frel_ 'float >. float (push) $A4 (bit3..1=010)
bc_fne word @frel_ 'float <>. float (push) $A6 (bit3..1=011)
bc_fe word @frel_ 'float ==. float (push) $A8 (bit3..1=100)
bc_flte word @frel_ 'float <=. float (push) $AA (bit3..1=101)
bc_fgte word @frel_ 'float >=. float (push) $AC (bit3..1=110)
bc_round word @round_ 'ROUND(float) (push) $AE (bit1=1)
bc_trunc word @round_ 'TRUNC(float) (push) $B0 (bit1=0)
bc_float word @float_ 'FLOAT(integer) (push) $B2
alignl 'long-align for rest of interpreter
'
'
'*********************************
'* Interpreter - cog registers *
'*********************************
'
org $122 'start of reg code (user area below)
reg_code
'
'
' RETURN (1 long)
'
return_ jmp #returnh 'continue in hub
'
'
' ABORT (1 long)
'
abort_ jmp #aborth 'continue in hub
'
'
' Add pbase to x (1 long)
'
addbase _ret_ add x,pbase
'
'
' Miscellaneous (17 longs)
'
pop2 mov w,x ' b c d e f g a: CASE done
cased setq #2-1 'a b c d e f g b: PINWRITE(pins,val)
rdlong x,--ptra 'a b c d e f g c: WRPIN(pins,val)
add y,pbase 'a | | | | | | d: WXPIN(pins,val)
_ret_ rdfast #0,y 'a | | | | | | e: WYPIN(pins,val)
jmp #pinw_ ' b | | | | | f: COGINIT(cog,pgm,ptr) (push)
_ret_ wrpin w,y ' c | | | | g: COGINIT(cog,pgm,ptr)
_ret_ wxpin w,y ' d | | | h: COGSTOP(cog)
_ret_ wypin w,y ' e | | i: LOCKRET(lock)
setq w ' f g j: LOCKREL(lock)
coginit x,y wc ' f g k: COGATN(mask)
_ret_ bitc x,#31 ' f |
cogstop_ cogstop x ' | h
lockret_ lockret x ' | | i
lockrel_ lockrel x ' | | | j
cogatn_ cogatn x ' | | | | k
_ret_ popa x ' g h i j k
'
'
' Variable assignments / math operators (85 longs)
'
una_iso mov w,x ' m a: !!
una_psh pusha x 'push | n b: !
alti rd 'rd m n c: - (neg)
op_notb test x wz 'rd,!! m n a d: ABS
op_quna rep #99,#1 ' x x | i j k e: ENCOD use REP to protect cordic operation until ret/_ret_
qsqrt x,#0 'SQRT x x | i | | f: DECOD
qlog x 'LOG x x | | j | g: BMASK
qexp x 'EXP x x | | | k h: ONES
muxz x,_FFFFFFFF '!! x x a | | | i: SQRT
op_not not x '! x x | b | | | j: QLOG
op_neg neg x '- x x | | c | | | k: QEXP
op_abs abs x 'ABS x x | | | d | | |
op_encod encod x 'ENCOD x x | | | | e | | |
op_decod decod x 'DECOD x x | | | | | f | | |
op_bmask bmask x 'BMASK x x | | | | | | g | | |
op_ones ones x 'ONES x x | | | | | | | h | | |
getqx x ' x x | | | | | | | | i j k
alti wr 'wr m n | | | | | | | | | | |
ret 'wr,op m n a b c d e f g h i j k m: ?= var (isolated)
_ret_ mov x,w 'iso m | n: ?= var (push)
_ret_ zerox x,sz 'push n x: use a..j
sha_mod mov w,x ' x x a b c d e i j a: >>
rev_mod not w,x ' x x | | | | | f g h | | b: <<
alti rd 'rd m n | | | | | | | | | | c: SAR
popa x 'rd,op m n a b c d e f g h i j d: ROR
rev x 'REV x x | | | | | f | | | | e: ROL
shl x,w '<< x x | b | | | | g h | | f: REV
shr x,w '>> x x a | | | | f g | | | g: ZEROX
sar x,w 'SAR x x | | c | | | | h | | h: SIGNX
ror x,w 'ROR x x | | | d | | | | | | i: +
rol x,w 'ROL x x | | | | e | | | | | j: -
add x,w '+ x x | | | | | | | | i |
sub x,w '- x x | | | | | | | | | j
alti wr 'wr m n | | | | | | | | | |
ret 'wr,op m n a b c d e f g h i j m: var ?= exp (isolated)
_ret_ popa x 'iso m | n: var ?= exp (push)
_ret_ zerox x,sz 'push n x: use a..j
add_mod and x,#$1F 'addpb i j a: &&
shl x,#5 'addb i | b: ^^
shl x,#6 'addp | j c: ||
log_mod mov w,x wz ' x x a b c d e f g h i j d: &
muxnz w,_FFFFFFFF 'bool x x a b c | | | | | | | e: ^
alti rd 'rd m n | | | | | | | | | | f: |
popa x wz 'rd,op m n a b c d e f g h i j g: #>
muxnz x,_FFFFFFFF 'bool x x a b c | | | | | | | h: <#
and x,w '&&,& x x a | | d | | | | | | i: ADDBITS
xor x,w '^^,^ x x | b | | e | | | | | j: ADDPINS
and x,#$1F 'addb x x | | | | | | | | i |
and x,#$3F 'addp x x | | | | | | | | | j
or x,w '||,| x x | | c | | f | | i j
fges x,w '#> x x | | | | | | g | | |
fles x,w '<# x x | | | | | | | h | |
alti wr 'wr m n | | | | | | | | | |
ret 'wr,op m n a b c d e f g h i j m: var ?= exp (isolated)
_ret_ popa x 'iso m | n: var ?= exp (push)
_ret_ zerox x,sz 'push n x: use a..h
mul_mod abs w,x wc 'C=ys x x b d g a: *
muu_mod mov w,x ' x x a | c | e f | h b: /
alti rd 'rd m n | | | | | | | | c: +/
popa x 'rd,op m n a b c d e f g h d: //
testb x,#31 wz 'Z=xs x x | b | d | | g | e: +//
abs x ' x x | b | d | | g | f: SCA
rep #99,#1 ' x x a b c d e f g h g: SCAS use REP to protect cordic operation until call/ret/_ret_
qmul x,w '*,SCAx x x a | | | | f g | h: FRAC
qdiv x,w '/,// x x | b c d e | | |
qfrac x,w 'FRAC x x | | | | | | | h
getqx x ' x x a b c | | | | h
if_c_ne_z neg x '*,/ x x | b | | | | | |
getqy x ' x x | | | d e f g |
if_z neg x '// x x | | | d | | | |
getqx w 'SCAS x x | | | | | | g |
call #\.scas 'SCAS x x | | | | | | g |
alti wr 'wr m n | | | | | | | |
ret 'wr,op m n a b c d e f g h m: var ?= exp (isolated)
_ret_ popa x 'iso m | n: var ?= exp (push)
_ret_ zerox x,sz 'push n x: use a..h
.scas if_c_eq_z jmp #.scas2 'adjust 64-bit product for SCAS
neg w wz 'conditionally negate {x,w}
if_nz not x
if_z neg x
.scas2 shl x,#2 'x = {x,w}[61:30]
shr w,#32-2
_ret_ or x,w
'
'
' Variable pre/post modifiers (17 longs, must be in regs)
'
mod_iso mov w,x 'iso a b g i k l a: ++var, var++ (isolated)
mod_psh pusha x 'push | | c d e f | h | j | | m b: --var, var-- (isolated)
alti rd 'rd a b c d e f g h i j k l m c: ++var (push)
rd_field call #\rdf 'rd a b c d e f g h i j k l m d: --var (push) (pipeline spacer)
xoro32 x '?? | | | | | | | | | | | l m e: var++ (push)
mov v,x 'post | | | | e f | h | j k l m f: var-- (push)
add x,#1 '++ a | c | e | | | | | | | | g: var!! (isolated)
sub x,#1 '-- | b | d | f | | | | | | | h: var!! (push)
zerox x,sz 'ptr | | c d | | | | | | | | | i: var! (isolated)
muxz x,_FFFFFFFF '!! | | | | | | g h | | | | | j: var! (push)
not x '! | | | | | | | | i j | | | k: var\new (swap)
mov x,w 'swap | | | | | | | | | | k | | l: ??var (isolated)
alti wr 'wr a b c d e f g h i j k l m m: ??var (push)
wr_field call #\wrf 'wr a b c d e f g h i j k l m (pipeline spacer)
_ret_ mov x,w 'iso a b | | | | g | i | | l |
_ret_ mov x,v 'iso | | e f h j k m
ret 'main c d
'
'
' REPEAT-var init (10 longs, must be in regs)
'
' x initial
' ptra[-1] delta
' ptra[-2] terminal
' ptra[-3] address
'
repvari1 pusha #1 'set step to 1 (insert between terminal and initial)
repvari alti wr 'write variable
_FFFFFFFF long $FFFFFFFF '(pipeline spacer)
setq #2-1 'pop terminal/delta into y/z
rdlong y,--ptra
add ptra,#2*4 'repoint to top of stack
cmps y,x wc 'sign-correct delta
abs z
if_c neg z
_ret_ wrlong z,ptra[-1]
'
'
' REPEAT-var loop (11 longs, must be in regs)
'
' x current (was initial)
' ptra[-1] delta
' ptra[-2] terminal
' ptra[-3] address
'
repvarl setq #3-1 'pop address/terminal/delta into a/b/c
rdlong a,--ptra
add x,c 'add delta into current
testb c,#31 wz 'check for out-of-bounds
if_nz cmps b,x wc
if_z cmps x,b wc
if_c jmp #pop1 'if out-of-bounds, pop stack, continue
alti wr 'not out-of-bounds, write variable
dcall long 0 '(pipeline spacer)
add ptra,#3*4 'unpop data
jmp #absjmp 'loop
'
'
' PINW(pins,val) (9 longs, must be in regs)
'
pinw_ ror y,#6 wc 'y=pins, w=val (begins at pop2 in LUT)
bitc pinw_reg,#9 'select outa/outb for writing
bmask v,y 'make mask
rol y,#6
rol v,y 'justify mask
rol w,y 'justify val
setq v 'mux val into outa/outb using mask
pinw_reg muxq outa,w
_ret_ dirh y 'enable outputs
'
'
' Read bitfield (3 longs, must be in regs)
'
rdf long @lut_code 'read variable into x (rewritten)
ror x,fb 'lsb-justify bitfield
_ret_ zerox x,sz wz 'trim it, affect z
'
'
' Write bitfield (12 longs, must be in regs)
'
wrf mov fd,x 'get bitfield data
rol fd,fb
bmask fm,sz 'make bitfield mask
rol fm,fb
mov fx,x 'preserve x
rep @stall,#1 'use REP to protect variable from interrupts
wrf_rd push #$1FF 'read variable into x (rewritten) (initially: push $1FF, to begin xbyte on _ret_)
setq fm 'set bitfield mask (initially: no consequence)
muxq x,fd 'mux bitfield data into x (initially: no consequence)
wrf_wr _ret_ setq #$1A1 'write x back to variable (rewritten) (initially: begin xbyte, compress Ax..Fx, write flags)
stall _ret_ mov x,fx 'restore x
'
'
' Read/write instructions (8 longs, must be in regs)
'
rd_byte rdbyte x,ad wz 'all reads affect z
rd_word rdword x,ad wz
rd_long rdlong x,ad wz
rd_reg mov x,0 wz
wr_byte wrbyte x,ad
wr_word wrword x,ad
wr_long wrlong x,ad
wr_reg mov 0,x
'
'
' End of cog register code
'
reg_end
'
'
' Interpreter registers
'
v res 1 'v/pbase/vbase/dbase/mrecv/msend/w/x/y/z must remain in order
pbase res 1
vbase res 1
dbase res 1
mrecv res 1
msend res 1
w res 1
x res 0
ma res 1 '(x alias for float)
y res 1
z res 1
'
'
' PASM registers - 8 longs
'
pr0_ res 1 'pasm-use registers at $1D8
pr1_ res 1
pr2_ res 1
pr3_ res 1
pr4_ res 1
pr5_ res 1
pr6_ res 1
pr7_ res 1
'
'
' Buff registers - 16 longs
'
buff 'buff registers at $1E0
rd res 1 'variable registers
wr res 1
sz res 1
ad res 1
fd res 1 'bitfield registers
fb res 1
fm res 1
fx res 1
a res 0 'a/b/c/d/e/f/g/h must remain in order
na res 1 '(a alias for float)
b res 0
sa res 1 '(b alias for float)
c res 0
xa res 1 '(c alias for float)
d res 0
mb res 1 '(d alias for float)
e res 0
nb res 1 '(e alias for float)
f res 0
sb res 1 '(f alias for float)
g res 0
xb res 1 '(g alias for float)
h res 1
fit $1F0 'buff occupies $1E0..$1EF, adjust user area size to fit
'
'
'***************************
'* Interpreter - cog LUT *
'***************************
'
org $210 'leave $20x open for 16 streamer imm->LUT->DAC/pin values
lut_code
'
'
' Drop anchor (8 longs)
'
' dcall --> next_dbase[-1] (push)
' next_dbase --> dcall
'
'
' ptr[+0] <-- v := x (current top of stack)
' ptr[+1] <-- pbase | flags (trap_flag into bit 1, push_flag into bit 0)
' ptr[+2] <-- vbase
' ptr[+3] <-- dbase
' ptr[+4] <-- mrecv
' ptr[+5] <-- msend
' ptr += 6 (point to new top of stack)
' x (tos) <-- dcall (top of stack = dcall)
' dcall = ptr + 1*4 (set new dcall)
'
drop or pbase,pa 'get trap_flag into bit 1, get push_flag into bit 0
drophot mov v,x 'get top of stack into v
setq #6-1 'push v/pbase/vbase/dbase/mrecv/msend
wrlong v,ptra++ 'ptra points to dcall in stack
mov x,dcall 'get dcall (prior dbase) into top of stack
mov dcall,ptra 'update dcall (next dbase)
add dcall,#1*4
_ret_ andn pbase,#%11 'clear bits 1..0 in pbase
'
'
' Call method / Make method pointer (14 longs)
'
' dcall --> dbase (pop)
' dbase[-1] --> dcall
' retaddr --> dbase[-1]
'
'
callobj rfvar w 'a b g i j get obj into w
callsub rfvar v 'a b c | i j k get sub into v
getptr pb 'a b c g i j k get updated ptr
jmp #callh 'a b | | i j k continue in hub
jmp #callsubh ' c | continue in hub ('call sub' is optimized)
callptr jmp #callptrh ' d | continue in hub
callrecv jmp #callrecvh ' e | continue in hub
callsend jmp #callsendh ' f | continue in hub
jmp #callsendbh ' g continue in hub
callgo rdfast #0,x 'a b c d e f g h return from hub, start new bytecode read
rfvar x 'a b c d e f g h get number of local longs
_ret_ djnf x,#.clear 'a b c d e f g h if zero, continue
.clear setq x 'a b c d e f g h else, clear locals and point stack past them
_ret_ wrlong #0,ptra++ 'a b c d e f g h
'
'
' Miscellaneous (29 longs)
'
debug_ pusha x 'a a: DEBUG()
popx rfvar x 'a b b: pop #rfvar
sub ptra,x 'a b c: PINLOW(pins)
pinl_ drvl x '| | c d: PINHIGH(pins)
pinh_ drvh x '| | | d e: PINTOGGLE(pins)
pint_ drvnot x '| | | | e f: PINFLOAT(pins)
pinf_ fltl x '| | | | | f g g: PINCLEAR(pins)
wrpin #0,x '| | | | | | g h: AKPIN(pins)
akpin_ akpin x '| | | | | | | h
pop1 _ret_ popa x '| b c d e f g h
popa x 'a (continued in string_ + branch + hub_code)
'
'
' STRING()
'
string_ rfbyte w 'a b b: STRING() - push string address and jump over string
_ret_ brk w 'a |
pusha x ' b
add pb,#1 ' b
mov x,pb ' b (continued in branch + hub_code)
'
'
' Branches - jmp, jz, jnz, tjz, djnz
'
branch rfvars w ' | c d e f g c: jmp - branch
test x wz ' | | d e f | d: jz - test, pop, branch if z
popa x ' | | d e | | e: jnz - test, pop, branch if nz
if_nz ret ' | | d | f | f: tjz - test, if z then pop and branch
sub x,#1 wz ' | | | | | g g: djnz - dec, if z then pop, else branch
if_z popa x ' | | | | f g
if_z ret ' | | | e | g
add pb,w ' b c d e f g (continued in hub_code)
'
'
' Call hub bytecode routine
'
hub_code rfbyte pa ' | | | | | | get function index byte
getptr pb ' | | | | | | get updated bytecode pointer
rdword v,pa wcz ' | | | | | | lookup function address
call v ' | | | | | | call function in hub, c/z/v[31]=0
resume _ret_ rdfast #0,pb ' b c d e f g resume bytecode stream
'
'
' Setup reg variable (11 longs)
'
reg_im signx pa,#3 'a a: setup reg[$1D8..$1DF]/[$1F8..$1FF]
or pa,#$1D8 'a b: setup reg[rfvars]
' c: setup reg[rfvars][index]
reg_ap rfvars pa '| b c
add pa,x '| | c
popa x '| | c
mov rd,rd_reg 'a b c
mov wr,wr_reg 'a b c
sets rd,pa 'a b c
setd wr,pa 'a b c
mov sz,#31 'a b c
_ret_ setq2 #$0E0 'a b c (next bytecode is a variable operator)
'
'
' Setup hub variable (22 longs)
'
hub_im getnib ad,pa,#0 'a b a: setup long[vbase][0..15]
hub_ap rfvar ad '| | c d e f g h i j k l m n o p q r s t b: setup long[dbase][0..15]
hub_pp popa ad '| | | | | | | | | | | | | | | | | | | | u v w c: setup byte[pbase + rfvar]
' d: setup byte[vbase + rfvar]
shl x,#2 '| | | | | | | | | | | | | | | | | r s t | | w e: setup byte[dbase + rfvar]
shl x,#1 '| | | | | | | | | | | l m n | | | | | | | v | f: setup byte[pbase + rfvar][pop index]
add ad,x '| | | | | f g h | | | l m n | | | r s t u v w g: setup byte[vbase + rfvar][pop index]
shl ad,#2 'a b | | | | | | | | | | | | | | | | | | | | | h: setup byte[dbase + rfvar][pop index]
' i: setup word[pbase + rfvar]
add ad,pbase '| | c | | f | | i | | l | | o | | r | | | | | j: setup word[vbase + rfvar]
add ad,vbase 'a | | d | | g | | j | | m | | p | | s | | | | k: setup word[dbase + rfvar]
add ad,dbase '| b | | e | | h | | k | | n | | q | | t | | | l: setup word[pbase + rfvar][pop index]
' m: setup word[vbase + rfvar][pop index]
hub_p mov ad,x '| | | | | | | | | | | | | | | | | | | | | | | x y z n: setup word[dbase + rfvar][pop index]
popa x '| | | | | f g h | | | l m n | | | r s t u v w x y z o: setup long[pbase + rfvar]
' p: setup long[vbase + rfvar]
mov rd,rd_byte '| | c d e f g h | | | | | | | | | | | | u | | x | | q: setup long[dbase + rfvar]
mov rd,rd_word '| | | | | | | | i j k l m n | | | | | | | v | | y | r: setup long[pbase + rfvar][pop index]
mov rd,rd_long 'a b | | | | | | | | | | | | o p q r s t | | w | | z s: setup long[vbase + rfvar][pop index]
' t: setup long[dbase + rfvar][pop index]
mov wr,wr_byte '| | c d e f g h | | | | | | | | | | | | u | | x | | u: setup byte[pop base][pop index]
mov wr,wr_word '| | | | | | | | i j k l m n | | | | | | | v | | y | v: setup word[pop base][pop index]
mov wr,wr_long 'a b | | | | | | | | | | | | o p q r s t | | w | | z w: setup long[pop base][pop index]
' x: setup byte[pop address]
mov sz,#7 '| | c d e f g h | | | | | | | | | | | | u | | x | | y: setup word[pop address]
mov sz,#15 '| | | | | | | | i j k l m n | | | | | | | v | | y | z: setup long[pop address]
mov sz,#31 'a b | | | | | | | | | | | | o p q r s t | | w | | z
_ret_ setq2 #$0E0 'a b c d e f g h i j k l m n o p q r s t u v w x y z (next bytecode is a variable operator)
'
'
' Setup bitfield (13 longs)
'
bit_im mov fb,pa 'a a: setup bitfield [0..31]
and fb,#$1F 'a b: setup bitfield [rfvar]
' c: setup bitfield [pop]
bit_rf rfvar fb '| b
bit_p mov fb,x '| | c
popa x '| | c
mov sz,fb 'a b c
shr sz,#5 'a b c
mov rdf,rd 'a b c
mov wrf_rd,rd 'a b c
mov wrf_wr,wr 'a b c
mov rd,rd_field 'a b c
mov wr,wr_field 'a b c
_ret_ setq2 #$0E0 'a b c (next bytecode is a variable operator)
'
'
' Variable read/write (10 longs)
'
var_rd pusha x 'a c a: read long[dbase][0..15]
' b: write long[dbase][0..15] (isolated)
var_wr_im getnib ad,pa,#0 'a b | c: read var
shl ad,#2 'a b | d: write var (isolated)
add ad,dbase 'a b | e: write var (push)
alti rd '| | c
_ret_ rdlong x,ad 'a | c
var_wr alti wr ' | | d e
wrlong x,ad ' b | d e
_ret_ popa x ' b | d |
_ret_ zerox x,sz ' c e (ret for c, ret+zerox for e)
'
'
' Variable operator bytecodes at $27B - triggered via '_ret_ setq2 #$0E0'
'
altcodes
orgf $27B
bc_repeat_var_init_1 long repvari1 | %0 << 10 '7B REPEAT-var init, step=1
bc_repeat_var_init long repvari | %0 << 10 '7C REPEAT-var init
bc_repeat_var_loop long repvarl | %0 << 10 '7D REPEAT-var loop
bc_get_field long var_ptr | %00 << 10 '7E ^@anyvar
bc_get_addr long var_ptr | %0010 << 10 '7F @hubvar
bc_read long var_rd | %0111001110 << 10 '80 read var
bc_write long var_wr | %0 << 10 '81 write var (isolated)
bc_write_push long var_wr | %0100 << 10 '82 write var (push)
bc_var_inc long mod_iso | %000111110110010 << 10 '83 ++var, var++ (isolated)
bc_var_dec long mod_iso | %000111101110010 << 10 '84 --var, var-- (isolated)
bc_var_preinc_push long mod_psh | %0110011101011000_ << 10 '85 ++var (push)
bc_var_predec_push long mod_psh | %0110011100111000_ << 10 '86 --var (push)
bc_var_postinc_push long mod_psh | %010011111001000_ << 10 '87 var++ (push)
bc_var_postdec_push long mod_psh | %010011110101000_ << 10 '88 var-- (push)
bc_var_lognot long mod_iso | %000110111110010 << 10 '89 var!! (isolated)
bc_var_lognot_push long mod_psh | %010011011101000_ << 10 '8A var!! (push)
bc_var_bitnot long mod_iso | %000101111110010 << 10 '8B var! (isolated)
bc_var_bitnot_push long mod_psh | %010010111101000_ << 10 '8C var! (push)
bc_var_swap long mod_iso | %0100011111010010 << 10 '8D var\new (swap)
bc_var_rnd long mod_iso | %000111111000010 << 10 '8E ??var (isolated)
bc_var_rnd_push long mod_psh | %010011111100000_ << 10 '8F ??var (push)
bc_lognot_write long una_iso | %00011111111011110010 << 10 '90 !!= var (isolated)
bc_bitnot_write long una_iso | %00011111110111110010 << 10 '91 != var (isolated)
bc_neg_write long una_iso | %00011111101111110010 << 10 '92 -= var (isolated)
bc_abs_write long una_iso | %00011111011111110010 << 10 '93 ABS= var (isolated)
bc_encod_write long una_iso | %00011110111111110010 << 10 '94 ENCOD= var (isolated)
bc_decod_write long una_iso | %00011101111111110010 << 10 '95 DECOD= var (isolated)
bc_bmask_write long una_iso | %00011011111111110010 << 10 '96 BMASK= var (isolated)
bc_ones_write long una_iso | %00010111111111110010 << 10 '97 ONES= var (isolated)
bc_sqrt_write long una_iso | %00001111111111000010 << 10 '98 SQRT= var (isolated)
bc_qlog_write long una_iso | %00001111111110100010 << 10 '99 QLOG= var (isolated)
bc_qexp_write long una_iso | %00001111111101100010 << 10 '9A QEXP= var (isolated)
bc_shr_write long sha_mod | %000111110110010 << 10 '9B var >>= exp (isolated)
bc_shl_write long sha_mod | %000111111010010 << 10 '9C var <<= exp (isolated)
bc_sar_write long sha_mod | %000111101110010 << 10 '9D var SAR= exp (isolated)
bc_ror_write long sha_mod | %000111011110010 << 10 '9E var ROR= exp (isolated)
bc_rol_write long sha_mod | %000110111110010 << 10 '9F var ROL= exp (isolated)
bc_rev_write long rev_mod | %00011111010000_ << 10 'A0 var REV= exp (isolated)
bc_zerox_write long rev_mod | %00011111001000_ << 10 'A1 var ZEROX= exp (isolated)
bc_signx_write long rev_mod | %00011110101000_ << 10 'A2 var SIGNX= exp (isolated)
bc_add_write long sha_mod | %000101111110010 << 10 'A3 var += exp (isolated)
bc_sub_write long sha_mod | %000011111110010 << 10 'A4 var -= exp (isolated)
bc_logand_write long log_mod | %000111111000000___ << 10 'A5 var &&= exp (isolated)
bc_logxor_write long log_mod | %000111110100000___ << 10 'A6 var ^^= exp (isolated)
bc_logor_write long log_mod | %000110111100000___ << 10 'A7 var ||= exp (isolated)
bc_bitand_write long log_mod | %000111111010010___ << 10 'A8 var &= exp (isolated)
bc_bitxor_write long log_mod | %000111110110010___ << 10 'A9 var ^= exp (isolated)
bc_bitor_write long log_mod | %000110111110010___ << 10 'AA var |= exp (isolated)
bc_fge_write long log_mod | %000101111110010___ << 10 'AB var #>= exp (isolated)
bc_fle_write long log_mod | %000011111110010___ << 10 'AC var <#= exp (isolated)
bc_addbits_write long add_mod | %000110101110010100 << 10 'AD var ADDBITS exp (isolated)
bc_addpins_write long add_mod | %000110011110010010 << 10 'AE var ADDPINS exp (isolated)
bc_mul_write long muu_mod | %000111110110011000_ << 10 'AF var *= exp (isolated)
bc_div_write long mul_mod | %0001111001010000010 << 10 'B0 var /= exp (isolated)
bc_divu_write long muu_mod | %000111110101011000_ << 10 'B1 var +/= exp (isolated)
bc_rem_write long mul_mod | %0001100111010000010 << 10 'B2 var //= exp (isolated)
bc_remu_write long muu_mod | %000111011101011000_ << 10 'B3 var +//= exp (isolated)
bc_sca_write long muu_mod | %000111011110011000_ << 10 'B4 var SCA= exp (isolated)
bc_scas_write long mul_mod | %0000010111100000010 << 10 'B5 var SCAS= exp (isolated)
bc_frac_write long muu_mod | %000111110011011000_ << 10 'B6 var FRAC= exp (isolated)
bc_lognot_write_push long una_psh | %01001111111101111000 << 10 'B7 !!= var (push)
bc_bitnot_write_push long una_psh | %01001111111011111000 << 10 'B8 != var (push)
bc_neg_write_push long una_psh | %01001111110111111000 << 10 'B9 -= var (push)
bc_abs_write_push long una_psh | %01001111101111111000 << 10 'BA ABS= var (push)
bc_encod_write_push long una_psh | %01001111011111111000 << 10 'BB ENCOD= var (push)
bc_decod_write_push long una_psh | %01001110111111111000 << 10 'BC DECOD= var (push)
bc_bmask_write_push long una_psh | %01001101111111111000 << 10 'BD BMASK= var (push)
bc_ones_write_push long una_psh | %01001011111111111000 << 10 'BE ONES= var (push)
bc_sqrt_write_push long una_psh | %01000111111111100000 << 10 'BF SQRT= var (push)
bc_qlog_write_push long una_psh | %01000111111111010000 << 10 'C0 QLOG= var (push)
bc_qexp_write_push long una_psh | %01000111111110110000 << 10 'C1 QEXP= var (push)
bc_shr_write_push long sha_mod | %0100111110110010 << 10 'C2 var >>= exp (push)
bc_shl_write_push long sha_mod | %0100111111010010 << 10 'C3 var <<= exp (push)
bc_sar_write_push long sha_mod | %0100111101110010 << 10 'C4 var SAR= exp (push)
bc_ror_write_push long sha_mod | %0100111011110010 << 10 'C5 var ROR= exp (push)
bc_rol_write_push long sha_mod | %0100110111110010 << 10 'C6 var ROL= exp (push)
bc_rev_write_push long rev_mod | %010011111010000_ << 10 'C7 var REV= exp (push)
bc_zerox_write_push long rev_mod | %010011111001000_ << 10 'C8 var ZEROX= exp (push)
bc_signx_write_push long rev_mod | %010011110101000_ << 10 'C9 var SIGNX= exp (push)
bc_add_write_push long sha_mod | %0100101111110010 << 10 'CA var += exp (push)
bc_sub_write_push long sha_mod | %0100011111110010 << 10 'CB var -= exp (push)
bc_logand_write_push long log_mod | %0100111111000000___ << 10 'CC var &&= exp (push)
bc_logxor_write_push long log_mod | %0100111110100000___ << 10 'CD var ^^= exp (push)
bc_logor_write_push long log_mod | %0100110111100000___ << 10 'CE var ||= exp (push)
bc_bitand_write_push long log_mod | %0100111111010010___ << 10 'CF var &= exp (push)
bc_bitxor_write_push long log_mod | %0100111110110010___ << 10 'D0 var ^= exp (push)
bc_bitor_write_push long log_mod | %0100110111110010___ << 10 'D1 var |= exp (push)
bc_fge_write_push long log_mod | %0100101111110010___ << 10 'D2 var #>= exp (push)
bc_fle_write_push long log_mod | %0100011111110010___ << 10 'D3 var <#= exp (push)
bc_addbits_write_push long add_mod | %0100110101110010100 << 10 'D4 var ADDBITS exp (push)
bc_addpins_write_push long add_mod | %0100110011110010010 << 10 'D5 var ADDPINS exp (push)
bc_mul_write_push long muu_mod | %0100111110110011000_ << 10 'D6 var *= exp (push)
bc_div_write_push long mul_mod | %01001111001010000010 << 10 'D7 var /= exp (push)
bc_divu_write_push long muu_mod | %0100111110101011000_ << 10 'D8 var +/= exp (push)
bc_rem_write_push long mul_mod | %01001100111010000010 << 10 'D9 var //= exp (push)
bc_remu_write_push long muu_mod | %0100111011101011000_ << 10 'DA var +//= exp (push)
bc_sca_write_push long muu_mod | %0100111011110011000_ << 10 'DB var SCA= exp (push)
bc_scas_write_push long mul_mod | %01000010111100000010 << 10 'DC var SCAS= exp (push)
bc_frac_write_push long muu_mod | %0100111110011011000_ << 10 'DD var FRAC= exp (push)
bc_setup_bfield_pop long bit_p | %0 << 10 'DE * setup bitfield .[pop]
bc_setup_bfield_rfvar long bit_rf | %0110 << 10 'DF * setup bitfield .[rfvar]
'bytecodes Ex/Fx are collapsed at runtime to LUT entries E0/E1
bc_setup_bfield_0_31 long bit_im | %011100 << 10 'Ex * setup bitfield .[0..15]
long bit_im | %011100 << 10 'Fx * setup bitfield .[16..31]
'
'
' a: PINR(pins) (14 longs)
'
pinr_ testb x,#5 wc 'a read ina or inb
if_nc mov a,ina 'a
if_c mov a,inb 'a
ror a,x 'a lsb-justify
shr x,#6 'a trim
zerox a,x 'a (continued in pins_)
'
'
' PINSTART(pins,mode,xval,yval)
'
pins_ setq #4-1 '| pop parameters, including new top of stack
rdlong a,--ptra '| a=top of stack, b=pins, c=mode, d=xval, x=yval
fltl b '| reset smart pin(s)
wrpin c,b '| set smart pin(s) mode
wxpin d,b '| set smart pin(s) x
wypin x,b '| set smart pin(s) y
drvl b '| enable smart pin(s)
_ret_ mov x,a 'a set top of stack
'
'
' a: POLLCT(tick) (16 longs)
' b: LOOKUP/LOOKDOWN done
' n: WAITCT(tick)
'
pwct getct w 'a n a: POLLCT(tick)
cmpm w,x wc 'a n n: WAITCT(tick)
if_c jmp #pwct '| n
_ret_ popa x '| n
lookd sub ptra,#2*4 '| b (continued in op_rel)
'
'
' Relational operators
'
op_rel popa w '| | c d e f g h i j k l m c: <
cmps w,x wcz '| | c | | | g h i | | | m d: +<
cmps x,w wcz '| | | | e | | | | | k | | e: <=
cmp w,x wcz '| | | d | | | | | j | | | f: +<=
cmp x,w wcz '| | | | | f | | | | | l | g: ==
_ret_ muxnc x,_FFFFFFFF 'a b | | e f | | i j | | | h: <>
_ret_ muxc x,_FFFFFFFF ' c d | | k l | i: >=
_ret_ muxnz x,_FFFFFFFF ' | h | j: +>=
_ret_ muxz x,_FFFFFFFF ' g | k: >
muxc x,_FFFFFFFF ' m l: +>
_ret_ muxnz x,#1 ' m m: <=>
'
'
' Main bytecodes at $300
'
maincodes
orgf $300
bc_drop long drop | %0 << 10 '00 drop anchor (0..3)
bc_drop_push long drop | %0 << 10 '01 drop anchor, push
bc_drop_trap long drop | %0 << 10 '02 drop anchor, trap
bc_drop_trap_push long drop | %0 << 10 '03 drop anchor, trap, push
bc_return_results long return_ | %0 << 10 '04 Z=0 RETURN
bc_return_args long return_ | %0 << 10 '05 Z=1 RETURN x,y,z...
bc_abort_0 long abort_ | %0 << 10 '06 Z=0 ABORT
bc_abort_arg long abort_ | %0 << 10 '07 Z=1 ABORT x
bc_call_obj_sub long callobj | %01000010_0000 << 10 '08 call obj.sub
bc_call_obji_sub long callobj | %01001000000_0000 << 10 '09 call obj[].sub
bc_call_sub long callsub | %0_0100_ << 10 '0A call sub
bc_call_ptr long callptr | %0 << 10 '0B call ptr()
bc_call_recv long callrecv | %0 << 10 '0C call RECV()
bc_call_send long callsend | %0 << 10 '0D call SEND(x)
bc_call_send_bytes long callobj | %011111010 << 10 '0E call SEND(bytes...)
bc_mptr_obj_sub long callobj | %01100_0000010_0000 << 10 '0F @obj.sub (push)
bc_mptr_obji_sub long callobj | %01110_0000000_0000 << 10 '10 @obj[].sub (push)
bc_mptr_sub long callsub | %0111110_000_ << 10 '11 @sub (push)
bc_jmp long branch | %0111101111110 << 10 '12 jmp rfvars
bc_jz long branch | %0111101110000 << 10 '13 jz rfvars
bc_jnz long branch | %0111100111000 << 10 '14 jnz rfvars
bc_tjz long branch | %0111101010100 << 10 '15 tjz rfvars
bc_djnz long branch | %0111100001110 << 10 '16 djnz rfvars
bc_pop long pop1 | %0 << 10 '17 pop
bc_pop_rfvar long popx | %011111100 << 10 '18 pop rfvar
bc_hub_bytecode long hub_code | %0 << 10 '19 hub bytecode rfbyte
bc_case_fast_init long casefi | %01010000000000 << 10 '1A CASE_FAST init
bc_case_fast_done long casefd | %0 << 10 '1B CASE_FAST done
bc_case_value long casev | %0 << 10 '1C CASE value
bc_case_range long range | %0110110000000 << 10 '1D CASE value1..value2
bc_case_done long cased | %0000 << 10 '1E CASE done
bc_lookup_value long lookv | %00001000 << 10 '1F C=1 LOOKUP (target : ,,value,,)
bc_lookdown_value long lookv | %00000100 << 10 '20 C=0 LOOKDOWN(target : ,,value,,)
bc_lookup_range long range |%1100111111000000111100 << 10 '21 LOOKUP (target : ,,value1..value2,,)
bc_lookdown_range long range |%0011110000110000011100 << 10 '22 LOOKDOWN(target : ,,value1..value2,,)
bc_look_done long lookd | %0111110 << 10 '23 C=1 LOOKUP/LOOKDOWN done
bc_add_pbase long addbase | %0 << 10 '24 add pbase to x
bc_coginit long pop2 | %01111100111111000 << 10 '25 COGINIT(cog,pgm,ptr)
bc_coginit_push long pop2 | %000111111000 << 10 '26 COGINIT(cog,pgm,ptr) (push)
bc_cogstop long cogstop_ | %01110 << 10 '27 COGSTOP(cog)
bc_cogid long pushv | %01110 << 10 '28 COGID() (push)
bc_locknew long pushv | %0111111011110 << 10 '29 LOCKNEW() (push)
bc_lockret long lockret_ | %0110 << 10 '2A LOCKRET(lock)
bc_locktry long locktry_ | %00 << 10 '2B LOCKTRY(lock) (push)
bc_lockrel long lockrel_ | %010 << 10 '2C LOCKREL(lock)
bc_lockchk long lockchk_ | %0110 << 10 '2D LOCKCHK(lock) (push)
bc_cogatn long cogatn_ | %00 << 10 '2E COGATN(mask)
bc_pollatn long pushv | %011111110111110 << 10 '2F POLLATN() (push)
bc_waitatn long waitatn_ | %000 << 10 '30 WAITATN()
bc_getrnd long pushv | %010 << 10 '31 GETRND() (push)
bc_getct long pushv | %0110 << 10 '32 GETCT() (push)
bc_pollct long pwct | %01111111100 << 10 '33 POLLCT(tick) (push)
bc_waitct long pwct | %0 << 10 '34 WAITCT(tick)
bc_pinwrite long pop2 | %011000 << 10 '35 PINWRITE(pins,val)
bc_pinlow long pinl_ | %0111110 << 10 '36 PINLOW(pins)
bc_pinhigh long pinh_ | %011110 << 10 '37 PINHIGH(pins)
bc_pintoggle long pint_ | %01110 << 10 '38 PINTOGGLE(pins)
bc_pinfloat long pinf_ | %0110 << 10 '39 PINFLOAT(pins)
bc_pinread long pinr_ | %01111111000000 << 10 '3A PINREAD(pins) (push)
bc_pinstart long pins_ | %0 << 10 '3B PINSTART(pins,mode,xval,yval)
bc_pinclear long pinf_ | %0100 << 10 '3C PINCLEAR(pins)
bc_wrpin long pop2 | %0111000 << 10 '3D WRPIN(pins,val)
bc_wxpin long pop2 | %01111000 << 10 '3E WXPIN(pins,val)
bc_wypin long pop2 | %011111000 << 10 '3F WYPIN(pins,val)
bc_akpin long akpin_ | %00 << 10 '40 AKPIN(pins)
bc_rdpin long rdpin_ | %010 << 10 '41 RDPIN(pin) (push)
bc_rqpin long rqpin_ | %00 << 10 '42 RQPIN(pin) (push)
bc_debug long debug_ | %0001111111000 << 10 '43 DEBUG() rfvar,rfbyte
bc_con_rfbyte long const | %0110 << 10 '44 constant rfbyte
bc_con_rfbyte_not long const | %0111111101110 << 10 '45 constant rfbyte!
bc_con_rfword long const | %011110 << 10 '46 constant rfword
bc_con_rfword_not long const | %0111110111110 << 10 '47 constant rfword!
bc_con_rflong long const | %01111110 << 10 '48 constant rflong
bc_con_rfbyte_decod long const | %011101110 << 10 '49 constant rfbyte + decod
bc_con_rfbyte_decod_not long const | %0110111101110 << 10 '4A constant rfbyte + decod + not
bc_con_rfbyte_bmask long const | %01111101110 << 10 '4B constant rfbyte + bmask
bc_con_rfbyte_bmask_not long const | %0011111101110 << 10 '4C constant rfbyte + bmask + not
bc_setup_field_p long field_ | %0 << 10 '4D * setup field[pop field]
bc_setup_field_pi long fieldi_ | %0 << 10 '4E * setup field[pop field][pop index]
bc_setup_reg long reg_ap | %0110 << 10 '4F * setup reg[rfvars]
bc_setup_reg_pi long reg_ap | %0 << 10 '50 * setup reg[rfvars][pop index]
bc_setup_byte_pbase long hub_ap | %011011011011110111110 << 10 '51 * setup byte[pbase + rfvar]
bc_setup_byte_vbase long hub_ap | %011011011011101111110 << 10 '52 * setup byte[vbase + rfvar]
bc_setup_byte_dbase long hub_ap | %011011011011011111110 << 10 '53 * setup byte[dbase + rfvar]
bc_setup_byte_pbase_pi long hub_ap | %011011011001110101110 << 10 '54 * setup byte[pbase + rfvar][pop index]
bc_setup_byte_vbase_pi long hub_ap | %011011011001101101110 << 10 '55 * setup byte[vbase + rfvar][pop index]
bc_setup_byte_dbase_pi long hub_ap | %011011011001011101110 << 10 '56 * setup byte[dbase + rfvar][pop index]
bc_setup_word_pbase long hub_ap | %010110110111110111110 << 10 '57 * setup word[pbase + rfvar]
bc_setup_word_vbase long hub_ap | %010110110111101111110 << 10 '58 * setup word[vbase + rfvar]
bc_setup_word_dbase long hub_ap | %010110110111011111110 << 10 '59 * setup word[dbase + rfvar]
bc_setup_word_pbase_pi long hub_ap | %010110110101110100110 << 10 '5A * setup word[pbase + rfvar][pop index]
bc_setup_word_vbase_pi long hub_ap | %010110110101101100110 << 10 '5B * setup word[vbase + rfvar][pop index]
bc_setup_word_dbase_pi long hub_ap | %010110110101011100110 << 10 '5C * setup word[dbase + rfvar][pop index]
bc_setup_long_pbase long hub_ap | %001101101111110111110 << 10 '5D * setup long[pbase + rfvar]
bc_setup_long_vbase long hub_ap | %001101101111101111110 << 10 '5E * setup long[vbase + rfvar]
bc_setup_long_dbase long hub_ap | %001101101111011111110 << 10 '5F * setup long[dbase + rfvar]
bc_setup_long_pbase_pi long hub_ap | %001101101101110101010 << 10 '60 * setup long[pbase + rfvar][pop index]
bc_setup_long_vbase_pi long hub_ap | %001101101101101101010 << 10 '61 * setup long[vbase + rfvar][pop index]
bc_setup_long_dbase_pi long hub_ap | %001101101101011101010 << 10 '62 * setup long[dbase + rfvar][pop index]
bc_setup_byte_pb_pi long hub_pp | %01101101100111110110 << 10 '63 * setup byte[pop base][pop index]
bc_setup_word_pb_pi long hub_pp | %01011011010111110010 << 10 '64 * setup word[pop base][pop index]
bc_setup_long_pb_pi long hub_pp | %00110110110111110100 << 10 '65 * setup long[pop base][pop index]
bc_setup_byte_pa long hub_p | %011011011000 << 10 '66 * setup byte[pop address]
bc_setup_word_pa long hub_p | %010110110100 << 10 '67 * setup word[pop address]
bc_setup_long_pa long hub_p | %001101101100 << 10 '68 * setup long[pop address]
bc_unused1 long 0 | %0 << 10 '69
bc_unused2 long 0 | %0 << 10 '6A
bc_ternary long ternary | %0000 << 10 '6B x ? y : z
bc_lt long op_rel | %0111100 << 10 '6C exp < exp
bc_ltu long op_rel | %0110110 << 10 '6D exp +< exp
bc_lte long op_rel | %011010 << 10 '6E exp <= exp
bc_lteu long op_rel | %001110 << 10 '6F exp +<= exp
bc_e long op_rel | %011111100 << 10 '70 exp == exp
bc_ne long op_rel | %01111100 << 10 '71 exp <> exp
bc_gte long op_rel | %011100 << 10 '72 exp >= exp
bc_gteu long op_rel | %010110 << 10 '73 exp +>= exp
bc_gt long op_rel | %0111010 << 10 '74 exp > exp
bc_gtu long op_rel | %0101110 << 10 '75 exp +> exp
bc_ltegt long op_rel | %00111111100 << 10 '76 exp <=> exp
bc_lognot long op_notb | %0111111111011110 << 10 '77 !!exp (NOT exp)
bc_bitnot long op_not | %0111111110______ << 10 '78 !exp
bc_neg long op_neg | %011111110_______ << 10 '79 -exp
bc_abs long op_abs | %01111110________ << 10 '7A ABS exp
bc_encod long op_encod | %0111110_________ << 10 '7B ENCOD exp
bc_decod long op_decod | %011110__________ << 10 '7C DECOD exp
bc_bmask long op_bmask | %01110___________ << 10 '7D BMASK exp
bc_ones long op_ones | %0110____________ << 10 '7E ONES exp
bc_sqrt long op_quna | %010111111111100_ << 10 '7F SQRT exp
bc_qlog long op_quna | %010111111111010_ << 10 '80 QLOG exp
bc_qexp long op_quna | %010111111110110_ << 10 '81 QEXP exp
bc_shr long sha_mod | %01111110110110 << 10 '82 exp >> exp
bc_shl long sha_mod | %01111111010110 << 10 '83 exp << exp
bc_sar long sha_mod | %01111101110110 << 10 '84 exp SAR exp
bc_ror long sha_mod | %01111011110110 << 10 '85 exp ROR exp
bc_rol long sha_mod | %01110111110110 << 10 '86 exp ROL exp
bc_rev long rev_mod | %0111111010010_ << 10 '87 exp REV exp
bc_zerox long rev_mod | %0111111001010_ << 10 '88 exp ZEROX exp
bc_signx long rev_mod | %0111110101010_ << 10 '89 exp SIGNX exp
bc_add long sha_mod | %01101111110110 << 10 '8A exp + exp
bc_sub long sha_mod | %01011111110110 << 10 '8B exp - exp
bc_logand long log_mod | %01111111000100___ << 10 '8C exp && exp (exp AND exp)
bc_logxor long log_mod | %01111110100100___ << 10 '8D exp ^^ exp (exp XOR exp)
bc_logor long log_mod | %01110111100100___ << 10 '8E exp || exp (exp OR exp)
bc_bitand long log_mod | %01111111010110___ << 10 '8F exp & exp
bc_bitxor long log_mod | %01111110110110___ << 10 '90 exp ^ exp
bc_bitor long log_mod | %01110111110110___ << 10 '91 exp | exp