Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 174 → Rev 173

/programs/develop/fasm/trunk/x86_64.inc
114,7 → 114,7
jne invalid_operand
basic_mem:
call get_address
push edx ebx ecx
push edx bx cx
lods byte [esi]
cmp al,','
jne invalid_operand
128,7 → 128,7
lods byte [esi]
call convert_register
mov [postbyte_register],al
pop ecx ebx edx
pop cx bx edx
mov al,ah
cmp al,1
je basic_mem_reg_8bit
160,7 → 160,7
mov al,[base_code]
shr al,3
mov [postbyte_register],al
pop ecx ebx edx
pop cx bx edx
mov [base_code],80h
call store_instruction_with_imm8
jmp instruction_assembled
171,7 → 171,7
mov al,[base_code]
shr al,3
mov [postbyte_register],al
pop ecx ebx edx
pop cx bx edx
cmp [value_type],0
jne basic_mem_imm_16bit_store
cmp [size_declared],0
196,7 → 196,7
mov al,[base_code]
shr al,3
mov [postbyte_register],al
pop ecx ebx edx
pop cx bx edx
cmp [value_type],0
jne basic_mem_imm_32bit_store
cmp [size_declared],0
430,7 → 430,7
jne invalid_operand
mov_mem:
call get_address
push edx ebx ecx
push edx bx cx
lods byte [esi]
cmp al,','
jne invalid_operand
449,7 → 449,7
mov_mem_general_reg:
call convert_register
mov [postbyte_register],al
pop ecx ebx edx
pop cx bx edx
cmp ah,1
je mov_mem_reg_8bit
mov al,ah
542,7 → 542,7
mov_mem_sreg:
sub al,61h
mov [postbyte_register],al
pop ecx ebx edx
pop cx bx edx
mov ah,[operand_size]
or ah,ah
jz mov_mem_sreg_store
575,7 → 575,7
mov byte [value],al
mov [postbyte_register],0
mov [base_code],0C6h
pop ecx ebx edx
pop cx bx edx
call store_instruction_with_imm8
jmp instruction_assembled
mov_mem_imm_16bit:
584,7 → 584,7
mov word [value],ax
mov [postbyte_register],0
mov [base_code],0C7h
pop ecx ebx edx
pop cx bx edx
call store_instruction_with_imm16
jmp instruction_assembled
mov_mem_imm_32bit:
594,7 → 594,7
mov dword [value],eax
mov [postbyte_register],0
mov [base_code],0C7h
pop ecx ebx edx
pop cx bx edx
call store_instruction_with_imm32
jmp instruction_assembled
mov_mem_imm_64bit:
998,7 → 998,7
jne invalid_operand
test_mem:
call get_address
push edx ebx ecx
push edx bx cx
lods byte [esi]
cmp al,','
jne invalid_operand
1012,7 → 1012,7
lods byte [esi]
call convert_register
mov [postbyte_register],al
pop ecx ebx edx
pop cx bx edx
mov al,ah
cmp al,1
je test_mem_reg_8bit
1044,7 → 1044,7
mov byte [value],al
mov [postbyte_register],0
mov [base_code],0F6h
pop ecx ebx edx
pop cx bx edx
call store_instruction_with_imm8
jmp instruction_assembled
test_mem_imm_16bit:
1053,7 → 1053,7
mov word [value],ax
mov [postbyte_register],0
mov [base_code],0F7h
pop ecx ebx edx
pop cx bx edx
call store_instruction_with_imm16
jmp instruction_assembled
test_mem_imm_32bit:
1063,7 → 1063,7
mov dword [value],eax
mov [postbyte_register],0
mov [base_code],0F7h
pop ecx ebx edx
pop cx bx edx
call store_instruction_with_imm32
jmp instruction_assembled
test_mem_imm_64bit:
1200,7 → 1200,7
jne invalid_operand
xchg_mem:
call get_address
push edx ebx ecx
push edx bx cx
lods byte [esi]
cmp al,','
jne invalid_operand
2055,7 → 2055,7
jne invalid_operand
sh_mem:
call get_address
push edx ebx ecx
push edx bx cx
mov al,[operand_size]
push eax
mov [operand_size],0
2072,7 → 2072,7
lods byte [esi]
cmp al,11h
jne invalid_operand
pop eax ecx ebx edx
pop eax cx bx edx
cmp al,1
je sh_mem_cl_8bit
jb sh_mem_cl_nosize
2099,7 → 2099,7
sh_mem_imm_size_ok:
call get_byte_value
mov byte [value],al
pop eax ecx ebx edx
pop eax cx bx edx
cmp al,1
je sh_mem_imm_8bit
jb sh_mem_imm_nosize
2207,7 → 2207,7
jne invalid_operand
shd_mem:
call get_address
push edx ebx ecx
push edx bx cx
lods byte [esi]
cmp al,','
jne invalid_operand
2233,7 → 2233,7
lods byte [esi]
cmp al,11h
jne invalid_operand
pop eax ecx ebx edx
pop eax cx bx edx
call operand_autodetect
inc [extended_code]
call store_instruction
2247,7 → 2247,7
shd_mem_reg_imm_size_ok:
call get_byte_value
mov byte [value],al
pop eax ecx ebx edx
pop eax cx bx edx
call operand_autodetect
call store_instruction_with_imm8
jmp instruction_assembled
2422,7 → 2422,7
cmp al,'['
jne invalid_operand
call get_address
push eax ebx ecx
push eax bx cx
lods byte [esi]
cmp al,','
jne invalid_operand
2440,7 → 2440,7
lods byte [esi]
call convert_register
mov [postbyte_register],al
pop ecx ebx edx
pop cx bx edx
mov al,ah
call operand_autodetect
call store_instruction
2466,7 → 2466,7
jz bt_mem_imm_nosize
call operand_autodetect
bt_mem_imm_store:
pop ecx ebx edx
pop cx bx edx
mov [extended_code],0BAh
call store_instruction_with_imm8
jmp instruction_assembled
2620,12 → 2620,12
jne invalid_operand
imul_reg_mem:
call get_address
push edx ebx ecx
push edx bx cx
cmp byte [esi],','
je imul_reg_mem_imm
mov al,[operand_size]
call operand_autodetect
pop ecx ebx edx
pop cx bx edx
mov [base_code],0Fh
mov [extended_code],0AFh
call store_instruction
2657,7 → 2657,7
cmp ax,80h
jl imul_reg_mem_imm_8bit_store
imul_reg_mem_imm_16bit_store:
pop ecx ebx edx
pop cx bx edx
mov [base_code],69h
call store_instruction_with_imm16
jmp instruction_assembled
2675,7 → 2675,7
cmp eax,80h
jl imul_reg_mem_imm_8bit_store
imul_reg_mem_imm_32bit_store:
pop ecx ebx edx
pop cx bx edx
mov [base_code],69h
call store_instruction_with_imm32
jmp instruction_assembled
2688,7 → 2688,7
jae long_immediate_not_encodable
jmp imul_reg_mem_imm_32bit_ok
imul_reg_mem_imm_8bit_store:
pop ecx ebx edx
pop cx bx edx
mov [base_code],6Bh
call store_instruction_with_imm8
jmp instruction_assembled
3168,9 → 3168,26
stos word [edi]
jmp instruction_assembled
calculate_jump_offset:
add edi,2
call calculate_relative_offset
sub edi,2
cmp [value_undefined],0
jne jump_offset_ok
add eax,dword [org_origin]
adc edx,dword [org_origin+4]
lea ebx,[edi+2]
sub eax,ebx
sbb edx,0
mov bl,[value_type]
or bl,bl
je jump_offset_ok
test bl,1
jnz invalid_use_of_symbol
cmp bl,[labels_type]
jne invalid_use_of_symbol
mov [value_type],0
mov ecx,[symbol_identifier]
cmp ecx,[org_symbol]
je jump_offset_ok
mov [value_type],3
jump_offset_ok:
ret
check_for_short_jump:
cmp [jump_type],1
3593,7 → 3610,7
or bl,ch
jnz invalid_address
mov al,[segment_register]
push eax ebx
push ax bx
lods byte [esi]
cmp al,','
jne invalid_operand
3606,7 → 3623,7
jnz invalid_address
or bl,ch
jnz invalid_address
pop edx eax
pop dx ax
cmp [segment_register],1
ja invalid_address
mov [segment_register],al
3937,7 → 3954,7
cmp al,'['
jne invalid_operand
call get_address
push edx ebx ecx
push edx bx cx
lods byte [esi]
cmp al,','
jne invalid_operand
3948,7 → 3965,7
lods byte [esi]
call convert_register
mov [postbyte_register],al
pop ecx ebx edx
pop cx bx edx
mov al,ah
cmp al,1
je basic_486_mem_reg_8bit
4029,49 → 4046,6
cmpxchgx_store:
call store_instruction
jmp instruction_assembled
nop_instruction:
mov ah,[esi]
cmp ah,10h
je extended_nop
cmp ah,11h
je extended_nop
cmp ah,'['
je extended_nop
stos byte [edi]
jmp instruction_assembled
extended_nop:
mov [base_code],0Fh
mov [extended_code],1Fh
mov [postbyte_register],0
lods byte [esi]
call get_size_operator
cmp al,10h
je extended_nop_reg
cmp al,'['
jne invalid_operand
call get_address
mov al,[operand_size]
or al,al
jz extended_nop_nosize
call operand_autodetect
extended_nop_store:
call store_instruction
jmp instruction_assembled
extended_nop_nosize:
cmp [error_line],0
jne extended_nop_store
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
jmp extended_nop_store
extended_nop_reg:
lods byte [esi]
call convert_register
mov bl,al
mov al,ah
call operand_autodetect
call store_nomem_instruction
jmp instruction_assembled
 
basic_fpu_instruction:
mov [postbyte_register],al
4498,10 → 4472,9
stos word [edi]
jmp instruction_assembled
 
basic_mmx_instruction:
mmx_instruction:
mov [base_code],0Fh
mov [extended_code],al
mmx_instruction:
lods byte [esi]
call get_size_operator
cmp al,10h
4600,7 → 4573,7
call store_nomem_instruction
jmp instruction_assembled
mmx_imm8:
push ebx ecx edx
push bx cx edx
mov [operand_size],0
lods byte [esi]
cmp al,','
4613,7 → 4586,7
jne invalid_operand
call get_byte_value
mov byte [value],al
pop edx ecx ebx
pop edx cx bx
call store_instruction_with_imm8
jmp instruction_assembled
mmx_nomem_imm8:
5345,9 → 5318,9
cmp al,[mmx_size]
jne invalid_operand_size
sse_cmp_size_ok:
push ebx ecx edx
push bx cx edx
call get_nextbyte
pop edx ecx ebx
pop edx cx bx
call store_instruction_with_imm8
jmp instruction_assembled
sse_cmp_xmmreg_xmmreg:
5509,40 → 5482,6
jne invalid_operand_size
call operand_64bit
jmp sse_reg
 
ssse3_instruction:
mov [base_code],0Fh
mov [extended_code],38h
mov [supplemental_code],al
jmp mmx_instruction
palignr_instruction:
mov [base_code],0Fh
mov [extended_code],3Ah
mov [supplemental_code],0Fh
lods byte [esi]
call get_size_operator
cmp al,10h
jne invalid_operand
lods byte [esi]
call convert_mmx_register
call make_mmx_prefix
mov [postbyte_register],al
lods byte [esi]
cmp al,','
jne invalid_operand
lods byte [esi]
call get_size_operator
cmp al,10h
je palignr_mmreg_mmreg
cmp al,'['
jne invalid_operand
call get_address
jmp mmx_imm8
palignr_mmreg_mmreg:
lods byte [esi]
call convert_mmx_register
mov bl,al
jmp mmx_nomem_imm8
amd3dnow_instruction:
mov [base_code],0Fh
mov [extended_code],0Fh
6009,11 → 5948,15
jnz address_ok
calculate_relative_address:
call calculate_relative_offset
cmp byte [esi-1],']'
jne invalid_address
mov [address_high],edx
mov edx,[symbol_identifier]
mov [address_symbol],edx
mov edx,eax
mov ch,[value_type]
mov bx,0FF00h
xor cl,cl
address_ok:
ret
 
6108,16 → 6051,8
store_extended_code:
mov al,[extended_code]
stos byte [edi]
cmp al,38h
je store_supplemental_code
cmp al,3Ah
je store_supplemental_code
instruction_code_ok:
ret
store_supplemental_code:
mov al,[supplemental_code]
stos byte [edi]
ret
store_nomem_instruction:
test [postbyte_register],1000b
jz nomem_reg_code_ok
6438,8 → 6373,7
store_address_32bit_value:
test ch,0F0h
jz address_32bit_relocation_ok
mov eax,ecx
shr eax,16
mov al,2
xchg [value_type],al
mov ebx,[address_symbol]
xchg ebx,[symbol_identifier]
6453,8 → 6387,7
store_address_64bit_value:
test ch,0F0h
jz address_64bit_relocation_ok
mov eax,ecx
shr eax,16
mov al,4
xchg [value_type],al
mov ebx,[address_symbol]
xchg ebx,[symbol_identifier]
6470,8 → 6403,8
address_immediate_sib:
test ch,not 44h
jnz invalid_address_size
test ecx,0FF0000h
jnz address_immediate_sib_nosignextend
cmp [value_type],0
jne address_immediate_sib_nosignextend
test edx,80000000h
jz address_immediate_sib_prefix_ok
address_immediate_sib_nosignextend:
6503,13 → 6436,12
shl cl,3
or al,cl
stos byte [edi]
shr ecx,16
xchg [value_type],cl
xchg [value_type],ch
mov ebx,[address_symbol]
xchg ebx,[symbol_identifier]
mov eax,edx
call mark_relocation
mov [value_type],cl
mov [value_type],ch
mov [symbol_identifier],ebx
stos dword [edi]
ret