Page 1 of 1

int 13h problem

Posted: Mon Oct 20, 2008 10:27 am
by renovatio
hello, i can't read more than 4 sectors using int 13h... here is my code... if i try to read 5 or more it loads zeroes.... the procedure is load_sector or load_root (both can have a problem), i'm running this code in windows (fasm).... thanks

Code: Select all

org 100h

;/******************************************************************************
;*Main                                                                         *
;******************************************************************************/

call print_root
mov ah, 10h
int 16h
ret

;/******************************************************************************
;*Load sector                                                                  *
;******************************************************************************/

load_sector: mov ah, 2h
	     mov dl, 0
	     int 13h
	     ret

;/******************************************************************************
;*Load root directory                                                          *
;******************************************************************************/

load_root: mov al, 4              ;;;;;; HEREEEEEEEEEEEEEEEEEEEEEEEEEEE
	   mov bx, root_dir
	   mov ch, 0
	   mov cl, 2
	   mov dh, 1
	   call load_sector
	   ret

;/******************************************************************************
;*Print name                                                                   *
;******************************************************************************/

print_name: mov ah, 0eh
	    mov cx, 11

    .again: lodsb
	    int 10h
	    loop .again
	    ret

;/******************************************************************************
;*Print new line                                                               *
;******************************************************************************/

print_new_line: mov ah, 0eh
		mov al, 10
		int 10h
		mov al, 13
		int 10h
		ret

;/******************************************************************************
;*Print root                                                                   *
;******************************************************************************/

print_root: call load_root
	    mov si, root_dir
	    mov cx, 224

    .again: cmp byte [si], 0xe5
	    je .skip
	    cmp byte [si], 0
	    je .end
	    push si
	    call print_name
	    pop si
	    call print_new_line

     .skip: add si, 32
	    loop .again

      .end: ret

;/******************************************************************************
;*Root directory                                                               *
;******************************************************************************/

root_dir: times 7168 db 0

Re: int 13h problem

Posted: Mon Oct 20, 2008 11:41 am
by salil_bhagurkar
1. What have you initialized your ES to? Int 13h uses ES:BX as the buffer to read your sectors

A question that may not be related to your problem:
1. Why does your root directory start at sector-2 head-1 (cl = 2 , dh = 1)?

Re: int 13h problem

Posted: Mon Oct 20, 2008 5:28 pm
by renovatio
1) i think ES is not the problem because windows set segments before the app starts and because if i load 4 or less sector everything works....

2) i think its correct because i can read file names but up to 4 sectors.....

thanks

Re: int 13h problem

Posted: Mon Oct 20, 2008 11:55 pm
by egos
The buffer must not cross 64K boundaries. Reserve 2*BUFFER_SIZE-1 bytes and calculate the buffer address satisfying this requirement.

Edit: and add error checking in your code!

Edit: and exclude LFNs and volume labels from the search.

Re: int 13h problem

Posted: Tue Oct 21, 2008 4:08 am
by Masterkiller
Some BIOSes may not load too much sectors. It is recommended to read 1 sector per int13h. Just call it several times and everything will be OK.