Bootloader Rebuild
Posted: Sun Sep 05, 2010 6:25 pm
I have gone through and fixed all i can, data errors dma errors (09h from what i recall) but it still cannot find my file. i have decided to show a dot for every time it loads a root directory sector i have it display a dot to make sure its loading correctly. and i have a screen shot.

Every dot printed plus 1 is how many times it is loading a sector of the root directory to its destination (0x0200).
Any suggestions?
Fasm Assembly Code
Hopefully This may help ?
Ive made the size bigger to help any that may want to look at my code, Thank you
[Edit by quok] And I've fixed it so the size is normal. Please don't do that again.

Every dot printed plus 1 is how many times it is loading a sector of the root directory to its destination (0x0200).
Any suggestions?
Fasm Assembly Code
Code: Select all
;vboot 1.0 build 0001
use16
org 0x0
jmp start_boot
;;;;Bios Parameter Block;;;;
bpbBytesPerSector dw 512
bpbSectorsPerCluster db 1
bpbReservedSectors dw 1
bpbNumberOfFATs db 2
bpbRootEntries dw 224
bpbTotalSectors dw 2880
bpbMedia db 0xf0
bpbSectorsPerFAT dw 9
bpbSectorsPerTrack dw 18
bpbHeadsPerCylinder dw 2
bpbHiddenSectors dd 0
bpbTotalSectorsBig dd 0
bsDriveNumber db 0
bsUnused db 0
bsExtBootSignature db 0x29
bsSerialNumber dd 0xa0a1a2a3
bsVolumeLabel db "VolTroXDisk"
bsFileSystem db "FAT12 "
filename db "VTXLDR EXE"
startingcluster dw 0
fatoffset = (startingcluster + (startingcluster / 2))
locationof_rootdirectory = (2 * bpbSectorsPerFAT + bpbReservedSectors + 1)
sizeof_rootdirectory = (bpbRootEntries * 32 / bpbBytesPerSector)
sizeof_fats = (bpbNumberOfFATs * bpbSectorsPerFAT)
locationof_fats = (bpbReservedSectors + 1)
sectorlba = ( 33 + startingcluster - 2)
absoluteSector db 0
absoluteHead db 0
absoluteTrack db 0
fileloadaddress dw 0x1000
currentaddressofFAT dw 0
fcounter db 0
LBACHS:
xor dx, dx ; prepare dx:ax for operation
div WORD [bpbSectorsPerTrack] ; divide by sectors per track
inc dl ; add 1 (obsolute sector formula)
mov BYTE [absoluteSector], dl
; these forumlas are very simular...
xor dx, dx ; prepare dx:ax for operation
div WORD [bpbHeadsPerCylinder] ; mod by number of heads (Absolue head formula)
mov BYTE [absoluteHead], dl ; everything else was already done from the first formula
mov BYTE [absoluteTrack], al ; not much else to do :)
ret
print:
push ax
mov ah, 0eh
cont_print:
lodsb
cmp al, 0
je .done
int 10h
jmp cont_print
.done:
pop ax
ret
putletter:
mov ah, 0eh
int 10h
cli
hlt
read_sector: ;;ch cylinder number, dh head number, [al number of sectors to read], cl sector number
mov al, 1
mov ah,0
mov dl,0
int 13h
cmp ah, 0
jne ferrorh
mov ah, 02h
int 13h
;cmp ah, 00h
;jne ferrorh
ret
ferrorh:
cmp [fcounter], 3
je ferror
add [fcounter], 1
jmp read_sector
ferror:
mov si, derr
call print
cli
hlt
derr db "HARDWARE FAILURE: |FLOPPY DRIVE|, PLEASE RESTART",0
file_not_found:
mov si, fnf
call print
cli
hlt
fnf db "LOADX WAS NOT FOUND, PLEASE RESTART",0
sord db 0
lord db 0
alrd dw 0
start_boot:
mov ax, 7c0h
mov es,ax
mov ds,ax
mov ss,ax
mov sp, 0
;;test
load_root:
mov al, [sizeof_rootdirectory]
mov cl, [locationof_rootdirectory]
mov bx, 0x0200
first_loadr:
mov [sord], al
mov [lord], cl
mov [alrd], bx
call read_sector
dec [sord]
cmp [sord], 0
je done_lrd
cont_ldrt:
push ax
mov al, '.'
mov ah, 0eh
int 10h
pop ax
inc [lord]
add [alrd], 512
mov cl, [lord] ;sector to load
mov bx, [alrd]
call read_sector
dec [sord]
cmp [sord], 0
je done_lrd
jmp cont_ldrt
done_lrd:
mov cx, [bpbRootEntries] ;how many entries we will go through
mov di, 0x0200 ;di contains address of correct entry
browsefat:
push cx ;Save root entry number
mov cx, 11 ;Size of name
mov si, filename
push di ;Dont increment the correct addres
rep cmpsb ;Check every letter inc'ing di, but we saved the address of the entry
pop di ;di contains entry address
je load_fat ;Match
pop cx; cx contains number of entries left
cmp cx, 0
je file_not_found
add di, 32 ;root address plus 32 (next entry)
sub cx, 1
jmp browsefat
load_fat:
mov dx, [di + 26] ;di contains the address to the entry. plus 26 is the starting cluster number
;;dx contains starting cluster number
mov cl, [sizeof_fats]
mov al, [locationof_fats]
mov bx, 0x0200
call read_sector
mov WORD [startingcluster], dx
load_image:
mov ax, [startingcluster]
call LBACHS
mov ch, [absoluteTrack]
mov cl, [absoluteSector]
mov dh, [absoluteHead]
mov al, 1
mov bx, [fileloadaddress]
call read_sector
mov bx, 0x0200 ;location of fats atm
add bx, [fatoffset] ;now bx contains fatoffset
mov [currentaddressofFAT], bx
loop_read_image:
add [fileloadaddress], 512
mov ax, WORD [currentaddressofFAT]
mov cx, ax
mov dx, ax ;DX and CX contain cluster
shr dx, 0x0001
add cx, dx ;Add modified dx, with current cx, cx is now modified
mov bx, 0x0200 ;moves word at location of fat's into 0x200
add bx, cx
mov dx, WORD [bx] ;Moves word into word register
test ax, 0x0001 ;Test bit tp check for odd, if not zero, its odd
jnz odd_cluster
and dx, 0000111111111111b
jmp done_cluster
odd_cluster:
shr dx, 0x0004
done_cluster:
mov WORD [currentaddressofFAT], dx
cmp dx, 0x0ff0
jb loop_read_image
jmp 0x1000 ;?
TIMES 510-($-$$) DB 0
DW 0xAA55
;;;;Hopefully This may help ?
Ive made the size bigger to help any that may want to look at my code, Thank you
[Edit by quok] And I've fixed it so the size is normal. Please don't do that again.