Subversion Repositories Kolibri OS

Rev

Rev 4478 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4478 Rev 6467
Line 1... Line -...
1
; flat assembler core
-
 
2
; Copyright (c) 1999-2013, Tomasz Grysztar.
1
; flat assembler core
3
; All rights reserved.
2
; Copyright (c) 1999-2016, Tomasz Grysztar.
4
 
3
; All rights reserved.
Line 5... Line 4...
5
calculate_expression:
4
 
6
	mov	[current_offset],edi
5
calculate_expression:
7
	mov	[value_undefined],0
6
	mov	[current_offset],edi
8
	cmp	byte [esi],0
7
	mov	[value_undefined],0
9
	je	get_string_value
8
	cmp	byte [esi],0
10
	cmp	byte [esi],'.'
9
	je	get_string_value
11
	je	convert_fp
10
	cmp	byte [esi],'.'
12
      calculation_loop:
11
	je	convert_fp
-
 
12
      calculation_loop:
-
 
13
	mov	eax,[tagged_blocks]
-
 
14
	sub	eax,0Ch
-
 
15
	cmp	eax,edi
13
	lods	byte [esi]
16
	jbe	out_of_memory
14
	cmp	al,1
17
	lods	byte [esi]
15
	je	get_byte_number
18
	cmp	al,1
16
	cmp	al,2
19
	je	get_byte_number
17
	je	get_word_number
20
	cmp	al,2
Line 34... Line 37...
34
	sub	edi,14h
37
	je	invalid_expression
35
	mov	ebx,edi
38
	sub	edi,14h
36
	sub	ebx,14h
39
	mov	ebx,edi
37
	cmp	al,0E0h
40
	sub	ebx,14h
38
	je	calculate_rva
41
	cmp	al,0F0h
39
	cmp	al,0E1h
42
	je	calculate_rva
40
	je	calculate_plt
43
	cmp	al,0F1h
41
	cmp	al,0D0h
44
	je	calculate_plt
42
	je	calculate_not
45
	cmp	al,0D0h
43
	cmp	al,083h
46
	je	calculate_not
44
	je	calculate_neg
47
	cmp	al,0E0h
-
 
48
	je	calculate_bsf
-
 
49
	cmp	al,0E1h
-
 
50
	je	calculate_bsr
-
 
51
	cmp	al,083h
45
	mov	dx,[ebx+8]
52
	je	calculate_neg
46
	or	dx,[edi+8]
53
	mov	dx,[ebx+8]
47
	cmp	al,80h
54
	or	dx,[edi+8]
48
	je	calculate_add
55
	cmp	al,80h
49
	cmp	al,81h
56
	je	calculate_add
Line 195... Line 202...
195
	mov	al,[ebx+10]
202
	add	edi,0Ch
196
	or	al,al
203
	mov	al,[ebx+10]
197
	jz	calculation_loop
204
	or	al,al
198
	cmp	[size_override],-1
205
	jz	calculation_loop
199
	je	calculation_loop
206
	test	[operand_flags],1
200
	cmp	[size_override],0
-
 
201
	je	check_size
-
 
202
	cmp	[operand_size],0
-
 
203
	jne	calculation_loop
-
 
204
	mov	[operand_size],al
207
	jnz	calculation_loop
205
	jmp	calculation_loop
208
      check_size:
206
      check_size:
-
 
207
	xchg	[operand_size],al
-
 
208
	or	al,al
209
	xchg	[operand_size],al
209
	jz	calculation_loop
210
	or	al,al
210
	cmp	al,[operand_size]
211
	jz	calculation_loop
211
	jne	operand_sizes_do_not_match
212
	cmp	al,[operand_size]
212
	jmp	calculation_loop
213
	jne	operand_sizes_do_not_match
Line 621... Line 622...
621
	xor	[ebx],eax
622
	mov	cl,[edi+13]
622
	xor	[ebx+4],edx
623
	xor	[ebx],eax
623
	xor	[ebx+13],cl
624
	xor	[ebx+4],edx
624
	jz	calculation_loop
625
	xor	[ebx+13],cl
625
	or	cl,cl
626
	jmp	calculation_loop
626
	jz	xor_size_check
-
 
627
	xor	eax,[ebx]
-
 
628
	xor	edx,[ebx+4]
-
 
629
      xor_size_check:
-
 
630
	mov	cl,[value_size]
-
 
631
	cmp	cl,1
-
 
632
	je	xor_byte_result
-
 
633
	cmp	cl,2
-
 
634
	je	xor_word_result
-
 
635
	cmp	cl,4
-
 
636
	je	xor_dword_result
-
 
637
	cmp	cl,6
-
 
638
	je	xor_pword_result
-
 
639
	cmp	cl,8
-
 
640
	jne	calculation_loop
-
 
641
	xor	edx,[ebx+4]
-
 
642
	js	xor_result_truncated
-
 
643
	jmp	calculation_loop
-
 
644
      xor_pword_result:
-
 
645
	test	edx,0FFFF0000h
-
 
646
	jnz	calculation_loop
-
 
647
	cmp	word [ebx+6],-1
-
 
648
	jne	calculation_loop
-
 
649
	xor	dx,[ebx+4]
-
 
650
	jns	calculation_loop
-
 
651
	not	word [ebx+6]
-
 
652
	jmp	xor_result_truncated
-
 
653
      xor_dword_result:
-
 
654
	test	edx,edx
-
 
655
	jnz	calculation_loop
-
 
656
	cmp	dword [ebx+4],-1
-
 
657
	jne	calculation_loop
-
 
658
	xor	eax,[ebx]
-
 
659
	jns	calculation_loop
-
 
660
	not	dword [ebx+4]
-
 
661
	jmp	xor_result_truncated
-
 
662
      xor_word_result:
-
 
663
	test	edx,edx
-
 
664
	jnz	calculation_loop
-
 
665
	test	eax,0FFFF0000h
-
 
666
	jnz	calculation_loop
-
 
667
	cmp	dword [ebx+4],-1
-
 
668
	jne	calculation_loop
-
 
669
	cmp	word [ebx+2],-1
-
 
670
	jne	calculation_loop
-
 
671
	xor	ax,[ebx]
-
 
672
	jns	calculation_loop
-
 
673
	not	dword [ebx+4]
-
 
674
	not	word [ebx+2]
-
 
675
	jmp	xor_result_truncated
-
 
676
      xor_byte_result:
-
 
677
	test	edx,edx
-
 
678
	jnz	calculation_loop
-
 
679
	test	eax,0FFFFFF00h
-
 
680
	jnz	calculation_loop
-
 
681
	cmp	dword [ebx+4],-1
-
 
682
	jne	calculation_loop
-
 
683
	cmp	word [ebx+2],-1
-
 
684
	jne	calculation_loop
-
 
685
	cmp	byte [ebx+1],-1
-
 
686
	jne	calculation_loop
-
 
687
	xor	al,[ebx]
-
 
688
	jns	calculation_loop
-
 
689
	not	dword [ebx+4]
-
 
690
	not	word [ebx+2]
-
 
691
	not	byte [ebx+1]
-
 
692
      xor_result_truncated:
-
 
693
	mov	byte [ebx+13],0
-
 
694
	jmp	calculation_loop
-
 
695
      shr_negative:
-
 
696
	mov	byte [edi+13],0
627
      shr_negative:
697
	not	dword [edi]
628
	mov	byte [edi+13],0
698
	not	dword [edi+4]
629
	not	dword [edi]
699
	add	dword [edi],1
630
	not	dword [edi+4]
700
	adc	dword [edi+4],0
631
	add	dword [edi],1
Line 759... Line 690...
759
      calculate_shr:
690
	dec	dword [edi+4]
760
	cmp	byte [edi+13],0
691
      calculate_shr:
761
	jne	shr_negative
692
	cmp	byte [edi+13],0
762
	cmp	byte [ebx+13],0
693
	jne	shr_negative
763
	je	do_shr
694
	mov	edx,[ebx+4]
764
	mov	al,[value_size]
-
 
765
	cmp	al,1
-
 
766
	je	shr_negative_byte
-
 
767
	cmp	al,2
-
 
768
	je	shr_negative_word
-
 
769
	cmp	al,4
-
 
770
	je	shr_negative_dword
-
 
771
	cmp	al,6
-
 
772
	je	shr_negative_pword
-
 
773
	cmp	al,8
-
 
774
	jne	do_shr
-
 
775
      shr_negative_qword:
-
 
776
	test	byte [ebx+7],80h
-
 
777
	jz	do_shr
-
 
778
      shr_truncated:
-
 
779
	mov	byte [ebx+13],0
-
 
780
      do_shr:
-
 
781
	mov	edx,[ebx+4]
-
 
782
	mov	eax,[ebx]
-
 
783
	cmp	dword [edi+4],0
695
	mov	eax,[ebx]
784
	jne	shr_over
696
	cmp	dword [edi+4],0
785
	mov	ecx,[edi]
697
	jne	shr_over
786
	cmp	ecx,64
698
	mov	ecx,[edi]
787
	jae	shr_over
699
	cmp	ecx,64
Line 807... Line 719...
807
	mov	dword [ebx],eax
719
	movsx	eax,byte [ebx+13]
808
	mov	dword [ebx+4],eax
720
	mov	dword [ebx],eax
809
	jmp	calculation_loop
721
	mov	dword [ebx+4],eax
810
      shr_negative_byte:
722
	jmp	calculation_loop
811
	cmp	dword [ebx+4],-1
723
      calculate_not:
812
	jne	do_shr
-
 
813
	cmp	word [ebx+2],-1
-
 
814
	jne	do_shr
-
 
815
	cmp	byte [ebx+1],-1
-
 
816
	jne	do_shr
-
 
817
	test	byte [ebx],80h
-
 
818
	jz	do_shr
-
 
819
	not	dword [ebx+4]
-
 
820
	not	word [ebx+2]
-
 
821
	not	byte [ebx+1]
-
 
822
	jmp	shr_truncated
-
 
823
      shr_negative_word:
-
 
824
	cmp	dword [ebx+4],-1
-
 
825
	jne	do_shr
-
 
826
	cmp	word [ebx+2],-1
-
 
827
	jne	do_shr
-
 
828
	test	byte [ebx+1],80h
-
 
829
	jz	do_shr
-
 
830
	not	dword [ebx+4]
-
 
831
	not	word [ebx+2]
-
 
832
	jmp	shr_truncated
-
 
833
      shr_negative_dword:
-
 
834
	cmp	dword [ebx+4],-1
-
 
835
	jne	do_shr
-
 
836
	test	byte [ebx+3],80h
-
 
837
	jz	do_shr
-
 
838
	not	dword [ebx+4]
-
 
839
	jmp	shr_truncated
-
 
840
      shr_negative_pword:
-
 
841
	cmp	word [ebx+6],-1
-
 
842
	jne	do_shr
-
 
843
	test	byte [ebx+5],80h
-
 
844
	jz	do_shr
-
 
845
	not	word [ebx+6]
-
 
846
	jmp	shr_truncated
-
 
847
      calculate_not:
-
 
848
	cmp	word [edi+8],0
-
 
849
	jne	invalid_expression
724
	cmp	word [edi+8],0
850
	cmp	byte [edi+12],0
725
	jne	invalid_expression
851
	je	not_ok
726
	cmp	byte [edi+12],0
852
	call	recoverable_misuse
727
	je	not_ok
853
      not_ok:
728
	call	recoverable_misuse
854
	mov	al,[value_size]
729
      not_ok:
855
	cmp	al,1
730
	not	dword [edi]
856
	je	not_byte
-
 
857
	cmp	al,2
-
 
858
	je	not_word
-
 
859
	cmp	al,4
-
 
860
	je	not_dword
-
 
861
	cmp	al,6
-
 
862
	je	not_pword
-
 
863
	cmp	al,8
-
 
864
	je	not_qword
-
 
865
	not	dword [edi]
-
 
866
	not	dword [edi+4]
-
 
867
	not	byte [edi+13]
731
	not	dword [edi+4]
868
	add	edi,14h
732
	not	byte [edi+13]
869
	jmp	calculation_loop
733
	add	edi,14h
870
      not_qword:
734
	jmp	calculation_loop
871
	not	dword [edi]
735
      calculate_bsf:
-
 
736
	cmp	word [edi+8],0
-
 
737
	jne	invalid_expression
-
 
738
	cmp	byte [edi+12],0
-
 
739
	je	bsf_ok
-
 
740
	call	recoverable_misuse
-
 
741
      bsf_ok:
872
	not	dword [edi+4]
742
	xor	ecx,ecx
-
 
743
	bsf	eax,[edi]
873
      finish_not:
744
	jnz	finish_bs
-
 
745
	mov	ecx,32
-
 
746
	bsf	eax,[edi+4]
-
 
747
	jnz	finish_bs
-
 
748
	cmp	byte [edi+13],0
-
 
749
	jne	finish_bs
-
 
750
      bs_overflow:
-
 
751
	call	recoverable_overflow
-
 
752
	add	edi,14h
-
 
753
	jmp	calculation_loop
-
 
754
      calculate_bsr:
-
 
755
	cmp	word [edi+8],0
874
	mov	byte [edi+13],0
756
	jne	invalid_expression
-
 
757
	cmp	byte [edi+12],0
-
 
758
	je	bsr_ok
-
 
759
	call	recoverable_misuse
-
 
760
      bsr_ok:
-
 
761
	cmp	byte [edi+13],0
-
 
762
	jne	bs_overflow
-
 
763
	mov	ecx,32
-
 
764
	bsr	eax,[edi+4]
-
 
765
	jnz	finish_bs
-
 
766
	xor	ecx,ecx
-
 
767
	bsr	eax,[edi]
-
 
768
	jz	bs_overflow
-
 
769
      finish_bs:
875
	add	edi,14h
770
	add	eax,ecx
-
 
771
	xor	edx,edx
-
 
772
	mov	[edi],eax
-
 
773
	mov	[edi+4],edx
-
 
774
	mov	[edi+13],dl
876
	jmp	calculation_loop
775
	add	edi,14h
877
      not_byte:
776
	jmp	calculation_loop
878
	cmp	dword [edi+4],0
777
      calculate_neg:
879
	jne	not_qword
-
 
880
	cmp	word [edi+2],0
-
 
881
	jne	not_qword
-
 
882
	cmp	byte [edi+1],0
-
 
883
	jne	not_qword
-
 
884
	not	byte [edi]
-
 
885
	jmp	finish_not
-
 
886
      not_word:
-
 
887
	cmp	dword [edi+4],0
-
 
888
	jne	not_qword
-
 
889
	cmp	word [edi+2],0
-
 
890
	jne	not_qword
-
 
891
	not	word [edi]
-
 
892
	jmp	finish_not
-
 
893
      not_dword:
-
 
894
	cmp	dword [edi+4],0
-
 
895
	jne	not_qword
-
 
896
	not	dword [edi]
-
 
897
	jmp	finish_not
-
 
898
      not_pword:
-
 
899
	cmp	word [edi+6],0
-
 
900
	jne	not_qword
-
 
901
	not	word [edi+4]
-
 
902
	not	dword [edi]
-
 
903
	jmp	finish_not
-
 
904
      calculate_neg:
-
 
905
	cmp	byte [edi+8],0
-
 
906
	je	neg_first_register_ok
778
	cmp	byte [edi+8],0
907
	neg	byte [edi+10]
779
	je	neg_first_register_ok
908
	jo	invalid_expression
780
	neg	byte [edi+10]
909
      neg_first_register_ok:
781
	jo	invalid_expression
910
	cmp	byte [edi+9],0
782
      neg_first_register_ok:
Line 1156... Line 1028...
1156
	cmp	al,4
1028
	je	convert_fp_word
1157
	je	convert_fp_dword
1029
	cmp	al,4
1158
	test	al,not 8
1030
	je	convert_fp_dword
1159
	jnz	invalid_value
1031
	test	al,not 8
1160
      convert_fp_qword:
1032
	jz	convert_fp_qword
1161
	xor	eax,eax
1033
	call	recoverable_misuse
-
 
1034
      convert_fp_qword:
1162
	xor	edx,edx
1035
	xor	eax,eax
1163
	cmp	word [esi+8],8000h
1036
	xor	edx,edx
1164
	je	fp_qword_store
1037
	cmp	word [esi+8],8000h
1165
	mov	bx,[esi+8]
1038
	je	fp_qword_store
1166
	mov	eax,[esi]
1039
	mov	bx,[esi+8]
Line 1192... Line 1065...
1192
	cmp	cx,52
1065
	inc	cx
1193
	ja	value_out_of_range
1066
	cmp	cx,52
1194
	cmp	cx,32
1067
	ja	value_out_of_range
1195
	jbe	fp_qword_small_shift
1068
	cmp	cx,32
1196
	sub	cx,32
1069
	jb	fp_qword_small_shift
1197
	mov	eax,edx
1070
	sub	cx,32
1198
	xor	edx,edx
1071
	mov	eax,edx
1199
	shr	eax,cl
1072
	xor	edx,edx
1200
	jmp	fp_qword_shift_done
1073
	shr	eax,cl
1201
      fp_qword_small_shift:
1074
	jmp	fp_qword_shift_done
1202
	mov	ebx,edx
1075
      fp_qword_small_shift:
Line 1336... Line 1209...
1336
 
1209
	ret
1337
get_byte_value:
1210
 
Line 1338... Line 1211...
1338
	mov	[value_size],1
1211
get_byte_value:
1339
	mov	[size_override],-1
1212
	mov	[value_size],1
1340
	call	calculate_value
1213
	or	[operand_flags],1
1341
	or	al,al
1214
	call	calculate_value
1342
	jz	check_byte_value
1215
	or	al,al
1343
	call	recoverable_misuse
1216
	jz	check_byte_value
1344
      check_byte_value:
1217
	call	recoverable_misuse
1345
	mov	eax,[edi]
1218
      check_byte_value:
Line 1348... Line 1221...
1348
	je	byte_positive
1221
	cmp	byte [edi+13],0
1349
	cmp	edx,-1
1222
	je	byte_positive
1350
	jne	range_exceeded
1223
	cmp	edx,-1
1351
	cmp	eax,-80h
1224
	jne	range_exceeded
1352
	jb	range_exceeded
1225
	cmp	eax,-100h
1353
	ret
1226
	jb	range_exceeded
1354
      byte_positive:
1227
	ret
1355
	test	edx,edx
1228
      byte_positive:
1356
	jnz	range_exceeded
1229
	test	edx,edx
1357
	cmp	eax,100h
1230
	jnz	range_exceeded
1358
	jae	range_exceeded
1231
	cmp	eax,100h
Line 1380... Line 1253...
1380
	ret
1253
      ignore_misuse:
1381
get_word_value:
1254
	ret
1382
	mov	[value_size],2
1255
get_word_value:
1383
	mov	[size_override],-1
1256
	mov	[value_size],2
1384
	call	calculate_value
1257
	or	[operand_flags],1
1385
	cmp	al,2
1258
	call	calculate_value
1386
	jb	check_word_value
1259
	cmp	al,2
1387
	call	recoverable_misuse
1260
	jb	check_word_value
1388
      check_word_value:
1261
	call	recoverable_misuse
1389
	mov	eax,[edi]
1262
      check_word_value:
1390
	mov	edx,[edi+4]
1263
	mov	eax,[edi]
Line 1392... Line 1265...
1392
	je	word_positive
1265
	cmp	byte [edi+13],0
1393
	cmp	edx,-1
1266
	je	word_positive
1394
	jne	range_exceeded
1267
	cmp	edx,-1
1395
	cmp	eax,-8000h
1268
	jne	range_exceeded
1396
	jb	range_exceeded
1269
	cmp	eax,-10000h
1397
	ret
1270
	jb	range_exceeded
1398
      word_positive:
1271
	ret
1399
	test	edx,edx
1272
      word_positive:
1400
	jnz	range_exceeded
1273
	test	edx,edx
1401
	cmp	eax,10000h
1274
	jnz	range_exceeded
1402
	jae	range_exceeded
1275
	cmp	eax,10000h
1403
	ret
1276
	jae	range_exceeded
1404
get_dword_value:
1277
	ret
1405
	mov	[value_size],4
1278
get_dword_value:
1406
	mov	[size_override],-1
1279
	mov	[value_size],4
1407
	call	calculate_value
1280
	or	[operand_flags],1
1408
	cmp	al,4
1281
	call	calculate_value
1409
	jne	check_dword_value
1282
	cmp	al,4
1410
	mov	[value_type],2
1283
	jne	check_dword_value
1411
	mov	eax,[edi]
1284
	mov	[value_type],2
1412
	cdq
1285
	mov	eax,[edi]
1413
	cmp	edx,[edi+4]
1286
	cdq
Line 1424... Line 1297...
1424
	je	dword_positive
1297
	cmp	byte [edi+13],0
1425
	cmp	edx,-1
1298
	je	dword_positive
1426
	jne	range_exceeded
1299
	cmp	edx,-1
1427
	bt	eax,31
1300
	jne	range_exceeded
1428
	jnc	range_exceeded
1301
	ret
1429
	ret
-
 
1430
      dword_positive:
-
 
1431
	test	edx,edx
1302
      dword_positive:
1432
	jne	range_exceeded
1303
	test	edx,edx
1433
	ret
1304
	jne	range_exceeded
1434
get_pword_value:
1305
	ret
1435
	mov	[value_size],6
1306
get_pword_value:
1436
	mov	[size_override],-1
1307
	mov	[value_size],6
1437
	call	calculate_value
1308
	or	[operand_flags],1
1438
	cmp	al,4
1309
	call	calculate_value
1439
	jne	check_pword_value
1310
	cmp	al,4
1440
	call	recoverable_misuse
1311
	jne	check_pword_value
1441
      check_pword_value:
1312
	call	recoverable_misuse
1442
	mov	eax,[edi]
1313
      check_pword_value:
1443
	mov	edx,[edi+4]
1314
	mov	eax,[edi]
1444
	cmp	byte [edi+13],0
1315
	mov	edx,[edi+4]
1445
	je	pword_positive
1316
	cmp	byte [edi+13],0
1446
	cmp	edx,-8000h
1317
	je	pword_positive
1447
	jb	range_exceeded
1318
	cmp	edx,-10000h
1448
	ret
1319
	jb	range_exceeded
1449
      pword_positive:
1320
	ret
1450
	cmp	edx,10000h
1321
      pword_positive:
1451
	jae	range_exceeded
1322
	cmp	edx,10000h
1452
	ret
1323
	jae	range_exceeded
1453
get_qword_value:
1324
	ret
1454
	mov	[value_size],8
1325
get_qword_value:
1455
	mov	[size_override],-1
1326
	mov	[value_size],8
1456
	call	calculate_value
1327
	or	[operand_flags],1
1457
      check_qword_value:
1328
	call	calculate_value
1458
	mov	eax,[edi]
1329
      check_qword_value:
1459
	mov	edx,[edi+4]
1330
	mov	eax,[edi]
1460
	cmp	byte [edi+13],0
1331
	mov	edx,[edi+4]
1461
	je	qword_positive
1332
	ret
1462
	cmp	edx,-80000000h
-
 
1463
	jb	range_exceeded
-
 
1464
      qword_positive:
-
 
1465
	ret
-
 
1466
get_count_value:
-
 
1467
	mov	[value_size],8
1333
get_count_value:
1468
	mov	[size_override],-1
1334
	mov	[value_size],8
1469
	call	calculate_expression
1335
	or	[operand_flags],1
1470
	cmp	word [edi+8],0
1336
	call	calculate_expression
1471
	jne	invalid_value
1337
	cmp	word [edi+8],0
1472
	mov	[value_sign],0
1338
	jne	invalid_value
1473
	mov	al,[edi+12]
1339
	mov	[value_sign],0
1474
	or	al,al
1340
	mov	al,[edi+12]
1475
	jz	check_count_value
1341
	or	al,al
Line 1634... Line 1500...
1634
	mov	ax,bx
1500
	call	get_address_register
1635
	shr	ah,4
1501
	mov	ax,bx
1636
	shr	al,4
1502
	shr	ah,4
1637
	cmp	ah,0Ch
1503
	shr	al,4
1638
	je	check_vsib_address
1504
	or	bh,bh
1639
	cmp	ah,0Dh
-
 
1640
	je	check_vsib_address
-
 
1641
	cmp	al,0Ch
-
 
1642
	je	check_vsib_address
-
 
1643
	cmp	al,0Dh
-
 
1644
	je	check_vsib_address
-
 
1645
	or	bh,bh
-
 
1646
	jz	check_address_registers
-
 
1647
	or	bl,bl
1505
	jz	check_address_registers
1648
	jz	check_address_registers
1506
	or	bl,bl
1649
	cmp	al,ah
1507
	jz	check_address_registers
1650
	jne	invalid_address
1508
	cmp	al,ah
1651
      check_address_registers:
1509
	jne	check_vsib
1652
	or	al,ah
1510
      check_address_registers:
1653
	mov	ah,[address_size]
1511
	or	al,ah
1654
	and	ah,0Fh
1512
	cmp	al,0Ch
-
 
1513
	jae	check_vsib
-
 
1514
	cmp	al,6
-
 
1515
	je	check_vsib
-
 
1516
	cmp	al,7
-
 
1517
	je	check_vsib
-
 
1518
	mov	ah,[address_size]
1655
	jz	address_registers_sizes_ok
1519
	and	ah,0Fh
1656
	cmp	al,ah
1520
	jz	address_registers_sizes_ok
1657
	jne	address_sizes_do_not_match
1521
	cmp	al,ah
1658
      address_registers_sizes_ok:
1522
	jne	invalid_address
1659
	cmp	al,4
1523
      address_registers_sizes_ok:
1660
	je	sib_allowed
1524
	cmp	al,4
1661
	cmp	al,8
1525
	je	sib_allowed
1662
	je	sib_allowed
1526
	cmp	al,8
1663
	cmp	al,0Fh
1527
	je	sib_allowed
1664
	je	check_ip_relative_address
1528
	cmp	al,9
1665
	cmp	cl,1
1529
	je	check_ip_relative_address
1666
	ja	invalid_address
1530
	cmp	cl,1
1667
	cmp	[free_address_range],0
1531
	ja	invalid_address
1668
	jne	check_qword_value
1532
	cmp	[free_address_range],0
1669
	jmp	check_word_value
1533
	jne	check_qword_value
1670
      address_sizes_do_not_match:
1534
	jmp	check_word_value
Line 1677... Line 1541...
1677
      check_ip_relative_address:
1541
	jne	invalid_address
1678
	or	bl,bl
1542
      check_ip_relative_address:
1679
	jnz	invalid_address
1543
	or	bl,bl
1680
	cmp	bh,0F8h
1544
	jnz	invalid_address
1681
	je	check_rip_relative_address
1545
	cmp	bh,98h
1682
	cmp	bh,0F4h
1546
	je	check_rip_relative_address
1683
	jne	invalid_address
1547
	cmp	bh,94h
1684
	cmp	[free_address_range],0
1548
	jne	invalid_address
1685
	jne	check_qword_value
1549
	cmp	[free_address_range],0
1686
	jmp	check_dword_value
1550
	je	check_dword_value
1687
      check_rip_relative_address:
1551
	mov	eax,[edi]
-
 
1552
	mov	edx,[edi+4]
1688
	mov	eax,[edi]
1553
	ret
-
 
1554
      check_rip_relative_address:
1689
	cdq
1555
	mov	eax,[edi]
1690
	cmp	edx,[edi+4]
1556
	cdq
1691
	jne	range_exceeded
1557
	cmp	edx,[edi+4]
1692
	cmp	dl,[edi+13]
1558
	jne	range_exceeded
1693
	jne	range_exceeded
1559
	cmp	dl,[edi+13]
Line 1790... Line 1656...
1790
	and	al,cl
1656
	dec	al
1791
	jz	check_immediate_address
1657
	and	al,cl
1792
	jmp	invalid_address
1658
	jz	check_immediate_address
1793
      check_vsib_address:
1659
	jmp	invalid_address
1794
	cmp	ah,0Ch
1660
      check_vsib:
1795
	je	swap_vsib_registers
1661
	xor	ah,ah
1796
	cmp	ah,0Dh
-
 
1797
	jne	check_vsib_base
-
 
1798
      swap_vsib_registers:
1662
      check_vsib_base:
1799
	cmp	cl,1
-
 
1800
	ja	invalid_address
-
 
1801
	xchg	bl,bh
-
 
1802
	mov	cl,1
-
 
1803
      check_vsib_base:
-
 
1804
	test	bh,bh
-
 
1805
	jz	vsib_base_ok
1663
	test	bh,bh
1806
	mov	al,bh
1664
	jz	check_vsib_index
1807
	shr	al,4
1665
	mov	al,bh
1808
	cmp	al,4
1666
	shr	al,4
1809
	je	vsib_base_ok
1667
	cmp	al,4
1810
	cmp	[code_type],64
1668
	je	check_vsib_base_size
1811
	jne	invalid_address
1669
	cmp	[code_type],64
1812
	cmp	al,8
1670
	jne	swap_vsib_registers
1813
	jne	invalid_address
1671
	cmp	al,8
1814
      vsib_base_ok:
1672
	jne	swap_vsib_registers
-
 
1673
      check_vsib_base_size:
-
 
1674
	mov	ah,[address_size]
-
 
1675
	and	ah,0Fh
-
 
1676
	jz	check_vsib_index
-
 
1677
	cmp	al,ah
-
 
1678
	jne	invalid_address
1815
	mov	al,bl
1679
      check_vsib_index:
1816
	shr	al,4
1680
	mov	al,bl
1817
	cmp	al,0Ch
1681
	and	al,0E0h
1818
	je	check_index_scale
1682
	cmp	al,0C0h
1819
	cmp	al,0Dh
1683
	jae	check_index_scale
1820
	je	check_index_scale
1684
	cmp	al,60h
1821
	jmp	invalid_address
1685
	je	check_index_scale
1822
 
1686
	jmp	invalid_address
1823
calculate_relative_offset:
1687
      swap_vsib_registers:
-
 
1688
	xor	ah,-1
-
 
1689
	jz	invalid_address
-
 
1690
	cmp	cl,1
-
 
1691
	ja	invalid_address
-
 
1692
	xchg	bl,bh
-
 
1693
	mov	cl,1
-
 
1694
	jmp	check_vsib_base
-
 
1695
 
Line 1824... Line 1696...
1824
	cmp	[value_undefined],0
1696
calculate_relative_offset:
1825
	jne	relative_offset_ok
1697
	cmp	[value_undefined],0
1826
	test	bh,bh
1698
	jne	relative_offset_ok
1827
	setne	ch
1699
	test	bh,bh
Line 1910... Line 1782...
1910
	jmp	logical_loop
1782
	pop	eax
1911
  get_value_for_comparison:
1783
	jmp	logical_loop
1912
	mov	[value_size],8
1784
  get_value_for_comparison:
1913
	mov	[size_override],-1
1785
	mov	[value_size],8
1914
	lods	byte [esi]
1786
	or	[operand_flags],1
1915
	call	calculate_expression
1787
	lods	byte [esi]
1916
	cmp	byte [edi+8],0
1788
	call	calculate_expression
1917
	jne	first_register_size_ok
1789
	cmp	byte [edi+8],0
1918
	mov	byte [edi+10],0
1790
	jne	first_register_size_ok
1919
      first_register_size_ok:
1791
	mov	byte [edi+10],0
1920
	cmp	byte [edi+9],0
1792
      first_register_size_ok:
Line 1941... Line 1813...
1941
      negation_ok:
1813
	jmp	check_for_negation
1942
	push	eax
1814
      negation_ok:
1943
	mov	al,[esi]
1815
	push	eax
1944
	cmp	al,'{'
1816
	mov	al,[esi]
1945
	je	logical_expression
1817
	cmp	al,91h
1946
	cmp	al,0FFh
1818
	je	logical_expression
1947
	je	invalid_expression
1819
	cmp	al,0FFh
1948
	cmp	al,88h
1820
	je	invalid_expression
1949
	je	check_for_defined
1821
	cmp	al,88h
1950
	cmp	al,89h
1822
	je	check_for_defined
1951
	je	check_for_used
1823
	cmp	al,89h
Line 1963... Line 1835...
1963
	jz	logical_number
1835
	or	al,al
1964
	cmp	al,0Fh
1836
	jz	logical_number
1965
	je	logical_number
1837
	cmp	al,0Fh
1966
	cmp	al,'}'
1838
	je	logical_number
1967
	je	logical_number
1839
	cmp	al,92h
1968
	cmp	al,'&'
1840
	je	logical_number
1969
	je	logical_number
1841
	cmp	al,'&'
1970
	cmp	al,'|'
1842
	je	logical_number
1971
	je	logical_number
1843
	cmp	al,'|'
1972
	inc	esi
1844
	je	logical_number
1973
	mov	[compare_type],al
1845
	inc	esi
Line 2122... Line 1994...
2122
	inc	esi
1994
      defined_register:
2123
	jmp	check_expression
1995
	inc	esi
2124
      defined_fp_value:
1996
	jmp	check_expression
2125
	add	esi,12
1997
      defined_fp_value:
2126
	jmp	expression_checked
1998
	add	esi,12+1
2127
      defined_string:
1999
	jmp	expression_checked
2128
	lods	dword [esi]
2000
      defined_string:
2129
	add	esi,eax
2001
	lods	dword [esi]
2130
	inc	esi
2002
	add	esi,eax
2131
	jmp	expression_checked
2003
	inc	esi
2132
      check_if_symbol_defined:
2004
	jmp	expression_checked
Line 2204... Line 2076...
2204
	mov	[logical_value_wrapping],dl
2076
	pop	edx
2205
	push	eax
2077
	mov	[logical_value_wrapping],dl
2206
	lods	byte [esi]
2078
	push	eax
2207
	cmp	al,'}'
2079
	lods	byte [esi]
2208
	jne	invalid_expression
2080
	cmp	al,92h
2209
	pop	eax
2081
	jne	invalid_expression
2210
      logical_value_ok:
2082
	pop	eax
2211
	pop	ebx
2083
      logical_value_ok:
2212
	xor	al,bl
2084
	pop	ebx
2213
	ret
2085
	xor	al,bl
2214
 
2086
	ret