Problem with Launching Stage 2 Bootloader
Posted: Fri Apr 05, 2013 5:09 pm
Hey everyone!
I've been following the BrokenThorn Series on OS Dev. Right now, as a part of my journey through the tutorial I'm currently coding the part that loads in a second stage bootloader, but unfortunately, the code crashes. Here is the portion of the code that I think is troublesome:
This portion of code looks for the file in the FAT table. However, it is not able to find it, and so crashes.
In this code, ImageName is a variable with the value "KRNLDR SYS" in it. In my floppy drive, I have a file called "KRNLDR SYS" in my floppy drive (with the spaces, not "KRNLDR.SYS"). It would be a great help if anyone could offer any advice.
Note: I'm currently runnning a 64-bit Windows 7 PC
I've been following the BrokenThorn Series on OS Dev. Right now, as a part of my journey through the tutorial I'm currently coding the part that loads in a second stage bootloader, but unfortunately, the code crashes. Here is the portion of the code that I think is troublesome:
Code: Select all
;browse root directory for binary image
mov ax, WORD [bpbRootEntries]; load loop counter, bpbRootEntries is the number of entries in the FAT table
mov di, 0x0000 ; because rep cmpsb compares the string in es:di to ds:si, and es holds 0x7e00 (the location of the FAT Table), I decided to set di to 0x0000
mov cx, 0x000B; eleven character name
lea si, [ImageName] ;set si to the memory location of ImageName so ds:si points to ImageName
.LOOP:
rep cmpsb
jz LOAD_FAT
add di, 32 ; queue next directory entry
dec ax
cmp ax, 0x0
jne .LOOP
jmp FAILURE
In this code, ImageName is a variable with the value "KRNLDR SYS" in it. In my floppy drive, I have a file called "KRNLDR SYS" in my floppy drive (with the spaces, not "KRNLDR.SYS"). It would be a great help if anyone could offer any advice.
Note: I'm currently runnning a 64-bit Windows 7 PC