1,6 → 1,6 |
|
; flat assembler core |
; Copyright (c) 1999-2011, Tomasz Grysztar. |
; Copyright (c) 1999-2012, Tomasz Grysztar. |
; All rights reserved. |
|
preprocessor: |
826,7 → 826,7 |
mov [macro_status],al |
mov eax,[current_line] |
mov [error_line],eax |
xor bl,bl |
xor ebp,ebp |
lods byte [esi] |
or al,al |
jz line_preprocessed |
839,7 → 839,7 |
je skip_macro_argument |
cmp al,'[' |
jne invalid_macro_arguments |
xor bl,-1 |
or ebp,-1 |
jz invalid_macro_arguments |
lods byte [esi] |
cmp al,1Ah |
849,6 → 849,8 |
inc esi |
add esi,eax |
lods byte [esi] |
cmp al,'=' |
je macro_argument_with_default_value |
cmp al,'*' |
jne macro_argument_end |
lods byte [esi] |
858,9 → 860,9 |
cmp al,']' |
jne end_macro_arguments |
lods byte [esi] |
not bl |
not ebp |
end_macro_arguments: |
or bl,bl |
or ebp,ebp |
jnz invalid_macro_arguments |
or al,al |
jz line_preprocessed |
867,6 → 869,76 |
cmp al,'{' |
je found_macro_block |
jmp invalid_macro_arguments |
macro_argument_with_default_value: |
call skip_macro_argument_value |
inc esi |
jmp macro_argument_end |
skip_macro_argument_value: |
cmp byte [esi],'<' |
jne simple_argument |
mov ecx,1 |
inc esi |
enclosed_argument: |
lods byte [esi] |
or al,al |
jz invalid_macro_arguments |
cmp al,1Ah |
je enclosed_symbol |
cmp al,22h |
je enclosed_string |
cmp al,'>' |
je enclosed_argument_end |
cmp al,'<' |
jne enclosed_argument |
inc ecx |
jmp enclosed_argument |
enclosed_symbol: |
movzx eax,byte [esi] |
inc esi |
add esi,eax |
jmp enclosed_argument |
enclosed_string: |
lods dword [esi] |
add esi,eax |
jmp enclosed_argument |
enclosed_argument_end: |
loop enclosed_argument |
lods byte [esi] |
or al,al |
jz argument_value_end |
cmp al,',' |
je argument_value_end |
or ebp,ebp |
jz invalid_macro_arguments |
cmp al,']' |
je argument_value_end |
jmp invalid_macro_arguments |
simple_argument: |
lods byte [esi] |
or al,al |
jz argument_value_end |
cmp al,',' |
je argument_value_end |
cmp al,22h |
je argument_string |
cmp al,1Ah |
je argument_symbol |
or ebp,ebp |
jz simple_argument |
cmp al,']' |
je argument_value_end |
argument_symbol: |
movzx eax,byte [esi] |
inc esi |
add esi,eax |
jmp simple_argument |
argument_string: |
lods dword [esi] |
add esi,eax |
jmp simple_argument |
argument_value_end: |
dec esi |
ret |
find_macro_block: |
add esi,2 |
lods byte [esi] |
1386,6 → 1458,7 |
mov eax,[edx+12] |
mov [macro_line],eax |
mov [counter_limit],0 |
xor ebp,ebp |
process_macro_arguments: |
mov al,[esi] |
or al,al |
1427,73 → 1500,14 |
add esi,ecx |
xchg esi,ebx |
mov [edx+12],esi |
cmp byte [esi],'<' |
jne simple_argument |
inc esi |
mov [edx+12],esi |
mov ecx,1 |
enclosed_argument: |
lods byte [esi] |
or al,al |
jz invalid_macro_arguments |
cmp al,1Ah |
je enclosed_symbol |
cmp al,22h |
je enclosed_string |
cmp al,'>' |
je enclosed_argument_end |
cmp al,'<' |
jne enclosed_argument |
inc ecx |
jmp enclosed_argument |
enclosed_symbol: |
movzx eax,byte [esi] |
inc esi |
add esi,eax |
jmp enclosed_argument |
enclosed_string: |
lods dword [esi] |
add esi,eax |
jmp enclosed_argument |
enclosed_argument_end: |
loop enclosed_argument |
mov al,[esi] |
or al,al |
jz enclosed_argument_ok |
cmp al,',' |
jne invalid_macro_arguments |
enclosed_argument_ok: |
mov eax,esi |
sub eax,[edx+12] |
dec eax |
or eax,80000000h |
mov [edx+8],eax |
jmp argument_value_ok |
simple_argument: |
lods byte [esi] |
or al,al |
jz argument_value_end |
cmp al,',' |
je argument_value_end |
cmp al,22h |
je argument_string |
cmp al,1Ah |
jne simple_argument |
movzx eax,byte [esi] |
inc esi |
add esi,eax |
jmp simple_argument |
argument_string: |
lods dword [esi] |
add esi,eax |
jmp simple_argument |
argument_value_end: |
dec esi |
mov eax,esi |
sub eax,[edx+12] |
mov [edx+8],eax |
argument_value_ok: |
push ebp |
xor ebp,ebp |
call skip_macro_argument_value |
pop ebp |
call finish_macro_argument |
xchg esi,ebx |
cmp byte [esi],'=' |
je argument_with_default_value |
cmp byte [esi],'*' |
jne macro_argument_ok |
cmp dword [edx+8],0 |
1501,6 → 1515,27 |
inc esi |
macro_argument_ok: |
ret |
finish_macro_argument: |
mov eax,[edx+12] |
mov ecx,esi |
sub ecx,eax |
cmp byte [eax],'<' |
jne argument_value_length_ok |
inc dword [edx+12] |
sub ecx,2 |
argument_value_length_ok: |
mov [edx+8],ecx |
ret |
argument_with_default_value: |
inc esi |
push esi |
call skip_macro_argument_value |
pop eax |
cmp dword [edx+8],0 |
jne macro_argument_ok |
mov [edx+12],eax |
call finish_macro_argument |
jmp macro_argument_ok |
arguments_end: |
cmp byte [ebx],0 |
jne invalid_macro_arguments |
1619,6 → 1654,8 |
lods byte [esi] |
cmp [base_code],1 |
ja irps_name_ok |
cmp al,'=' |
je irp_with_default_value |
cmp al,'*' |
jne irp_name_ok |
lods byte [esi] |
1626,6 → 1663,10 |
cmp al,',' |
jne invalid_macro_arguments |
jmp irp_parameters_start |
irp_with_default_value: |
xor ebp,ebp |
call skip_macro_argument_value |
inc esi |
irps_name_ok: |
cmp al,',' |
jne invalid_macro_arguments |