forked from RolfRolles/SynesthesiaYS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
synesthesia-x86.ys
3977 lines (3824 loc) · 159 KB
/
synesthesia-x86.ys
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
; TODO: daa, das, aaa, aas, imul (2), lea, sahf, lahf, GROUP: mov Eb, Ib for ggg = 0, GROUP: mov Ev, Iz for ggg = 0, aam Ib, aad Ib, salc
; Loosen yices' arbitrary restriction on iteration count. (')
(set-param ef-max-iters 1000)
; Data types used throughout the formula.
(define-type Bit (bitvector 1))
(define-type Byte (bitvector 8))
(define-type Word (bitvector 16))
(define-type Dword (bitvector 32))
(define-type RegIdx (bitvector 3))
(define EaxIdx::RegIdx (mk-bv 3 0)) (define AxIdx::RegIdx (mk-bv 3 0)) (define ALIdx::RegIdx (mk-bv 3 0)) ; EAX/AX/AL = 0
(define EcxIdx::RegIdx (mk-bv 3 1)) (define CxIdx::RegIdx (mk-bv 3 1)) (define CLIdx::RegIdx (mk-bv 3 1)) ; ECX/CX/CL = 1
(define EdxIdx::RegIdx (mk-bv 3 2)) (define DxIdx::RegIdx (mk-bv 3 2)) (define DLIdx::RegIdx (mk-bv 3 2)) ; EDX/DX/DL = 2
(define EbxIdx::RegIdx (mk-bv 3 3)) (define BxIdx::RegIdx (mk-bv 3 3)) (define BLIdx::RegIdx (mk-bv 3 3)) ; EBX/BX/BL = 3
(define EspIdx::RegIdx (mk-bv 3 4)) (define SpIdx::RegIdx (mk-bv 3 4)) (define AHIdx::RegIdx (mk-bv 3 4)) ; ESP/SP/AH = 4
(define EbpIdx::RegIdx (mk-bv 3 5)) (define BpIdx::RegIdx (mk-bv 3 5)) (define CHIdx::RegIdx (mk-bv 3 5)) ; EBP/BP/CH = 5
(define EsiIdx::RegIdx (mk-bv 3 6)) (define SiIdx::RegIdx (mk-bv 3 6)) (define DHIdx::RegIdx (mk-bv 3 6)) ; ESI/SI/DH = 6
(define EdiIdx::RegIdx (mk-bv 3 7)) (define DiIdx::RegIdx (mk-bv 3 7)) (define BHIdx::RegIdx (mk-bv 3 7)) ; EDI/DI/BH = 7
(define-type FlagIdx (bitvector 3))
(define CFIdx::RegIdx (mk-bv 3 0)) ; CF = 0
(define PFIdx::RegIdx (mk-bv 3 1)) ; PF = 1
(define AFIdx::RegIdx (mk-bv 3 2)) ; AF = 2
(define ZFIdx::RegIdx (mk-bv 3 3)) ; ZF = 3
(define SFIdx::RegIdx (mk-bv 3 4)) ; SF = 4
(define DFIdx::RegIdx (mk-bv 3 5)) ; DF = 5
(define OFIdx::RegIdx (mk-bv 3 6)) ; OF = 6
(define-type Reg32State (bitvector 256))
(define-type MachineState (bitvector 264))
(define-type MachineStateRes8 (bitvector 272))
(define-type MachineStateRes16 (bitvector 280))
(define-type MachineStateRes32 (bitvector 296))
(define-type DecodedMachineState (bitvector 268))
(define NumInstrs::Byte)
(define bytecode00::Byte) (define bytecode01::Byte)
(define bytecode02::Byte) (define bytecode03::Byte)
(define bytecode04::Byte) (define bytecode05::Byte)
(define bytecode06::Byte) (define bytecode07::Byte)
(define bytecode08::Byte) (define bytecode09::Byte)
(define bytecode0A::Byte) (define bytecode0B::Byte)
(define bytecode0C::Byte) (define bytecode0D::Byte)
(define bytecode0E::Byte) (define bytecode0F::Byte)
(define bytecode10::Byte) (define bytecode11::Byte)
(define bytecode12::Byte) (define bytecode13::Byte)
(define bytecode14::Byte) (define bytecode15::Byte)
(define bytecode16::Byte) (define bytecode17::Byte)
(define bytecode18::Byte) (define bytecode19::Byte)
(define bytecode1A::Byte) (define bytecode1B::Byte)
(define bytecode1C::Byte) (define bytecode1D::Byte)
(define bytecode1E::Byte) (define bytecode1F::Byte)
(define bytecode20::Byte) (define bytecode21::Byte)
(define bytecode22::Byte) (define bytecode23::Byte)
(define bytecode24::Byte) (define bytecode25::Byte)
(define bytecode26::Byte) (define bytecode27::Byte)
(define bytecode28::Byte) (define bytecode29::Byte)
(define bytecode2A::Byte) (define bytecode2B::Byte)
(define bytecode2C::Byte) (define bytecode2D::Byte)
(define bytecode2E::Byte) (define bytecode2F::Byte)
(define bytecode30::Byte) (define bytecode31::Byte)
(define bytecode32::Byte) (define bytecode33::Byte)
(define bytecode34::Byte) (define bytecode35::Byte)
(define bytecode36::Byte) (define bytecode37::Byte)
(define bytecode38::Byte) (define bytecode39::Byte)
(define bytecode3A::Byte) (define bytecode3B::Byte)
(define bytecode3C::Byte) (define bytecode3D::Byte)
(define bytecode3E::Byte) (define bytecode3F::Byte)
(define bytecode40::Byte) (define bytecode41::Byte)
(define bytecode42::Byte) (define bytecode43::Byte)
(define bytecode44::Byte) (define bytecode45::Byte)
(define bytecode46::Byte) (define bytecode47::Byte)
(define bytecode48::Byte) (define bytecode49::Byte)
(define bytecode4A::Byte) (define bytecode4B::Byte)
(define bytecode4C::Byte) (define bytecode4D::Byte)
(define bytecode4E::Byte) (define bytecode4F::Byte)
(define bytecode50::Byte) (define bytecode51::Byte)
(define bytecode52::Byte) (define bytecode53::Byte)
(define bytecode54::Byte) (define bytecode55::Byte)
(define bytecode56::Byte) (define bytecode57::Byte)
(define bytecode58::Byte) (define bytecode59::Byte)
(define bytecode5A::Byte) (define bytecode5B::Byte)
(define bytecode5C::Byte) (define bytecode5D::Byte)
(define bytecode5E::Byte) (define bytecode5F::Byte)
(define bytecode60::Byte) (define bytecode61::Byte)
(define bytecode62::Byte) (define bytecode63::Byte)
(define bytecode64::Byte) (define bytecode65::Byte)
(define bytecode66::Byte) (define bytecode67::Byte)
(define bytecode68::Byte) (define bytecode69::Byte)
(define bytecode6A::Byte) (define bytecode6B::Byte)
(define bytecode6C::Byte) (define bytecode6D::Byte)
(define bytecode6E::Byte) (define bytecode6F::Byte)
(define bytecode70::Byte) (define bytecode71::Byte)
(define bytecode72::Byte) (define bytecode73::Byte)
(define bytecode74::Byte) (define bytecode75::Byte)
(define bytecode76::Byte) (define bytecode77::Byte)
(define bytecode78::Byte) (define bytecode79::Byte)
(define bytecode7A::Byte) (define bytecode7B::Byte)
(define bytecode7C::Byte) (define bytecode7D::Byte)
(define bytecode7E::Byte) (define bytecode7F::Byte)
(define bytecode80::Byte) (define bytecode81::Byte)
(define bytecode82::Byte) (define bytecode83::Byte)
(define bytecode84::Byte) (define bytecode85::Byte)
(define bytecode86::Byte) (define bytecode87::Byte)
(define bytecode88::Byte) (define bytecode89::Byte)
(define bytecode8A::Byte) (define bytecode8B::Byte)
(define bytecode8C::Byte) (define bytecode8D::Byte)
(define bytecode8E::Byte) (define bytecode8F::Byte)
(define bytecode90::Byte) (define bytecode91::Byte)
(define bytecode92::Byte) (define bytecode93::Byte)
(define bytecode94::Byte) (define bytecode95::Byte)
(define bytecode96::Byte) (define bytecode97::Byte)
(define bytecode98::Byte) (define bytecode99::Byte)
(define bytecode9A::Byte) (define bytecode9B::Byte)
(define bytecode9C::Byte) (define bytecode9D::Byte)
(define bytecode9E::Byte) (define bytecode9F::Byte)
(define bytecodeA0::Byte) (define bytecodeA1::Byte)
(define bytecodeA2::Byte) (define bytecodeA3::Byte)
(define bytecodeA4::Byte) (define bytecodeA5::Byte)
(define bytecodeA6::Byte) (define bytecodeA7::Byte)
(define bytecodeA8::Byte) (define bytecodeA9::Byte)
(define bytecodeAA::Byte) (define bytecodeAB::Byte)
(define bytecodeAC::Byte) (define bytecodeAD::Byte)
(define bytecodeAE::Byte) (define bytecodeAF::Byte)
(define bytecodeB0::Byte) (define bytecodeB1::Byte)
(define bytecodeB2::Byte) (define bytecodeB3::Byte)
(define bytecodeB4::Byte) (define bytecodeB5::Byte)
(define bytecodeB6::Byte) (define bytecodeB7::Byte)
(define bytecodeB8::Byte) (define bytecodeB9::Byte)
(define bytecodeBA::Byte) (define bytecodeBB::Byte)
(define bytecodeBC::Byte) (define bytecodeBD::Byte)
(define bytecodeBE::Byte) (define bytecodeBF::Byte)
(define bytecodeC0::Byte) (define bytecodeC1::Byte)
(define bytecodeC2::Byte) (define bytecodeC3::Byte)
(define bytecodeC4::Byte) (define bytecodeC5::Byte)
(define bytecodeC6::Byte) (define bytecodeC7::Byte)
(define bytecodeC8::Byte) (define bytecodeC9::Byte)
(define bytecodeCA::Byte) (define bytecodeCB::Byte)
(define bytecodeCC::Byte) (define bytecodeCD::Byte)
(define bytecodeCE::Byte) (define bytecodeCF::Byte)
(define bytecodeD0::Byte) (define bytecodeD1::Byte)
(define bytecodeD2::Byte) (define bytecodeD3::Byte)
(define bytecodeD4::Byte) (define bytecodeD5::Byte)
(define bytecodeD6::Byte) (define bytecodeD7::Byte)
(define bytecodeD8::Byte) (define bytecodeD9::Byte)
(define bytecodeDA::Byte) (define bytecodeDB::Byte)
(define bytecodeDC::Byte) (define bytecodeDD::Byte)
(define bytecodeDE::Byte) (define bytecodeDF::Byte)
(define bytecodeE0::Byte) (define bytecodeE1::Byte)
(define bytecodeE2::Byte) (define bytecodeE3::Byte)
(define bytecodeE4::Byte) (define bytecodeE5::Byte)
(define bytecodeE6::Byte) (define bytecodeE7::Byte)
(define bytecodeE8::Byte) (define bytecodeE9::Byte)
(define bytecodeEA::Byte) (define bytecodeEB::Byte)
(define bytecodeEC::Byte) (define bytecodeED::Byte)
(define bytecodeEE::Byte) (define bytecodeEF::Byte)
(define bytecodeF0::Byte) (define bytecodeF1::Byte)
(define bytecodeF2::Byte) (define bytecodeF3::Byte)
(define bytecodeF4::Byte) (define bytecodeF5::Byte)
(define bytecodeF6::Byte) (define bytecodeF7::Byte)
(define bytecodeF8::Byte) (define bytecodeF9::Byte)
(define bytecodeFA::Byte) (define bytecodeFB::Byte)
(define bytecodeFC::Byte) (define bytecodeFD::Byte)
(define bytecodeFE::Byte) (define bytecodeFF::Byte)
; Used instead of an array lookup. Pass in byte XX, get back the bytecodeXX
; variable.
(define get-byte::(-> Byte Byte)
(lambda (x::Byte)
(ite (= x 0x00) bytecode00
(ite (= x 0x01) bytecode01
(ite (= x 0x02) bytecode02
(ite (= x 0x03) bytecode03
(ite (= x 0x04) bytecode04
(ite (= x 0x05) bytecode05
(ite (= x 0x06) bytecode06
(ite (= x 0x07) bytecode07
(ite (= x 0x08) bytecode08
(ite (= x 0x09) bytecode09
(ite (= x 0x0A) bytecode0A
(ite (= x 0x0B) bytecode0B
(ite (= x 0x0C) bytecode0C
(ite (= x 0x0D) bytecode0D
(ite (= x 0x0E) bytecode0E
(ite (= x 0x0F) bytecode0F
(ite (= x 0x10) bytecode10
(ite (= x 0x11) bytecode11
(ite (= x 0x12) bytecode12
(ite (= x 0x13) bytecode13
(ite (= x 0x14) bytecode14
(ite (= x 0x15) bytecode15
(ite (= x 0x16) bytecode16
(ite (= x 0x17) bytecode17
(ite (= x 0x18) bytecode18
(ite (= x 0x19) bytecode19
(ite (= x 0x1A) bytecode1A
(ite (= x 0x1B) bytecode1B
(ite (= x 0x1C) bytecode1C
(ite (= x 0x1D) bytecode1D
(ite (= x 0x1E) bytecode1E
(ite (= x 0x1F) bytecode1F
(ite (= x 0x20) bytecode20
(ite (= x 0x21) bytecode21
(ite (= x 0x22) bytecode22
(ite (= x 0x23) bytecode23
(ite (= x 0x24) bytecode24
(ite (= x 0x25) bytecode25
(ite (= x 0x26) bytecode26
(ite (= x 0x27) bytecode27
(ite (= x 0x28) bytecode28
(ite (= x 0x29) bytecode29
(ite (= x 0x2A) bytecode2A
(ite (= x 0x2B) bytecode2B
(ite (= x 0x2C) bytecode2C
(ite (= x 0x2D) bytecode2D
(ite (= x 0x2E) bytecode2E
(ite (= x 0x2F) bytecode2F
(ite (= x 0x30) bytecode30
(ite (= x 0x31) bytecode31
(ite (= x 0x32) bytecode32
(ite (= x 0x33) bytecode33
(ite (= x 0x34) bytecode34
(ite (= x 0x35) bytecode35
(ite (= x 0x36) bytecode36
(ite (= x 0x37) bytecode37
(ite (= x 0x38) bytecode38
(ite (= x 0x39) bytecode39
(ite (= x 0x3A) bytecode3A
(ite (= x 0x3B) bytecode3B
(ite (= x 0x3C) bytecode3C
(ite (= x 0x3D) bytecode3D
(ite (= x 0x3E) bytecode3E
(ite (= x 0x3F) bytecode3F
(ite (= x 0x40) bytecode40
(ite (= x 0x41) bytecode41
(ite (= x 0x42) bytecode42
(ite (= x 0x43) bytecode43
(ite (= x 0x44) bytecode44
(ite (= x 0x45) bytecode45
(ite (= x 0x46) bytecode46
(ite (= x 0x47) bytecode47
(ite (= x 0x48) bytecode48
(ite (= x 0x49) bytecode49
(ite (= x 0x4A) bytecode4A
(ite (= x 0x4B) bytecode4B
(ite (= x 0x4C) bytecode4C
(ite (= x 0x4D) bytecode4D
(ite (= x 0x4E) bytecode4E
(ite (= x 0x4F) bytecode4F
(ite (= x 0x50) bytecode50
(ite (= x 0x51) bytecode51
(ite (= x 0x52) bytecode52
(ite (= x 0x53) bytecode53
(ite (= x 0x54) bytecode54
(ite (= x 0x55) bytecode55
(ite (= x 0x56) bytecode56
(ite (= x 0x57) bytecode57
(ite (= x 0x58) bytecode58
(ite (= x 0x59) bytecode59
(ite (= x 0x5A) bytecode5A
(ite (= x 0x5B) bytecode5B
(ite (= x 0x5C) bytecode5C
(ite (= x 0x5D) bytecode5D
(ite (= x 0x5E) bytecode5E
(ite (= x 0x5F) bytecode5F
(ite (= x 0x60) bytecode60
(ite (= x 0x61) bytecode61
(ite (= x 0x62) bytecode62
(ite (= x 0x63) bytecode63
(ite (= x 0x64) bytecode64
(ite (= x 0x65) bytecode65
(ite (= x 0x66) bytecode66
(ite (= x 0x67) bytecode67
(ite (= x 0x68) bytecode68
(ite (= x 0x69) bytecode69
(ite (= x 0x6A) bytecode6A
(ite (= x 0x6B) bytecode6B
(ite (= x 0x6C) bytecode6C
(ite (= x 0x6D) bytecode6D
(ite (= x 0x6E) bytecode6E
(ite (= x 0x6F) bytecode6F
(ite (= x 0x70) bytecode70
(ite (= x 0x71) bytecode71
(ite (= x 0x72) bytecode72
(ite (= x 0x73) bytecode73
(ite (= x 0x74) bytecode74
(ite (= x 0x75) bytecode75
(ite (= x 0x76) bytecode76
(ite (= x 0x77) bytecode77
(ite (= x 0x78) bytecode78
(ite (= x 0x79) bytecode79
(ite (= x 0x7A) bytecode7A
(ite (= x 0x7B) bytecode7B
(ite (= x 0x7C) bytecode7C
(ite (= x 0x7D) bytecode7D
(ite (= x 0x7E) bytecode7E
(ite (= x 0x7F) bytecode7F
(ite (= x 0x80) bytecode80
(ite (= x 0x81) bytecode81
(ite (= x 0x82) bytecode82
(ite (= x 0x83) bytecode83
(ite (= x 0x84) bytecode84
(ite (= x 0x85) bytecode85
(ite (= x 0x86) bytecode86
(ite (= x 0x87) bytecode87
(ite (= x 0x88) bytecode88
(ite (= x 0x89) bytecode89
(ite (= x 0x8A) bytecode8A
(ite (= x 0x8B) bytecode8B
(ite (= x 0x8C) bytecode8C
(ite (= x 0x8D) bytecode8D
(ite (= x 0x8E) bytecode8E
(ite (= x 0x8F) bytecode8F
(ite (= x 0x90) bytecode90
(ite (= x 0x91) bytecode91
(ite (= x 0x92) bytecode92
(ite (= x 0x93) bytecode93
(ite (= x 0x94) bytecode94
(ite (= x 0x95) bytecode95
(ite (= x 0x96) bytecode96
(ite (= x 0x97) bytecode97
(ite (= x 0x98) bytecode98
(ite (= x 0x99) bytecode99
(ite (= x 0x9A) bytecode9A
(ite (= x 0x9B) bytecode9B
(ite (= x 0x9C) bytecode9C
(ite (= x 0x9D) bytecode9D
(ite (= x 0x9E) bytecode9E
(ite (= x 0x9F) bytecode9F
(ite (= x 0xA0) bytecodeA0
(ite (= x 0xA1) bytecodeA1
(ite (= x 0xA2) bytecodeA2
(ite (= x 0xA3) bytecodeA3
(ite (= x 0xA4) bytecodeA4
(ite (= x 0xA5) bytecodeA5
(ite (= x 0xA6) bytecodeA6
(ite (= x 0xA7) bytecodeA7
(ite (= x 0xA8) bytecodeA8
(ite (= x 0xA9) bytecodeA9
(ite (= x 0xAA) bytecodeAA
(ite (= x 0xAB) bytecodeAB
(ite (= x 0xAC) bytecodeAC
(ite (= x 0xAD) bytecodeAD
(ite (= x 0xAE) bytecodeAE
(ite (= x 0xAF) bytecodeAF
(ite (= x 0xB0) bytecodeB0
(ite (= x 0xB1) bytecodeB1
(ite (= x 0xB2) bytecodeB2
(ite (= x 0xB3) bytecodeB3
(ite (= x 0xB4) bytecodeB4
(ite (= x 0xB5) bytecodeB5
(ite (= x 0xB6) bytecodeB6
(ite (= x 0xB7) bytecodeB7
(ite (= x 0xB8) bytecodeB8
(ite (= x 0xB9) bytecodeB9
(ite (= x 0xBA) bytecodeBA
(ite (= x 0xBB) bytecodeBB
(ite (= x 0xBC) bytecodeBC
(ite (= x 0xBD) bytecodeBD
(ite (= x 0xBE) bytecodeBE
(ite (= x 0xBF) bytecodeBF
(ite (= x 0xC0) bytecodeC0
(ite (= x 0xC1) bytecodeC1
(ite (= x 0xC2) bytecodeC2
(ite (= x 0xC3) bytecodeC3
(ite (= x 0xC4) bytecodeC4
(ite (= x 0xC5) bytecodeC5
(ite (= x 0xC6) bytecodeC6
(ite (= x 0xC7) bytecodeC7
(ite (= x 0xC8) bytecodeC8
(ite (= x 0xC9) bytecodeC9
(ite (= x 0xCA) bytecodeCA
(ite (= x 0xCB) bytecodeCB
(ite (= x 0xCC) bytecodeCC
(ite (= x 0xCD) bytecodeCD
(ite (= x 0xCE) bytecodeCE
(ite (= x 0xCF) bytecodeCF
(ite (= x 0xD0) bytecodeD0
(ite (= x 0xD1) bytecodeD1
(ite (= x 0xD2) bytecodeD2
(ite (= x 0xD3) bytecodeD3
(ite (= x 0xD4) bytecodeD4
(ite (= x 0xD5) bytecodeD5
(ite (= x 0xD6) bytecodeD6
(ite (= x 0xD7) bytecodeD7
(ite (= x 0xD8) bytecodeD8
(ite (= x 0xD9) bytecodeD9
(ite (= x 0xDA) bytecodeDA
(ite (= x 0xDB) bytecodeDB
(ite (= x 0xDC) bytecodeDC
(ite (= x 0xDD) bytecodeDD
(ite (= x 0xDE) bytecodeDE
(ite (= x 0xDF) bytecodeDF
(ite (= x 0xE0) bytecodeE0
(ite (= x 0xE1) bytecodeE1
(ite (= x 0xE2) bytecodeE2
(ite (= x 0xE3) bytecodeE3
(ite (= x 0xE4) bytecodeE4
(ite (= x 0xE5) bytecodeE5
(ite (= x 0xE6) bytecodeE6
(ite (= x 0xE7) bytecodeE7
(ite (= x 0xE8) bytecodeE8
(ite (= x 0xE9) bytecodeE9
(ite (= x 0xEA) bytecodeEA
(ite (= x 0xEB) bytecodeEB
(ite (= x 0xEC) bytecodeEC
(ite (= x 0xED) bytecodeED
(ite (= x 0xEE) bytecodeEE
(ite (= x 0xEF) bytecodeEF
(ite (= x 0xF0) bytecodeF0
(ite (= x 0xF1) bytecodeF1
(ite (= x 0xF2) bytecodeF2
(ite (= x 0xF3) bytecodeF3
(ite (= x 0xF4) bytecodeF4
(ite (= x 0xF5) bytecodeF5
(ite (= x 0xF6) bytecodeF6
(ite (= x 0xF7) bytecodeF7
(ite (= x 0xF8) bytecodeF8
(ite (= x 0xF9) bytecodeF9
(ite (= x 0xFA) bytecodeFA
(ite (= x 0xFB) bytecodeFB
(ite (= x 0xFC) bytecodeFC
(ite (= x 0xFD) bytecodeFD
(ite (= x 0xFE) bytecodeFE
(ite (= x 0xFF) bytecodeFF
bytecode04))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)
)
(define get-word::(-> Byte Word)
(lambda (x::Byte)
(bv-concat (get-byte (bv-add x 0x01)) (get-byte x))
)
)
(define get-dword::(-> Byte Dword)
(lambda (x::Byte)
(bv-concat (get-byte (bv-add x 0x03)) (get-byte (bv-add x 0x02)) (get-byte (bv-add x 0x01)) (get-byte x))
)
)
; getreg32(regidx,state). Return the value of 32-bit register 'reg' from state
; 'state'.
(define getreg32::(-> RegIdx MachineState Dword)
(lambda (x::RegIdx z::MachineState)
(ite (= x 0b000) (bv-extract 31 0 z)
(ite (= x 0b001) (bv-extract 63 32 z)
(ite (= x 0b010) (bv-extract 95 64 z)
(ite (= x 0b011) (bv-extract 127 96 z)
(ite (= x 0b100) (bv-extract 159 128 z)
(ite (= x 0b101) (bv-extract 191 160 z)
(ite (= x 0b110) (bv-extract 223 192 z)
(bv-extract 255 224 z)
)))))))
)
)
; getreg16(regidx,state). Return the value of 16-bit register 'reg' from state
; 'state'.
(define getreg16::(-> RegIdx MachineState Word)
(lambda (x::RegIdx z::MachineState)
(ite (= x 0b000) (bv-extract 15 0 z)
(ite (= x 0b001) (bv-extract 47 32 z)
(ite (= x 0b010) (bv-extract 79 64 z)
(ite (= x 0b011) (bv-extract 111 96 z)
(ite (= x 0b100) (bv-extract 143 128 z)
(ite (= x 0b101) (bv-extract 175 160 z)
(ite (= x 0b110) (bv-extract 207 192 z)
(bv-extract 239 224 z)
)))))))
)
)
; getreg8(regidx,state). Return the value of 16-bit register 'reg' from state
; 'state'.
(define getreg8::(-> RegIdx MachineState Byte)
(lambda (x::RegIdx z::MachineState)
(ite (= x 0b000) (bv-extract 7 0 z)
(ite (= x 0b001) (bv-extract 39 32 z)
(ite (= x 0b010) (bv-extract 71 64 z)
(ite (= x 0b011) (bv-extract 103 96 z)
(ite (= x 0b100) (bv-extract 15 8 z)
(ite (= x 0b101) (bv-extract 47 40 z)
(ite (= x 0b110) (bv-extract 79 72 z)
(bv-extract 111 104 z)
)))))))
)
)
; getflag(flagidx,state). Return the value of flag 'flagidx' from state 'state'.
(define getflag::(-> FlagIdx MachineState Bit)
(lambda (x::FlagIdx z::MachineState)
(let ((fs (bv-extract 263 256 z)))
(ite (= x 0b000) (bv-extract 0 0 fs) ; CF = 0
(ite (= x 0b001) (bv-extract 1 1 fs) ; PF = 1
(ite (= x 0b010) (bv-extract 2 2 fs) ; AF = 2
(ite (= x 0b011) (bv-extract 3 3 fs) ; ZF = 3
(ite (= x 0b100) (bv-extract 4 4 fs) ; SF = 4
(ite (= x 0b101) (bv-extract 5 5 fs) ; DF = 5
(ite (= x 0b110) (bv-extract 6 6 fs) ; OF = 6
(bv-extract 6 6 fs) ; Default [BAD]: OF
))))))))
)
)
; getextra(state). Return the value of extra constraint from state 'state'.
(define getextra::(-> MachineState Bit)
(lambda (z::MachineState)
(bv-extract 263 263 z)
)
)
; putreg32(reg,value,state). Update 32-bit register 'reg' to value 'value' in
; state 'state'; return the new state.
(define putreg32::(-> RegIdx Dword MachineState MachineState)
(lambda (x::RegIdx y::Dword z::MachineState)
(let ((rs (bv-extract 255 0 z)))
(let ((fs (bv-extract 263 256 z)))
(bv-concat fs
(ite (= x 0b000) (bv-concat (bv-extract 255 32 rs) y)
(ite (= x 0b001) (bv-concat (bv-extract 255 64 rs) y (bv-extract 31 0 rs))
(ite (= x 0b010) (bv-concat (bv-extract 255 96 rs) y (bv-extract 63 0 rs))
(ite (= x 0b011) (bv-concat (bv-extract 255 128 rs) y (bv-extract 95 0 rs))
(ite (= x 0b100) (bv-concat (bv-extract 255 160 rs) y (bv-extract 127 0 rs))
(ite (= x 0b101) (bv-concat (bv-extract 255 192 rs) y (bv-extract 159 0 rs))
(ite (= x 0b110) (bv-concat (bv-extract 255 224 rs) y (bv-extract 191 0 rs))
(bv-concat y (bv-extract 223 0 rs))
))))))))))
)
)
; putreg16(reg,value,state). Update 16-bit register 'reg' to value 'value' in
; state 'state'; return the new state.
(define putreg16::(-> RegIdx Word MachineState MachineState)
(lambda (x::RegIdx y::Word z::MachineState)
(let ((rs (bv-extract 255 0 z)))
(let ((fs (bv-extract 263 256 z)))
(bv-concat fs
(ite (= x 0b000) (bv-concat (bv-extract 255 16 rs) y)
(ite (= x 0b001) (bv-concat (bv-extract 255 48 rs) y (bv-extract 31 0 rs))
(ite (= x 0b010) (bv-concat (bv-extract 255 80 rs) y (bv-extract 63 0 rs))
(ite (= x 0b011) (bv-concat (bv-extract 255 112 rs) y (bv-extract 95 0 rs))
(ite (= x 0b100) (bv-concat (bv-extract 255 144 rs) y (bv-extract 127 0 rs))
(ite (= x 0b101) (bv-concat (bv-extract 255 176 rs) y (bv-extract 159 0 rs))
(ite (= x 0b110) (bv-concat (bv-extract 255 208 rs) y (bv-extract 191 0 rs))
(bv-concat (bv-extract 255 240 rs) y (bv-extract 223 0 rs))
))))))))))
)
)
; putreg8(reg,value,state). Update 16-bit register 'reg' to value 'value' in
; state 'state'; return the new state.
(define putreg8::(-> RegIdx Byte MachineState MachineState)
(lambda (x::RegIdx y::Byte z::MachineState)
(let ((rs (bv-extract 255 0 z)))
(let ((fs (bv-extract 263 256 z)))
(bv-concat fs
(ite (= x 0b000) (bv-concat (bv-extract 255 8 rs) y)
(ite (= x 0b001) (bv-concat (bv-extract 255 40 rs) y (bv-extract 31 0 rs))
(ite (= x 0b010) (bv-concat (bv-extract 255 72 rs) y (bv-extract 63 0 rs))
(ite (= x 0b011) (bv-concat (bv-extract 255 104 rs) y (bv-extract 95 0 rs))
(ite (= x 0b100) (bv-concat (bv-extract 255 16 rs) y (bv-extract 7 0 rs))
(ite (= x 0b101) (bv-concat (bv-extract 255 48 rs) y (bv-extract 39 0 rs))
(ite (= x 0b110) (bv-concat (bv-extract 255 80 rs) y (bv-extract 71 0 rs))
(bv-concat (bv-extract 255 112 rs) y (bv-extract 103 0 rs))
))))))))))
)
)
; putflag(flag,value,state). Update 1-bit flag 'flag' to value 'value' in
; state 'state'; return the new state.
(define putflag::(-> FlagIdx Bit MachineState MachineState)
(lambda (x::FlagIdx y::Bit z::MachineState)
(let ((rs (bv-extract 255 0 z)))
(let ((fs (bv-extract 263 256 z)))
(let ((newfs
(ite (= x 0b000) (bv-concat (bv-extract 7 1 fs) y)
(ite (= x 0b001) (bv-concat (bv-extract 7 2 fs) y (bv-extract 0 0 fs))
(ite (= x 0b010) (bv-concat (bv-extract 7 3 fs) y (bv-extract 1 0 fs))
(ite (= x 0b011) (bv-concat (bv-extract 7 4 fs) y (bv-extract 2 0 fs))
(ite (= x 0b100) (bv-concat (bv-extract 7 5 fs) y (bv-extract 3 0 fs))
(ite (= x 0b101) (bv-concat (bv-extract 7 6 fs) y (bv-extract 4 0 fs))
(ite (= x 0b110) (bv-concat (bv-extract 7 7 fs) y (bv-extract 5 0 fs))
(bv-concat (bv-extract 7 7 fs) y (bv-extract 5 0 fs)))))))))))
(bv-concat newfs rs)
)))
)
)
; putextra(state). Update 1-bit extra constraint in state 'state'.
(define putextra::(-> Bit MachineState MachineState)
(lambda (b::Bit z::MachineState)
(bv-concat b (bv-extract 262 0 z))
)
)
(define consume-opsize-prefix::(-> Byte Bit)
(lambda (byte::Byte)
(ite (= byte 0x66) 0b1 0b0)
)
)
(define consume-addrsize-prefix::(-> Byte Bit)
(lambda (byte::Byte)
(ite (= byte 0x67) 0b1 0b0)
)
)
(define update-eip::(-> Byte Bit Byte)
(lambda (eip::Byte b::Bit)
(ite (= 0b1 b) (bv-add eip 0x01) eip)
)
)
(define bool-to-bit::(-> bool Bit)
(lambda (b::bool)
(ite b 0b1 0b0)
)
)
(define bit-to-bool::(-> Bit bool)
(lambda (b::Bit)
(= b 0b1)
)
)
(define x86-parity8::(-> Byte Bit)
(lambda (b::Byte)
(bv-not
(bv-xor
(bv-extract 7 7 b) (bv-extract 6 6 b) (bv-extract 5 5 b) (bv-extract 4 4 b)
(bv-extract 3 3 b) (bv-extract 2 2 b) (bv-extract 1 1 b) (bv-extract 0 0 b)
) ; end bv-xor
) ; end bv-not
) ; end lambda
) ; end define function
(define x86-parity16::(-> Word Bit)
(lambda (w::Word)
(x86-parity8 (bv-extract 7 0 w))
) ; end lambda
) ; end define function
(define x86-parity32::(-> Dword Bit)
(lambda (d::Dword)
(x86-parity8 (bv-extract 7 0 d))
) ; end lambda
) ; end define function
(define x86-signdiff8::(-> Byte Byte Bit)
(lambda (lhs::Byte rhs::Byte)
(bv-xor (bv-extract 7 7 lhs) (bv-extract 7 7 rhs))
)
)
(define x86-signdiff16::(-> Word Word Bit)
(lambda (lhs::Word rhs::Word)
(bv-xor (bv-extract 15 15 lhs) (bv-extract 15 15 rhs))
)
)
(define x86-signdiff32::(-> Dword Dword Bit)
(lambda (lhs::Dword rhs::Dword)
(bv-xor (bv-extract 31 31 lhs) (bv-extract 31 31 rhs))
)
)
(define x86-zero-cao::(-> MachineState MachineState)
(lambda (state::MachineState)
(let ((cfstate (putflag CFIdx 0b0 state)))
(let ((afstate (putflag AFIdx 0b0 cfstate)))
(let ((ofstate (putflag OFIdx 0b0 afstate)))
ofstate)))
) ; end lambda
) ; end define function
(define x86-standard-zps8::(-> Byte MachineState MachineState)
(lambda (res::Byte state::MachineState)
(let ((zfstate (putflag ZFIdx (bool-to-bit (= res 0x00)) state)))
(let ((sfstate (putflag SFIdx (bv-extract 7 7 res) zfstate)))
(let ((pfstate (putflag PFIdx (x86-parity8 res) sfstate)))
pfstate)))
) ; end lambda
) ; end define function
(define x86-standard-zps16::(-> Word MachineState MachineState)
(lambda (res::Word state::MachineState)
(let ((zfstate (putflag ZFIdx (bool-to-bit (= res 0x0000)) state)))
(let ((sfstate (putflag SFIdx (bv-extract 15 15 res) zfstate)))
(let ((pfstate (putflag PFIdx (x86-parity16 res) sfstate)))
pfstate)))
) ; end lambda
) ; end define function
(define x86-standard-zps32::(-> Dword MachineState MachineState)
(lambda (res::Dword state::MachineState)
(let ((zfstate (putflag ZFIdx (bool-to-bit (= res 0x00000000)) state)))
(let ((sfstate (putflag SFIdx (bv-extract 31 31 res) zfstate)))
(let ((pfstate (putflag PFIdx (x86-parity32 res) sfstate)))
pfstate)))
) ; end lambda
) ; end define function
(define x86-predicated-flag::(-> FlagIdx Bit Bit MachineState MachineState)
(lambda (idx::FlagIdx cond::Bit fexpr::Bit state::MachineState)
(let ((ef (getflag idx state)))
(putflag idx (ite (bit-to-bool cond) ef fexpr) state))
) ; end lambda
) ; end define function
(define x86-predicated-zps8::(-> Byte Byte MachineState MachineState)
(lambda (count::Byte res::Byte state::MachineState)
(let ((cond (bool-to-bit (= count 0x00))))
(let ((zfstate (x86-predicated-flag ZFIdx cond (bool-to-bit (= res 0x00)) state)))
(let ((sfstate (x86-predicated-flag SFIdx cond (bv-extract 7 7 res) zfstate)))
(let ((pfstate (x86-predicated-flag PFIdx cond (x86-parity8 res) sfstate)))
pfstate))))
) ; end lambda
) ; end define function
(define x86-predicated-zps16::(-> Byte Word MachineState MachineState)
(lambda (count::Byte res::Word state::MachineState)
(let ((cond (bool-to-bit (= count 0x00))))
(let ((zfstate (x86-predicated-flag ZFIdx cond (bool-to-bit (= res 0x0000)) state)))
(let ((sfstate (x86-predicated-flag SFIdx cond (bv-extract 15 15 res) zfstate)))
(let ((pfstate (x86-predicated-flag PFIdx cond (x86-parity16 res) sfstate)))
pfstate))))
) ; end lambda
) ; end define function
(define x86-predicated-zps32::(-> Byte Dword MachineState MachineState)
(lambda (count::Byte res::Dword state::MachineState)
(let ((cond (bool-to-bit (= count 0x00))))
(let ((zfstate (x86-predicated-flag ZFIdx cond (bool-to-bit (= res 0x00000000)) state)))
(let ((sfstate (x86-predicated-flag SFIdx cond (bv-extract 31 31 res) zfstate)))
(let ((pfstate (x86-predicated-flag PFIdx cond (x86-parity32 res) sfstate)))
pfstate))))
) ; end lambda
) ; end define function
(define x86-store-res8::(-> MachineStateRes8 RegIdx MachineState)
(lambda (mrr8::MachineStateRes8 idx::RegIdx)
(let ((ms (bv-extract 263 0 mrr8)))
(let ((res (bv-extract 271 264 mrr8)))
(putreg8 idx res ms)))
) ; end lambda
) ; end define function
(define x86-store-res16::(-> MachineStateRes16 RegIdx MachineState)
(lambda (mrr16::MachineStateRes16 idx::RegIdx)
(let ((ms (bv-extract 263 0 mrr16)))
(let ((res (bv-extract 279 264 mrr16)))
(putreg16 idx res ms)))
) ; end lambda
) ; end define function
(define x86-store-res32::(-> MachineStateRes32 RegIdx MachineState)
(lambda (mrr32::MachineStateRes32 idx::RegIdx)
(let ((ms (bv-extract 263 0 mrr32)))
(let ((res (bv-extract 295 264 mrr32)))
(putreg32 idx res ms)))
) ; end lambda
) ; end define function
(define x86-add8::(-> Byte Byte MachineState MachineStateRes8)
(lambda (lhs::Byte rhs::Byte state::MachineState)
(let ((eRes (bv-add lhs rhs)))
(let ((zpsState (x86-standard-zps8 eRes state)))
(let ((zpsaState (putflag AFIdx (bv-extract 4 4 (bv-xor lhs rhs)) zpsState)))
(let ((zpsaoState (putflag OFIdx (bv-and (x86-signdiff8 eRes lhs) (x86-signdiff8 eRes rhs)) zpsaState)))
(let ((zpsaocState (putflag CFIdx (bool-to-bit (bv-lt eRes rhs)) zpsaoState)))
(bv-concat eRes zpsaocState))))))
) ; end lambda
) ; end define function
(define x86-add16::(-> Word Word MachineState MachineStateRes16)
(lambda (lhs::Word rhs::Word state::MachineState)
(let ((eRes (bv-add lhs rhs)))
(let ((zpsState (x86-standard-zps16 eRes state)))
(let ((zpsaState (putflag AFIdx (bv-extract 4 4 (bv-xor lhs rhs)) zpsState)))
(let ((zpsaoState (putflag OFIdx (bv-and (x86-signdiff16 eRes lhs) (x86-signdiff16 eRes rhs)) zpsaState)))
(let ((zpsaocState (putflag CFIdx (bool-to-bit (bv-lt eRes rhs)) zpsaoState)))
(bv-concat eRes zpsaocState))))))
) ; end lambda
) ; end define function
(define x86-add32::(-> Dword Dword MachineState MachineStateRes32)
(lambda (lhs::Dword rhs::Dword state::MachineState)
(let ((eRes (bv-add lhs rhs)))
(let ((zpsState (x86-standard-zps32 eRes state)))
(let ((zpsaState (putflag AFIdx (bv-extract 4 4 (bv-xor lhs rhs)) zpsState)))
(let ((zpsaoState (putflag OFIdx (bv-and (x86-signdiff32 eRes lhs) (x86-signdiff32 eRes rhs)) zpsaState)))
(let ((zpsaocState (putflag CFIdx (bool-to-bit (bv-lt eRes rhs)) zpsaoState)))
(bv-concat eRes zpsaocState))))))
) ; end lambda
) ; end define function
(define x86-inc8::(-> Byte MachineState MachineStateRes8)
(lambda (lhs::Byte state::MachineState)
(let ((rhs 0x01))
(let ((eRes (bv-add lhs rhs)))
(let ((zpsState (x86-standard-zps8 eRes state)))
(let ((zpsaState (putflag AFIdx (bv-extract 4 4 (bv-xor lhs rhs)) zpsState)))
(let ((zpsaoState (putflag OFIdx (bv-and (x86-signdiff8 eRes lhs) (x86-signdiff8 eRes rhs)) zpsaState)))
(bv-concat eRes zpsaoState))))))
) ; end lambda
) ; end define function
(define x86-inc16::(-> Word MachineState MachineStateRes16)
(lambda (lhs::Word state::MachineState)
(let ((rhs 0x0001))
(let ((eRes (bv-add lhs rhs)))
(let ((zpsState (x86-standard-zps16 eRes state)))
(let ((zpsaState (putflag AFIdx (bv-extract 4 4 (bv-xor lhs rhs)) zpsState)))
(let ((zpsaoState (putflag OFIdx (bv-and (x86-signdiff16 eRes lhs) (x86-signdiff16 eRes rhs)) zpsaState)))
(bv-concat eRes zpsaoState))))))
) ; end lambda
) ; end define function
(define x86-inc32::(-> Dword MachineState MachineStateRes32)
(lambda (lhs::Dword state::MachineState)
(let ((rhs 0x00000001))
(let ((eRes (bv-add lhs rhs)))
(let ((zpsState (x86-standard-zps32 eRes state)))
(let ((zpsaState (putflag AFIdx (bv-extract 4 4 (bv-xor lhs rhs)) zpsState)))
(let ((zpsaoState (putflag OFIdx (bv-and (x86-signdiff32 eRes lhs) (x86-signdiff32 eRes rhs)) zpsaState)))
(bv-concat eRes zpsaoState))))))
) ; end lambda
) ; end define function
(define x86-or8::(-> Byte Byte MachineState MachineStateRes8)
(lambda (lhs::Byte rhs::Byte state::MachineState)
(let ((eRes (bv-or lhs rhs)))
(let ((zpsState (x86-standard-zps8 eRes state)))
(let ((zpsaocState (x86-zero-cao zpsState)))
(bv-concat eRes zpsaocState))))
) ; end lambda
) ; end define function
(define x86-or16::(-> Word Word MachineState MachineStateRes16)
(lambda (lhs::Word rhs::Word state::MachineState)
(let ((eRes (bv-or lhs rhs)))
(let ((zpsState (x86-standard-zps16 eRes state)))
(let ((zpsaocState (x86-zero-cao zpsState)))
(bv-concat eRes zpsaocState))))
) ; end lambda
) ; end define function
(define x86-or32::(-> Dword Dword MachineState MachineStateRes32)
(lambda (lhs::Dword rhs::Dword state::MachineState)
(let ((eRes (bv-or lhs rhs)))
(let ((zpsState (x86-standard-zps32 eRes state)))
(let ((zpsaocState (x86-zero-cao zpsState)))
(bv-concat eRes zpsaocState))))
) ; end lambda
) ; end define function
(define x86-xor8::(-> Byte Byte MachineState MachineStateRes8)
(lambda (lhs::Byte rhs::Byte state::MachineState)
(let ((eRes (bv-xor lhs rhs)))
(let ((zpsState (x86-standard-zps8 eRes state)))
(let ((zpsaocState (x86-zero-cao zpsState)))
(bv-concat eRes zpsaocState))))
) ; end lambda
) ; end define function
(define x86-xor16::(-> Word Word MachineState MachineStateRes16)
(lambda (lhs::Word rhs::Word state::MachineState)
(let ((eRes (bv-xor lhs rhs)))
(let ((zpsState (x86-standard-zps16 eRes state)))
(let ((zpsaocState (x86-zero-cao zpsState)))
(bv-concat eRes zpsaocState))))
) ; end lambda
) ; end define function
(define x86-xor32::(-> Dword Dword MachineState MachineStateRes32)
(lambda (lhs::Dword rhs::Dword state::MachineState)
(let ((eRes (bv-xor lhs rhs)))
(let ((zpsState (x86-standard-zps32 eRes state)))
(let ((zpsaocState (x86-zero-cao zpsState)))
(bv-concat eRes zpsaocState))))
) ; end lambda
) ; end define function
(define x86-and8::(-> Byte Byte MachineState MachineStateRes8)
(lambda (lhs::Byte rhs::Byte state::MachineState)
(let ((eRes (bv-and lhs rhs)))
(let ((zpsState (x86-standard-zps8 eRes state)))
(let ((zpsaocState (x86-zero-cao zpsState)))
(bv-concat eRes zpsaocState))))
) ; end lambda
) ; end define function
(define x86-and16::(-> Word Word MachineState MachineStateRes16)
(lambda (lhs::Word rhs::Word state::MachineState)
(let ((eRes (bv-and lhs rhs)))
(let ((zpsState (x86-standard-zps16 eRes state)))
(let ((zpsaocState (x86-zero-cao zpsState)))
(bv-concat eRes zpsaocState))))
) ; end lambda
) ; end define function
(define x86-and32::(-> Dword Dword MachineState MachineStateRes32)
(lambda (lhs::Dword rhs::Dword state::MachineState)
(let ((eRes (bv-and lhs rhs)))
(let ((zpsState (x86-standard-zps32 eRes state)))
(let ((zpsaocState (x86-zero-cao zpsState)))
(bv-concat eRes zpsaocState))))
) ; end lambda
) ; end define function
(define x86-adc8::(-> Byte Byte MachineState MachineStateRes8)
(lambda (lhs::Byte rhs::Byte state::MachineState)
(let ((eRhsPlus (bv-add rhs (bv-zero-extend (getflag CFIdx state) 7) )))
(let ((eRes (bv-add lhs eRhsPlus)))
(let ((zpsState (x86-standard-zps8 eRes state)))
(let ((zpsaState (putflag AFIdx (bv-extract 4 4 (bv-xor lhs rhs eRes)) zpsState)))
(let ((zpsaoState (putflag OFIdx (bv-and (x86-signdiff8 eRes lhs) (x86-signdiff8 eRes rhs)) zpsaState)))
(let ((zpsaocState (putflag CFIdx (bv-or (bool-to-bit (bv-lt eRes rhs)) (bool-to-bit (bv-lt eRhsPlus rhs))) zpsaoState)))
(bv-concat eRes zpsaocState)))))))
) ; end lambda
) ; end define function
(define x86-adc16::(-> Word Word MachineState MachineStateRes16)
(lambda (lhs::Word rhs::Word state::MachineState)
(let ((eRhsPlus (bv-add rhs (bv-zero-extend (getflag CFIdx state) 15) )))
(let ((eRes (bv-add lhs rhs)))
(let ((zpsState (x86-standard-zps16 eRes state)))
(let ((zpsaState (putflag AFIdx (bv-extract 4 4 (bv-xor lhs rhs eRes)) zpsState)))
(let ((zpsaoState (putflag OFIdx (bv-and (x86-signdiff16 eRes lhs) (x86-signdiff16 eRes rhs)) zpsaState)))
(let ((zpsaocState (putflag CFIdx (bv-or (bool-to-bit (bv-lt eRes rhs)) (bool-to-bit (bv-lt eRhsPlus rhs))) zpsaoState)))
(bv-concat eRes zpsaocState)))))))
) ; end lambda
) ; end define function
(define x86-adc32::(-> Dword Dword MachineState MachineStateRes32)
(lambda (lhs::Dword rhs::Dword state::MachineState)
(let ((eRhsPlus (bv-add rhs (bv-zero-extend (getflag CFIdx state) 31) )))
(let ((eRes (bv-add lhs rhs)))
(let ((zpsState (x86-standard-zps32 eRes state)))
(let ((zpsaState (putflag AFIdx (bv-extract 4 4 (bv-xor lhs rhs eRes)) zpsState)))
(let ((zpsaoState (putflag OFIdx (bv-and (x86-signdiff32 eRes lhs) (x86-signdiff32 eRes rhs)) zpsaState)))
(let ((zpsaocState (putflag CFIdx (bv-or (bool-to-bit (bv-lt eRes rhs)) (bool-to-bit (bv-lt eRhsPlus rhs))) zpsaoState)))
(bv-concat eRes zpsaocState)))))))
) ; end lambda
) ; end define function
(define x86-sbb8::(-> Byte Byte MachineState MachineStateRes8)
(lambda (lhs::Byte rhs::Byte state::MachineState)
(let ((eRhsPlus (bv-add rhs (bv-zero-extend (getflag CFIdx state) 7) )))
(let ((eRes (bv-sub lhs eRhsPlus)))
(let ((zpsState (x86-standard-zps8 eRes state)))
(let ((zpsaState (putflag AFIdx (bv-extract 4 4 (bv-xor lhs rhs eRes)) zpsState)))
(let ((zpsaoState (putflag OFIdx (bv-and (x86-signdiff8 eRes lhs) (x86-signdiff8 lhs rhs)) zpsaState)))
(let ((zpsaocState (putflag CFIdx (bv-or (bool-to-bit (bv-lt lhs eRhsPlus)) (bool-to-bit (bv-lt eRhsPlus rhs))) zpsaoState)))
(bv-concat eRes zpsaocState)))))))
) ; end lambda
) ; end define function
(define x86-sbb16::(-> Word Word MachineState MachineStateRes16)
(lambda (lhs::Word rhs::Word state::MachineState)
(let ((eRhsPlus (bv-add rhs (bv-zero-extend (getflag CFIdx state) 15) )))
(let ((eRes (bv-sub lhs rhs)))
(let ((zpsState (x86-standard-zps16 eRes state)))
(let ((zpsaState (putflag AFIdx (bv-extract 4 4 (bv-xor lhs rhs eRes)) zpsState)))
(let ((zpsaoState (putflag OFIdx (bv-and (x86-signdiff16 eRes lhs) (x86-signdiff16 lhs rhs)) zpsaState)))
(let ((zpsaocState (putflag CFIdx (bv-or (bool-to-bit (bv-lt lhs eRhsPlus)) (bool-to-bit (bv-lt eRhsPlus rhs))) zpsaoState)))
(bv-concat eRes zpsaocState)))))))
) ; end lambda
) ; end define function
(define x86-sbb32::(-> Dword Dword MachineState MachineStateRes32)
(lambda (lhs::Dword rhs::Dword state::MachineState)
(let ((eRhsPlus (bv-add rhs (bv-zero-extend (getflag CFIdx state) 31) )))
(let ((eRes (bv-sub lhs rhs)))
(let ((zpsState (x86-standard-zps32 eRes state)))
(let ((zpsaState (putflag AFIdx (bv-extract 4 4 (bv-xor lhs rhs eRes)) zpsState)))
(let ((zpsaoState (putflag OFIdx (bv-and (x86-signdiff32 eRes lhs) (x86-signdiff32 lhs rhs)) zpsaState)))
(let ((zpsaocState (putflag CFIdx (bv-or (bool-to-bit (bv-lt lhs eRhsPlus)) (bool-to-bit (bv-lt eRhsPlus rhs))) zpsaoState)))
(bv-concat eRes zpsaocState)))))))
) ; end lambda
) ; end define function
(define x86-sub8::(-> Byte Byte MachineState MachineStateRes8)
(lambda (lhs::Byte rhs::Byte state::MachineState)
(let ((eRes (bv-sub lhs rhs)))
(let ((zpsState (x86-standard-zps8 eRes state)))
(let ((zpsaState (putflag AFIdx (bv-extract 4 4 (bv-xor lhs rhs eRes)) zpsState)))
(let ((zpsaoState (putflag OFIdx (bv-and (x86-signdiff8 eRes lhs) (x86-signdiff8 lhs rhs)) zpsaState)))
(let ((zpsaocState (putflag CFIdx (bool-to-bit (bv-lt lhs rhs)) zpsaoState)))
(bv-concat eRes zpsaocState))))))
) ; end lambda
) ; end define function
(define x86-sub16::(-> Word Word MachineState MachineStateRes16)
(lambda (lhs::Word rhs::Word state::MachineState)
(let ((eRes (bv-sub lhs rhs)))
(let ((zpsState (x86-standard-zps16 eRes state)))