Code: Select all
LoadKernelSector:
mov si, Dot
call PrintMsg
pop bx ; Restore write address
push ax ; Preserve sectore number
add ax, 001Fh ; Add data cluster offset
mov cx, 0001h ; Load 1 sector
call LoadSectors
pop ax ; Restore sector number
push bx ; Preserve write address
mov bx, ax ; Copy sector number
shr bx, 0001h ; Divide by 2
add bx, ax ; Add orginal sector number
add bx, 0200h ; Add offset to FAT
mov bx, WORD [bx] ; Load next sector number
test ax, 0001h ; Get lostest byte of sector number
jnz ODD ; If present the number is odd
and bx, 0FFFh ; if even take low 12 bytes
jmp Done
ODD:
shr bx, 0004h ; If odd take high 12 bytes
Done:
mov ax, bx ; Move sector number back into ax
cmp ax, 0FF0h ; Check for EOF
jb LoadKernelSector ;load next sector
mov si, KernelDone
call PrintMsg