Subversion Repositories Kolibri OS

Rev

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

Rev 1115 Rev 1189
Line 131... Line 131...
131
	sub	edi,8
131
	sub	edi,8
132
	mov	[edi],ecx
132
	mov	[edi],ecx
133
	or	dword [edi+4],-1
133
	or	dword [edi+4],-1
134
	sub	edi,ecx
134
	sub	edi,ecx
135
	cmp	edi,[esp]
135
	cmp	edi,[current_offset]
136
	jbe	out_of_memory
136
	jbe	out_of_memory
137
	mov	[display_buffer],edi
137
	mov	[display_buffer],edi
138
	mov	esi,[memory_end]
138
	mov	esi,[memory_end]
139
      copy_labels:
139
      copy_labels:
140
	sub	esi,32
140
	sub	esi,32
141
	cmp	esi,[labels_list]
141
	cmp	esi,[labels_list]
Line 1299... Line 1299...
1299
      init_pe_data:
1299
      init_pe_data:
1300
	or	ecx,ecx
1300
	or	ecx,ecx
1301
	jnz	data_already_defined
1301
	jnz	data_already_defined
1302
	call	allocate_structure_data
1302
	call	allocate_structure_data
1303
	mov	word [ebx],data_directive-assembler
1303
	mov	word [ebx],data_directive-instruction_handler
1304
	mov	[ebx+2],al
1304
	mov	[ebx+2],al
1305
	mov	edx,[current_line]
1305
	mov	edx,[current_line]
1306
	mov	[ebx+4],edx
1306
	mov	[ebx+4],edx
1307
	call	generate_pe_data
1307
	call	generate_pe_data
1308
	jmp	instruction_assembled
1308
	jmp	instruction_assembled
1309
      end_data:
1309
      end_data:
Line 3589... Line 3589...
3589
 
3589
 
Line 3590... Line 3590...
3590
format_elf_exe:
3590
format_elf_exe:
3591
	add	esi,2
3591
	add	esi,2
3592
	or	[format_flags],1
3592
	or	[format_flags],1
-
 
3593
	cmp	byte [esi],'('
-
 
3594
	jne	elf_exe_brand_ok
-
 
3595
	inc	esi
-
 
3596
	cmp	byte [esi],'.'
-
 
3597
	je	invalid_value
-
 
3598
	push	edx
-
 
3599
	call	get_byte_value
-
 
3600
	cmp	[value_type],0
-
 
3601
	jne	invalid_use_of_symbol
-
 
3602
	pop	edx
-
 
3603
	mov	[edx+7],al
-
 
3604
      elf_exe_brand_ok:
3593
	mov	[image_base],8048000h
3605
	mov	[image_base],8048000h
3594
	cmp	byte [esi],80h
3606
	cmp	byte [esi],80h
3595
	jne	elf_exe_base_ok
3607
	jne	elf_exe_base_ok
3596
	lods	word [esi]
3608
	lods	word [esi]
3597
	cmp	ah,'('
3609
	cmp	ah,'('
Line 3641... Line 3653...
3641
	jmp	format_defined
3653
	jmp	format_defined
3642
      format_elf64_exe:
3654
      format_elf64_exe:
3643
	add	esi,2
3655
	add	esi,2
3644
	or	[format_flags],1
3656
	or	[format_flags],1
3645
	mov	[image_base],400000h
3657
	cmp	byte [esi],'('
-
 
3658
	jne	elf64_exe_brand_ok
-
 
3659
	inc	esi
-
 
3660
	cmp	byte [esi],'.'
-
 
3661
	je	invalid_value
-
 
3662
	push	edx
-
 
3663
	call	get_byte_value
-
 
3664
	cmp	[value_type],0
-
 
3665
	jne	invalid_use_of_symbol
-
 
3666
	pop	edx
-
 
3667
	mov	[edx+7],al
-
 
3668
      elf64_exe_brand_ok:
-
 
3669
	mov	[image_base],400000h
3646
	mov	[image_base_high],0
3670
	mov	[image_base_high],0
3647
	cmp	byte [esi],80h
3671
	cmp	byte [esi],80h
3648
	jne	elf64_exe_base_ok
3672
	jne	elf64_exe_base_ok
3649
	lods	word [esi]
3673
	lods	word [esi]
3650
	cmp	ah,'('
3674
	cmp	ah,'('
Line 3746... Line 3770...
3746
      new_elf_segment:
3770
      new_elf_segment:
3747
	mov	byte [ebx],1
3771
	mov	byte [ebx],1
3748
	mov	word [ebx+1Ch],1000h
3772
	mov	word [ebx+1Ch],1000h
3749
      elf_segment_flags:
3773
      elf_segment_flags:
3750
	cmp	byte [esi],19h
3774
	cmp	byte [esi],1Eh
-
 
3775
	je	elf_segment_type
-
 
3776
	cmp	byte [esi],19h
3751
	jne	elf_segment_flags_ok
3777
	jne	elf_segment_flags_ok
3752
	lods	word [esi]
3778
	lods	word [esi]
3753
	sub	ah,28
3779
	sub	ah,28
3754
	jbe	invalid_argument
3780
	jbe	invalid_argument
3755
	cmp	ah,1
3781
	cmp	ah,1
Line 3764... Line 3790...
3764
	test	[ebx+18h],ah
3790
	test	[ebx+18h],ah
3765
	jnz	setting_already_specified
3791
	jnz	setting_already_specified
3766
	or	[ebx+18h],ah
3792
	or	[ebx+18h],ah
3767
	jmp	elf_segment_flags
3793
	jmp	elf_segment_flags
3768
      elf_segment_flags_ok:
3794
      elf_segment_type:
-
 
3795
	cmp	byte [ebx],1
-
 
3796
	jne	setting_already_specified
-
 
3797
	lods	word [esi]
-
 
3798
	mov	ecx,[number_of_sections]
-
 
3799
	jecxz	elf_segment_type_ok
-
 
3800
	mov	edx,[code_start]
-
 
3801
	add	edx,34h
-
 
3802
      scan_elf_segment_types:
-
 
3803
	cmp	edx,[symbols_stream]
-
 
3804
	jae	elf_segment_type_ok
-
 
3805
	cmp	[edx],ah
-
 
3806
	je	data_already_defined
-
 
3807
	add	edx,20h
-
 
3808
	loop	scan_elf_segment_types
-
 
3809
      elf_segment_type_ok:
-
 
3810
	mov	[ebx],ah
-
 
3811
	mov	word [ebx+1Ch],1
-
 
3812
	jmp	elf_segment_flags
-
 
3813
      elf_segment_flags_ok:
3769
	mov	eax,edi
3814
	mov	eax,edi
3770
	sub	eax,[code_start]
3815
	sub	eax,[code_start]
3771
	mov	[ebx+4],eax
3816
	mov	[ebx+4],eax
3772
	pop	edx
3817
	pop	edx
3773
	and	eax,0FFFh
3818
	and	eax,0FFFh
Line 3822... Line 3867...
3822
	add	eax,edi
3867
	add	eax,edi
3823
	sub	eax,edx
3868
	sub	eax,edx
3824
	mov	[ebx+10h],eax
3869
	mov	[ebx+10h],eax
3825
	mov	eax,[ebx+8]
3870
	mov	eax,[ebx+8]
3826
	add	eax,[ebx+14h]
3871
	cmp	byte [ebx],1
-
 
3872
	jne	elf_segment_position_ok
-
 
3873
	add	eax,[ebx+14h]
3827
	add	eax,0FFFh
3874
	add	eax,0FFFh
3828
	and	eax,not 0FFFh
3875
      elf_segment_position_ok:
-
 
3876
	and	eax,not 0FFFh
3829
	ret
3877
	ret
3830
      elf64_segment:
3878
      elf64_segment:
3831
	call	close_elf64_segment
3879
	call	close_elf64_segment
3832
	push	eax edx
3880
	push	eax edx
3833
	mov	ebx,[number_of_sections]
3881
	mov	ebx,[number_of_sections]
Line 3848... Line 3896...
3848
      new_elf64_segment:
3896
      new_elf64_segment:
3849
	mov	byte [ebx],1
3897
	mov	byte [ebx],1
3850
	mov	word [ebx+30h],1000h
3898
	mov	word [ebx+30h],1000h
3851
      elf64_segment_flags:
3899
      elf64_segment_flags:
3852
	cmp	byte [esi],19h
3900
	cmp	byte [esi],1Eh
-
 
3901
	je	elf64_segment_type
-
 
3902
	cmp	byte [esi],19h
3853
	jne	elf64_segment_flags_ok
3903
	jne	elf64_segment_flags_ok
3854
	lods	word [esi]
3904
	lods	word [esi]
3855
	sub	ah,28
3905
	sub	ah,28
3856
	jbe	invalid_argument
3906
	jbe	invalid_argument
3857
	cmp	ah,1
3907
	cmp	ah,1
Line 3866... Line 3916...
3866
	test	[ebx+4],ah
3916
	test	[ebx+4],ah
3867
	jnz	setting_already_specified
3917
	jnz	setting_already_specified
3868
	or	[ebx+4],ah
3918
	or	[ebx+4],ah
3869
	jmp	elf64_segment_flags
3919
	jmp	elf64_segment_flags
3870
      elf64_segment_flags_ok:
3920
      elf64_segment_type:
-
 
3921
	cmp	byte [ebx],1
-
 
3922
	jne	setting_already_specified
-
 
3923
	lods	word [esi]
-
 
3924
	mov	ecx,[number_of_sections]
-
 
3925
	jecxz	elf64_segment_type_ok
-
 
3926
	mov	edx,[code_start]
-
 
3927
	add	edx,40h
-
 
3928
      scan_elf64_segment_types:
-
 
3929
	cmp	edx,[symbols_stream]
-
 
3930
	jae	elf64_segment_type_ok
-
 
3931
	cmp	[edx],ah
-
 
3932
	je	data_already_defined
-
 
3933
	add	edx,38h
-
 
3934
	loop	scan_elf64_segment_types
-
 
3935
      elf64_segment_type_ok:
-
 
3936
	mov	[ebx],ah
-
 
3937
	mov	word [ebx+30h],1
-
 
3938
	jmp	elf64_segment_flags
-
 
3939
      elf64_segment_flags_ok:
3871
	mov	ecx,edi
3940
	mov	ecx,edi
3872
	sub	ecx,[code_start]
3941
	sub	ecx,[code_start]
3873
	mov	[ebx+8],ecx
3942
	mov	[ebx+8],ecx
3874
	pop	edx eax
3943
	pop	edx eax
3875
	and	ecx,0FFFh
3944
	and	ecx,0FFFh
Line 3927... Line 3996...
3927
	sub	eax,edx
3996
	sub	eax,edx
3928
	mov	[ebx+20h],eax
3997
	mov	[ebx+20h],eax
3929
	mov	eax,[ebx+10h]
3998
	mov	eax,[ebx+10h]
3930
	mov	edx,[ebx+10h+4]
3999
	mov	edx,[ebx+10h+4]
3931
	add	eax,[ebx+28h]
4000
	cmp	byte [ebx],1
-
 
4001
	jne	elf64_segment_position_ok
-
 
4002
	add	eax,[ebx+28h]
3932
	adc	edx,0
4003
	adc	edx,0
3933
	sub	eax,1
4004
	add	eax,0FFFh
3934
	sbb	edx,0
-
 
3935
	shrd	eax,edx,12
-
 
3936
	shr	edx,12
-
 
3937
	add	eax,1
-
 
3938
	adc	edx,0
4005
	adc	edx,0
3939
	shld	edx,eax,12
4006
      elf64_segment_position_ok:
3940
	shl	eax,12
4007
	and	eax,not 0FFFh
3941
	ret
4008
	ret
3942
close_elf_exe:
4009
 
-
 
4010
close_elf_exe:
3943
	test	[format_flags],8
4011
	test	[format_flags],8
3944
	jnz	close_elf64_exe
4012
	jnz	close_elf64_exe
3945
	call	close_elf_segment
4013
	call	close_elf_segment
3946
	mov	edx,[code_start]
4014
	mov	edx,[code_start]
3947
	mov	eax,[number_of_sections]
4015
	mov	eax,[number_of_sections]
Line 4147... Line 4215...
4147
	sub	[esi+8],eax
4215
	sub	[esi+8],eax
4148
	sub	[esi+12],eax
4216
	sub	[esi+12],eax
4149
      prepare_next_preprocessed_line:
4217
      prepare_next_preprocessed_line:
4150
	add	esi,16
4218
	add	esi,16
4151
	call	skip_foreign_line
4219
      skip_preprocessed_line:
-
 
4220
	lods	byte [esi]
-
 
4221
	cmp	al,1Ah
-
 
4222
	je	skip_preprocessed_symbol
-
 
4223
	cmp	al,3Bh
-
 
4224
	je	skip_preprocessed_symbol
-
 
4225
	cmp	al,22h
-
 
4226
	je	skip_preprocessed_string
-
 
4227
	or	al,al
-
 
4228
	jnz	skip_preprocessed_line
4152
	jmp	prepare_preprocessed_source
4229
	jmp	prepare_preprocessed_source
4153
      preprocessed_source_ok:
4230
      skip_preprocessed_string:
-
 
4231
	lods	dword [esi]
-
 
4232
	add	esi,eax
-
 
4233
	jmp	skip_preprocessed_line
-
 
4234
      skip_preprocessed_symbol:
-
 
4235
	lods	byte [esi]
-
 
4236
	movzx	eax,al
-
 
4237
	add	esi,eax
-
 
4238
	jmp	skip_preprocessed_line
-
 
4239
      preprocessed_source_ok:
4154
	mov	esi,[labels_list]
4240
	mov	esi,[labels_list]
4155
	mov	ebp,edi
4241
	mov	ebp,edi
4156
      make_lines_dump:
4242
      make_lines_dump:
4157
	cmp	esi,[display_buffer]
4243
	cmp	esi,[display_buffer]
4158
	je	lines_dump_ok
4244
	je	lines_dump_ok