So basically your problem is that you can't code assembly. It's pretty stupid then abandoning C.abuashraf wrote:I already wrote complete fat12 driver in C,but now I'm writing it in asm
but I'm really having problem with this specific function
JAL
So basically your problem is that you can't code assembly. It's pretty stupid then abandoning C.abuashraf wrote:I already wrote complete fat12 driver in C,but now I'm writing it in asm
but I'm really having problem with this specific function
I really fail to understand that, if you have a working C-version, you are not able to make an assembly one. What is your problem?abuashraf wrote:I wrote a lot of Dos programs,but I'm having trouble with this specific fumction
Code: Select all
setcluster:
push cx dx bx
mov cx, ax ;copy current cluster
mov dx, ax ;copy current cluster
shr dx, 0x0001 ;divide by two
add cx, dx ;cx=offset into FAT
mov bx,[es:0x500] ;address of fat table
add bx, cx ;index into FAT
mov dx, WORD [bx] ;read two bytes from FAT(old value in dx)
test ax, 0x0001
jnz .odd
.eve:
mov bx,dx
and bx,0xF000 ;bx holds the old value
and word[value],0x0FFF ;next cluster
or word[value],bx
mov dx,word[value]
mov word [bx],dx
jmp donexx
.odd:
mov bx,dx
and bx,0x000F ;bx holds the old value
shl word[value],4 ;next_cluster
or word[value],bx
mov dx,word[value]
mov word [bx],dx ;save the new value
donexx:
pop bx dx cx
ret
Code: Select all
setcluster:
push cx
mov cx, ax ;copy current cluster
mov dx, ax ;copy current cluster
shr dx, 0x0001 ;divide by two
add cx, dx ;cx=offset into FAT
mov bx,[es:0x500] ;address of fat table
add bx, cx ;index into FAT
push bx
mov dx, WORD [bx] ;read two bytes from FAT(old value in dx)
test ax, 0x0001
jnz .odd
.eve:
mov bx,dx
and bx,0xF000 ;bx holds the old value
and word[value],0x0FFF ;next cluster
or word[value],bx
mov dx,word[value]
pop bx
mov word [bx],dx
jmp donexx
.odd:
mov bx,dx
and bx,0x000F ;bx holds the old value
shl word[value],4 ;next_cluster
or word[value],bx
mov dx,word[value]
pop bx
mov word [bx],dx ;save the new value
donexx:
pop cx
ret