Loading root directory and kernel does not work
Posted: Sat Mar 22, 2025 12:00 pm
Hello, so I have been trying to have the root directory load, find the kernel file and then load the kernel to 0x1000:0x0000, but for some reason it does not work at all. Is there any reason, why?
I have attempted to fix it multiple ways, including changing the sector for LOAD_ROOT_DIR, checking the kernel file's ORG, which is at 0x0000, even changed it to 0x1000, which yielded no results whatsoever, and even did ah=0x01 on it, which didn't even print anything out at all. This is the READ_ERR and DAP that I set up before the changes done to it in the functions:
What could the problem be if I did all that, and the MBR did load the FAT Boot Sector correctly with the ah=0x42? And, the hex dump for 32 bytes in the root directory printed a string of different hexes(which did not show up nowhere in the partition AT ALL, the hex codes are in the given screenshot), so it can't be a 13h extensions support issue, especially if it loaded the FAT boot sector properly.
I would very much appreciate as much help as I can receive and can give more information as needed.
Code: Select all
LOAD_ROOT_DIR:
mov si, DAP
mov word [si + 2], ROOT_DIR_SCTRS ;32
mov word [si + 4], 0x0000
mov word [si + 6], 0x4000
mov dword [si + 8], 514 ;active@ hex editor shows 514 to be the root directory start sector
mov ah, 0x42
mov dl, 0x80
int 0x13
jc READ_ERR
mov si, di
mov cx, 32
call PRINT_HEX_DUMP
RET
FIND_KRNL:
mov di, BUFFER ;0x4000
mov cx, BPB_NUM_OF_POSSIBLE_ROOT_ENTRIES ;512
.find:
push cx
mov si, FILENAME ; 'KERNEL BIN'
mov dx, 11
repe cmpsb
je .found
add di, 32
pop cx
loop .find
pop cx
mov ah, 0x0E
mov al, 'E'
int 0x10
RET
.found:
pop cx
mov ax, [di + 26] ; Load low word of the starting cluster number
mov [KERNEL_START], ax ; Store kernel start LBA
RET
CLUSTR_LBA:
xor ax, ax
mov bx, ax
mov cx, ax
mov ax, [KERNEL_START]
sub ax, 2
mov bx, [BPB_SECTORS_PER_CLUSTER]
mul bx
add ax, 514
add ax, ROOT_DIR_SCTRS
mov [KERNEL_START], ax
RET
LOAD_KRNL:
mov si, DAP
mov ax, KRNLSEGMNT
mov es, ax
mov bx, KRNLOFFSET
mov word [si + 2], 1
mov word [si + 4], bx
mov word [si + 6], ax
xor ax, ax
mov ax, [KERNEL_START]
mov dword [si + 8], eax
mov ah, 0x42
mov dl, 0x80
int 0x13
jc READ_ERR
mov ah, 0x0E
mov al, '6'
int 0x10
jmp 0x1000:0x0000
Code: Select all
DAP:
db 0x10
db 0x00
DW 0x0001
DW 0x0000
DW 0x0000
DD 0x00000000
DD 0x00000000
READ_ERR:
mov bl, ah
cmp bl, 9
jg HEX_ERR
add bl, '0'
jmp PRINT_ERR
HEX_ERR:
add bl, 'A' - 10
PRINT_ERR:
mov ah, 0x0E
mov al, bl
int 0x10
jmp $