flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > first free entry(fat12) |
Author |
|
Dex4u 05 Aug 2008, 18:16
Is the buffer Address store at es:0x400 or is the buffer at es:0x400, because if the buffer is at es:0x400 try this code
Code: ;-----------------------------------------------;;return the first free entry in Ax ;;-----------------------------------------------; ffentry: xor ax,ax ;zero ax mov bx,ax ;zero bx mov dx,ax ;zero dx mov si,ax ;zero si mov di,ax ;zero di mov di,0x400 ;[es:0x400] ;di points to the buffer mov cx,16 xor ax,ax @@.loop: inc dx ;dx points to the first free entry test byte[es:di+11],1 shl 3 ;is it a volume label? jnz @nextentry ;go to the next entry mov al,[es:di+bx] ;fetch chars from the buffer cmp al,0xE5 ;is it deleted file? je @del ;yes cmp al,0 ;is this end of files/directories? je @del @del: mov ax,dx ;ax=first free entry jmp @@.quit ;returb @nextentry: add bx,32 ;go to the next entry @@.again: loop @@.loop @@.quit: ret If not, than yours is OK |
|||
05 Aug 2008, 18:16 |
|
abuashraf 06 Aug 2008, 07:10
unfortunatelly it gave me the same result which is 1,
here's the first part of my function: Code: mov bx,[es:0x400] ;the buffer xor ax,ax ;zero ax mov cx,ax ;zero cx mov dx,ax ;zero dx mov ax,19 ;first sector of the root directory mov cx,14 ;root directory occupy 14 sectors call read_sectors ;read 14 sectors call ffentry ;get first free entry call int_to_string ;print it ret |
|||
06 Aug 2008, 07:10 |
|
Dex4u 06 Aug 2008, 14:56
Does your "int_to_string" function work OK ?, try this just incase
Code: ;-------------------------------------;;convert number into string ;;where: AX=num , ;;-------------------------------------;int_to_string: pushad mov ebx,eax shr eax,8 call write_hex8 mov eax,ebx call write_hex8 popad ret ;----------------------------------------------------; ; write hex ; ;----------------------------------------------------;write_hex8: push eax push eax shr al,4 call hexget call print_char pop eax call hexget call print_char pop eax rethexget: and eax,0x0000000f or eax,0x00000030 cmp eax,0x39 ja add7 retadd7: add eax,7 retprint_char: mov ah,0Eh int 10h ret |
|||
06 Aug 2008, 14:56 |
|
abuashraf 07 Aug 2008, 00:29
thank you Dex for your help,anyway I tried your "int_to_string"
function and I got the same result which is 1,I'm really confused |
|||
07 Aug 2008, 00:29 |
|
Alphonso 07 Aug 2008, 03:33
Check your conditional jump 'je @del'. Only if it's a volume label does it not go to @del:. Maybe change to this or similar...
Code: ;[snip] @@.loop: inc dx ;dx points to the first free entry test byte[es:di+11],1 shl 3 ;is it a volume label? jnz @nextentry ;go to the next entry mov al,[es:di+bx] ;fetch chars from the buffer cmp al,0xE5 ;is it deleted file? je @del ;yes cmp al,0 ;is this end of files/directories? jnz @nextentry ;<---- from je @del @del: mov ax,dx ;ax=first free entry jmp @@.quit ;returb @nextentry: add bx,32 ;go to the next entry @@.again: loop @@.loop @@.quit: ret |
|||
07 Aug 2008, 03:33 |
|
Dex4u 07 Aug 2008, 20:30
I would use your int_to_string function and dump some of the regs, eg: DI AND AL, also put a
Code: push axxor ax,axint 16hpop ax after each reg dump so you can step through the code. Also add this after this label nextentry: Code: nextentry: pusha mov al,"V" mov ah,0Eh int 10h popa So we know if it gets called. |
|||
07 Aug 2008, 20:30 |
|
abuashraf 08 Aug 2008, 08:39
It's working now,thank you guys for your help...
here's the code: Code: ffentry: xor ax,ax ;zero ax mov bx,ax ;zero bx mov dx,ax ;zero dx mov si,ax ;zero si mov di,ax ;zero di mov di,[es:0x400] ;di points to the buffer mov cx,224 ;number of root directory entries @@.loop: inc dx test byte[di+0x0b],1 shl 3 ;is it a volume label? jnz volume cmp byte [di],0xE5 ;is it deleted file? je @del ;yes, cmp byte [di],0x00 ;is this the end of files/directories? je @del ;yes, add di,32 ;go to the next entry jmp @@.again ;continue looping @del: mov ax,dx ;save the first free entry in ax jmp @@.quit ;quit volume: ;it is a volume label... add di,32 ;just go to the next entry @@.again: loop @@.loop ;continue looping! @@.quit: ret ;return |
|||
08 Aug 2008, 08:39 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.