Problem with int 13h *FIXED*

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
Jabus
Member
Member
Posts: 39
Joined: Sun Jan 07, 2007 7:54 am

Problem with int 13h *FIXED*

Post by Jabus »

I am currently writing the second stage of my bootloader and I have a problem. There is one point in the code where I call int 13h. However when I call this all the code seems to stop executing and no instructions after the call to int 13h are executed. I reset the floppy drive in the first stage and I called int 13h earlier on i my second stage and it worked there.
Here is the code where I call int 13h and no more code is executed.

Code: Select all

LoadFile:
call lbaToChs
mov dl,0
mov al,1
mov ah,2
int 13h
jc errorLoad
add bx,510
mov cx,[es:bx]
mov ax,cx
sub ax,0xFFFF
jz return
add cx,1
jmp LoadFile
Note: lbaToChs uses the value in cx to calculate the sector number, cylinder and head to use. It returns with the sector number, cylinder number and head number all in the correct registers for the call to int13h.

Here is the successful code where I called int 13h and the code afterwards was executed.

Code: Select all

loadRootDirectory:
mov cx,1 ; get the sector number etc. for the root dir
call lbaToChs
mov ax,0 ;we will load files to 0x07c00
mov es,ax
mov bx,0x07c00
mov ah,2
mov al,1
int 13h ; hopefully it will load first time
jnc loadedRoot
jmp errorLoad
Thank you for all your help.

Edit *Fixed*:
It turns out that lbaToChs was creating some duff values. It turns out that i was using the quotient when I should have been using the remainder and vice versa in some calculations.
Post Reply