mirror of
https://github.com/tgrysztar/fasm
synced 2026-08-26 00:23:06 -04:00
unreleased version 0.90
This commit is contained in:
commit
61a1789231
7 changed files with 8628 additions and 0 deletions
5398
SOURCE/ASSEMBLE.INC
Normal file
5398
SOURCE/ASSEMBLE.INC
Normal file
File diff suppressed because it is too large
Load diff
201
SOURCE/ERRORS.INC
Normal file
201
SOURCE/ERRORS.INC
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
|
||||
out_of_memory:
|
||||
mov edi,_out_of_memory
|
||||
jmp fatal_error
|
||||
main_file_not_found:
|
||||
mov edi,_file_not_found
|
||||
jmp fatal_error
|
||||
code_cannot_be_generated:
|
||||
mov edi,_code_cannot_be_generated
|
||||
jmp fatal_error
|
||||
unexpected_end_of_file:
|
||||
mov edi,_unexpected_end_of_file
|
||||
jmp fatal_error
|
||||
file_not_found:
|
||||
mov edi,_file_not_found
|
||||
jmp assembler_error
|
||||
invalid_macro_arguments:
|
||||
mov edi,_invalid_macro_arguments
|
||||
jmp assembler_error
|
||||
unexpected_characters:
|
||||
mov edi,_unexpected_characters
|
||||
jmp assembler_error
|
||||
invalid_argument:
|
||||
mov edi,_invalid_argument
|
||||
jmp assembler_error
|
||||
illegal_instruction:
|
||||
mov edi,_illegal_instruction
|
||||
jmp assembler_error
|
||||
invalid_operand:
|
||||
mov edi,_invalid_operand
|
||||
jmp assembler_error
|
||||
invalid_operand_size:
|
||||
mov edi,_invalid_operand_size
|
||||
jmp assembler_error
|
||||
operand_size_not_specified:
|
||||
mov edi,_operand_size_not_specified
|
||||
jmp assembler_error
|
||||
operand_sizes_do_not_match:
|
||||
mov edi,_operand_sizes_do_not_match
|
||||
jmp assembler_error
|
||||
address_sizes_do_not_agree:
|
||||
mov edi,_address_sizes_do_not_agree
|
||||
jmp assembler_error
|
||||
invalid_expression:
|
||||
mov edi,_invalid_expression
|
||||
jmp assembler_error
|
||||
invalid_address:
|
||||
mov edi,_invalid_address
|
||||
jmp assembler_error
|
||||
invalid_value:
|
||||
mov edi,_invalid_value
|
||||
jmp assembler_error
|
||||
value_out_of_range:
|
||||
mov edi,_value_out_of_range
|
||||
jmp assembler_error
|
||||
relative_jump_out_of_range:
|
||||
mov edi,_relative_jump_out_of_range
|
||||
jmp assembler_error
|
||||
extra_characters_on_line:
|
||||
mov edi,_extra_characters_on_line
|
||||
jmp assembler_error
|
||||
name_too_long:
|
||||
mov edi,_name_too_long
|
||||
jmp assembler_error
|
||||
argument_too_long:
|
||||
mov edi,_argument_too_long
|
||||
jmp assembler_error
|
||||
reserved_word_used_as_symbol:
|
||||
mov edi,_reserved_word_used_as_symbol
|
||||
jmp assembler_error
|
||||
symbol_already_defined:
|
||||
mov edi,_symbol_already_defined
|
||||
jmp assembler_error
|
||||
missing_end_quote:
|
||||
mov edi,_missing_end_quote
|
||||
jmp assembler_error
|
||||
|
||||
fatal_error:
|
||||
mov edx,error_prefix
|
||||
mov ah,9
|
||||
int 21h
|
||||
mov edx,edi
|
||||
int 21h
|
||||
mov edx,cr_lf
|
||||
int 21h
|
||||
mov ax,4CFFh
|
||||
int 21h
|
||||
assembler_error:
|
||||
mov edx,[home_line]
|
||||
mov ebp,[edx]
|
||||
call display_line_number
|
||||
mov edx,[current_line]
|
||||
cmp edx,[home_line]
|
||||
je line_number_ok
|
||||
mov ebp,[edx]
|
||||
mov dl,20h
|
||||
mov ah,2
|
||||
int 21h
|
||||
call display_line_number
|
||||
line_number_ok:
|
||||
mov edx,line_number_end
|
||||
mov ah,9
|
||||
int 21h
|
||||
mov edx,[home_line]
|
||||
add edx,5
|
||||
int 21h
|
||||
mov edx,cr_lf
|
||||
int 21h
|
||||
mov edx,error_prefix
|
||||
int 21h
|
||||
mov edx,edi
|
||||
int 21h
|
||||
mov edx,cr_lf
|
||||
int 21h
|
||||
mov ax,4C01h
|
||||
int 21h
|
||||
display_line_number:
|
||||
mov ecx,ebp
|
||||
shr ecx,24
|
||||
dec ecx
|
||||
mov esi,[files_list]
|
||||
inc esi
|
||||
get_error_file:
|
||||
jecxz error_file_found
|
||||
skip_file_name:
|
||||
lodsb
|
||||
or al,al
|
||||
jnz skip_file_name
|
||||
add esi,5
|
||||
loop get_error_file
|
||||
error_file_found:
|
||||
mov edx,esi
|
||||
mov ah,9
|
||||
int 21h
|
||||
mov edx,line_number_start
|
||||
int 21h
|
||||
mov eax,ebp
|
||||
and eax,not 11111111b shl 24
|
||||
call display_number
|
||||
mov dl,']'
|
||||
mov ah,2
|
||||
int 21h
|
||||
ret
|
||||
display_number:
|
||||
mov ecx,1000000000
|
||||
xor edx,edx
|
||||
xor bl,bl
|
||||
display_loop:
|
||||
div ecx
|
||||
push edx
|
||||
cmp ecx,1
|
||||
je display_digit
|
||||
or bl,bl
|
||||
jnz display_digit
|
||||
or al,al
|
||||
jz digit_ok
|
||||
not bl
|
||||
display_digit:
|
||||
mov dl,al
|
||||
add dl,30h
|
||||
mov ah,2
|
||||
int 21h
|
||||
digit_ok:
|
||||
mov eax,ecx
|
||||
xor edx,edx
|
||||
mov ecx,10
|
||||
div ecx
|
||||
mov ecx,eax
|
||||
pop eax
|
||||
or ecx,ecx
|
||||
jnz display_loop
|
||||
ret
|
||||
|
||||
error_prefix db 'error: ',0
|
||||
cr_lf db 0Dh,0Ah,0
|
||||
line_number_start db ' [',0
|
||||
line_number_end db ':',0Dh,0Ah,0
|
||||
_out_of_memory db 'out of memory',0
|
||||
_code_cannot_be_generated db 'code cannot be generated',0
|
||||
_unexpected_end_of_file db 'unexpected end of file',0
|
||||
_file_not_found db 'file not found',0
|
||||
_invalid_macro_arguments db 'invalid macro arguments',0
|
||||
_unexpected_characters db 'unexpected characters',0
|
||||
_invalid_argument db 'invalid argument',0
|
||||
_illegal_instruction db 'illegal instruction',0
|
||||
_invalid_operand db 'invalid operand',0
|
||||
_invalid_operand_size db 'invalid size of operand',0
|
||||
_operand_size_not_specified db 'operand size not specified',0
|
||||
_operand_sizes_do_not_match db 'operand sizes do not match',0
|
||||
_address_sizes_do_not_agree db 'address sizes do not agree',0
|
||||
_invalid_expression db 'invalid expression',0
|
||||
_invalid_address db 'invalid address',0
|
||||
_invalid_value db 'invalid value',0
|
||||
_value_out_of_range db 'value out of range',0
|
||||
_relative_jump_out_of_range db 'relative jump out of range',0
|
||||
_extra_characters_on_line db 'extra characters on line',0
|
||||
_name_too_long db 'name too long',0
|
||||
_argument_too_long db 'argument too long',0
|
||||
_reserved_word_used_as_symbol db 'reserved word used as symbol',0
|
||||
_symbol_already_defined db 'symbol already defined',0
|
||||
_missing_end_quote db 'missing end quote',0
|
||||
984
SOURCE/EXPRESSI.INC
Normal file
984
SOURCE/EXPRESSI.INC
Normal file
|
|
@ -0,0 +1,984 @@
|
|||
|
||||
get_byte_value:
|
||||
mov [current_offset],edi
|
||||
mov [value_size],1
|
||||
mov [expression_start],esi
|
||||
call get_expression
|
||||
jc invalid_value
|
||||
cmp word [edi+24],0
|
||||
jne invalid_value
|
||||
mov eax,[edi]
|
||||
cmp dword [edi+4],0
|
||||
je byte_positive
|
||||
cmp dword [edi+4],-1
|
||||
jne value_out_of_range
|
||||
cmp eax,-80h
|
||||
jb value_out_of_range
|
||||
mov edi,[current_offset]
|
||||
ret
|
||||
byte_positive:
|
||||
cmp eax,100h
|
||||
jae value_out_of_range
|
||||
mov edi,[current_offset]
|
||||
ret
|
||||
get_word_value:
|
||||
mov [current_offset],edi
|
||||
mov [value_size],2
|
||||
mov [expression_start],esi
|
||||
call get_expression
|
||||
jc invalid_value
|
||||
cmp word [edi+24],0
|
||||
jne invalid_value
|
||||
check_word_value:
|
||||
mov eax,[edi]
|
||||
cmp dword [edi+4],0
|
||||
je word_positive
|
||||
cmp dword [edi+4],-1
|
||||
jne value_out_of_range
|
||||
cmp eax,-8000h
|
||||
jb value_out_of_range
|
||||
mov edi,[current_offset]
|
||||
ret
|
||||
word_positive:
|
||||
cmp eax,10000h
|
||||
jae value_out_of_range
|
||||
mov edi,[current_offset]
|
||||
clc
|
||||
ret
|
||||
get_dword_value:
|
||||
mov [current_offset],edi
|
||||
mov [value_size],4
|
||||
mov [expression_start],esi
|
||||
call get_expression
|
||||
jc invalid_value
|
||||
cmp word [edi+24],0
|
||||
jne invalid_value
|
||||
check_dword_value:
|
||||
mov eax,[edi]
|
||||
cmp dword [edi+4],0
|
||||
je dword_positive
|
||||
cmp dword [edi+4],-1
|
||||
jne value_out_of_range
|
||||
test eax,1 shl 31
|
||||
jz value_out_of_range
|
||||
dword_positive:
|
||||
mov edi,[current_offset]
|
||||
clc
|
||||
ret
|
||||
get_pword_value:
|
||||
mov [current_offset],edi
|
||||
mov [value_size],6
|
||||
mov [expression_start],esi
|
||||
call get_expression
|
||||
jc invalid_value
|
||||
cmp word [edi+24],0
|
||||
jne invalid_value
|
||||
mov eax,[edi]
|
||||
mov edx,[edi+4]
|
||||
cmp edx,10000h
|
||||
jge value_out_of_range
|
||||
cmp edx,-8000h
|
||||
jl value_out_of_range
|
||||
mov edi,[current_offset]
|
||||
ret
|
||||
get_qword_value:
|
||||
mov [current_offset],edi
|
||||
mov [value_size],8
|
||||
mov [expression_start],esi
|
||||
call get_expression
|
||||
jc invalid_value
|
||||
cmp word [edi+24],0
|
||||
jne invalid_value
|
||||
mov eax,[edi]
|
||||
mov edx,[edi+4]
|
||||
mov edi,[current_offset]
|
||||
ret
|
||||
get_memory_address:
|
||||
mov [expression_start],esi
|
||||
mov [current_offset],edi
|
||||
mov edi,size_operators
|
||||
call get_operator
|
||||
mov [operand_size],al
|
||||
find_memory_address_start:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je find_memory_address_start
|
||||
cmp al,'['
|
||||
jne bad_expression
|
||||
mov [segment_register],0
|
||||
mov edi,segment_registers
|
||||
push esi
|
||||
call get_register
|
||||
pop edx
|
||||
jc get_address_expression
|
||||
mov [segment_register],al
|
||||
lodsb
|
||||
cmp al,':'
|
||||
je get_address_expression
|
||||
mov esi,edx
|
||||
get_address_expression:
|
||||
mov edi,[current_offset]
|
||||
mov [value_size],4
|
||||
call get_expression
|
||||
jc invalid_address
|
||||
lodsb
|
||||
cmp al,']'
|
||||
jne invalid_address
|
||||
xor bx,bx
|
||||
xor cl,cl
|
||||
cmp word [edi+24],0
|
||||
je check_dword_value
|
||||
mov al,[edi+24]
|
||||
lea edx,[edi+8]
|
||||
call get_address_register
|
||||
mov al,[edi+25]
|
||||
lea edx,[edi+16]
|
||||
call get_address_register
|
||||
mov ax,bx
|
||||
shr ah,4
|
||||
shr al,4
|
||||
or bh,bh
|
||||
jz check_address_registers
|
||||
or bl,bl
|
||||
jz check_address_registers
|
||||
cmp al,ah
|
||||
jne bad_expression
|
||||
check_address_registers:
|
||||
or al,ah
|
||||
cmp al,2
|
||||
je address_16bit
|
||||
cmp al,4
|
||||
jne bad_expression
|
||||
or bh,bh
|
||||
jnz check_index_scale
|
||||
cmp cl,2
|
||||
je special_index_scale
|
||||
cmp cl,3
|
||||
je special_index_scale
|
||||
cmp cl,5
|
||||
je special_index_scale
|
||||
cmp cl,9
|
||||
je special_index_scale
|
||||
check_index_scale:
|
||||
or cl,cl
|
||||
jz address_registers_ok
|
||||
cmp cl,1
|
||||
je address_registers_ok
|
||||
cmp cl,2
|
||||
je address_registers_ok
|
||||
cmp cl,4
|
||||
je address_registers_ok
|
||||
cmp cl,8
|
||||
je address_registers_ok
|
||||
jmp bad_expression
|
||||
special_index_scale:
|
||||
mov bh,bl
|
||||
dec cl
|
||||
address_registers_ok:
|
||||
jmp check_dword_value
|
||||
address_16bit:
|
||||
or cl,cl
|
||||
jz check_word_value
|
||||
cmp cl,1
|
||||
je check_word_value
|
||||
jmp bad_expression
|
||||
get_address_register:
|
||||
or al,al
|
||||
jz address_register_ok
|
||||
cmp dword [edx+4],0
|
||||
jne address_register_error
|
||||
cmp dword [edx],1
|
||||
jne scaled_register
|
||||
or bh,bh
|
||||
jnz scaled_register
|
||||
mov bh,al
|
||||
address_register_ok:
|
||||
clc
|
||||
ret
|
||||
scaled_register:
|
||||
or bl,bl
|
||||
jnz address_register_error
|
||||
mov bl,al
|
||||
mov ecx,[edx]
|
||||
cmp ecx,255
|
||||
ja address_register_error
|
||||
clc
|
||||
ret
|
||||
address_register_error:
|
||||
add esp,4
|
||||
jmp bad_expression
|
||||
get_expression:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je get_expression
|
||||
dec esi
|
||||
xor eax,eax
|
||||
stosb
|
||||
times 8 stosd
|
||||
lodsb
|
||||
cmp al,'-'
|
||||
je value_negative
|
||||
cmp al,'+'
|
||||
je value_positive
|
||||
dec esi
|
||||
mov al,10h
|
||||
stosb
|
||||
jmp value_start
|
||||
value_positive:
|
||||
mov al,10h
|
||||
stosb
|
||||
jmp get_value
|
||||
value_negative:
|
||||
mov al,11h
|
||||
stosb
|
||||
jmp get_value
|
||||
value_start:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je value_start
|
||||
dec esi
|
||||
mov ebp,edi
|
||||
mov edi,single_operand_operators
|
||||
call get_operator
|
||||
mov edi,ebp
|
||||
mov word [edi+24],0
|
||||
or al,al
|
||||
jnz value_loop
|
||||
get_value:
|
||||
cmp byte [esi],'('
|
||||
jne value_register
|
||||
inc esi
|
||||
push edi
|
||||
call get_expression
|
||||
mov ebx,esi
|
||||
mov esi,edi
|
||||
pop edi
|
||||
mov ebp,edi
|
||||
mov ecx,8
|
||||
rep movsd
|
||||
mov esi,ebx
|
||||
lodsb
|
||||
cmp al,')'
|
||||
jne bad_expression
|
||||
jmp value_operator
|
||||
value_register:
|
||||
mov word [edi+24],0
|
||||
mov ebp,edi
|
||||
mov edi,index_registers
|
||||
call get_register
|
||||
jc value_number
|
||||
mov edi,ebp
|
||||
mov [edi+24],al
|
||||
xor eax,eax
|
||||
mov [edi],eax
|
||||
mov [edi+4],eax
|
||||
mov dword [edi+8],1
|
||||
mov [edi+8+4],eax
|
||||
mov [edi+25],al
|
||||
jmp value_operator
|
||||
value_number:
|
||||
call get_number
|
||||
jnc value_operator
|
||||
mov ecx,eax
|
||||
sub ecx,esi
|
||||
push ebp
|
||||
call get_symbol
|
||||
pop ebp
|
||||
cmp cl,1
|
||||
jb invalid_number
|
||||
ja store_symbol_value
|
||||
mov [next_pass_needed],1
|
||||
store_symbol_value:
|
||||
mov dword [ds:ebp],eax
|
||||
mov dword [ds:ebp+4],edx
|
||||
value_operator:
|
||||
mov edi,operators
|
||||
call get_operator
|
||||
mov edi,ebp
|
||||
value_loop:
|
||||
mov bl,[edi-1]
|
||||
and bl,0F0h
|
||||
mov ah,al
|
||||
and ah,0F0h
|
||||
cmp bl,ah
|
||||
jbe value_next
|
||||
mov ebp,edi
|
||||
find_calculations_start:
|
||||
sub edi,32+1
|
||||
mov bh,[edi-1]
|
||||
and bh,0F0h
|
||||
cmp bh,bl
|
||||
je find_calculations_start
|
||||
push eax esi
|
||||
mov esi,edi
|
||||
calculate:
|
||||
add edi,32+1
|
||||
cmp edi,[symbols_list]
|
||||
jae out_of_memory
|
||||
mov al,[edi-1]
|
||||
cmp al,10h
|
||||
je calculate_add
|
||||
cmp al,11h
|
||||
je calculate_sub
|
||||
cmp al,20h
|
||||
je calculate_mul
|
||||
cmp al,21h
|
||||
je calculate_div
|
||||
mov dx,[esi+24]
|
||||
or dx,[edi+24]
|
||||
jnz calculate_error
|
||||
cmp al,30h
|
||||
je calculate_mod
|
||||
cmp al,40h
|
||||
je calculate_and
|
||||
cmp al,41h
|
||||
je calculate_or
|
||||
cmp al,42h
|
||||
je calculate_xor
|
||||
cmp al,50h
|
||||
je calculate_not
|
||||
cmp al,60h
|
||||
je calculate_shl
|
||||
cmp al,61h
|
||||
je calculate_shr
|
||||
jmp calculate_done
|
||||
calculate_add:
|
||||
mov eax,[edi]
|
||||
add [esi],eax
|
||||
mov eax,[edi+4]
|
||||
adc [esi+4],eax
|
||||
lea ebx,[edi+8]
|
||||
mov cl,[edi+24]
|
||||
call add_register
|
||||
lea ebx,[edi+16]
|
||||
mov cl,[edi+25]
|
||||
call add_register
|
||||
jmp calculate_done
|
||||
add_register:
|
||||
or cl,cl
|
||||
jz add_register_done
|
||||
add_register_start:
|
||||
cmp [esi+24],cl
|
||||
jne add_in_second_slot
|
||||
mov eax,[ebx]
|
||||
add [esi+8],eax
|
||||
mov eax,[ebx+4]
|
||||
adc [esi+8+4],eax
|
||||
ret
|
||||
add_in_second_slot:
|
||||
cmp [esi+25],cl
|
||||
jne create_in_first_slot
|
||||
mov eax,[ebx]
|
||||
add [esi+16],eax
|
||||
mov eax,[ebx+4]
|
||||
adc [esi+16+4],eax
|
||||
ret
|
||||
create_in_first_slot:
|
||||
cmp byte [esi+24],0
|
||||
jne create_in_second_slot
|
||||
mov [esi+24],cl
|
||||
mov eax,[ebx]
|
||||
mov [esi+8],eax
|
||||
mov eax,[ebx+4]
|
||||
mov [esi+8+4],eax
|
||||
ret
|
||||
create_in_second_slot:
|
||||
cmp byte [esi+25],0
|
||||
jne add_register_error
|
||||
mov [esi+25],cl
|
||||
mov eax,[ebx]
|
||||
mov [esi+16],eax
|
||||
mov eax,[ebx+4]
|
||||
mov [esi+16+4],eax
|
||||
add_register_done:
|
||||
ret
|
||||
add_register_error:
|
||||
add esp,4
|
||||
jmp calculate_error
|
||||
calculate_sub:
|
||||
mov eax,[edi]
|
||||
sub [esi],eax
|
||||
mov eax,[edi+4]
|
||||
sbb [esi+4],eax
|
||||
lea ebx,[edi+8]
|
||||
mov cl,[edi+24]
|
||||
call sub_register
|
||||
lea ebx,[edi+16]
|
||||
mov cl,[edi+25]
|
||||
call sub_register
|
||||
jmp calculate_done
|
||||
sub_register:
|
||||
or cl,cl
|
||||
jz add_register_done
|
||||
not dword [ebx]
|
||||
not dword [ebx+4]
|
||||
add dword [ebx],1
|
||||
adc dword [ebx+4],0
|
||||
jmp add_register_start
|
||||
calculate_mul:
|
||||
cmp word [esi+24],0
|
||||
jne mul_start
|
||||
mov eax,[esi]
|
||||
xchg eax,[edi]
|
||||
mov [esi],eax
|
||||
mov eax,[esi+4]
|
||||
xchg eax,[edi+4]
|
||||
mov [esi+4],eax
|
||||
mov eax,[esi+8]
|
||||
xchg eax,[edi+8]
|
||||
mov [esi+8],eax
|
||||
mov eax,[esi+8+4]
|
||||
xchg eax,[edi+8+4]
|
||||
mov [esi+8+4],eax
|
||||
mov eax,[esi+16]
|
||||
xchg eax,[edi+16]
|
||||
mov [esi+16],eax
|
||||
mov eax,[esi+16+4]
|
||||
xchg eax,[edi+16+4]
|
||||
mov [esi+16+4],eax
|
||||
mov ax,[esi+24]
|
||||
xchg ax,[edi+24]
|
||||
mov [esi+24],ax
|
||||
mul_start:
|
||||
call mul_64
|
||||
jc calculate_error
|
||||
cmp word [edi+24],0
|
||||
jne calculate_error
|
||||
add esi,8
|
||||
cmp byte [esi+16],0
|
||||
je mul_first_register_ok
|
||||
call mul_64
|
||||
jc calculate_error
|
||||
mul_first_register_ok:
|
||||
add esi,8
|
||||
cmp byte [esi+9],0
|
||||
je mul_second_register_ok
|
||||
call mul_64
|
||||
jc calculate_error
|
||||
mul_second_register_ok:
|
||||
sub esi,16
|
||||
jmp calculate_done
|
||||
mul_64:
|
||||
xor bl,bl
|
||||
test dword [esi+4],1 shl 31
|
||||
jz mul_first_sign_ok
|
||||
not dword [esi]
|
||||
not dword [esi+4]
|
||||
add dword [esi],1
|
||||
adc dword [esi+4],0
|
||||
not bl
|
||||
mul_first_sign_ok:
|
||||
test dword [edi+4],1 shl 31
|
||||
jz mul_second_sign_ok
|
||||
not dword [edi]
|
||||
not dword [edi+4]
|
||||
add dword [edi],1
|
||||
adc dword [edi+4],0
|
||||
not bl
|
||||
mul_second_sign_ok:
|
||||
cmp dword [esi+4],0
|
||||
jz mul_numbers
|
||||
cmp dword [edi+4],0
|
||||
jnz mul_error
|
||||
mul_numbers:
|
||||
mov eax,[esi+4]
|
||||
mul dword [edi]
|
||||
or edx,edx
|
||||
jnz mul_error
|
||||
mov ecx,eax
|
||||
mov eax,[esi]
|
||||
mul dword [edi+4]
|
||||
or edx,edx
|
||||
jnz mul_error
|
||||
add ecx,eax
|
||||
jc mul_error
|
||||
mov eax,[esi]
|
||||
mul dword [edi]
|
||||
add edx,ecx
|
||||
jc mul_error
|
||||
mov [esi],eax
|
||||
mov [esi+4],edx
|
||||
or bl,bl
|
||||
jz mul_ok
|
||||
not dword [esi]
|
||||
not dword [esi+4]
|
||||
add dword [esi],1
|
||||
adc dword [esi+4],0
|
||||
mul_ok:
|
||||
clc
|
||||
ret
|
||||
mul_error:
|
||||
stc
|
||||
ret
|
||||
calculate_div:
|
||||
call div_64
|
||||
cmp word [edi+24],0
|
||||
jne calculate_error
|
||||
add esi,8
|
||||
cmp byte [esi+16],0
|
||||
je div_first_register_ok
|
||||
call div_64
|
||||
or eax,edx
|
||||
jnz calculate_error
|
||||
div_first_register_ok:
|
||||
add esi,8
|
||||
cmp byte [esi+9],0
|
||||
je div_second_register_ok
|
||||
call div_64
|
||||
or eax,edx
|
||||
jnz calculate_error
|
||||
div_second_register_ok:
|
||||
sub esi,16
|
||||
jmp calculate_done
|
||||
div_64:
|
||||
xor bl,bl
|
||||
test dword [esi+4],1 shl 31
|
||||
jz div_first_sign_ok
|
||||
not dword [esi]
|
||||
not dword [esi+4]
|
||||
add dword [esi],1
|
||||
adc dword [esi+4],0
|
||||
not bl
|
||||
div_first_sign_ok:
|
||||
test dword [edi+4],1 shl 31
|
||||
jz div_second_sign_ok
|
||||
not dword [edi]
|
||||
not dword [edi+4]
|
||||
add dword [edi],1
|
||||
adc dword [edi+4],0
|
||||
not bl
|
||||
div_second_sign_ok:
|
||||
cmp dword [edi+4],0
|
||||
jne div_high
|
||||
mov ecx,[edi]
|
||||
mov eax,[esi+4]
|
||||
xor edx,edx
|
||||
div ecx
|
||||
mov [esi+4],eax
|
||||
mov eax,[esi]
|
||||
div ecx
|
||||
mov [esi],eax
|
||||
mov eax,edx
|
||||
xor edx,edx
|
||||
jmp div_done
|
||||
div_high:
|
||||
mov eax,[esi+4]
|
||||
xor edx,edx
|
||||
div dword [edi+4]
|
||||
mov ebx,[esi]
|
||||
mov [esi],eax
|
||||
mov dword [esi+4],0
|
||||
mov ecx,edx
|
||||
mul dword [edi]
|
||||
div_high_loop:
|
||||
cmp ecx,edx
|
||||
ja div_high_done
|
||||
jb div_high_change
|
||||
cmp ebx,eax
|
||||
jae div_high_done
|
||||
div_high_change:
|
||||
dec dword [esi]
|
||||
sub eax,[edi]
|
||||
sbb edx,[edi+4]
|
||||
jnc div_high_loop
|
||||
div_high_done:
|
||||
sub ebx,eax
|
||||
sbb ecx,edx
|
||||
mov edx,ecx
|
||||
mov eax,ebx
|
||||
ret
|
||||
div_done:
|
||||
or bl,bl
|
||||
jz div_ok
|
||||
not dword [esi]
|
||||
not dword [esi+4]
|
||||
add dword [esi],1
|
||||
adc dword [esi+4],0
|
||||
div_ok:
|
||||
ret
|
||||
calculate_mod:
|
||||
call div_64
|
||||
mov [esi],eax
|
||||
mov [esi+4],edx
|
||||
jmp calculate_done
|
||||
calculate_and:
|
||||
mov eax,[edi]
|
||||
and [esi],eax
|
||||
mov eax,[edi+4]
|
||||
and [esi+4],eax
|
||||
jmp calculate_done
|
||||
calculate_or:
|
||||
mov eax,[edi]
|
||||
or [esi],eax
|
||||
mov eax,[edi+4]
|
||||
or [esi+4],eax
|
||||
jmp calculate_done
|
||||
calculate_xor:
|
||||
cmp [value_size],1
|
||||
je xor_byte
|
||||
cmp [value_size],2
|
||||
je xor_word
|
||||
cmp [value_size],4
|
||||
je xor_dword
|
||||
cmp [value_size],6
|
||||
je xor_pword
|
||||
xor_qword:
|
||||
mov eax,[edi]
|
||||
xor [esi],eax
|
||||
mov eax,[edi+4]
|
||||
xor [esi+4],eax
|
||||
jmp calculate_done
|
||||
xor_byte:
|
||||
cmp dword [edi+4],0
|
||||
jne xor_qword
|
||||
cmp word [edi+2],0
|
||||
jne xor_qword
|
||||
cmp byte [edi+1],0
|
||||
jne xor_qword
|
||||
mov al,[edi]
|
||||
xor [esi],al
|
||||
jmp calculate_done
|
||||
xor_word:
|
||||
cmp dword [edi+4],0
|
||||
jne xor_qword
|
||||
cmp word [edi+2],0
|
||||
jne xor_qword
|
||||
mov ax,[edi]
|
||||
xor [esi],ax
|
||||
jmp calculate_done
|
||||
xor_dword:
|
||||
cmp dword [edi+4],0
|
||||
jne xor_qword
|
||||
mov eax,[edi]
|
||||
xor [esi],eax
|
||||
jmp calculate_done
|
||||
xor_pword:
|
||||
cmp word [edi+6],0
|
||||
jne xor_qword
|
||||
mov eax,[edi]
|
||||
xor [esi],eax
|
||||
mov ax,[edi+4]
|
||||
xor [esi+4],ax
|
||||
jmp calculate_done
|
||||
calculate_not:
|
||||
mov dword [esi],0
|
||||
mov dword [esi+4],0
|
||||
cmp [value_size],1
|
||||
je not_byte
|
||||
cmp [value_size],2
|
||||
je not_word
|
||||
cmp [value_size],4
|
||||
je not_dword
|
||||
cmp [value_size],6
|
||||
je not_pword
|
||||
not_qword:
|
||||
mov eax,[edi]
|
||||
not eax
|
||||
mov [esi],eax
|
||||
mov eax,[edi+4]
|
||||
not eax
|
||||
mov [esi+4],eax
|
||||
jmp calculate_done
|
||||
not_byte:
|
||||
cmp dword [edi+4],0
|
||||
jne not_qword
|
||||
cmp word [edi+2],0
|
||||
jne not_qword
|
||||
cmp byte [edi+1],0
|
||||
jne not_qword
|
||||
mov al,[edi]
|
||||
not al
|
||||
mov [esi],al
|
||||
jmp calculate_done
|
||||
not_word:
|
||||
cmp dword [edi+4],0
|
||||
jne not_qword
|
||||
cmp word [edi+2],0
|
||||
jne not_qword
|
||||
mov ax,[edi]
|
||||
not ax
|
||||
mov [esi],ax
|
||||
jmp calculate_done
|
||||
not_dword:
|
||||
cmp dword [edi+4],0
|
||||
jne not_qword
|
||||
mov eax,[edi]
|
||||
not eax
|
||||
mov [esi],eax
|
||||
jmp calculate_done
|
||||
not_pword:
|
||||
cmp word [edi+6],0
|
||||
jne not_qword
|
||||
mov eax,[edi]
|
||||
not eax
|
||||
mov [esi],eax
|
||||
mov ax,[edi+4]
|
||||
not ax
|
||||
mov [esi+4],ax
|
||||
jmp calculate_done
|
||||
calculate_shl:
|
||||
mov eax,dword [edi+4]
|
||||
test eax,1 shl 31
|
||||
jnz shl_negative
|
||||
or eax,eax
|
||||
jnz zero_value
|
||||
mov ecx,[edi]
|
||||
cmp ecx,64
|
||||
jae zero_value
|
||||
cmp ecx,32
|
||||
jae shl_high
|
||||
mov edx,[esi+4]
|
||||
mov eax,[esi]
|
||||
shld edx,eax,cl
|
||||
shl eax,cl
|
||||
mov [esi],eax
|
||||
mov [esi+4],edx
|
||||
jmp calculate_done
|
||||
shl_high:
|
||||
sub cl,32
|
||||
mov eax,[esi]
|
||||
shl eax,cl
|
||||
mov [esi+4],eax
|
||||
mov dword [esi],0
|
||||
jmp calculate_done
|
||||
shl_negative:
|
||||
not dword [edi]
|
||||
not dword [edi+4]
|
||||
add dword [edi],1
|
||||
adc dword [edi+4],0
|
||||
calculate_shr:
|
||||
mov eax,dword [edi+4]
|
||||
test eax,1 shl 31
|
||||
jnz shr_negative
|
||||
or eax,eax
|
||||
jnz zero_value
|
||||
mov ecx,[edi]
|
||||
cmp ecx,64
|
||||
jae zero_value
|
||||
cmp ecx,32
|
||||
jae shr_high
|
||||
mov edx,[esi+4]
|
||||
mov eax,[esi]
|
||||
shrd eax,edx,cl
|
||||
shr edx,cl
|
||||
mov [esi],eax
|
||||
mov [esi+4],edx
|
||||
jmp calculate_done
|
||||
shr_high:
|
||||
sub cl,32
|
||||
mov eax,[esi+4]
|
||||
shr eax,cl
|
||||
mov [esi],eax
|
||||
mov dword [esi+4],0
|
||||
jmp calculate_done
|
||||
shr_negative:
|
||||
not dword [edi]
|
||||
not dword [edi+4]
|
||||
add dword [edi],1
|
||||
adc dword [edi+4],0
|
||||
jmp calculate_shl
|
||||
zero_value:
|
||||
mov dword [esi],0
|
||||
mov dword [esi+4],0
|
||||
jmp calculate_done
|
||||
calculate_error:
|
||||
add esp,8
|
||||
jmp bad_expression
|
||||
calculate_done:
|
||||
cmp byte [esi+24],0
|
||||
je first_register_ok
|
||||
mov eax,[esi+8]
|
||||
or eax,[esi+8+4]
|
||||
jnz first_register_ok
|
||||
mov byte [esi+24],0
|
||||
first_register_ok:
|
||||
cmp byte [esi+25],0
|
||||
je second_register_ok
|
||||
mov eax,[esi+16]
|
||||
or eax,[esi+16+4]
|
||||
jnz second_register_ok
|
||||
mov byte [esi+25],0
|
||||
second_register_ok:
|
||||
cmp edi,ebp
|
||||
jne calculate
|
||||
mov edi,esi
|
||||
pop esi eax
|
||||
jmp value_loop
|
||||
value_next:
|
||||
or al,al
|
||||
jz value_end
|
||||
add edi,32
|
||||
stosb
|
||||
jmp value_start
|
||||
value_end:
|
||||
clc
|
||||
ret
|
||||
bad_expression:
|
||||
mov esi,[expression_start]
|
||||
mov edi,[current_offset]
|
||||
stc
|
||||
ret
|
||||
get_number:
|
||||
mov [number_start],esi
|
||||
cmp byte [esi],27h
|
||||
je get_text_number
|
||||
find_number_end:
|
||||
lodsb
|
||||
mov edi,special_characters+1
|
||||
movzx ecx,[special_characters]
|
||||
repne scasb
|
||||
jne find_number_end
|
||||
number_end:
|
||||
dec esi
|
||||
cmp esi,[number_start]
|
||||
je no_number
|
||||
push esi
|
||||
sub esi,2
|
||||
mov dword [ds:ebp],0
|
||||
mov dword [ds:ebp+4],0
|
||||
cmp byte [esi+1],'h'
|
||||
je get_hex_number
|
||||
cmp byte [esi+1],'b'
|
||||
je get_bin_number
|
||||
cmp byte [esi+1],'d'
|
||||
je get_dec_number
|
||||
inc esi
|
||||
get_dec_number:
|
||||
xor edx,edx
|
||||
mov ebx,1
|
||||
get_dec_digit:
|
||||
movzx eax,byte [esi]
|
||||
mov edi,special_characters+1
|
||||
movzx ecx,[special_characters]
|
||||
repne scasb
|
||||
je number_ok
|
||||
sub al,30h
|
||||
jc no_number
|
||||
cmp al,9
|
||||
ja no_number
|
||||
mov ecx,eax
|
||||
jecxz next_dec_digit
|
||||
convert_dec_digit:
|
||||
add dword [ds:ebp],ebx
|
||||
adc dword [ds:ebp+4],edx
|
||||
loop convert_dec_digit
|
||||
next_dec_digit:
|
||||
dec esi
|
||||
mov ecx,edx
|
||||
mov eax,10
|
||||
mul ebx
|
||||
mov ebx,eax
|
||||
imul ecx,10
|
||||
jo no_number
|
||||
add edx,ecx
|
||||
jnc get_dec_digit
|
||||
no_number:
|
||||
mov esi,[number_start]
|
||||
pop eax
|
||||
invalid_number:
|
||||
stc
|
||||
ret
|
||||
get_bin_number:
|
||||
xor bl,bl
|
||||
get_bin_digit:
|
||||
movzx eax,byte [esi]
|
||||
mov edi,special_characters+1
|
||||
movzx ecx,[special_characters]
|
||||
repne scasb
|
||||
je number_ok
|
||||
cmp bl,64
|
||||
je no_number
|
||||
sub al,30h
|
||||
jc no_number
|
||||
cmp al,1
|
||||
ja no_number
|
||||
xor edx,edx
|
||||
mov cl,bl
|
||||
dec esi
|
||||
inc bl
|
||||
cmp cl,32
|
||||
jae bin_digit_high
|
||||
shl eax,cl
|
||||
or dword [ds:ebp],eax
|
||||
jmp get_bin_digit
|
||||
bin_digit_high:
|
||||
sub cl,32
|
||||
shl eax,cl
|
||||
or dword [ds:ebp+4],eax
|
||||
jmp get_bin_digit
|
||||
get_hex_number:
|
||||
xor bl,bl
|
||||
get_hex_digit:
|
||||
movzx eax,byte [esi]
|
||||
mov edi,special_characters+1
|
||||
movzx ecx,[special_characters]
|
||||
repne scasb
|
||||
je number_ok
|
||||
cmp bl,64
|
||||
je no_number
|
||||
sub al,30h
|
||||
jc no_number
|
||||
cmp al,9
|
||||
jbe hex_digit_ok
|
||||
sub al,7
|
||||
jc no_number
|
||||
cmp al,15
|
||||
ja no_number
|
||||
hex_digit_ok:
|
||||
xor edx,edx
|
||||
mov cl,bl
|
||||
dec esi
|
||||
add bl,4
|
||||
cmp cl,32
|
||||
jae hex_digit_high
|
||||
shl eax,cl
|
||||
or dword [ds:ebp],eax
|
||||
jmp get_hex_digit
|
||||
hex_digit_high:
|
||||
sub cl,32
|
||||
shl eax,cl
|
||||
or dword [ds:ebp+4],eax
|
||||
jmp get_hex_digit
|
||||
get_text_number:
|
||||
inc esi
|
||||
xor bl,bl
|
||||
mov dword [ds:ebp],0
|
||||
mov dword [ds:ebp+4],0
|
||||
get_text_character:
|
||||
lodsb
|
||||
cmp al,27h
|
||||
jne text_character_ok
|
||||
lodsb
|
||||
cmp al,27h
|
||||
je text_character_ok
|
||||
dec esi
|
||||
clc
|
||||
ret
|
||||
text_character_ok:
|
||||
cmp bl,64
|
||||
je no_number
|
||||
or al,al
|
||||
jz missing_end_quote
|
||||
movzx eax,al
|
||||
xor edx,edx
|
||||
mov cl,bl
|
||||
add bl,8
|
||||
cmp cl,32
|
||||
jae text_character_high
|
||||
shl eax,cl
|
||||
or dword [ds:ebp],eax
|
||||
jmp get_text_character
|
||||
text_character_high:
|
||||
sub cl,32
|
||||
shl eax,cl
|
||||
or dword [ds:ebp+4],eax
|
||||
jmp get_text_character
|
||||
number_ok:
|
||||
pop esi
|
||||
clc
|
||||
ret
|
||||
|
||||
expression_start dd 0
|
||||
number_start dd 0
|
||||
value_size db 0
|
||||
value dd 0
|
||||
232
SOURCE/FASM.ASM
Normal file
232
SOURCE/FASM.ASM
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
|
||||
; flat assembler project
|
||||
; by privalov
|
||||
; started at: 1999-03-23 14:24:33
|
||||
; version 0.90 finished at: 1999-05-04 15:23:26
|
||||
|
||||
HF
|
||||
code 32
|
||||
entry start
|
||||
|
||||
include 'tables.inc'
|
||||
include 'expressions.inc'
|
||||
include 'symbols.inc'
|
||||
include 'errors.inc'
|
||||
include 'preprocessor.inc'
|
||||
include 'assembler.inc'
|
||||
|
||||
start:
|
||||
|
||||
call get_params
|
||||
cmp [params],0
|
||||
je information
|
||||
lea eax,[params+1]
|
||||
mov [input_file],eax
|
||||
movzx ecx,byte [eax-1]
|
||||
add eax,ecx
|
||||
cmp byte [eax],0
|
||||
je information
|
||||
inc eax
|
||||
mov [output_file],eax
|
||||
mov ax,4811h
|
||||
mov edx,2000h
|
||||
mov [additional_memory_end],edx
|
||||
int 31h
|
||||
jc allocation_error
|
||||
mov [additional_memory],edx
|
||||
add [additional_memory_end],edx
|
||||
mov ax,4810h
|
||||
int 31h
|
||||
sub edx,4000h
|
||||
jc allocation_error
|
||||
mov [memory_end],edx
|
||||
mov ax,4811h
|
||||
int 31h
|
||||
jnc allocation_ok
|
||||
allocation_error:
|
||||
jmp out_of_memory
|
||||
allocation_ok:
|
||||
mov [memory_start],edx
|
||||
add [memory_end],edx
|
||||
mov [source_start],edx
|
||||
mov edx,[additional_memory]
|
||||
mov [files_list],edx
|
||||
|
||||
call preprocessor
|
||||
|
||||
call assembler
|
||||
sub edi,[code_start]
|
||||
mov [code_size],edi
|
||||
|
||||
mov ah,3Ch
|
||||
xor cx,cx
|
||||
mov edx,[output_file]
|
||||
int 21h
|
||||
cmp [program_format],48h
|
||||
je save_HF_program
|
||||
jmp save_raw_code
|
||||
save_HF_program:
|
||||
cmp [entry_code_type],32
|
||||
jne HF_code_type_ok
|
||||
or [HF_attributes],1
|
||||
HF_code_type_ok:
|
||||
mov eax,[code_size]
|
||||
mov ecx,eax
|
||||
mov edi,[code_start]
|
||||
add edi,ecx
|
||||
cmp [undefined_data_end],edi
|
||||
jne create_HF_header
|
||||
sub edi,[undefined_data_start]
|
||||
sub eax,edi
|
||||
create_HF_header:
|
||||
mov [code_size],eax
|
||||
mov [HF_code_size],eax
|
||||
mov [HF_code_size+4],eax
|
||||
mov [HF_memory_needed],ecx
|
||||
mov edx,HF_header
|
||||
mov ecx,HF_header_end-HF_header
|
||||
add eax,ecx
|
||||
sub eax,10h
|
||||
mov [HF_size],eax
|
||||
mov eax,[entry_point]
|
||||
mov [HF_initial_EIP],eax
|
||||
mov [HF_initial_ESP],0
|
||||
mov ah,40h
|
||||
int 21h
|
||||
mov edx,[code_start]
|
||||
mov ecx,[code_size]
|
||||
mov ah,40h
|
||||
int 21h
|
||||
jmp exit
|
||||
save_raw_code:
|
||||
mov edx,[code_start]
|
||||
mov ecx,[code_size]
|
||||
mov ah,40h
|
||||
int 21h
|
||||
exit:
|
||||
mov ax,4C00h
|
||||
int 21h
|
||||
|
||||
information:
|
||||
mov edx,_information
|
||||
mov ah,9
|
||||
int 21h
|
||||
mov ax,4C00h
|
||||
int 21h
|
||||
|
||||
get_params:
|
||||
mov ax,4801h
|
||||
int 31h
|
||||
add esi,81h
|
||||
mov edi,params
|
||||
mov edx,switches
|
||||
find_param:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je find_param
|
||||
cmp al,0Dh
|
||||
je all_params
|
||||
or al,al
|
||||
jz all_params
|
||||
cmp al,'/'
|
||||
je get_switch
|
||||
cmp al,'-'
|
||||
je get_switch
|
||||
no_switch:
|
||||
inc edi
|
||||
mov ebx,edi
|
||||
move_param:
|
||||
stosb
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je param_end
|
||||
cmp al,0Dh
|
||||
je param_end
|
||||
cmp al,'/'
|
||||
je param_end
|
||||
cmp al,'-'
|
||||
je param_end
|
||||
or al,al
|
||||
jz param_end
|
||||
jmp move_param
|
||||
get_switch:
|
||||
cmp byte [esi],20h
|
||||
je no_switch
|
||||
cmp byte [esi],0Dh
|
||||
je no_switch
|
||||
cmp byte [esi],0
|
||||
je no_switch
|
||||
mov ebx,edi
|
||||
mov edi,edx
|
||||
inc edi
|
||||
move_switch:
|
||||
lodsb
|
||||
stosb
|
||||
cmp al,20h
|
||||
je switch_end
|
||||
cmp al,0Dh
|
||||
je switch_end
|
||||
or al,al
|
||||
jz switch_end
|
||||
cmp al,'/'
|
||||
je switch_end
|
||||
cmp al,'-'
|
||||
je switch_end
|
||||
jmp move_switch
|
||||
switch_end:
|
||||
dec esi
|
||||
mov byte [edi-1],0
|
||||
mov eax,edi
|
||||
sub eax,edx
|
||||
dec eax
|
||||
xchg edi,edx
|
||||
stosb
|
||||
mov edi,ebx
|
||||
jmp find_param
|
||||
param_end:
|
||||
dec esi
|
||||
xor al,al
|
||||
stosb
|
||||
mov eax,edi
|
||||
sub eax,ebx
|
||||
mov [ebx-1],al
|
||||
jmp find_param
|
||||
all_params:
|
||||
xor al,al
|
||||
stosb
|
||||
mov edi,edx
|
||||
stosb
|
||||
ret
|
||||
|
||||
_information db 'flat assembler version 0.90',0Dh,0Ah
|
||||
db 'copyright (c) 1999 by privalov',0Dh,0Ah
|
||||
db 'usage: fasm source output',0Dh,0Ah
|
||||
db 0
|
||||
|
||||
program_format db 0
|
||||
|
||||
HF_header:
|
||||
HF_signature db 'HF: Program',1Ah
|
||||
HF_size dd 0
|
||||
dd 'head',0,10h,10h
|
||||
HF_attributes dd 0
|
||||
HF_memory_needed dd 0
|
||||
HF_initial_EIP dd 0
|
||||
HF_initial_ESP dd 0
|
||||
dd 'code',0
|
||||
HF_code_size dd 0,0
|
||||
HF_header_end:
|
||||
|
||||
input_file rd 1
|
||||
output_file rd 1
|
||||
|
||||
memory_start dd 0
|
||||
memory_end dd 0
|
||||
additional_memory dd 0
|
||||
additional_memory_end dd 0
|
||||
source_start dd 0
|
||||
|
||||
params rb 100h
|
||||
switches rb 100h
|
||||
code_start dd 0
|
||||
code_size dd 0
|
||||
746
SOURCE/PREPROCE.INC
Normal file
746
SOURCE/PREPROCE.INC
Normal file
|
|
@ -0,0 +1,746 @@
|
|||
|
||||
preprocessor:
|
||||
mov eax,[additional_memory_end]
|
||||
mov [symbols_list],eax
|
||||
mov [file_number],1
|
||||
push [memory_end]
|
||||
mov esi,[input_file]
|
||||
mov edi,[memory_start]
|
||||
call preprocess_file
|
||||
jc main_file_not_found
|
||||
mov [code_start],edi
|
||||
pop [memory_end]
|
||||
ret
|
||||
|
||||
preprocess_file:
|
||||
push edi
|
||||
mov edi,[additional_memory]
|
||||
xor al,al
|
||||
stosb
|
||||
mov edx,edi
|
||||
copy_file_name:
|
||||
lodsb
|
||||
cmp edi,[additional_memory_end]
|
||||
jae out_of_memory
|
||||
stosb
|
||||
cmp al,27h
|
||||
je file_name_end
|
||||
or al,al
|
||||
jnz copy_file_name
|
||||
file_name_end:
|
||||
mov byte [edi-1],0
|
||||
mov ax,3D00h
|
||||
int 21h
|
||||
jc no_source_file
|
||||
mov ax,4202h
|
||||
xor edx,edx
|
||||
int 21h
|
||||
push eax
|
||||
mov ax,4200h
|
||||
xor edx,edx
|
||||
int 21h
|
||||
pop ecx
|
||||
mov edx,[memory_end]
|
||||
mov ebp,edx
|
||||
sub edx,ecx
|
||||
mov esi,edx
|
||||
mov [memory_end],edx
|
||||
mov eax,edi
|
||||
add eax,4
|
||||
cmp eax,[additional_memory_end]
|
||||
jae out_of_memory
|
||||
mov eax,edx
|
||||
stosd
|
||||
mov [additional_memory],edi
|
||||
mov ah,3Fh
|
||||
int 21h
|
||||
mov ah,3Eh
|
||||
int 21h
|
||||
pop edi
|
||||
movzx ecx,[file_number]
|
||||
inc [file_number]
|
||||
shl ecx,24
|
||||
preprocess_source:
|
||||
inc ecx
|
||||
mov [current_line],edi
|
||||
mov [home_line],edi
|
||||
mov edx,[memory_end]
|
||||
xor bl,bl
|
||||
call convert_line
|
||||
mov [current_line_end],edi
|
||||
call preprocess_instruction
|
||||
next_line:
|
||||
cmp esi,ebp
|
||||
jb preprocess_source
|
||||
clc
|
||||
ret
|
||||
no_source_file:
|
||||
add esp,4
|
||||
stc
|
||||
ret
|
||||
convert_line:
|
||||
mov eax,ecx
|
||||
stosd
|
||||
mov al,bl
|
||||
stosb
|
||||
copy_line:
|
||||
cmp edi,edx
|
||||
jae out_of_memory
|
||||
cmp esi,ebp
|
||||
je line_end
|
||||
lodsb
|
||||
cmp al,0Ah
|
||||
je lf_character
|
||||
cmp al,0Dh
|
||||
je cr_character
|
||||
stosb
|
||||
jmp copy_line
|
||||
lf_character:
|
||||
cmp al,0Dh
|
||||
je line_end
|
||||
dec esi
|
||||
jmp line_end
|
||||
cr_character:
|
||||
cmp al,0Ah
|
||||
je line_end
|
||||
dec esi
|
||||
line_end:
|
||||
add esi,2
|
||||
xor al,al
|
||||
stosb
|
||||
ret
|
||||
|
||||
preprocess_instruction:
|
||||
push ecx esi edi ebp
|
||||
mov esi,[current_line]
|
||||
add esi,5
|
||||
find_directive:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je find_directive
|
||||
or al,al
|
||||
jz no_directive
|
||||
cmp al,';'
|
||||
je no_directive
|
||||
dec esi
|
||||
mov edx,esi
|
||||
find_directive_end:
|
||||
lodsb
|
||||
mov edi,special_characters+1
|
||||
movzx ecx,[special_characters]
|
||||
repne scasb
|
||||
jne find_directive_end
|
||||
cmp al,':'
|
||||
je find_directive
|
||||
lea ecx,[esi-1]
|
||||
mov esi,edx
|
||||
sub ecx,esi
|
||||
jecxz no_directive
|
||||
mov edi,preprocessor_directives
|
||||
call get_instruction
|
||||
jc no_directive
|
||||
jmp ebx
|
||||
no_directive:
|
||||
mov edi,[files_list]
|
||||
mov eax,1
|
||||
get_macro:
|
||||
cmp edi,[additional_memory]
|
||||
je instruction_preprocessed
|
||||
cmp byte [edi],0
|
||||
je skip_file
|
||||
movzx ecx,byte [edi]
|
||||
inc edi
|
||||
mov ebx,edi
|
||||
add ebx,ecx
|
||||
add ebx,5
|
||||
cmp ecx,ebp
|
||||
jne skip_macro
|
||||
mov edx,esi
|
||||
repe cmpsb
|
||||
je use_macro
|
||||
mov esi,edx
|
||||
mov edi,ebx
|
||||
jmp get_macro
|
||||
skip_macro:
|
||||
mov edi,ebx
|
||||
inc eax
|
||||
jmp get_macro
|
||||
skip_file:
|
||||
inc edi
|
||||
cmp byte [edi],0
|
||||
jne skip_file
|
||||
add edi,5
|
||||
inc eax
|
||||
jmp get_macro
|
||||
instruction_preprocessed:
|
||||
pop ebp edi esi ecx
|
||||
ret
|
||||
include_file:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je include_file
|
||||
cmp al,27h
|
||||
jne invalid_argument
|
||||
mov edx,[current_line]
|
||||
mov byte [edx+4],':'
|
||||
mov eax,[additional_memory_end]
|
||||
cmp eax,[symbols_list]
|
||||
jne illegal_instruction
|
||||
mov edx,esi
|
||||
find_include_end:
|
||||
lodsb
|
||||
cmp al,27h
|
||||
jne find_include_end
|
||||
lodsb
|
||||
cmp al,27h
|
||||
je find_include_end
|
||||
dec esi
|
||||
check_include_line:
|
||||
lodsb
|
||||
or al,al
|
||||
jz preprocess_included_file
|
||||
cmp al,';'
|
||||
je preprocess_included_file
|
||||
cmp al,20h
|
||||
je check_include_line
|
||||
jmp extra_characters_on_line
|
||||
preprocess_included_file:
|
||||
mov esi,edx
|
||||
mov edi,[current_line_end]
|
||||
call preprocess_file
|
||||
jc file_not_found
|
||||
pop ebp
|
||||
add esp,4
|
||||
pop esi ecx
|
||||
ret
|
||||
define_macro:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je define_macro
|
||||
dec esi
|
||||
mov edx,[current_line]
|
||||
mov byte [edx+4],':'
|
||||
mov eax,[additional_memory_end]
|
||||
cmp eax,[symbols_list]
|
||||
jne illegal_instruction
|
||||
mov edx,[additional_memory]
|
||||
mov ebx,edx
|
||||
inc edx
|
||||
copy_macro_name:
|
||||
lodsb
|
||||
mov edi,special_characters+1
|
||||
movzx ecx,[special_characters]
|
||||
repne scasb
|
||||
je macro_name_end
|
||||
mov [edx],al
|
||||
inc edx
|
||||
jmp copy_macro_name
|
||||
macro_name_end:
|
||||
dec esi
|
||||
mov edi,edx
|
||||
sub edx,[additional_memory]
|
||||
dec edx
|
||||
cmp edx,100h
|
||||
jae name_too_long
|
||||
mov [ebx],dl
|
||||
xor al,al
|
||||
stosb
|
||||
mov eax,esi
|
||||
stosd
|
||||
mov [additional_memory],edi
|
||||
inc [file_number]
|
||||
mov edi,[current_line_end]
|
||||
find_macro_argument:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je find_macro_argument
|
||||
or al,al
|
||||
jz find_macro_start
|
||||
cmp al,';'
|
||||
je find_macro_start
|
||||
cmp al,'{'
|
||||
je find_macro_end
|
||||
skip_macro_argument:
|
||||
mov ebx,edi
|
||||
mov edi,special_characters+1
|
||||
movzx ecx,[special_characters]
|
||||
repne scasb
|
||||
mov edi,ebx
|
||||
je macro_argument_end
|
||||
lodsb
|
||||
jmp skip_macro_argument
|
||||
macro_argument_end:
|
||||
dec esi
|
||||
cmp byte [esi-1],20h
|
||||
je invalid_macro_arguments
|
||||
find_next_macro_argument:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je find_next_macro_argument
|
||||
or al,al
|
||||
jz find_macro_start
|
||||
cmp al,';'
|
||||
je find_macro_start
|
||||
cmp al,'{'
|
||||
je find_macro_end
|
||||
cmp al,','
|
||||
je next_macro_argument
|
||||
jmp invalid_macro_arguments
|
||||
next_macro_argument:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je next_macro_argument
|
||||
dec esi
|
||||
or al,al
|
||||
jz invalid_macro_arguments
|
||||
cmp al,';'
|
||||
je invalid_macro_arguments
|
||||
jmp find_macro_argument
|
||||
find_macro_start:
|
||||
mov ebp,esp
|
||||
call get_macro_line
|
||||
add esi,5
|
||||
check_macro_start:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je check_macro_start
|
||||
or al,al
|
||||
jz find_macro_start
|
||||
cmp al,';'
|
||||
je find_macro_start
|
||||
cmp al,'{'
|
||||
jne unexpected_characters
|
||||
find_macro_end:
|
||||
lodsb
|
||||
mov ebx,edi
|
||||
mov edi,special_characters+1
|
||||
movzx ecx,[special_characters]
|
||||
repne scasb
|
||||
mov edi,ebx
|
||||
je special_character_in_macro
|
||||
cmp al,27h
|
||||
je skip_string_in_macro
|
||||
jmp find_macro_end
|
||||
skip_string_in_macro:
|
||||
lodsb
|
||||
or al,al
|
||||
jz missing_end_quote
|
||||
cmp al,27h
|
||||
jne skip_string_in_macro
|
||||
lodsb
|
||||
cmp al,27h
|
||||
je skip_string_in_macro
|
||||
dec esi
|
||||
jmp find_macro_end
|
||||
special_character_in_macro:
|
||||
or al,al
|
||||
jnz check_macro_end
|
||||
mov ebp,esp
|
||||
call get_macro_line
|
||||
add esi,5
|
||||
jmp find_macro_end
|
||||
check_macro_end:
|
||||
cmp al,'}'
|
||||
jne find_macro_end
|
||||
check_macro_after_end:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je check_macro_after_end
|
||||
or al,al
|
||||
jz macro_definition_ok
|
||||
cmp al,';'
|
||||
je macro_definition_ok
|
||||
jmp extra_characters_on_line
|
||||
macro_definition_ok:
|
||||
pop ebp
|
||||
add esp,4
|
||||
pop esi ecx
|
||||
ret
|
||||
get_macro_line:
|
||||
push edi
|
||||
mov [current_line],edi
|
||||
mov [home_line],edi
|
||||
mov esi,[ebp+8]
|
||||
mov ecx,[ebp+Ch]
|
||||
inc ecx
|
||||
mov [ebp+Ch],ecx
|
||||
mov edx,[memory_end]
|
||||
mov bl,'{'
|
||||
push ebp
|
||||
mov ebp,[ebp]
|
||||
cmp esi,ebp
|
||||
jae unexpected_end_of_file
|
||||
call convert_line
|
||||
pop ebp
|
||||
mov [ebp+8],esi
|
||||
pop esi
|
||||
ret
|
||||
use_macro:
|
||||
push [symbols_list]
|
||||
shl eax,24
|
||||
push eax
|
||||
mov edx,[current_line]
|
||||
mov [esp+Ch],edx
|
||||
mov al,':'
|
||||
cmp byte [edx+4],20h
|
||||
jne set_macro_line_type
|
||||
mov al,';'
|
||||
set_macro_line_type:
|
||||
mov byte [edx+4],al
|
||||
mov ebx,esi
|
||||
mov esi,[edi+1]
|
||||
mov edi,[symbols_list]
|
||||
dec edi
|
||||
mov byte [edi],0
|
||||
mov [symbols_list],edi
|
||||
find_argument:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je find_argument
|
||||
dec esi
|
||||
or al,al
|
||||
jz find_macro_instructions
|
||||
cmp al,'{'
|
||||
je find_macro_instructions
|
||||
cmp al,';'
|
||||
je find_macro_instructions
|
||||
mov edx,esi
|
||||
find_argument_end:
|
||||
lodsb
|
||||
cmp al,','
|
||||
je argument_end
|
||||
or al,al
|
||||
jz argument_end
|
||||
cmp al,';'
|
||||
je argument_end
|
||||
cmp al,20h
|
||||
jne find_argument_end
|
||||
argument_end:
|
||||
dec esi
|
||||
xchg esi,ebx
|
||||
find_argument_value:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je find_argument_value
|
||||
dec esi
|
||||
or al,al
|
||||
jz invalid_macro_arguments
|
||||
cmp al,'{'
|
||||
je invalid_macro_arguments
|
||||
cmp al,';'
|
||||
je invalid_macro_arguments
|
||||
mov ebp,esi
|
||||
find_argument_value_end:
|
||||
lodsb
|
||||
cmp al,','
|
||||
je argument_value_end
|
||||
or al,al
|
||||
jz argument_value_end
|
||||
cmp al,';'
|
||||
jne find_argument_value_end
|
||||
argument_value_end:
|
||||
dec esi
|
||||
xchg esi,ebx
|
||||
push ebx esi
|
||||
mov edi,[symbols_list]
|
||||
sub esi,edx
|
||||
sub ebx,ebp
|
||||
sub edi,esi
|
||||
sub edi,ebx
|
||||
sub edi,2
|
||||
cmp edi,[additional_memory]
|
||||
jbe out_of_memory
|
||||
mov [symbols_list],edi
|
||||
mov ecx,esi
|
||||
cmp ecx,100h
|
||||
jae name_too_long
|
||||
mov esi,edx
|
||||
mov al,cl
|
||||
stosb
|
||||
rep movsb
|
||||
mov ecx,ebx
|
||||
or ecx,ecx
|
||||
jz invalid_macro_arguments
|
||||
cmp ecx,100h
|
||||
jae argument_too_long
|
||||
mov esi,ebp
|
||||
mov al,cl
|
||||
stosb
|
||||
rep movsb
|
||||
pop esi ebx
|
||||
check_for_next_argument:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je check_for_next_argument
|
||||
xchg esi,ebx
|
||||
cmp al,','
|
||||
je next_argument
|
||||
dec ebx
|
||||
lodsb
|
||||
cmp al,0
|
||||
je arguments_ok
|
||||
cmp al,';'
|
||||
je arguments_ok
|
||||
jmp invalid_macro_arguments
|
||||
next_argument:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je next_argument
|
||||
cmp al,','
|
||||
jne invalid_macro_arguments
|
||||
xchg esi,ebx
|
||||
jmp find_argument
|
||||
arguments_ok:
|
||||
mov esi,ebx
|
||||
find_macro_instructions:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je find_macro_instructions
|
||||
cmp al,'{'
|
||||
je macro_instructions_start
|
||||
cmp al,';'
|
||||
je skip_macro_comment
|
||||
or al,al
|
||||
jnz unexpected_characters
|
||||
add esi,5
|
||||
jmp find_macro_instructions
|
||||
skip_macro_comment:
|
||||
lodsb
|
||||
or al,al
|
||||
jnz skip_macro_comment
|
||||
add esi,5
|
||||
jmp find_macro_instructions
|
||||
macro_instructions_start:
|
||||
mov edi,[current_line_end]
|
||||
mov [current_line],edi
|
||||
mov eax,[esp]
|
||||
stosd
|
||||
mov al,20h
|
||||
stosb
|
||||
inc dword [esp]
|
||||
mov [macro_directive_allowed],1
|
||||
macro_process:
|
||||
lodsb
|
||||
stosb
|
||||
mov ebx,edi
|
||||
mov edi,special_characters+1
|
||||
movzx ecx,[special_characters]
|
||||
repne scasb
|
||||
mov edi,ebx
|
||||
je special_character
|
||||
cmp al,27h
|
||||
je skip_string
|
||||
dec esi
|
||||
dec edi
|
||||
push edi
|
||||
mov edi,[symbols_list]
|
||||
mov ebx,edi
|
||||
mov edx,esi
|
||||
check_macro_variable:
|
||||
movzx ecx,byte [edi]
|
||||
jecxz no_macro_variable
|
||||
inc edi
|
||||
mov ebp,edi
|
||||
add ebp,ecx
|
||||
repe cmpsb
|
||||
jnz next_macro_variable
|
||||
mov al,[esi]
|
||||
mov ebx,edi
|
||||
mov edi,special_characters+1
|
||||
movzx ecx,[special_characters]
|
||||
repne scasb
|
||||
mov edi,ebx
|
||||
jne next_macro_variable
|
||||
pop edi
|
||||
mov ebx,ebp
|
||||
movzx ecx,byte [ebx]
|
||||
inc ebx
|
||||
copy_macro_variable:
|
||||
mov al,[ebx]
|
||||
inc ebx
|
||||
stosb
|
||||
loop copy_macro_variable
|
||||
jmp macro_process
|
||||
next_macro_variable:
|
||||
mov edi,ebp
|
||||
movzx ecx,byte [edi]
|
||||
inc edi
|
||||
add edi,ecx
|
||||
mov esi,edx
|
||||
jmp check_macro_variable
|
||||
no_macro_variable:
|
||||
pop edi
|
||||
mov edx,esi
|
||||
mov ebp,edi
|
||||
check_for_macro_directive:
|
||||
lodsb
|
||||
stosb
|
||||
mov ebx,edi
|
||||
mov edi,special_characters+1
|
||||
movzx ecx,[special_characters]
|
||||
repne scasb
|
||||
mov edi,ebx
|
||||
jne check_for_macro_directive
|
||||
dec esi
|
||||
mov ecx,esi
|
||||
sub ecx,edx
|
||||
push esi
|
||||
cmp [macro_directive_allowed],1
|
||||
jne no_macro_directive
|
||||
cmp byte [esi],':'
|
||||
je no_macro_directive
|
||||
mov [macro_directive_allowed],0
|
||||
push edi ebp
|
||||
mov esi,edx
|
||||
mov edi,macro_directives
|
||||
call get_instruction
|
||||
pop ebp edi
|
||||
jc no_macro_directive
|
||||
add esp,4
|
||||
mov edi,ebp
|
||||
jmp ebx
|
||||
local_symbols:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je local_symbols
|
||||
or al,al
|
||||
jz invalid_argument
|
||||
cmp al,';'
|
||||
je invalid_argument
|
||||
lea edx,[esi-1]
|
||||
get_local_name:
|
||||
mov ebx,edi
|
||||
mov edi,special_characters+1
|
||||
movzx ecx,[special_characters]
|
||||
repne scasb
|
||||
mov edi,ebx
|
||||
je local_name_end
|
||||
lodsb
|
||||
jmp get_local_name
|
||||
local_name_end:
|
||||
dec esi
|
||||
mov ecx,esi
|
||||
sub ecx,edx
|
||||
or ecx,ecx
|
||||
jz invalid_argument
|
||||
cmp ecx,100h
|
||||
jae name_too_long
|
||||
push edi
|
||||
mov edi,[symbols_list]
|
||||
sub edi,2
|
||||
sub edi,ecx
|
||||
sub edi,5
|
||||
cmp edi,[additional_memory]
|
||||
jbe out_of_memory
|
||||
mov [symbols_list],edi
|
||||
mov al,cl
|
||||
stosb
|
||||
mov esi,edx
|
||||
rep movsb
|
||||
mov al,5
|
||||
stosb
|
||||
mov al,'?'
|
||||
stosb
|
||||
mov eax,[locals_counter]
|
||||
stosd
|
||||
pop edi
|
||||
inc byte [locals_counter+3]
|
||||
cmp byte [locals_counter+3],'9'
|
||||
jbe find_next_local_name
|
||||
mov byte [locals_counter+3],'0'
|
||||
inc byte [locals_counter+2]
|
||||
cmp byte [locals_counter+2],'9'
|
||||
jbe find_next_local_name
|
||||
mov byte [locals_counter+2],'0'
|
||||
inc byte [locals_counter+1]
|
||||
cmp byte [locals_counter+1],'9'
|
||||
jbe find_next_local_name
|
||||
mov byte [locals_counter+1],'0'
|
||||
inc byte [locals_counter]
|
||||
find_next_local_name:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je find_next_local_name
|
||||
cmp al,','
|
||||
je local_symbols
|
||||
or al,al
|
||||
jz macro_directive_end
|
||||
cmp al,';'
|
||||
je macro_directive_comment
|
||||
jmp invalid_argument
|
||||
macro_directive_comment:
|
||||
lodsb
|
||||
or al,al
|
||||
jnz macro_directive_comment
|
||||
macro_directive_end:
|
||||
stosb
|
||||
jmp next_macro_line
|
||||
no_macro_directive:
|
||||
pop esi
|
||||
lodsb
|
||||
jmp special_character
|
||||
skip_string:
|
||||
lodsb
|
||||
stosb
|
||||
or al,al
|
||||
jz missing_end_quote
|
||||
cmp al,27h
|
||||
jne skip_string
|
||||
lodsb
|
||||
stosb
|
||||
cmp al,27h
|
||||
je skip_string
|
||||
dec esi
|
||||
dec edi
|
||||
jmp macro_process
|
||||
skip_comment:
|
||||
lodsb
|
||||
stosb
|
||||
or al,al
|
||||
jnz skip_comment
|
||||
jmp next_macro_line
|
||||
special_character:
|
||||
cmp al,';'
|
||||
je skip_comment
|
||||
or al,al
|
||||
jnz check_for_end
|
||||
next_macro_line:
|
||||
add esi,5
|
||||
mov [current_line_end],edi
|
||||
mov ebp,[esp+4]
|
||||
call preprocess_instruction
|
||||
mov [current_line],edi
|
||||
mov eax,[esp]
|
||||
stosd
|
||||
mov al,20h
|
||||
stosb
|
||||
inc dword [esp]
|
||||
mov [macro_directive_allowed],1
|
||||
jmp macro_process
|
||||
check_for_end:
|
||||
cmp al,'}'
|
||||
jne macro_process
|
||||
dec edi
|
||||
xor al,al
|
||||
stosb
|
||||
mov [current_line_end],edi
|
||||
mov ecx,[esp+14h]
|
||||
mov ebp,[esp+8]
|
||||
call preprocess_instruction
|
||||
add esp,4
|
||||
pop [symbols_list]
|
||||
pop ebp
|
||||
pop [current_line]
|
||||
pop esi ecx
|
||||
ret
|
||||
HF_directive:
|
||||
mov edx,[current_line]
|
||||
mov byte [edx+4],':'
|
||||
mov [program_format],48h
|
||||
pop ebp edi esi ecx
|
||||
ret
|
||||
|
||||
file_number db 0
|
||||
files_list dd 0
|
||||
macro_directive_allowed db 0
|
||||
locals_counter dd '0000'
|
||||
169
SOURCE/SYMBOLS.INC
Normal file
169
SOURCE/SYMBOLS.INC
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
|
||||
create_symbol:
|
||||
cmp ecx,256
|
||||
jae name_too_long
|
||||
push esi edi
|
||||
push eax edx
|
||||
mov esi,ebx
|
||||
push esi ecx
|
||||
call check_symbol_name
|
||||
cmp byte [esi],'.'
|
||||
je section_ok
|
||||
inc [current_section]
|
||||
section_ok:
|
||||
mov ecx,[esp]
|
||||
call get_symbol
|
||||
cmp cl,1
|
||||
jbe add_symbol
|
||||
cmp cl,3
|
||||
jne reserved_word_used_as_symbol
|
||||
add esp,8
|
||||
mov al,[current_pass]
|
||||
cmp al,[ebx+9]
|
||||
je symbol_already_defined
|
||||
mov [ebx+9],al
|
||||
pop edx eax
|
||||
cmp [ebx],eax
|
||||
jne redefine_symbol
|
||||
cmp [ebx+4],edx
|
||||
jne redefine_symbol
|
||||
pop edi esi
|
||||
ret
|
||||
redefine_symbol:
|
||||
mov [ebx],eax
|
||||
mov [ebx+4],edx
|
||||
mov [next_pass_needed],1
|
||||
pop edi esi
|
||||
ret
|
||||
add_symbol:
|
||||
pop ecx esi
|
||||
mov edi,[symbols_list]
|
||||
sub edi,ecx
|
||||
sub edi,16
|
||||
lea ebx,[edi-1]
|
||||
mov [ebx],cl
|
||||
rep movsb
|
||||
mov [symbols_list],ebx
|
||||
mov ebx,edi
|
||||
mov eax,[current_section]
|
||||
mov [ebx+Ch],eax
|
||||
mov al,[current_pass]
|
||||
mov [ebx+9],al
|
||||
pop edx eax
|
||||
mov [ebx],eax
|
||||
mov [ebx+4],edx
|
||||
pop edi esi
|
||||
cmp ebx,edi
|
||||
jbe out_of_memory
|
||||
ret
|
||||
check_symbol_name:
|
||||
cmp [current_pass],0
|
||||
jne symbol_name_ok
|
||||
mov ebp,edi
|
||||
call get_number
|
||||
jnc illegal_instruction
|
||||
mov edi,general_registers
|
||||
call get_register
|
||||
jnc reserved_word_used_as_symbol
|
||||
mov edi,segment_registers
|
||||
call get_register
|
||||
jnc reserved_word_used_as_symbol
|
||||
mov edi,control_registers
|
||||
call get_register
|
||||
jnc reserved_word_used_as_symbol
|
||||
mov edi,debug_registers
|
||||
call get_register
|
||||
jnc reserved_word_used_as_symbol
|
||||
mov edi,fpu_registers
|
||||
call get_register
|
||||
jnc reserved_word_used_as_symbol
|
||||
mov edi,size_operators
|
||||
call get_operator
|
||||
or al,al
|
||||
jnz reserved_word_used_as_symbol
|
||||
mov edi,single_operand_operators
|
||||
call get_operator
|
||||
or al,al
|
||||
jnz reserved_word_used_as_symbol
|
||||
mov edi,jump_operators
|
||||
call get_operator
|
||||
or al,al
|
||||
jnz reserved_word_used_as_symbol
|
||||
cmp ecx,1
|
||||
jne symbol_name_ok
|
||||
cmp byte [esi],'$'
|
||||
je reserved_word_used_as_symbol
|
||||
symbol_name_ok:
|
||||
ret
|
||||
get_symbol:
|
||||
cmp cl,1
|
||||
jne get_symbol_from_list
|
||||
cmp byte [esi],'$'
|
||||
jne get_symbol_from_list
|
||||
mov al,[esi+1]
|
||||
mov edi,special_characters+1
|
||||
movzx ecx,[special_characters]
|
||||
repne scasb
|
||||
jne get_symbol_from_list
|
||||
inc esi
|
||||
mov eax,[current_offset]
|
||||
sub eax,[org_start]
|
||||
xor edx,edx
|
||||
mov cl,2
|
||||
ret
|
||||
get_symbol_from_list:
|
||||
mov edi,[symbols_list]
|
||||
mov edx,esi
|
||||
mov ebp,ecx
|
||||
check_symbol:
|
||||
mov esi,edx
|
||||
movzx eax,byte [edi]
|
||||
or al,al
|
||||
jz no_symbol
|
||||
mov ecx,ebp
|
||||
inc edi
|
||||
mov ebx,edi
|
||||
add ebx,eax
|
||||
cmp cl,al
|
||||
jne next_symbol
|
||||
mov ah,[esi]
|
||||
repe cmpsb
|
||||
je symbol_found
|
||||
next_symbol:
|
||||
mov edi,ebx
|
||||
add edi,16
|
||||
jmp check_symbol
|
||||
no_symbol:
|
||||
mov esi,edx
|
||||
cmp [current_pass],0
|
||||
je no_symbol_yet
|
||||
symbol_undefined:
|
||||
xor cl,cl
|
||||
ret
|
||||
no_symbol_yet:
|
||||
mov esi,edx
|
||||
add esi,ebp
|
||||
xor eax,eax
|
||||
xor edx,edx
|
||||
mov cl,1
|
||||
ret
|
||||
symbol_found:
|
||||
cmp ah,'.'
|
||||
jne symbol_ok
|
||||
mov eax,[edi+Ch]
|
||||
cmp eax,[current_section]
|
||||
jne next_symbol
|
||||
symbol_ok:
|
||||
mov ebx,edi
|
||||
cmp [operand_size],0
|
||||
jne operand_size_ok
|
||||
mov al,[ebx+8]
|
||||
mov [operand_size],al
|
||||
operand_size_ok:
|
||||
mov eax,[ebx]
|
||||
mov edx,[ebx+4]
|
||||
mov cl,3
|
||||
ret
|
||||
|
||||
symbols_list dd 0
|
||||
current_section dd 0
|
||||
898
SOURCE/TABLES.INC
Normal file
898
SOURCE/TABLES.INC
Normal file
|
|
@ -0,0 +1,898 @@
|
|||
|
||||
get_operator:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je get_operator
|
||||
dec esi
|
||||
mov edx,esi
|
||||
check_operator:
|
||||
mov esi,edx
|
||||
movzx ecx,byte [edi]
|
||||
jecxz no_operator
|
||||
inc edi
|
||||
mov ebx,edi
|
||||
add ebx,ecx
|
||||
mov eax,ecx
|
||||
repe cmpsb
|
||||
je operator_found
|
||||
mov edi,ebx
|
||||
inc edi
|
||||
jmp check_operator
|
||||
no_operator:
|
||||
xor al,al
|
||||
mov esi,edx
|
||||
ret
|
||||
operator_found:
|
||||
mov ebx,edi
|
||||
cmp eax,1
|
||||
je operator_ok
|
||||
mov al,[esi]
|
||||
mov edi,special_characters+1
|
||||
movzx ecx,[special_characters]
|
||||
repne scasb
|
||||
jne no_operator
|
||||
operator_ok:
|
||||
mov al,[ebx]
|
||||
ret
|
||||
get_register:
|
||||
lodsb
|
||||
cmp al,20h
|
||||
je get_register
|
||||
dec esi
|
||||
mov edx,esi
|
||||
check_register:
|
||||
mov esi,edx
|
||||
movzx ecx,byte [edi]
|
||||
jecxz no_register
|
||||
inc edi
|
||||
mov ebx,edi
|
||||
add ebx,ecx
|
||||
mov eax,ecx
|
||||
repe cmpsb
|
||||
je register_found
|
||||
next_register:
|
||||
mov edi,ebx
|
||||
inc edi
|
||||
jmp check_register
|
||||
no_register:
|
||||
mov esi,edx
|
||||
stc
|
||||
ret
|
||||
register_found:
|
||||
mov ebx,edi
|
||||
mov al,[esi]
|
||||
mov edi,special_characters+1
|
||||
movzx ecx,[special_characters]
|
||||
repne scasb
|
||||
jne next_register
|
||||
mov al,[ebx]
|
||||
clc
|
||||
ret
|
||||
get_instruction:
|
||||
mov edx,esi
|
||||
mov ebp,ecx
|
||||
check_instruction:
|
||||
mov esi,edx
|
||||
movzx eax,byte [edi]
|
||||
or al,al
|
||||
jz no_instruction
|
||||
mov ecx,ebp
|
||||
inc edi
|
||||
mov ebx,edi
|
||||
add ebx,eax
|
||||
cmp cl,al
|
||||
jne next_instruction
|
||||
repe cmpsb
|
||||
je instruction_ok
|
||||
next_instruction:
|
||||
mov edi,ebx
|
||||
add edi,5
|
||||
jmp check_instruction
|
||||
no_instruction:
|
||||
mov esi,edx
|
||||
stc
|
||||
ret
|
||||
instruction_ok:
|
||||
mov al,[ebx]
|
||||
mov ebx,[ebx+1]
|
||||
clc
|
||||
ret
|
||||
|
||||
special_characters db 16
|
||||
db 0,' +-/*:=()[]{},;'
|
||||
|
||||
operators:
|
||||
db 1,'+',10h
|
||||
db 1,'-',11h
|
||||
db 1,'*',20h
|
||||
db 1,'/',21h
|
||||
db 3,'mod',30h
|
||||
db 3,'and',40h
|
||||
db 2,'or',41h
|
||||
db 3,'xor',42h
|
||||
db 3,'shl',60h
|
||||
db 3,'shr',61h
|
||||
db 0
|
||||
|
||||
single_operand_operators:
|
||||
db 3,'not',50h
|
||||
db 0
|
||||
|
||||
size_operators:
|
||||
db 4,'byte',1
|
||||
db 4,'word',2
|
||||
db 5,'dword',4
|
||||
db 5,'pword',6
|
||||
db 5,'qword',8
|
||||
db 5,'tbyte',10
|
||||
db 0
|
||||
|
||||
jump_operators:
|
||||
db 4,'near',1
|
||||
db 3,'far',2
|
||||
db 0
|
||||
|
||||
special_operators:
|
||||
db 2,'at',1
|
||||
db 0
|
||||
|
||||
code_types:
|
||||
db 2,'16',16
|
||||
db 2,'32',32
|
||||
db 0
|
||||
|
||||
index_registers:
|
||||
db 3,'eax',40h
|
||||
db 3,'ecx',41h
|
||||
db 3,'edx',42h
|
||||
db 3,'ebx',43h
|
||||
db 3,'esp',44h
|
||||
db 3,'ebp',45h
|
||||
db 3,'esi',46h
|
||||
db 3,'edi',47h
|
||||
db 2,'bx',23h
|
||||
db 2,'bp',25h
|
||||
db 2,'si',26h
|
||||
db 2,'di',27h
|
||||
db 0
|
||||
|
||||
general_registers:
|
||||
db 3,'eax',40h
|
||||
db 3,'ecx',41h
|
||||
db 3,'edx',42h
|
||||
db 3,'ebx',43h
|
||||
db 3,'esp',44h
|
||||
db 3,'ebp',45h
|
||||
db 3,'esi',46h
|
||||
db 3,'edi',47h
|
||||
db 2,'al',10h
|
||||
db 2,'cl',11h
|
||||
db 2,'dl',12h
|
||||
db 2,'bl',13h
|
||||
db 2,'ah',14h
|
||||
db 2,'ch',15h
|
||||
db 2,'dh',16h
|
||||
db 2,'bh',17h
|
||||
db 2,'ax',20h
|
||||
db 2,'cx',21h
|
||||
db 2,'dx',22h
|
||||
db 2,'bx',23h
|
||||
db 2,'sp',24h
|
||||
db 2,'bp',25h
|
||||
db 2,'si',26h
|
||||
db 2,'di',27h
|
||||
db 0
|
||||
|
||||
segment_registers:
|
||||
db 2,'es',1
|
||||
db 2,'cs',2
|
||||
db 2,'ss',3
|
||||
db 2,'ds',4
|
||||
db 2,'fs',5
|
||||
db 2,'gs',6
|
||||
db 0
|
||||
|
||||
control_registers:
|
||||
db 3,'cr0',0
|
||||
db 3,'cr2',2
|
||||
db 3,'cr3',3
|
||||
db 3,'cr4',4
|
||||
db 0
|
||||
|
||||
debug_registers:
|
||||
db 3,'dr0',0
|
||||
db 3,'dr1',1
|
||||
db 3,'dr2',2
|
||||
db 3,'dr3',3
|
||||
db 3,'dr5',5
|
||||
db 3,'dr6',6
|
||||
db 3,'dr7',7
|
||||
db 0
|
||||
|
||||
fpu_registers:
|
||||
db 2,'st',0
|
||||
db 3,'st0',0
|
||||
db 3,'st1',1
|
||||
db 3,'st2',2
|
||||
db 3,'st3',3
|
||||
db 3,'st4',4
|
||||
db 3,'st5',5
|
||||
db 3,'st6',6
|
||||
db 3,'st7',7
|
||||
db 0
|
||||
|
||||
preprocessor_directives:
|
||||
db 7,'include',0
|
||||
dd include_file
|
||||
db 5,'macro',0
|
||||
dd define_macro
|
||||
db 2,'HF',0
|
||||
dd HF_directive
|
||||
db 0
|
||||
|
||||
macro_directives:
|
||||
db 5,'local',0
|
||||
dd local_symbols
|
||||
db 0
|
||||
|
||||
instructions:
|
||||
db 3,'mov',0
|
||||
dd mov_instruction
|
||||
db 3,'cmp',38h
|
||||
dd basic_instruction
|
||||
db 3,'sub',28h
|
||||
dd basic_instruction
|
||||
db 3,'add',00h
|
||||
dd basic_instruction
|
||||
db 3,'int',CDh
|
||||
dd int_instruction
|
||||
db 4,'int3',CCh
|
||||
dd simple_instruction
|
||||
db 4,'into',CEh
|
||||
dd simple_instruction
|
||||
db 4,'iret',CFh
|
||||
dd simple_instruction
|
||||
db 5,'iretw',CFh
|
||||
dd simple_instruction_16bit
|
||||
db 5,'iretd',CFh
|
||||
dd simple_instruction_32bit
|
||||
db 2,'or',08h
|
||||
dd basic_instruction
|
||||
db 3,'adc',10h
|
||||
dd basic_instruction
|
||||
db 3,'sbb',18h
|
||||
dd basic_instruction
|
||||
db 3,'and',20h
|
||||
dd basic_instruction
|
||||
db 3,'xor',30h
|
||||
dd basic_instruction
|
||||
db 3,'daa',27h
|
||||
dd simple_instruction
|
||||
db 3,'das',2Fh
|
||||
dd simple_instruction
|
||||
db 3,'aaa',37h
|
||||
dd simple_instruction
|
||||
db 3,'aas',3Fh
|
||||
dd simple_instruction
|
||||
db 5,'pusha',60h
|
||||
dd simple_instruction
|
||||
db 4,'popa',61h
|
||||
dd simple_instruction
|
||||
db 6,'pushaw',60h
|
||||
dd simple_instruction_16bit
|
||||
db 5,'popaw',61h
|
||||
dd simple_instruction_16bit
|
||||
db 6,'pushad',60h
|
||||
dd simple_instruction_32bit
|
||||
db 5,'popad',61h
|
||||
dd simple_instruction_32bit
|
||||
db 3,'ins',0
|
||||
dd ins_instruction
|
||||
db 4,'insb',6Ch
|
||||
dd simple_instruction
|
||||
db 4,'insw',6Dh
|
||||
dd simple_instruction_16bit
|
||||
db 4,'insd',6Dh
|
||||
dd simple_instruction_32bit
|
||||
db 4,'outs',0
|
||||
dd outs_instruction
|
||||
db 5,'outsb',6Eh
|
||||
dd simple_instruction
|
||||
db 5,'outsw',6Fh
|
||||
dd simple_instruction_16bit
|
||||
db 5,'outsd',6Fh
|
||||
dd simple_instruction_32bit
|
||||
db 3,'nop',90h
|
||||
dd simple_instruction
|
||||
db 4,'wait',9Bh
|
||||
dd simple_instruction
|
||||
db 5,'pushf',9Ch
|
||||
dd simple_instruction
|
||||
db 6,'pushfw',9Ch
|
||||
dd simple_instruction_16bit
|
||||
db 6,'pushfd',9Ch
|
||||
dd simple_instruction_32bit
|
||||
db 4,'popf',9Dh
|
||||
dd simple_instruction
|
||||
db 5,'popfw',9Dh
|
||||
dd simple_instruction_16bit
|
||||
db 5,'popfd',9Dh
|
||||
dd simple_instruction_32bit
|
||||
db 4,'sahf',9Eh
|
||||
dd simple_instruction
|
||||
db 4,'lahf',9Fh
|
||||
dd simple_instruction
|
||||
db 3,'cbw',98h
|
||||
dd simple_instruction_16bit
|
||||
db 4,'cwde',98h
|
||||
dd simple_instruction_32bit
|
||||
db 3,'cwd',99h
|
||||
dd simple_instruction_16bit
|
||||
db 3,'cdq',99h
|
||||
dd simple_instruction_32bit
|
||||
db 4,'movs',0
|
||||
dd movs_instruction
|
||||
db 5,'movsb',A4h
|
||||
dd simple_instruction
|
||||
db 5,'movsw',A5h
|
||||
dd simple_instruction_16bit
|
||||
db 5,'movsd',A5h
|
||||
dd simple_instruction_32bit
|
||||
db 4,'cmps',0
|
||||
dd cmps_instruction
|
||||
db 5,'cmpsb',A6h
|
||||
dd simple_instruction
|
||||
db 5,'cmpsw',A7h
|
||||
dd simple_instruction_16bit
|
||||
db 5,'cmpsd',A7h
|
||||
dd simple_instruction_32bit
|
||||
db 4,'stos',AAh
|
||||
dd stos_instruction
|
||||
db 5,'stosb',AAh
|
||||
dd simple_instruction
|
||||
db 5,'stosw',ABh
|
||||
dd simple_instruction_16bit
|
||||
db 5,'stosd',ABh
|
||||
dd simple_instruction_32bit
|
||||
db 4,'lods',0
|
||||
dd lods_instruction
|
||||
db 5,'lodsb',ACh
|
||||
dd simple_instruction
|
||||
db 5,'lodsw',ADh
|
||||
dd simple_instruction_16bit
|
||||
db 5,'lodsd',ADh
|
||||
dd simple_instruction_32bit
|
||||
db 4,'scas',AEh
|
||||
dd stos_instruction
|
||||
db 5,'scasb',AEh
|
||||
dd simple_instruction
|
||||
db 5,'scasw',AFh
|
||||
dd simple_instruction_16bit
|
||||
db 5,'scasd',AFh
|
||||
dd simple_instruction_32bit
|
||||
db 4,'xlat',D7h
|
||||
dd simple_instruction
|
||||
db 4,'lock',F0h
|
||||
dd prefix_instruction
|
||||
db 3,'rep',F3h
|
||||
dd prefix_instruction
|
||||
db 4,'repe',F3h
|
||||
dd prefix_instruction
|
||||
db 4,'repz',F3h
|
||||
dd prefix_instruction
|
||||
db 5,'repne',F2h
|
||||
dd prefix_instruction
|
||||
db 5,'repnz',F2h
|
||||
dd prefix_instruction
|
||||
db 3,'hlt',F4h
|
||||
dd simple_instruction
|
||||
db 3,'cmc',F5h
|
||||
dd simple_instruction
|
||||
db 3,'clc',F8h
|
||||
dd simple_instruction
|
||||
db 3,'stc',F9h
|
||||
dd simple_instruction
|
||||
db 3,'cli',FAh
|
||||
dd simple_instruction
|
||||
db 3,'sti',FBh
|
||||
dd simple_instruction
|
||||
db 3,'cld',FCh
|
||||
dd simple_instruction
|
||||
db 3,'std',FDh
|
||||
dd simple_instruction
|
||||
db 4,'push',0
|
||||
dd push_instruction
|
||||
db 3,'pop',0
|
||||
dd pop_instruction
|
||||
db 3,'inc',0
|
||||
dd inc_instruction
|
||||
db 3,'dec',1
|
||||
dd inc_instruction
|
||||
db 5,'bound',0
|
||||
dd bound_instruction
|
||||
db 4,'arpl',0
|
||||
dd arpl_instruction
|
||||
db 2,'jo',70h
|
||||
dd conditional_jump
|
||||
db 3,'jno',71h
|
||||
dd conditional_jump
|
||||
db 2,'jc',72h
|
||||
dd conditional_jump
|
||||
db 2,'jb',72h
|
||||
dd conditional_jump
|
||||
db 4,'jnae',72h
|
||||
dd conditional_jump
|
||||
db 3,'jnc',73h
|
||||
dd conditional_jump
|
||||
db 3,'jnb',73h
|
||||
dd conditional_jump
|
||||
db 3,'jae',73h
|
||||
dd conditional_jump
|
||||
db 2,'je',74h
|
||||
dd conditional_jump
|
||||
db 2,'jz',74h
|
||||
dd conditional_jump
|
||||
db 3,'jne',75h
|
||||
dd conditional_jump
|
||||
db 3,'jnz',75h
|
||||
dd conditional_jump
|
||||
db 3,'jna',76h
|
||||
dd conditional_jump
|
||||
db 3,'jbe',76h
|
||||
dd conditional_jump
|
||||
db 2,'ja',77h
|
||||
dd conditional_jump
|
||||
db 4,'jnbe',77h
|
||||
dd conditional_jump
|
||||
db 2,'js',78h
|
||||
dd conditional_jump
|
||||
db 3,'jns',79h
|
||||
dd conditional_jump
|
||||
db 2,'jp',7Ah
|
||||
dd conditional_jump
|
||||
db 3,'jpe',7Ah
|
||||
dd conditional_jump
|
||||
db 3,'jnp',7Bh
|
||||
dd conditional_jump
|
||||
db 3,'jpo',7Bh
|
||||
dd conditional_jump
|
||||
db 2,'jl',7Ch
|
||||
dd conditional_jump
|
||||
db 4,'jnge',7Ch
|
||||
dd conditional_jump
|
||||
db 3,'jnl',7Dh
|
||||
dd conditional_jump
|
||||
db 3,'jge',7Dh
|
||||
dd conditional_jump
|
||||
db 3,'jng',7Eh
|
||||
dd conditional_jump
|
||||
db 3,'jle',7Eh
|
||||
dd conditional_jump
|
||||
db 2,'jg',7Fh
|
||||
dd conditional_jump
|
||||
db 4,'jnle',7Fh
|
||||
dd conditional_jump
|
||||
db 4,'jcxz',0
|
||||
dd jcxz_instruction
|
||||
db 5,'jecxz',0
|
||||
dd jecxz_instruction
|
||||
db 4,'loop',E2h
|
||||
dd loop_instruction
|
||||
db 5,'loope',E1h
|
||||
dd loop_instruction
|
||||
db 5,'loopz',E1h
|
||||
dd loop_instruction
|
||||
db 6,'loopne',E0h
|
||||
dd loop_instruction
|
||||
db 6,'loopnz',E0h
|
||||
dd loop_instruction
|
||||
db 5,'loopw',E2h
|
||||
dd loop_instruction_16bit
|
||||
db 6,'loopew',E1h
|
||||
dd loop_instruction_16bit
|
||||
db 6,'loopzw',E1h
|
||||
dd loop_instruction_16bit
|
||||
db 7,'loopnew',E0h
|
||||
dd loop_instruction_16bit
|
||||
db 7,'loopnzw',E0h
|
||||
dd loop_instruction_16bit
|
||||
db 5,'loopd',E2h
|
||||
dd loop_instruction_32bit
|
||||
db 6,'looped',E1h
|
||||
dd loop_instruction_32bit
|
||||
db 6,'loopzd',E1h
|
||||
dd loop_instruction_32bit
|
||||
db 7,'loopned',E0h
|
||||
dd loop_instruction_32bit
|
||||
db 7,'loopnzd',E0h
|
||||
dd loop_instruction_32bit
|
||||
db 4,'call',0
|
||||
dd call_instruction
|
||||
db 3,'jmp',0
|
||||
dd jmp_instruction
|
||||
db 3,'ret',0
|
||||
dd ret_instruction
|
||||
db 4,'retn',0
|
||||
dd ret_instruction
|
||||
db 4,'retf',0
|
||||
dd retf_instruction
|
||||
db 4,'test',0
|
||||
dd test_instruction
|
||||
db 4,'xchg',0
|
||||
dd xchg_instruction
|
||||
db 3,'lea',0
|
||||
dd lea_instruction
|
||||
db 3,'les',0
|
||||
dd ls_instruction
|
||||
db 3,'lcs',1
|
||||
dd ls_instruction
|
||||
db 3,'lss',2
|
||||
dd ls_instruction
|
||||
db 3,'lds',3
|
||||
dd ls_instruction
|
||||
db 3,'lfs',4
|
||||
dd ls_instruction
|
||||
db 3,'lgs',5
|
||||
dd ls_instruction
|
||||
db 5,'enter',0
|
||||
dd enter_instruction
|
||||
db 5,'leave',C9h
|
||||
dd simple_instruction
|
||||
db 3,'not',2
|
||||
dd single_operand_instruction
|
||||
db 3,'neg',3
|
||||
dd single_operand_instruction
|
||||
db 3,'mul',4
|
||||
dd single_operand_instruction
|
||||
db 3,'div',6
|
||||
dd single_operand_instruction
|
||||
db 4,'idiv',7
|
||||
dd single_operand_instruction
|
||||
db 4,'imul',0
|
||||
dd imul_instruction
|
||||
db 3,'rol',0
|
||||
dd sh_instruction
|
||||
db 3,'ror',1
|
||||
dd sh_instruction
|
||||
db 3,'rcl',2
|
||||
dd sh_instruction
|
||||
db 3,'rcr',3
|
||||
dd sh_instruction
|
||||
db 3,'shl',4
|
||||
dd sh_instruction
|
||||
db 3,'shr',5
|
||||
dd sh_instruction
|
||||
db 3,'sal',6
|
||||
dd sh_instruction
|
||||
db 3,'sar',7
|
||||
dd sh_instruction
|
||||
db 2,'in',0
|
||||
dd in_instruction
|
||||
db 3,'out',0
|
||||
dd out_instruction
|
||||
db 4,'seto',90h
|
||||
dd set_instruction
|
||||
db 5,'setno',91h
|
||||
dd set_instruction
|
||||
db 4,'setc',92h
|
||||
dd set_instruction
|
||||
db 4,'setb',92h
|
||||
dd set_instruction
|
||||
db 6,'setnae',92h
|
||||
dd set_instruction
|
||||
db 5,'setnc',93h
|
||||
dd set_instruction
|
||||
db 5,'setnb',93h
|
||||
dd set_instruction
|
||||
db 5,'setae',93h
|
||||
dd set_instruction
|
||||
db 4,'sete',94h
|
||||
dd set_instruction
|
||||
db 4,'setz',94h
|
||||
dd set_instruction
|
||||
db 5,'setne',95h
|
||||
dd set_instruction
|
||||
db 5,'setnz',95h
|
||||
dd set_instruction
|
||||
db 5,'setna',96h
|
||||
dd set_instruction
|
||||
db 5,'setbe',96h
|
||||
dd set_instruction
|
||||
db 4,'seta',97h
|
||||
dd set_instruction
|
||||
db 6,'setnbe',97h
|
||||
dd set_instruction
|
||||
db 4,'sets',98h
|
||||
dd set_instruction
|
||||
db 5,'setns',99h
|
||||
dd set_instruction
|
||||
db 4,'setp',9Ah
|
||||
dd set_instruction
|
||||
db 5,'setpe',9Ah
|
||||
dd set_instruction
|
||||
db 5,'setnp',9Bh
|
||||
dd set_instruction
|
||||
db 5,'setpo',9Bh
|
||||
dd set_instruction
|
||||
db 4,'setl',9Ch
|
||||
dd set_instruction
|
||||
db 6,'setnge',9Ch
|
||||
dd set_instruction
|
||||
db 5,'setnl',9Dh
|
||||
dd set_instruction
|
||||
db 5,'setge',9Dh
|
||||
dd set_instruction
|
||||
db 5,'setng',9Eh
|
||||
dd set_instruction
|
||||
db 5,'setle',9Eh
|
||||
dd set_instruction
|
||||
db 4,'setg',9Fh
|
||||
dd set_instruction
|
||||
db 6,'setnle',9Fh
|
||||
dd set_instruction
|
||||
db 4,'shld',A4h
|
||||
dd shd_instruction
|
||||
db 4,'shrd',ACh
|
||||
dd shd_instruction
|
||||
db 5,'movzx',B6h
|
||||
dd movx_instruction
|
||||
db 5,'movsx',BEh
|
||||
dd movx_instruction
|
||||
db 6,'setalc',D6h
|
||||
dd simple_instruction
|
||||
db 2,'bt',4
|
||||
dd bt_instruction
|
||||
db 3,'bts',5
|
||||
dd bt_instruction
|
||||
db 3,'btr',6
|
||||
dd bt_instruction
|
||||
db 3,'btc',7
|
||||
dd bt_instruction
|
||||
db 3,'bsf',BCh
|
||||
dd bs_instruction
|
||||
db 3,'bsr',BDh
|
||||
dd bs_instruction
|
||||
db 4,'clts',6
|
||||
dd simple_extended_instruction
|
||||
db 4,'invd',8
|
||||
dd simple_extended_instruction
|
||||
db 6,'wbinvd',9
|
||||
dd simple_extended_instruction
|
||||
db 5,'wrmsr',30h
|
||||
dd simple_extended_instruction
|
||||
db 5,'rdtsc',31h
|
||||
dd simple_extended_instruction
|
||||
db 5,'rdmsr',32h
|
||||
dd simple_extended_instruction
|
||||
db 3,'rsm',AAh
|
||||
dd simple_extended_instruction
|
||||
db 4,'sldt',0
|
||||
dd pm_word_instruction
|
||||
db 3,'str',1
|
||||
dd pm_word_instruction
|
||||
db 4,'lldt',2
|
||||
dd pm_word_instruction
|
||||
db 3,'ltr',3
|
||||
dd pm_word_instruction
|
||||
db 4,'verr',4
|
||||
dd pm_word_instruction
|
||||
db 4,'verw',5
|
||||
dd pm_word_instruction
|
||||
db 4,'smsw',14h
|
||||
dd pm_word_instruction
|
||||
db 4,'lmsw',16h
|
||||
dd pm_word_instruction
|
||||
db 4,'sgdt',0
|
||||
dd pm_pword_instruction
|
||||
db 4,'sidt',1
|
||||
dd pm_pword_instruction
|
||||
db 4,'lgdt',2
|
||||
dd pm_pword_instruction
|
||||
db 4,'lidt',3
|
||||
dd pm_pword_instruction
|
||||
db 3,'lar',2
|
||||
dd lar_instruction
|
||||
db 3,'lsl',3
|
||||
dd lar_instruction
|
||||
db 6,'invlpg',0
|
||||
dd invlpg_instruction
|
||||
db 7,'cmpxchg',B0h
|
||||
dd basic_486_instruction
|
||||
db 4,'xadd',C0h
|
||||
dd basic_486_instruction
|
||||
db 5,'bswap',0
|
||||
dd bswap_instruction
|
||||
db 9,'cmpxchg8b',0
|
||||
dd cmpxchg8b_instruction
|
||||
db 5,'cpuid',A2h
|
||||
dd simple_extended_instruction
|
||||
db 4,'fadd',0
|
||||
dd basic_fpu_instruction
|
||||
db 4,'fmul',1
|
||||
dd basic_fpu_instruction
|
||||
db 4,'fcom',2
|
||||
dd basic_fpu_instruction
|
||||
db 5,'fcomp',3
|
||||
dd basic_fpu_instruction
|
||||
db 4,'fsub',4
|
||||
dd basic_fpu_instruction
|
||||
db 5,'fsubr',5
|
||||
dd basic_fpu_instruction
|
||||
db 4,'fdiv',6
|
||||
dd basic_fpu_instruction
|
||||
db 5,'fdivr',7
|
||||
dd basic_fpu_instruction
|
||||
db 4,'fnop',010000b
|
||||
dd simple_fpu_instruction
|
||||
db 4,'fchs',100000b
|
||||
dd simple_fpu_instruction
|
||||
db 4,'fabs',100001b
|
||||
dd simple_fpu_instruction
|
||||
db 4,'ftst',100100b
|
||||
dd simple_fpu_instruction
|
||||
db 4,'fxam',100101b
|
||||
dd simple_fpu_instruction
|
||||
db 4,'fld1',101000b
|
||||
dd simple_fpu_instruction
|
||||
db 6,'fldl2t',101001b
|
||||
dd simple_fpu_instruction
|
||||
db 6,'fldl2e',101010b
|
||||
dd simple_fpu_instruction
|
||||
db 5,'fldpi',101011b
|
||||
dd simple_fpu_instruction
|
||||
db 6,'fldlg2',101100b
|
||||
dd simple_fpu_instruction
|
||||
db 6,'fldln2',101101b
|
||||
dd simple_fpu_instruction
|
||||
db 4,'fldz',101110b
|
||||
dd simple_fpu_instruction
|
||||
db 5,'f2xm1',110000b
|
||||
dd simple_fpu_instruction
|
||||
db 5,'fyl2x',110001b
|
||||
dd simple_fpu_instruction
|
||||
db 5,'fptan',110010b
|
||||
dd simple_fpu_instruction
|
||||
db 6,'fpatan',110011b
|
||||
dd simple_fpu_instruction
|
||||
db 7,'fxtract',110100b
|
||||
dd simple_fpu_instruction
|
||||
db 6,'fprem1',110101b
|
||||
dd simple_fpu_instruction
|
||||
db 7,'fdecstp',110110b
|
||||
dd simple_fpu_instruction
|
||||
db 7,'fincstp',110111b
|
||||
dd simple_fpu_instruction
|
||||
db 5,'fprem',111000b
|
||||
dd simple_fpu_instruction
|
||||
db 7,'fyl2xp1',111001b
|
||||
dd simple_fpu_instruction
|
||||
db 5,'fsqrt',111010b
|
||||
dd simple_fpu_instruction
|
||||
db 7,'fsincos',111011b
|
||||
dd simple_fpu_instruction
|
||||
db 7,'frndint',111100b
|
||||
dd simple_fpu_instruction
|
||||
db 6,'fscale',111101b
|
||||
dd simple_fpu_instruction
|
||||
db 4,'fsin',111110b
|
||||
dd simple_fpu_instruction
|
||||
db 4,'fcos',111111b
|
||||
dd simple_fpu_instruction
|
||||
db 5,'fiadd',0
|
||||
dd fi_instruction
|
||||
db 5,'fimul',1
|
||||
dd fi_instruction
|
||||
db 5,'ficom',2
|
||||
dd fi_instruction
|
||||
db 6,'ficomp',3
|
||||
dd fi_instruction
|
||||
db 5,'fisub',4
|
||||
dd fi_instruction
|
||||
db 6,'fisubr',5
|
||||
dd fi_instruction
|
||||
db 5,'fidiv',6
|
||||
dd fi_instruction
|
||||
db 6,'fidivr',7
|
||||
dd fi_instruction
|
||||
db 3,'fld',0
|
||||
dd fld_instruction
|
||||
db 3,'fst',2
|
||||
dd fld_instruction
|
||||
db 4,'fstp',3
|
||||
dd fld_instruction
|
||||
db 4,'fild',0
|
||||
dd fild_instruction
|
||||
db 4,'fist',2
|
||||
dd fild_instruction
|
||||
db 5,'fistp',3
|
||||
dd fild_instruction
|
||||
db 4,'fbld',4
|
||||
dd fbld_instruction
|
||||
db 5,'fbstp',6
|
||||
dd fbld_instruction
|
||||
db 5,'faddp',0
|
||||
dd faddp_instruction
|
||||
db 5,'fmulp',1
|
||||
dd faddp_instruction
|
||||
db 5,'fsubp',4
|
||||
dd faddp_instruction
|
||||
db 6,'fsubrp',5
|
||||
dd faddp_instruction
|
||||
db 5,'fdivp',6
|
||||
dd faddp_instruction
|
||||
db 6,'fdivrp',7
|
||||
dd faddp_instruction
|
||||
db 6,'fcompp',0
|
||||
dd fcompp_instruction
|
||||
db 4,'fxch',1
|
||||
dd fxch_instruction
|
||||
db 5,'ffree',0
|
||||
dd ffree_instruction
|
||||
db 5,'fucom',4
|
||||
dd ffree_instruction
|
||||
db 6,'fucomp',5
|
||||
dd ffree_instruction
|
||||
db 6,'fldenv',4
|
||||
dd fldenv_instruction
|
||||
db 6,'fstenv',6
|
||||
dd fldenv_instruction
|
||||
db 5,'fldcw',5
|
||||
dd fldcw_instruction
|
||||
db 5,'fstcw',7
|
||||
dd fldcw_instruction
|
||||
db 5,'fsave',6
|
||||
dd fsave_instruction
|
||||
db 6,'frstor',4
|
||||
dd fsave_instruction
|
||||
db 5,'fstsw',0
|
||||
dd fstsw_instruction
|
||||
db 5,'fclex',E2h
|
||||
dd finit_instruction
|
||||
db 5,'finit',E3h
|
||||
dd finit_instruction
|
||||
db 2,'es',26h
|
||||
dd prefix_instruction
|
||||
db 2,'cs',2Eh
|
||||
dd prefix_instruction
|
||||
db 2,'ss',36h
|
||||
dd prefix_instruction
|
||||
db 2,'ds',3Eh
|
||||
dd prefix_instruction
|
||||
db 2,'fs',64h
|
||||
dd prefix_instruction
|
||||
db 2,'gs',65h
|
||||
dd prefix_instruction
|
||||
db 3,'org',0
|
||||
dd org_directive
|
||||
db 4,'code',0
|
||||
dd code_directive
|
||||
db 5,'label',0
|
||||
dd label_directive
|
||||
db 5,'times',0
|
||||
dd times_directive
|
||||
db 5,'entry',0
|
||||
dd entry_directive
|
||||
data_instructions:
|
||||
db 2,'db',1
|
||||
dd data_bytes
|
||||
db 2,'dw',2
|
||||
dd data_words
|
||||
db 2,'dd',4
|
||||
dd data_dwords
|
||||
db 2,'dp',6
|
||||
dd data_pwords
|
||||
db 2,'dq',8
|
||||
dd data_qwords
|
||||
db 2,'rb',1
|
||||
dd reserve_bytes
|
||||
db 2,'rw',2
|
||||
dd reserve_words
|
||||
db 2,'rd',4
|
||||
dd reserve_dwords
|
||||
db 2,'rp',6
|
||||
dd reserve_pwords
|
||||
db 2,'rq',8
|
||||
dd reserve_qwords
|
||||
db 4,'file',1
|
||||
dd data_file
|
||||
db 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue