feat: ajout du chargement de la FAT12 en bloc mémoire Mise a jour STDCALL/CE de la fonction "changedir" Remaniement total des fonctions loadfile, projfile, execfile La fonction "cmpnames" prend en compte les répertoires "." et ".."

This commit is contained in:
Nicolas Hordé 2007-03-23 16:42:51 +00:00
parent 780f0d4287
commit f145c0617c
1 changed files with 128 additions and 70 deletions

View File

@ -79,16 +79,16 @@ PROC getfat near
push cs push cs
pop es pop es
;call [cs:mbfindsb],offset datafat,cs call [cs:mbfindsb],offset datafat,cs
; mov es,ax mov es,ax
mov ax,cx mov ax,cx
mov bx,ax mov bx,ax
and bx,0000000000000001b and bx,0000000000000001b
shr ax,1 shr ax,1
mov cx,3 mov cx,3
mul cx mul cx
mov si,offset fatter ;mov si,offset fatter
;xor si,si xor si,si
add si,ax add si,ax
cmp bx,0h cmp bx,0h
jnz evenfat jnz evenfat
@ -118,14 +118,27 @@ endp getfat
;<- Flag Carry si erreur ;<- Flag Carry si erreur
;===================================================== ;=====================================================
PROC loadfile FAR PROC loadfile FAR
ARG @name:word,@pointer:word ARG @name:word,@pointer:word
USES cx,si,di LOCAL @@temp:word:48
mov si,[@name] USES cx,si,di,ds,es
call searchfile,si push ss
pop es
lea di,[@@temp]
push ds di
mov si,[@name]
mov cx,48/4
cld
rep movsd
push ss
pop ds
pop di es
call searchfile,di
jne errorload jne errorload
jc errorload jc errorload
mov cx,[(find si).result.filegroup] mov cx,[(find di).result.filegroup]
mov eax,[(find si).result.filesize] mov eax,[(find di).result.filesize]
push es
pop ds
call loadway,cx,eax,[@pointer] call loadway,cx,eax,[@pointer]
jc errorload jc errorload
clc clc
@ -142,15 +155,12 @@ endp loadfile
;<- Flag Carry si erreur ;<- Flag Carry si erreur
;===================================================== ;=====================================================
PROC execfile FAR PROC execfile FAR
pushf ARG @file:word
push bp dx pushad
mov bp,sp
mov dx,[ss:bp+10]
pushad
push ds es fs gs push ds es fs gs
call projfile,dx call projfile,[@file]
jc @@reallyerror jc @@reallyerrornoblock
call [cs:mbchown],ax,dx call [cs:mbchown],ax,[word ptr ss:bp+4]
jc @@reallyerror jc @@reallyerror
call [cs:mbloadfuncs],ax call [cs:mbloadfuncs],ax
jc @@reallyerror jc @@reallyerror
@ -166,10 +176,17 @@ PROC execfile FAR
push ds push ds
push ds push ds
push ds push ds
pop ds pop es
pop fs pop fs
pop gs pop gs
push 7202h push 7202h
xor eax,eax
xor ebx,ebx
xor ecx,ecx
xor edx,edx
xor esi,esi
xor edi,edi
xor ebp,ebp
popf popf
sti sti
db 0CBh db 0CBh
@ -179,14 +196,13 @@ PROC execfile FAR
call [cs:mbfree],ax call [cs:mbfree],ax
pop gs fs es ds pop gs fs es ds
popad popad
pop dx bp clc
popf
ret ret
@@reallyerror: @@reallyerror:
call [cs:mbfree],ax
@@reallyerrornoblock:
pop gs fs es ds pop gs fs es ds
popad popad
pop dx bp
popf
stc stc
ret ret
endp execfile endp execfile
@ -198,30 +214,39 @@ endp execfile
;===================================================== ;=====================================================
PROC projfile FAR PROC projfile FAR
ARG @pointer:word ARG @pointer:word
LOCAL @@temp:word:64
USES cx,si,di,ds,es USES cx,si,di,ds,es
push ds push ss
pop es pop es
mov si,[@pointer] lea di,[@@temp]
call uppercase,si push di
call [cs:mbfind],si mov si,[@pointer]
mov cx,64/4
cld
rep movsd
push ss
pop ds
pop di
call uppercase,di
call [cs:mbfind],di
jnc @@errorload jnc @@errorload
call searchfile,si call searchfile,di
jne @@errorload jne @@errorload
jc @@errorload jc @@errorload
mov eax,[es:(find si).result.filesize] mov eax,[es:(find di).result.filesize]
call [cs:mbcreate],si,ax call [cs:mbcreate],di,ax
jc @@errorload jc @@errorload
mov ds,ax mov ds,ax
mov cx,[es:(find si).result.filegroup] mov cx,[es:(find di).result.filegroup]
mov eax,[es:(find si).result.filesize] mov eax,[es:(find di).result.filesize]
call loadway,cx,eax,0 call loadway,cx,eax,0
jc @@errorload jc @@errorload
mov ax,ds mov ax,ds
clc clc
ret ret
@@errorload: @@errorload:
stc
xor eax,eax xor eax,eax
stc
ret ret
endp projfile endp projfile
@ -262,7 +287,7 @@ ARG @pointer:word
endp searchfile endp searchfile
;Transforme la chaine ds:%0 en maj ;Transforme la chaine ds:%0 en maj
PROC uppercase far PROC uppercase FAR
ARG @strs:word ARG @strs:word
USES si,ax USES si,ax
mov si,[@strs] mov si,[@strs]
@ -290,6 +315,17 @@ PROC cmpnames FAR
USES ax,cx,si,di,es USES ax,cx,si,di,es
mov si,[@off1] mov si,[@off1]
mov di,[@off2] mov di,[@off2]
cmp [byte ptr si],"."
jne @@notaredir
cmp [word ptr si],".."
jne @@onlyonedir
cmp [word ptr di],".."
je @@itok
jmp @@notequal
@@onlyonedir:
cmp [word ptr di]," ."
je @@itok
@@notaredir:
push ds push ds
pop es pop es
mov cx,8 mov cx,8
@ -342,10 +378,10 @@ PROC loadway NEAR
ror eax,16 ror eax,16
div [cs:clustersize] div [cs:clustersize]
mov bx,ax mov bx,ax
cmp bx,1
jb @@adjustlast
mov cx,[@sector] mov cx,[@sector]
mov di,[@offset] mov di,[@offset]
cmp bx,1
jb @@adjustlast
@@loadfat: @@loadfat:
call readcluster,cx,di call readcluster,cx,di
jc @@noway jc @@noway
@ -445,20 +481,20 @@ PROC initdrive FAR
xor eax,eax xor eax,eax
mov ax,[myboot.sectorsperfat] mov ax,[myboot.sectorsperfat]
mul [myboot.sectorsize] mul [myboot.sectorsize]
;call [cs:mbfindsb],offset datafat,cs call [cs:mbfindsb],offset datafat,cs
;jnc @@hadafatbloc jnc @@hadafatbloc
;call [cs:mbcreate],offset datafat,ax call [cs:mbcreate],offset datafat,ax
;jc @@errorinit jc @@errorinit
;call [cs:mbresident],ax call [cs:mbresident],ax
;jc @@errorinit jc @@errorinit
;call [cs:mbchown],ax,cs call [cs:mbchown],ax,cs
;jc @@errorinit jc @@errorinit
@@hadafatbloc: @@hadafatbloc:
mov dx,[myboot.sectorsperfat] mov dx,[myboot.sectorsperfat]
mov cx,[adressfat] mov cx,[adressfat]
;xor di,di xor di,di
mov di,offset fatter ;mov di,offset fatter
;mov ds,ax mov ds,ax
@@seefat: @@seefat:
call readsector,cx,di call readsector,cx,di
jc @@errorinit jc @@errorinit
@ -623,8 +659,9 @@ errorfree:
PROC readcluster FAR PROC readcluster FAR
ARG @sector:word,@pointer:word ARG @sector:word,@pointer:word
USES ax,bx,dx,si USES ax,bx,dx,si
mov bl,[cs:myboot.sectorspercluster] mov al,[cs:myboot.sectorspercluster]
xor bh,bh xor ah,ah
mov bx,ax
mul [@sector] mul [@sector]
add ax,[cs:addingvalue] add ax,[cs:addingvalue]
mov si,[@pointer] mov si,[@pointer]
@ -650,8 +687,9 @@ endp readcluster
PROC writecluster FAR PROC writecluster FAR
ARG @sector:word,@pointer:word ARG @sector:word,@pointer:word
USES ax,bx,dx,si USES ax,bx,dx,si
mov bl,[cs:myboot.sectorspercluster] mov al,[cs:myboot.sectorspercluster]
xor bh,bh xor ah,ah
mov bx,ax
mul [@sector] mul [@sector]
add ax,[cs:addingvalue] add ax,[cs:addingvalue]
mov si,[@pointer] mov si,[@pointer]
@ -933,51 +971,73 @@ fini:
;<- Flag Carry si erreur, Flag Equal si secteurs égaux ;<- Flag Carry si erreur, Flag Equal si secteurs égaux
;===================================================== ;=====================================================
PROC changedir FAR PROC changedir FAR
USES ax,cx,dx,si,di,ds,es ARG @pointer:word
push cs LOCAL @@temp:word:64
pop es USES cx,si,di,ds,es
;cmp [si],005Ch ;'\',0 (root dir) push ss
mov di,offset tempdir pop es
call searchfile lea di,[@@temp]
jc @@noch push di
mov cx,[cs:tempdir.filegroup] mov si,[@pointer]
mov cx,64/4
cld
rep movsd
push ss
pop ds
pop di
call searchfile,di
jne @@noch
jc @@noch
;cmp [si],005Ch ;'/',0 (root dir)
mov cx,[es:(find di).result.filegroup]
mov [cs:currentdir],cx mov [cs:currentdir],cx
mov [cs:adressdirectory],cx mov [cs:adressdirectory],cx
cmp [dword ptr cs:di],' ..' cmp [dword ptr es:(find di).result.filename],' .'
jne @@notback
cmp [dword ptr cs:di],' .'
je @@theend je @@theend
cmp [dword ptr es:(find di).result.filename],' ..'
jne @@notback
push cs
push cs
pop ds
pop es
mov di,offset currentdirstr mov di,offset currentdirstr
mov cx,128 mov cx,128
mov al,0 mov al,0
cld cld
repne scasb repne scasb
mov al,'\' mov al,'/'
std std
repne scasb repne scasb
inc di inc di
mov [byte ptr es:di],0 mov [byte ptr es:di],0
jmp @@theend jmp @@theend
@@notback: @@notback:
push cs
push cs
pop ds
pop es
mov di,offset currentdirstr mov di,offset currentdirstr
mov cx,128 mov cx,128
mov al,0 mov al,0
cld cld
repne scasb repne scasb
dec di dec di
mov al,'\' mov al,'/'
cld cld
stosb stosb
mov dx,di mov dx,di
push ds push ss
pop es pop es
mov di,si lea di,[@@temp]
mov si,di
mov cx,128 mov cx,128
mov al,0 mov al,0
cld cld
repne scasb repne scasb
sub cx,128 sub cx,128
neg cx neg cx
push ss
pop ds
push cs push cs
pop es pop es
mov di,dx mov di,dx
@ -991,8 +1051,6 @@ PROC changedir FAR
ret ret
endp changedir endp changedir
tempdir entries <>
;=============getdir============== ;=============getdir==============
;Recupere le repertoire courant a DS:%0 ;Recupere le repertoire courant a DS:%0
;-> ;->
@ -1025,4 +1083,4 @@ endp getdir
bufferread db 512 dup (0) bufferread db 512 dup (0)
bufferwrite db 512 dup (0) bufferwrite db 512 dup (0)
bufferentry db 512 dup (0) bufferentry db 512 dup (0)
fatter db 9*512 dup (0) ;fatter db 9*512 dup (0)