43,34 → 43,7 |
sti |
ret |
|
floppy_free_space: |
;--------------------------------------------- |
; |
; returns free space in edi |
; |
;--------------------------------------------- |
push eax ebx ecx |
call read_flp_fat |
cmp [FDC_Status],0 |
jne fdc_status_error_2 |
mov eax,0x282004 |
xor edi,edi |
mov ecx,2847 ;1448000/512 |
rdfs1_1: |
mov ebx,[eax] |
and ebx,4095 |
jne rdfs2_1 |
add edi,512 |
rdfs2_1: |
add eax,2 |
loop rdfs1_1 |
fdc_status_error_2: |
pop ecx ebx eax |
ret |
|
|
|
|
floppy_fileread: |
;---------------------------------------------------------------- |
; |
506,321 → 479,6 |
ret |
|
|
floppy_filedelete: |
;-------------------------------------------- |
; |
; filedelete - sys floppy |
; in: |
; eax - filename 11 chars - for root directory |
; edi pointer to path /fd/1/...... - for all files in nested directories |
; |
; out: |
; eax - 0 = successful, 1 = file not found, 10 = access denied |
; |
;-------------------------------------------- |
mov [path_pointer_flp],edi |
mov [save_flag],0 |
mov ebp,1 ; file not found as default |
filedelete_newtry_1: |
sub esp,32 |
call expand_filename |
push eax ebx ecx edx esi edi |
call read_flp_fat |
cmp [FDC_Status],0 |
jne frnoreadd_1 |
mov [FDD_Track],0 ; Öèëèíäð |
mov [FDD_Head],1 ; Ñòîðîíà |
mov [FDD_Sector],2 ; Ñåêòîð |
call SeekTrack |
mov dh,14 |
l.20_2: |
call ReadSectWithRetr |
cmp [FDC_Status],0 |
jne fdc_status_error_4 |
mov dl,16 |
mov edi,FDD_BUFF |
inc [FDD_Sector] |
l.21_2: |
mov esi,eax ;Name of file we want |
mov ecx,11 |
cld |
rep cmpsb ;Found the file? |
je fifoundd_1 ;Yes |
add ecx,21 |
add edi, ecx ;Advance to next entry |
dec dl |
jne l.21_2 |
dec dh |
jne l.20_2 |
jmp frnoreadd_1 |
|
fdc_status_error_4: |
pop edi esi edx ecx ebx eax |
add esp,32 |
jmp fdc_status_error_1 |
|
fifoundd_1: |
mov eax,[path_pointer_flp] |
cmp [eax+36],byte 0 |
je fifoundd_2 |
movzx eax, word [edi+0xf] |
mov ebx,[path_pointer_flp] |
add ebx,36 |
call get_cluster_of_a_path_flp |
jc frnoreadd_1_1 |
mov edi,ebx |
add edi,11 |
jmp fifoundd_2_1 |
fifoundd_2: |
dec [FDD_Sector] |
fifoundd_2_1: |
mov [edi-11],byte 0xE5 ;mark filename deleted |
movzx edi, word [edi+0xf] ;edi = cluster |
frnewd_1: |
shl edi,1 ;find next cluster from FAT |
add edi,FLOPPY_FAT |
mov eax,[edi] |
mov [edi],word 0x0 ;clear fat chain cluster |
and eax,4095 |
mov edi,eax |
cmp edi,dword 4095 ;last cluster ? |
jz frnoreadd2_1 |
jmp frnewd_1 |
|
frnoreadd2_1: |
call WriteSectWithRetr |
cmp [FDC_Status],0 |
jne fdc_status_error_4 |
call save_flp_fat |
cmp [FDC_Status],0 |
jne fdc_status_error_4 |
; pop edi esi edx ecx ebx eax |
; add esp,32 |
mov ebp,0 ; file found |
; jmp filedelete_newtry_1 |
jmp frnoreadd_1 |
|
frnoreadd_1_1: |
cmp [FDC_Status],0 |
jne fdc_status_error_4 |
frnoreadd_1: |
pop edi esi edx ecx ebx eax |
add esp,32 |
mov eax,ebp |
ret |
|
floppy_filesave: |
;---------------------------------------------------------- |
; |
; filesave - sys floppy |
; |
; eax ; pointer to file name 11 chars - for root directory |
; ebx ; buffer |
; ecx ; count to write in bytes |
; edx ; 0 create new , 1 append |
; edi pointer to path /fd/1/...... - for all files in nested directories |
; |
; output : eax = 0 - ok |
; 5 - file not found / directory not found |
; 8 - disk full |
; 10 - access denied |
;----------------------------------------------------------- |
mov [path_pointer_flp],edi |
sub esp,32 |
call expand_filename |
cmp edx,0 |
jnz fsdel_1 |
pusha |
call floppy_filedelete |
cmp [FDC_Status],0 |
jne fdc_status_error_6 |
popa |
mov [save_flag],1 |
fsdel_1: |
call floppy_free_space |
cmp [FDC_Status],0 |
jne fdc_status_error_6 |
cmp ecx,edi |
jb rd_do_save_1 |
add esp,32 |
mov eax,8 ; not enough free space |
mov [flp_status],0 |
ret |
|
fdc_status_error_6: |
popa |
add esp,32 |
jmp fdc_status_error_1 |
|
rd_do_save_1: |
push eax ebx ecx edx esi edi |
call read_flp_fat |
cmp [FDC_Status],0 |
jne fdc_status_error_7 |
push eax |
mov eax,[path_pointer_flp] |
cmp [eax+36],byte 0 |
jne fifoundds_2 |
pop eax |
mov [save_root_flag],1 |
call read_flp_root |
cmp [FDC_Status],0 |
jne fdc_status_error_7 |
mov edi,FLOPPY_BUFF ;Point at directory |
mov edx,224 +1 |
; find an empty spot for filename in the root dir |
l20ds_1: |
sub edx,1 |
jz frnoreadds_1 |
l21ds_1: |
cmp [edi],byte 0xE5 |
jz fifoundds_1 |
cmp [edi],byte 0x0 |
jz fifoundds_1 |
add edi,32 ; Advance to next entry |
jmp l20ds_1 |
|
fifoundds_2: |
pop eax |
mov [save_root_flag],0 |
mov [FDD_Track],0 ; Öèëèíäð |
mov [FDD_Head],1 ; Ñòîðîíà |
mov [FDD_Sector],2 ; Ñåêòîð |
call SeekTrack |
mov dh,14 |
l.20_3: |
call ReadSectWithRetr |
cmp [FDC_Status],0 |
jne fdc_status_error_7 |
mov dl,16 |
mov edi,FDD_BUFF |
inc [FDD_Sector] |
l.21_3: |
mov esi,eax ;Name of file we want |
mov ecx,11 |
cld |
rep cmpsb ;Found the file? |
je fifoundds_3 ;Yes |
add ecx,21 |
add edi, ecx ;Advance to next entry |
dec dl |
jne l.21_3 |
dec dh |
jne l.20_3 |
fdc_status_error_8: |
pop edi esi edx ecx ebx eax |
mov eax,5 ; file not found ? |
mov ebx,-1 |
add esp,32 |
mov [flp_status],0 |
ret |
|
fifoundds_3: |
add edi,0xf |
mov eax,[edi] |
and eax,65535 |
mov ebx,[path_pointer_flp] |
add ebx,36 |
call get_cluster_of_a_path_flp |
jc fdc_status_error_7_1 |
found_directory_for_writing_flp: |
call analyze_directory_to_write_flp |
jc fdc_status_error_7_1 |
mov edi,ebx |
fifoundds_1: |
push edi ; move the filename to root dir |
mov esi,[esp+4+20] |
cmp [save_root_flag],0 |
jne fifoundds_4 |
mov esi,[pointer_file_name_flp] |
fifoundds_4: |
mov ecx,11 |
cld |
rep movsb |
pop edi |
mov edx,edi |
add edx,11+0xf ; edx <- cluster save position |
mov ebx,[esp+12] ; save file size |
mov [edi+28],ebx |
mov [edi+11],byte 0x20 ; attribute |
call get_date_for_file ; from FAT32.INC |
mov [edi+24],ax ; date |
mov [edi+18],ax ; date |
call get_time_for_file ; from FAT32.INC |
mov [edi+22],ax ; time |
xor ax,ax |
mov [edi+20],ax |
mov ebx,1 ; first cluster |
cmp [save_root_flag],0 |
jne frnewds_1 |
call frnewds_2 |
pusha |
call WriteSectWithRetr |
popa |
cmp [FDC_Status],0 |
jne fdc_status_error_7 |
jmp frnewds_3 |
|
frnewds_1: |
call frnewds_2 |
frnewds_3: |
pusha ; move save to floppy cluster |
add ebx,31 |
mov eax,ebx |
mov esi,[esp+32+16] |
call take_data_from_application_1 |
call save_chs_sector |
cmp [FDC_Status],0 |
jne fdc_status_error_7 |
popa |
mov eax,[esp+12] |
cmp eax,512 |
jb flnsa_1 |
sub eax,512 |
mov [esp+12],eax |
mov eax,[esp+16] |
add eax,512 |
mov [esp+16],eax |
jmp frnewds_1 |
|
frnewds_2: |
add ebx,1 |
mov edi,ebx ; find free cluster in FAT |
shl edi,1 |
add edi,FLOPPY_FAT |
mov eax,[edi] |
and eax,4095 |
jnz frnewds_2 |
mov [edx],bx ; save next cluster pos. to prev cl. |
mov edx,edi ; next save pos abs mem add |
ret |
|
flnsa_1: |
mov [edi],word 4095 ; mark end of file - last cluster |
cmp [save_root_flag],1 |
jne flnsa_2 |
call save_flp_root |
cmp [FDC_Status],0 |
jne fdc_status_error_7 |
flnsa_2: |
call save_flp_fat |
cmp [FDC_Status],0 |
jne fdc_status_error_7 |
frnoreadds_1: |
pop edi esi edx ecx ebx eax |
add esp,32 |
mov eax,0 |
mov [flp_status],0 |
ret |
|
fdc_status_error_7_1: |
cmp [FDC_Status],0 |
je fdc_status_error_8 |
fdc_status_error_7: |
pop edi esi edx ecx ebx eax |
add esp,32 |
jmp fdc_status_error_1 |
|
save_chs_sector: |
call calculate_chs |
call WriteSectWithRetr |
965,115 → 623,6 |
ret |
|
|
analyze_directory_to_write_flp: |
;-------------------------------- |
; input : EAX = first cluster of the directory |
; output : IF CARRY=0 EAX = sector where the file is found |
; EBX = pointer in buffer |
; [buffer .. buffer+511] |
; ECX,EDX,EDI,EDI not changed |
; IF CARRY=1 |
;-------------------------------- |
|
push ecx |
push edx |
push esi |
|
adr561: |
mov [clust_tmp_flp],eax |
add eax,31 |
pusha |
call read_chs_sector |
popa |
cmp [FDC_Status],0 |
jne error_found_file_analyze1 |
|
mov ecx,512/32 |
mov ebx,FDD_BUFF |
|
adr1_analyze1: |
cmp byte [ebx],0x00 |
je found_file_analyze1 |
cmp byte [ebx],0xe5 |
je found_file_analyze1 |
|
avanti: |
add ebx,32 |
loop adr1_analyze1 |
|
mov eax,[clust_tmp_flp] |
shl eax,1 ;find next cluster from FAT |
add eax,FLOPPY_FAT |
mov eax,[eax] |
and eax,4095 |
cmp eax,0x0ff8 |
jb adr561 |
|
call get_free_FAT ;this block of code add a new cluster |
;for the directory because the directory |
;is full |
|
mov [edi],word 0x0fff |
|
mov eax,[clust_tmp_flp] |
shl eax,1 ;find next cluster from FAT |
add eax,FLOPPY_FAT |
sub edi,FLOPPY_FAT |
mov [eax],di |
|
pusha |
mov ecx,512/4 |
xor eax,eax |
mov edi,FDD_BUFF |
cld |
rep stosd |
popa |
|
mov eax,edi |
add eax,31 |
pusha |
call save_chs_sector |
popa |
cmp [FDC_Status],0 |
jne error_found_file_analyze1 |
mov ebx,FDD_BUFF |
|
found_file_analyze1: |
|
pop esi |
pop edx |
pop ecx |
clc ;file found |
ret |
|
error_found_file_analyze1: |
pop esi |
pop edx |
pop ecx |
stc |
ret |
|
get_free_FAT_flp: |
;------------------------------------------ |
; input : EAX = # cluster for start the searching |
; output : EAX = # first cluster found free |
;------------------------------------------- |
push ebx |
|
mov ebx,1 |
check_new_flp: |
add ebx,1 |
mov edi,ebx ; find free cluster in FAT |
shl edi,1 |
add edi,FLOPPY_FAT |
mov eax,[edi] |
and eax,4095 |
cmp eax,0x0 |
jnz check_new_flp |
|
pop ebx |
ret |
|
; \begin{diamond} |
fat_find_lfn: |
; in: esi->name |