Subversion Repositories Kolibri OS

Rev

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

Rev 2287 Rev 2664
Line 1... Line 1...
1
; flat assembler core
1
; flat assembler core
2
; Copyright (c) 1999-2011, Tomasz Grysztar.
2
; Copyright (c) 1999-2012, Tomasz Grysztar.
3
; All rights reserved.
3
; All rights reserved.
Line 4... Line 4...
4
 
4
 
5
preprocessor:
5
preprocessor:
6
	mov	edi,characters
6
        mov     edi,characters
Line 824... Line 824...
824
	or	al,1
824
        or      al,1
825
	mov	[macro_status],al
825
        mov     [macro_status],al
826
	mov	eax,[current_line]
826
        mov     eax,[current_line]
827
	mov	[error_line],eax
827
        mov     [error_line],eax
828
	xor	bl,bl
828
        xor     ebp,ebp
829
	lods	byte [esi]
829
        lods    byte [esi]
830
	or	al,al
830
        or      al,al
831
	jz	line_preprocessed
831
        jz      line_preprocessed
832
	cmp	al,'{'
832
        cmp     al,'{'
833
	je	found_macro_block
833
        je      found_macro_block
834
	dec	esi
834
        dec     esi
Line 837... Line 837...
837
	cmp	al,1Ah
837
        cmp     al,1Ah
838
	je	skip_macro_argument
838
        je      skip_macro_argument
839
	cmp	al,'['
839
        cmp     al,'['
840
	jne	invalid_macro_arguments
840
        jne     invalid_macro_arguments
841
	xor	bl,-1
841
        or      ebp,-1
842
	jz	invalid_macro_arguments
842
        jz      invalid_macro_arguments
843
	lods	byte [esi]
843
        lods    byte [esi]
844
	cmp	al,1Ah
844
        cmp     al,1Ah
845
	jne	invalid_macro_arguments
845
        jne     invalid_macro_arguments
846
      skip_macro_argument:
846
      skip_macro_argument:
847
	movzx	eax,byte [esi]
847
        movzx   eax,byte [esi]
848
	inc	esi
848
        inc     esi
849
	add	esi,eax
849
        add     esi,eax
850
	lods	byte [esi]
850
        lods    byte [esi]
851
	cmp	al,'*'
851
        cmp     al,'='
-
 
852
        je      macro_argument_with_default_value
-
 
853
        cmp     al,'*'
852
	jne	macro_argument_end
854
        jne     macro_argument_end
853
	lods	byte [esi]
855
        lods    byte [esi]
854
      macro_argument_end:
856
      macro_argument_end:
855
	cmp	al,','
857
        cmp     al,','
856
	je	skip_macro_arguments
858
        je      skip_macro_arguments
857
	cmp	al,']'
859
        cmp     al,']'
858
	jne	end_macro_arguments
860
        jne     end_macro_arguments
859
	lods	byte [esi]
861
        lods    byte [esi]
860
	not	bl
862
        not     ebp
861
      end_macro_arguments:
863
      end_macro_arguments:
862
	or	bl,bl
864
        or      ebp,ebp
863
	jnz	invalid_macro_arguments
865
        jnz     invalid_macro_arguments
864
	or	al,al
866
        or      al,al
865
	jz	line_preprocessed
867
        jz      line_preprocessed
866
	cmp	al,'{'
868
        cmp     al,'{'
867
	je	found_macro_block
869
        je      found_macro_block
868
	jmp	invalid_macro_arguments
870
        jmp     invalid_macro_arguments
869
      find_macro_block:
871
      macro_argument_with_default_value:
-
 
872
        call    skip_macro_argument_value
-
 
873
        inc     esi
-
 
874
        jmp     macro_argument_end
-
 
875
      skip_macro_argument_value:
-
 
876
        cmp     byte [esi],'<'
-
 
877
        jne     simple_argument
-
 
878
        mov     ecx,1
-
 
879
        inc     esi
-
 
880
      enclosed_argument:
-
 
881
        lods    byte [esi]
-
 
882
        or      al,al
-
 
883
        jz      invalid_macro_arguments
-
 
884
        cmp     al,1Ah
-
 
885
        je      enclosed_symbol
-
 
886
        cmp     al,22h
-
 
887
        je      enclosed_string
-
 
888
        cmp     al,'>'
-
 
889
        je      enclosed_argument_end
-
 
890
        cmp     al,'<'
-
 
891
        jne     enclosed_argument
-
 
892
        inc     ecx
-
 
893
        jmp     enclosed_argument
-
 
894
      enclosed_symbol:
-
 
895
        movzx   eax,byte [esi]
-
 
896
        inc     esi
-
 
897
        add     esi,eax
-
 
898
        jmp     enclosed_argument
-
 
899
      enclosed_string:
-
 
900
        lods    dword [esi]
-
 
901
        add     esi,eax
-
 
902
        jmp     enclosed_argument
-
 
903
      enclosed_argument_end:
-
 
904
        loop    enclosed_argument
-
 
905
        lods    byte [esi]
-
 
906
        or      al,al
-
 
907
        jz      argument_value_end
-
 
908
        cmp     al,','
-
 
909
        je      argument_value_end
-
 
910
        or      ebp,ebp
-
 
911
        jz      invalid_macro_arguments
-
 
912
        cmp     al,']'
-
 
913
        je      argument_value_end
-
 
914
        jmp     invalid_macro_arguments
-
 
915
      simple_argument:
-
 
916
        lods    byte [esi]
-
 
917
        or      al,al
-
 
918
        jz      argument_value_end
-
 
919
        cmp     al,','
-
 
920
        je      argument_value_end
-
 
921
        cmp     al,22h
-
 
922
        je      argument_string
-
 
923
        cmp     al,1Ah
-
 
924
        je      argument_symbol
-
 
925
        or      ebp,ebp
-
 
926
        jz      simple_argument
-
 
927
        cmp     al,']'
-
 
928
        je      argument_value_end
-
 
929
      argument_symbol:
-
 
930
        movzx   eax,byte [esi]
-
 
931
        inc     esi
-
 
932
        add     esi,eax
-
 
933
        jmp     simple_argument
-
 
934
      argument_string:
-
 
935
        lods    dword [esi]
-
 
936
        add     esi,eax
-
 
937
        jmp     simple_argument
-
 
938
      argument_value_end:
-
 
939
        dec     esi
-
 
940
        ret
-
 
941
      find_macro_block:
870
	add	esi,2
942
        add     esi,2
871
	lods	byte [esi]
943
        lods    byte [esi]
872
	or	al,al
944
        or      al,al
873
	jz	line_preprocessed
945
        jz      line_preprocessed
874
	cmp	al,'{'
946
        cmp     al,'{'
Line 1384... Line 1456...
1384
	mov	esi,[edx+8]
1456
        mov     esi,[edx+8]
1385
	mov	eax,[edx+12]
1457
        mov     eax,[edx+12]
1386
	mov	[macro_line],eax
1458
        mov     [macro_line],eax
1387
	mov	[counter_limit],0
1459
        mov     [counter_limit],0
1388
      process_macro_arguments:
1460
        xor     ebp,ebp
-
 
1461
      process_macro_arguments:
1389
	mov	al,[esi]
1462
        mov     al,[esi]
1390
	or	al,al
1463
        or      al,al
1391
	jz	arguments_end
1464
        jz      arguments_end
1392
	cmp	al,'{'
1465
        cmp     al,'{'
1393
	je	arguments_end
1466
        je      arguments_end
Line 1425... Line 1498...
1425
	call	add_macro_symbol
1498
        call    add_macro_symbol
1426
	add	esi,ecx
1499
        add     esi,ecx
1427
	xchg	esi,ebx
1500
        xchg    esi,ebx
1428
	mov	[edx+12],esi
1501
        mov     [edx+12],esi
1429
	cmp	byte [esi],'<'
1502
        push    ebp
1430
	jne	simple_argument
-
 
1431
	inc	esi
-
 
1432
	mov	[edx+12],esi
-
 
1433
	mov	ecx,1
-
 
1434
      enclosed_argument:
-
 
1435
	lods	byte [esi]
-
 
1436
	or	al,al
-
 
1437
	jz	invalid_macro_arguments
-
 
1438
	cmp	al,1Ah
-
 
1439
	je	enclosed_symbol
-
 
1440
	cmp	al,22h
-
 
1441
	je	enclosed_string
-
 
1442
	cmp	al,'>'
-
 
1443
	je	enclosed_argument_end
-
 
1444
	cmp	al,'<'
-
 
1445
	jne	enclosed_argument
-
 
1446
	inc	ecx
-
 
1447
	jmp	enclosed_argument
-
 
1448
      enclosed_symbol:
-
 
1449
	movzx	eax,byte [esi]
1503
        xor     ebp,ebp
1450
	inc	esi
-
 
1451
	add	esi,eax
-
 
1452
	jmp	enclosed_argument
-
 
1453
      enclosed_string:
-
 
1454
	lods	dword [esi]
1504
        call    skip_macro_argument_value
1455
	add	esi,eax
-
 
1456
	jmp	enclosed_argument
-
 
1457
      enclosed_argument_end:
-
 
1458
	loop	enclosed_argument
1505
        pop     ebp
1459
	mov	al,[esi]
-
 
1460
	or	al,al
-
 
1461
	jz	enclosed_argument_ok
-
 
1462
	cmp	al,','
-
 
1463
	jne	invalid_macro_arguments
-
 
1464
      enclosed_argument_ok:
-
 
1465
	mov	eax,esi
-
 
1466
	sub	eax,[edx+12]
-
 
1467
	dec	eax
-
 
1468
	or	eax,80000000h
-
 
1469
	mov	[edx+8],eax
-
 
1470
	jmp	argument_value_ok
-
 
1471
      simple_argument:
-
 
1472
	lods	byte [esi]
1506
        call    finish_macro_argument
1473
	or	al,al
-
 
1474
	jz	argument_value_end
-
 
1475
	cmp	al,','
-
 
1476
	je	argument_value_end
-
 
1477
	cmp	al,22h
-
 
1478
	je	argument_string
-
 
1479
	cmp	al,1Ah
-
 
1480
	jne	simple_argument
-
 
1481
	movzx	eax,byte [esi]
-
 
1482
	inc	esi
-
 
1483
	add	esi,eax
-
 
1484
	jmp	simple_argument
-
 
1485
      argument_string:
-
 
1486
	lods	dword [esi]
-
 
1487
	add	esi,eax
-
 
1488
	jmp	simple_argument
-
 
1489
      argument_value_end:
-
 
1490
	dec	esi
1507
        xchg    esi,ebx
1491
	mov	eax,esi
-
 
1492
	sub	eax,[edx+12]
-
 
1493
	mov	[edx+8],eax
-
 
1494
      argument_value_ok:
-
 
1495
	xchg	esi,ebx
-
 
1496
	cmp	byte [esi],'*'
1508
        cmp     byte [esi],'='
-
 
1509
        je      argument_with_default_value
-
 
1510
        cmp     byte [esi],'*'
1497
	jne	macro_argument_ok
1511
        jne     macro_argument_ok
1498
	cmp	dword [edx+8],0
1512
        cmp     dword [edx+8],0
1499
	je	invalid_macro_arguments
1513
        je      invalid_macro_arguments
1500
	inc	esi
1514
        inc     esi
1501
      macro_argument_ok:
1515
      macro_argument_ok:
1502
	ret
1516
        ret
1503
      arguments_end:
1517
      finish_macro_argument:
-
 
1518
        mov     eax,[edx+12]
-
 
1519
        mov     ecx,esi
-
 
1520
        sub     ecx,eax
-
 
1521
        cmp     byte [eax],'<'
-
 
1522
        jne     argument_value_length_ok
-
 
1523
        inc     dword [edx+12]
-
 
1524
        sub     ecx,2
-
 
1525
      argument_value_length_ok:
-
 
1526
        mov     [edx+8],ecx
-
 
1527
        ret
-
 
1528
      argument_with_default_value:
-
 
1529
        inc     esi
-
 
1530
        push    esi
-
 
1531
        call    skip_macro_argument_value
-
 
1532
        pop     eax
-
 
1533
        cmp     dword [edx+8],0
-
 
1534
        jne     macro_argument_ok
-
 
1535
        mov     [edx+12],eax
-
 
1536
        call    finish_macro_argument
-
 
1537
        jmp     macro_argument_ok
-
 
1538
      arguments_end:
1504
	cmp	byte [ebx],0
1539
        cmp     byte [ebx],0
1505
	jne	invalid_macro_arguments
1540
        jne     invalid_macro_arguments
1506
	mov	eax,[esp+4]
1541
        mov     eax,[esp+4]
1507
	dec	eax
1542
        dec     eax
1508
	call	process_macro
1543
        call    process_macro
Line 1617... Line 1652...
1617
	lea	esi,[esi+2+eax]
1652
        lea     esi,[esi+2+eax]
1618
	lods	byte [esi]
1653
        lods    byte [esi]
1619
	cmp	[base_code],1
1654
        cmp     [base_code],1
1620
	ja	irps_name_ok
1655
        ja      irps_name_ok
1621
	cmp	al,'*'
1656
        cmp     al,'='
-
 
1657
        je      irp_with_default_value
-
 
1658
        cmp     al,'*'
1622
	jne	irp_name_ok
1659
        jne     irp_name_ok
1623
	lods	byte [esi]
1660
        lods    byte [esi]
1624
      irp_name_ok:
1661
      irp_name_ok:
1625
	cmp	al,','
1662
        cmp     al,','
1626
	jne	invalid_macro_arguments
1663
        jne     invalid_macro_arguments
1627
	jmp	irp_parameters_start
1664
        jmp     irp_parameters_start
1628
      irps_name_ok:
1665
      irp_with_default_value:
-
 
1666
        xor     ebp,ebp
-
 
1667
        call    skip_macro_argument_value
-
 
1668
        inc     esi
-
 
1669
      irps_name_ok:
1629
	cmp	al,','
1670
        cmp     al,','
1630
	jne	invalid_macro_arguments
1671
        jne     invalid_macro_arguments
1631
	mov	al,[esi]
1672
        mov     al,[esi]
1632
	or	al,al
1673
        or      al,al
1633
	jz	instant_macro_done
1674
        jz      instant_macro_done