I went through my bootloader using bochs. After it loaded the Primary Volume Descriptor at address 0x9000, I used the bochs command "x" to see what it loaded. The address 0x9000 contains the value 0x01, which means it really is the Primary Volume Descriptor. So far so good. I noticed that the third byte in the directory entry of the root directory which contains the LBA address of the root directory, contains the value 0x18. Okay, that makes sense. The root directory begins at block 0x18. But when it loaded the root directory, I noticed that the second bytes in the first two entries which contain the LBA addresses of the first two files in the root directory, both contain the value 0x18! So the root directory and the first two files in it, all start at block 0x18! How is that possible?
Nothing is wrong with the image. I can mount it using Image Mounter and see it's contents.
Here is the code of my bootloader that loads the root directory:
Code: Select all
; at this point the Primary Volume Descriptor is already loaded at address 0x9000
push dx ; we don't want to overwrite dl as it contains the number of the drive this bootloader came from
mov ax,[0x909E]
mov [bx+8],ax
mov ax,[0x90A6]
mov dx,[0x90A8]
mov cx,2048
div cx
add ax,1
mov [bx+2],ax
pop dx
mov ah,0x42
int 0x13