As I promised from the other post, here are questions for bootloader 4.
1. We're trying to get to the start of the root directory. And this is the piece of code Mike wrote
Code: Select all
LOAD_ROOT:
; compute size of root directory and store in "cx"
xor cx, cx
xor dx, dx
mov ax, 0x0020 ; 32 byte directory entry
mul WORD [bpbRootEntries] ; total size of directory
div WORD [bpbBytesPerSector] ; sectors used by directory
xchg ax, cx
; compute location of root directory and store in "ax"
mov al, BYTE [bpbNumberOfFATs] ; number of FATs
mul WORD [bpbSectorsPerFAT] ; sectors used by FATs
add ax, WORD [bpbReservedSectors] ; adjust for bootsector
mov WORD [datasector], ax ; base of root directory
add WORD [datasector], cx
; read root directory into memory (7C00:0200)
mov bx, 0x0200 ; copy root dir above bootcode
call ReadSectors
Code: Select all
add ax, WORD [bpbReservedSectors]
2. with the piece of code that find stage 2
Code: Select all
;----------------------------------------------------
; Find stage 2
;----------------------------------------------------
; browse root directory for binary image
mov cx, [bpbRootEntries] ; the number of entrys. If we reach 0, file doesnt exist
mov di, 0x0200 ; Root directory was loaded here
.LOOP:
push cx
mov cx, 11 ; eleven character name
mov si, ImageName ; compare the 11 bytes with the name of our file
push di
rep cmpsb ; test for entry match
pop di
je LOAD_FAT ; they match, so begin loading FAT
pop cx
add di, 32 ; they dont match, so go to next entry (32 bytes)
loop .LOOP
jmp FAILURE
Sorry guys, I know I know I am a pain. Bear with me plz. And sorry for quoting lots of the codes here, that makes it so messy
Thank guys