-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.json
2385 lines (2385 loc) · 58.5 KB
/
tests.json
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
[
{
"name": "STOP",
"hint": "",
"code": {
"asm": "STOP",
"bin": "00"
},
"expect": {
"success": true,
"stack": []
}
},
{
"name": "PUSH0",
"hint": "Read \"Program Counter\" section of the course learning materials for an example on how to parse the bytecode",
"code": {
"asm": "PUSH0",
"bin": "5f"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "PUSH1",
"hint": "Read \"Program Counter\" section of the course learning materials for an example on how to parse the bytecode",
"code": {
"asm": "PUSH1 1",
"bin": "6001"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "PUSH2",
"hint": "PUSH2 reads the next 2 bytes, don't forget to properly increment PC",
"code": {
"asm": "PUSH2 0x1122",
"bin": "611122"
},
"expect": {
"stack": [
"0x1122"
],
"success": true
}
},
{
"name": "PUSH4",
"hint": "PUSH4 reads the next 4 bytes",
"code": {
"asm": "PUSH4 0x11223344",
"bin": "6311223344"
},
"expect": {
"stack": [
"0x11223344"
],
"success": true
}
},
{
"name": "PUSH6",
"hint": "PUSH6 reads the next 6 bytes. Can you implement all PUSH1...PUSH32 using the same code?",
"code": {
"asm": "PUSH6 0x112233445566",
"bin": "65112233445566"
},
"expect": {
"stack": [
"0x112233445566"
],
"success": true
}
},
{
"name": "PUSH10",
"hint": "SIZE = OPCODE - PUSH1 + 1, then transform take the next SIZE bytes, PC += SIZE",
"code": {
"asm": "PUSH10 0x112233445566778899aa",
"bin": "69112233445566778899aa"
},
"expect": {
"stack": [
"0x112233445566778899aa"
],
"success": true
}
},
{
"name": "PUSH11",
"hint": "SIZE = OPCODE - PUSH1 + 1, program.slice(pc + 1, pc + 1 + size)",
"code": {
"asm": "PUSH11 0x112233445566778899aabb",
"bin": "6a112233445566778899aabb"
},
"expect": {
"stack": [
"0x112233445566778899aabb"
],
"success": true
}
},
{
"name": "PUSH32",
"hint": "PUSH32 reads the next 32 bytes (256 bits)",
"code": {
"asm": "PUSH32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"bin": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
"expect": {
"stack": [
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
],
"success": true
}
},
{
"name": "PUSH (twice)",
"hint": "Note the order of items on the stack. The tests expect the top of the stack to be the first element",
"code": {
"asm": "PUSH1 1\nPUSH1 2",
"bin": "60016002"
},
"expect": {
"stack": [
"0x2",
"0x1"
],
"success": true
}
},
{
"name": "POP",
"hint": "POP removes the top item from the stack and discards it",
"code": {
"asm": "PUSH1 1\nPUSH1 2\nPOP",
"bin": "6001600250"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "STOP (midway)",
"hint": "Note that the `PUSH1 2` didn't execute because the program stops after STOP opcode",
"code": {
"asm": "PUSH1 1\nSTOP\nPUSH1 2",
"bin": "6001006002"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "ADD",
"hint": "ADD takes the first 2 items from the stack, adds them together and pushes the result",
"code": {
"asm": "PUSH1 0x01\nPUSH1 0x02\nADD",
"bin": "6001600201"
},
"expect": {
"stack": [
"0x3"
],
"success": true
}
},
{
"name": "ADD (overflow)",
"hint": "EVM operates with uint256, if you add 2 to the max possible value it overflows and wraps around",
"code": {
"asm": "PUSH32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\nPUSH1 0x02\nADD",
"bin": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600201"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "MUL",
"code": {
"asm": "PUSH1 0x02\nPUSH1 0x03\nMUL",
"bin": "6002600302"
},
"expect": {
"stack": [
"0x6"
],
"success": true
},
"hint": ""
},
{
"name": "MUL (overflow)",
"hint": "All math is performed with implicit [mod 2^256]",
"code": {
"asm": "PUSH32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\nPUSH1 0x02\nMUL",
"bin": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600202"
},
"expect": {
"stack": [
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"
],
"success": true
}
},
{
"name": "SUB",
"hint": "SUB takes the first element from the stack and subtracts the second element from the stack",
"code": {
"asm": "PUSH1 0x02\nPUSH1 0x03\nSUB",
"bin": "6002600303"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "SUB (underflow)",
"hint": "Underflow works the same way as overflow, 3 - 2 wraps around and results in MAX_UINT256",
"code": {
"asm": "PUSH1 0x03\nPUSH1 0x02\nSUB",
"bin": "6003600203"
},
"expect": {
"stack": [
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
],
"success": true
}
},
{
"name": "DIV",
"hint": "DIV takes the first element from the stack and divides it by the second element from the stack",
"code": {
"asm": "PUSH1 0x02\nPUSH1 0x06\nDIV",
"bin": "6002600604"
},
"expect": {
"stack": [
"0x3"
],
"success": true
}
},
{
"name": "DIV (whole)",
"hint": "Fraction part of the division is discarded",
"code": {
"asm": "PUSH1 0x06\nPUSH1 0x02\nDIV",
"bin": "6006600204"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "DIV (by zero)",
"hint": "In EVM you can divide by zero! Modern Solidity protects from this by adding instructions that check for zero",
"code": {
"asm": "PUSH1 0x00\nPUSH1 0x02\nDIV",
"bin": "6000600204"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "MOD",
"hint": "10 mod 3 = 1",
"code": {
"asm": "PUSH1 3\nPUSH1 10\nMOD",
"bin": "6003600a06"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "MOD (by larger number)",
"hint": "5 mod 17 = 5",
"code": {
"asm": "PUSH1 17\nPUSH1 5\nMOD",
"bin": "6011600506"
},
"expect": {
"stack": [
"0x5"
],
"success": true
}
},
{
"name": "MOD (by zero)",
"hint": "In EVM you can divide by zero! Modern Solidity protects from this by adding instructions that check for zero",
"code": {
"asm": "PUSH1 0\nPUSH1 2\nMOD",
"bin": "6000600206"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "ADDMOD",
"hint": "10 + 10 mod 8 = 4",
"code": {
"asm": "PUSH1 8\nPUSH1 10\nPUSH1 10\nADDMOD",
"bin": "6008600a600a08"
},
"expect": {
"stack": [
"0x4"
],
"success": true
}
},
{
"name": "ADDMOD (wrapped)",
"code": {
"asm": "PUSH1 2\nPUSH1 2\nPUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\nADDMOD",
"bin": "600260027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff08"
},
"expect": {
"stack": [
"0x1"
],
"success": true
},
"hint": ""
},
{
"name": "MULMOD",
"hint": "10 * 10 mod 8 = 4",
"code": {
"asm": "PUSH1 8\nPUSH1 10\nPUSH1 10\nMULMOD",
"bin": "6008600a600a09"
},
"expect": {
"stack": [
"0x4"
],
"success": true
}
},
{
"name": "MULMOD (wrapped)",
"code": {
"asm": "PUSH1 12\nPUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\nPUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\nMULMOD",
"bin": "600c7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff09"
},
"expect": {
"stack": [
"0x9"
],
"success": true
},
"hint": ""
},
{
"name": "EXP",
"code": {
"asm": "PUSH1 2\nPUSH1 10\nEXP",
"bin": "6002600a0a"
},
"expect": {
"stack": [
"0x64"
],
"success": true
},
"hint": ""
},
{
"name": "SIGNEXTEND (positive)",
"hint": "Read \"Negative Numbers\" section of the course learning materials. SIGNEXTEND has no effect on \"positive\" numbers",
"code": {
"asm": "PUSH1 0x7F\nPUSH1 0\nSIGNEXTEND",
"bin": "607f60000b"
},
"expect": {
"stack": [
"0x7f"
],
"success": true
}
},
{
"name": "SIGNEXTEND (negative)",
"hint": "Read \"Negative Numbers\" section of the course learning materials. The first bit of 0xFF is 1, so it is a negative number and needs to be padded by 1s in front",
"code": {
"asm": "PUSH1 0xFF\nPUSH1 0\nSIGNEXTEND",
"bin": "60ff60000b"
},
"expect": {
"stack": [
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
],
"success": true
}
},
{
"name": "SDIV",
"hint": "Read \"Negative Numbers\" section of the course learning materials. SDIV works like DIV for \"positive\" numbers",
"code": {
"asm": "PUSH1 10\nPUSH1 10\nSDIV",
"bin": "600a600a05"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "SDIV (negative)",
"hint": "Read \"Negative Numbers\" section of the course learning materials. -2 / -1 = 2",
"code": {
"asm": "PUSH32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\nPUSH32 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe\nSDIV",
"bin": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe05"
},
"expect": {
"stack": [
"0x2"
],
"success": true
}
},
{
"name": "SDIV (mix of negative and positive)",
"hint": "Read \"Negative Numbers\" section of the course learning materials. 10 / -2 = -5",
"code": {
"asm": "PUSH32 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe\nPUSH1 10\nSDIV",
"bin": "7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe600a05"
},
"expect": {
"stack": [
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffb"
],
"success": true
}
},
{
"name": "SMOD",
"hint": "Read \"Negative Numbers\" section of the course learning materials. SMOD works like MOD for \"positive\" numbers",
"code": {
"asm": "PUSH1 3\nPUSH1 10\nSMOD",
"bin": "6003600a07"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "SMOD (negative)",
"hint": "Read \"Negative Numbers\" section of the course learning materials. -10 mod -3 = -1",
"code": {
"asm": "PUSH32 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd\nPUSH32 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8\nSMOD",
"bin": "7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff807"
},
"expect": {
"stack": [
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"
],
"success": true
}
},
{
"name": "SDIV (by zero)",
"hint": "In EVM you can divide by zero",
"code": {
"asm": "PUSH1 0x00\nPUSH32 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd\nSDIV",
"bin": "60007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd05"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "SMOD (by zero)",
"hint": "In EVM you can divide by zero",
"code": {
"asm": "PUSH1 0x00\nPUSH32 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd\nSMOD",
"bin": "60007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd07"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "LT",
"hint": "9 < 10 = true (1)",
"code": {
"asm": "PUSH1 10\nPUSH1 9\nLT",
"bin": "600a600910"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "LT (equal)",
"hint": "10 < 10 = false (0)",
"code": {
"asm": "PUSH1 10\nPUSH1 10\nLT",
"bin": "600a600a10"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "LT (greater)",
"hint": "11 < 10 = false (0)",
"code": {
"asm": "PUSH1 10\nPUSH1 11\nLT",
"bin": "600a600b10"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "GT",
"hint": "10 > 9 = true (1)",
"code": {
"asm": "PUSH1 9\nPUSH1 10\nGT",
"bin": "6009600a11"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "GT (equal)",
"hint": "10 > 10 = false (0)",
"code": {
"asm": "PUSH1 10\nPUSH1 10\nGT",
"bin": "600a600a11"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "GT (less)",
"hint": "10 > 11 = false (0)",
"code": {
"asm": "PUSH1 11\nPUSH1 10\nGT",
"bin": "600b600a11"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "SLT",
"hint": "Same as LT but treats arguments as signed numbers. -1 < 0 = true (1)",
"code": {
"asm": "PUSH1 0\nPUSH32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\nSLT",
"bin": "60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff12"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "SLT (equal)",
"hint": "Same as LT but treats arguments as signed numbers. -1 < -1 = false (0)",
"code": {
"asm": "PUSH32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\nPUSH32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\nSLT",
"bin": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff12"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "SLT (greater)",
"hint": "Same as LT but treats arguments as signed numbers. -1 < -1 = false (0)",
"code": {
"asm": "PUSH32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\nPUSH1 0\nSLT",
"bin": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600012"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "SGT",
"hint": "Same as GT but treats arguments as signed numbers. No effect on \"positive\" numbers: 10 > 9 = true (1)",
"code": {
"asm": "PUSH1 9\nPUSH1 10\nSGT",
"bin": "6009600a13"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "SGT (equal)",
"hint": "Same as GT but treats arguments as signed numbers. -2 > -2 = false (0)",
"code": {
"asm": "PUSH32 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe\nPUSH32 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe\nSGT",
"bin": "7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe13"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "SGT (greater)",
"hint": "Same as GT but treats arguments as signed numbers. -2 > -3 = true (1)",
"code": {
"asm": "PUSH32 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd\nPUSH32 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe\nSGT",
"bin": "7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe13"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "EQ",
"hint": "10 == 10 = true (1)",
"code": {
"asm": "PUSH1 10\nPUSH1 10\nEQ",
"bin": "600a600a14"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "EQ (not equal)",
"hint": "10 == 9 = false (0)",
"code": {
"asm": "PUSH1 9\nPUSH1 10\nEQ",
"bin": "6009600a14"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "ISZERO (not zero)",
"hint": "If the top element on the stack is not zero, pushes 0",
"code": {
"asm": "PUSH1 9\nISZERO",
"bin": "600915"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "ISZERO (zero)",
"hint": "If the top element on the stack is zero, pushes 1",
"code": {
"asm": "PUSH1 0\nISZERO",
"bin": "600015"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "NOT",
"hint": "Bitwise NOT operation, flips every bit 1->0, 0->1",
"code": {
"asm": "PUSH1 0x0f\nNOT",
"bin": "600f19"
},
"expect": {
"stack": [
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
],
"success": true
}
},
{
"name": "AND",
"hint": "Bitwise AND operation of the top 2 items on the stack",
"code": {
"asm": "PUSH1 0xe\nPUSH1 0x3\nAND",
"bin": "600e600316"
},
"expect": {
"stack": [
"0x2"
],
"success": true
}
},
{
"name": "OR",
"hint": "Bitwise OR operation of the top 2 items on the stack",
"code": {
"asm": "PUSH1 0xe\nPUSH1 0x3\nOR",
"bin": "600e600317"
},
"expect": {
"stack": [
"0xf"
],
"success": true
}
},
{
"name": "XOR",
"hint": "Bitwise XOR operation of the top 2 items on the stack",
"code": {
"asm": "PUSH1 0xf0\nPUSH1 0x0f\nXOR",
"bin": "60f0600f18"
},
"expect": {
"stack": [
"0xff"
],
"success": true
}
},
{
"name": "SHL",
"hint": "Bitwise shift left, 1 << 1 = 2",
"code": {
"asm": "PUSH1 1\nPUSH1 1\nSHL",
"bin": "600160011b"
},
"expect": {
"stack": [
"0x2"
],
"success": true
}
},
{
"name": "SHL (discards)",
"hint": "Bits that end up outside MAX_UINT256 are discarded",
"code": {
"asm": "PUSH32 0xFF00000000000000000000000000000000000000000000000000000000000000\nPUSH1 4\nSHL",
"bin": "7fff0000000000000000000000000000000000000000000000000000000000000060041b"
},
"expect": {
"stack": [
"0xf000000000000000000000000000000000000000000000000000000000000000"
],
"success": true
}
},
{
"name": "SHL (too large)",
"hint": "When shift amount is too large, returns zero",
"code": {
"asm": "PUSH1 1\nPUSH4 0xFFFFFFFF\nSHL",
"bin": "600163ffffffff1b"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "SHR",
"hint": "Bitwise shift right, 2 >> 1 = 1",
"code": {
"asm": "PUSH1 2\nPUSH1 1\nSHR",
"bin": "600260011c"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "SHR (discards)",
"hint": "Bits that end up outside are discarded",
"code": {
"asm": "PUSH1 0xFF\nPUSH1 4\nSHR",
"bin": "60ff60041c"
},
"expect": {
"stack": [
"0xf"
],
"success": true
}
},
{
"name": "SHR (too large)",
"hint": "When shift amount is too large, returns zero",
"code": {
"asm": "PUSH1 1\nPUSH4 0xFFFFFFFF\nSHR",
"bin": "600163ffffffff1c"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "SAR",
"hint": "Like SHR but treats the argument as signed number. No effect on \"positive\" numbers, 2 >> 1 = 1",
"code": {
"asm": "PUSH1 2\nPUSH1 1\nSAR",
"bin": "600260011d"
},
"expect": {
"stack": [
"0x1"
],
"success": true
}
},
{
"name": "SAR (fills 1s)",
"hint": "Note that unlike SHR, it fills the empty space with 1s",
"code": {
"asm": "PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00\nPUSH1 4\nSAR",
"bin": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0060041d"
},
"expect": {
"stack": [
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0"
],
"success": true
}
},
{
"name": "SAR (too large)",
"hint": "When shift amount is too large and the first bit is 1, fills the whole number with 1s",
"code": {
"asm": "PUSH32 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00\nPUSH4 0xFFFFFFFF\nSAR",
"bin": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0063ffffffff1d"
},
"expect": {
"stack": [
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
],
"success": true
}
},
{
"name": "SAR (positive, too large)",
"hint": "When shift amount is too large and the first bit is 0, fills the whole number with 0s",
"code": {
"asm": "PUSH32 0x0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00\nPUSH4 0xFFFFFFFF\nSAR",
"bin": "7f0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0063ffffffff1d"
},
"expect": {
"stack": [
"0x0"
],
"success": true
}
},
{
"name": "BYTE",
"hint": "The value on the stack is treated as 32 bytes, take 31st (counting from the most significant one)",
"code": {
"asm": "PUSH1 0xff\nPUSH1 31\nBYTE",
"bin": "60ff601f1a"
},
"expect": {
"stack": [
"0xff"
],
"success": true
}
},
{
"name": "BYTE (30th)",
"hint": "The value on the stack is treated as 32 bytes, take 30st (counting from the most significant one)",
"code": {
"asm": "PUSH2 0xff00\nPUSH1 30\nBYTE",
"bin": "61ff00601e1a"
},
"expect": {
"stack": [
"0xff"
],
"success": true
}
},
{
"name": "BYTE (29th)",
"hint": "Try to generalize your code to work with any argument",
"code": {
"asm": "PUSH3 0xff0000\nPUSH1 29\nBYTE",
"bin": "62ff0000601d1a"
},
"expect": {
"stack": [
"0xff"
],
"success": true
}
},
{
"name": "BYTE (out of range)",
"hint": "Treat other elements as zeros",
"code": {
"asm": "PUSH32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\nPUSH1 42\nBYTE",
"bin": "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff602a1a"