Thanks Combuster that works very well... Apparently I'm also having trouble loading the kernel to anything higher than a WORD address. I am using int 0x13 to raw read the disk image / floppy. The BIOS call reads the specified data on disk to es:bx. This seems simple enough however, until now I have been determining the memory location to load the kernel to like this:
Code: Select all
xor bx,bx
mov es,bx
mov bx,kern_offset
Obviously that won't work to load the kernel to an address larger than 1 word, so I modified it to this:
Code: Select all
mov ebx,kern_offset
shr ebx,0x00000010
mov es,bx
mov ebx,kern_offset
But for one reason or another I am still only able to load the kernel to an address lower than 1 word.
Here is the entire kernel loading procedure:
Code: Select all
kernel_loader:
; determine # of sectors to load
; dx:ax / bx = ax remainder dx
mov dx,0x0000
mov ax,KERNEL_SIZE
mov bx,SECTOR_SIZE
div bx
; ensure size is even number of sectors
cmp dx,0x0000
jnz .kl_error
; setup to loop thru sectors
mov cx,ax
mov BYTE [ BLOC( sector_current ) ], KERNEL_SECTOR
mov DWORD [ BLOC( offset_current ) ], KERNEL_OFFSET
.kl_copy_sector:
push cx
; copy current sector
; disk loc -> es:bx in mem
mov dh,KERNEL_DRIVE
mov dl,KERNEL_HEAD
mov ch,KERNEL_TRACK
mov cl,[ BLOC( sector_current ) ]
; setup destination ( es:bx)
mov eax,DWORD [ BLOC( offset_current ) ]
shr eax,0x00000010
mov es,ax
mov ebx,DWORD [ BLOC( offset_current ) ]
mov ah,0x02
mov al,0x01
int 0x13
; prepare for next sector
add DWORD [ BLOC( offset_current ) ],SECTOR_SIZE
inc BYTE [ BLOC( sector_current ) ]
pop cx
loop .kl_copy_sector
; completed
jmp .kl_success
; error section
.kl_error:
jmp $
; success section
.kl_success:
ret
bl_data:
; kernel_load data
sector_current db 0x00 ; KERNEL_SECTOR
offset_current dd 0x00000000 ; KERNEL_OFFSET
KERNEL_SIZE is the size of the kernel in bytes and BLOC() is just a macro that adds 0x7C00 to an input variable. Does anyone see something wrong? Keep in mind this works for loading the kernel to an address lower than 1 word...
Brodeur235