FAT12
Posted: Sat Aug 30, 2008 7:43 am
Hi,
I'm trying to write a real mode os with asm,
now I'm writing a fat12 driver,till now I could
show list of files and directories,and read a text file,but now I'm trying to write a function that
sets an entry in the FAT table to a new value,for example when you write a new file you have to set
an entry in the FAT table to the cluster number of that file,but my function is not working...
Would you please help me,here's my code...
Please note that "value" holds the new value
Thanx
I'm trying to write a real mode os with asm,
now I'm writing a fat12 driver,till now I could
show list of files and directories,and read a text file,but now I'm trying to write a function that
sets an entry in the FAT table to a new value,for example when you write a new file you have to set
an entry in the FAT table to the cluster number of that file,but my function is not working...
Would you please help me,here's my code...
Code: Select all
setcluster:
push cx bx dx
mov ax,word [cluster]
mov cx, ax ;copy current cluster
mov dx, ax ;copy current cluster
shr dx, 0x0001 ;divide by two
add cx, dx ;sum for (3/2)
mov bx,[es:0x500] ;address of fat table
add bx, cx ;index into FAT
mov dx, WORD [bx] ;read two bytes from FAT
test ax, 0x0001
jnz .odd
.eve:
mov bx,dx
and dx,1111000000000000b
mov bx,word[value]
and bx,0000111111111111b
add dx,bx
mov word [bx],dx
jmp donexx
.odd:
mov bx,dx
and dx,0000000000001111b
mov bx,word[value]
shl bx,4
add dx,bx
mov word [bx],dx
donexx:
pop dx bx cx
ret
Thanx