flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Dex4u 31 Aug 2008, 14:59
First it may help if you post what it does when you run it
Code from DexOS floppy driver Code: ;====================================================; ; UpdateClusterValue. ; ;====================================================; UpdateClusterValue: pushad mov word[Cluster],ax mov word[UpdateValue],bx xor ecx,ecx mov cx,ax mov dx,ax shr dx,0x0001 add cx,dx mov esi,BpbFat12 add esi,512 add esi,ecx mov dx,word [ds:esi] ;mov [ClustOrigValue ],dx test ax,0x0001 jnz OddUpdateClusterValue EvenUpdateClusterValue: mov bx,dx and bx,0000111111111111b mov [ClustOrigValue ],bx and dx,1111000000000000b mov bx,word[UpdateValue] and bx,0000111111111111b add dx,bx mov word [ds:esi],dx jmp DoneUpdateClusterValue OddUpdateClusterValue: mov bx,dx shr bx,4 mov [ClustOrigValue ],bx and dx,0000000000001111b mov bx,word[UpdateValue] shl bx,4 add dx,bx mov word [ds:esi],dx DoneUpdateClusterValue: popad ret Can you see a differanc ? Also this does not seem right Code: mov bx,[es:0x500] Is your address of your FAT store there ? , because if not and its the address of of your FAT, its the wrong way to use it. See DexOS function. |
|||
![]() |
|
abuashraf 31 Aug 2008, 23:15
Quote: Is your address of your FAT store there ? Yes I loaded FAT table into memory at [es:0x500], Also I used this combination when getting an entry from fat table and it worked fine,because I was able to read 10KB TXT files. Quote: First it may help if you post what it does when you run it It dosent change any thing in the FAT table,so every time I try to make a new file,the first free cluster still the same,but when I make a new file from windows and and save it on the IMG,the first free cluster increases by one. |
|||
![]() |
|
abuashraf 01 Sep 2008, 04:54
Thank you Dex for your help,it's working now,the problem was that
I was lossing the value of BX which holds the FAT offset. here's the working code... Code: 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 |
|||
![]() |
|
baldr 21 Sep 2008, 13:10
Here is the snippet:
Code: ;;; di = cluster number; ax = new cluster number mov bx, di shr bx, 1 ; CF: odd? mov cx, FAT12[bx+di] jnc .even .odd: shl ax, 4 and cx, 0x000f jmp .done .even: and cx, 0xf000 .done: or cx, ax mov FAT12[bx+di], cx Code: ;;; si = cluster number mov bx, si shr bx, 1 mov ax, FAT12[bx+si] jnc @f shr ax, 4 @@: and ax, 0xfff ;;; ax = next cluster number ;;; si = cluster number xor cx, cx mov bx, si shr bx, 1 rcl cx, 3 ; 2 [log2(4)==2] +1 (respect the CF P.S. Beware of off-segment... |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.