int 13h problem

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
renovatio
Member
Member
Posts: 57
Joined: Fri May 23, 2008 5:13 am

int 13h problem

Post 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
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Re: int 13h problem

Post 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)?
renovatio
Member
Member
Posts: 57
Joined: Fri May 23, 2008 5:13 am

Re: int 13h problem

Post 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
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: int 13h problem

Post 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.
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
Masterkiller
Member
Member
Posts: 153
Joined: Sat May 05, 2007 6:20 pm

Re: int 13h problem

Post 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.
ALCA OS: Project temporarity suspended!
Current state: real-mode kernel-FS reader...
Post Reply