Scanning the root dir fails...

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Berry

Scanning the root dir fails...

Post by Berry »

Hello,

I find it difficult to find and scan the root-dir. I find the root-dir this way:

;bereken de LBA
mov ax, [num_fats]
mov bx, [sectors_per_fat]
mul bx ;num_fats * sectors_per_fat...
add ax, [num_boot_sectors] ;... + num_boot_sectors

push ax ;zet de LBA op de stack

;bereken aantal in te lezen sectors
mov ax, [num_root_dir_ents]
mov bx, 0x20
mul bx ;num_root_dir_ents * 0x20...
mov bx, [bytes_per_sector]
div bx ;... / bytes_per_sector
mov cx, ax ;cx = aantal in te lezen sectors

pop ax ;ax = LBA

mov bx, 0x0200
mov es, bx ;segment:
mov bx, 0x0000 ;offset van de root_dir

call load_sector ;laad de sectors van de floppy

load_sector resets the floppy drive, calls LBAtoCHS and loads the sectors where the root-dir is. I then scan the root-dir for

second.bin db 'SECOND  BIN',0

it doesn't find it... I use cmpsb to compare the string... Load the string in like this:

mov si, second.bin_file ;de string om te zoeken
mov bx, 0x0200
mov es, bx ;waar te zoeken
xor di, di ;di = 0

than call scan_root_dir

is anything wrong with this? Debugging for 2 days now...
Berry

RE:Scanning the root dir fails...

Post by Berry »

Ow, yes ofcourse! Your english...

;calculate the LBA
mov ax, [num_fats]
mov bx, [sectors_per_fat]
mul bx ;num_fats * sectors_per_fat...
add ax, [num_boot_sectors] ;... + num_boot_sectors

push ax ;push the LBA to the stack

;calculate number of sectors to read
mov ax, [num_root_dir_ents]
mov bx, 0x20
mul bx ;num_root_dir_ents * 0x20...
mov bx, [bytes_per_sector]
div bx ;... / bytes_per_sector
mov cx, ax ;cx = # sectors to read
pop ax ;ax = LBA

mov bx, 0x0200
mov es, bx ;segment:
mov bx, 0x0000 ;offset of the root_dir

call load_sector ;load the sectors from the root-dir

load_sector resets the floppy drive, calls LBAtoCHS and loads the sectors where the root-dir is. I then scan the root-dir for

second.bin db 'SECOND  BIN',0

it doesn't find it... I use cmpsb to compare the string... Load the string in like this:

mov si, second.bin_file ;the string to search
mov bx, 0x0200
mov es, bx ;where to search
xor di, di ;di = 0

then call scan_root_dir

If there's not anything wrong with this, please post that, then I will post all my code :)
ASHLEY4

RE:Scanning the root dir fails...

Post by ASHLEY4 »

Berry go here:

  http://alexfru.chat.ru/epm.html

And down load "bootprog.zip" in is the code to do what you want (Coded in nasm) compear it with yours, and see were you are going wrong.

ASHLEY4.
Post Reply