Page 1 of 1

reading floppy

Posted: Fri Mar 14, 2008 5:35 pm
by suthers
Im trying to load the kernel rom my bootloader.
I use the following code:

Code: Select all

	mov cx, 0x10
	.cylinder1
	mov ax,0x100000
	mov es,ax                     
	mov bx,0x10                   
	mov ah,2        	      
	mov al,17                     
	mov ch,0                      
	mov cl,2                      
	mov dh,0                      
	int 0x13                      
	jc .finish
	loop .cylinder1
and the following code to jump to it:

Code: Select all

jmp 08h:0x100000
But it just restarts any ideas why?
Thanks in advance,
Jules

Posted: Fri Mar 14, 2008 5:40 pm
by lukem95
if its restarting it probably means its triple faulting (some computers + bochs) reboot when this happens.

Posted: Fri Mar 14, 2008 5:51 pm
by Combuster
you've got your test the wrong way around it seems - you're looping until the read fails


And you can't fit 32 bits into a 16-bit register:

Code: Select all

mov ax,0x100000
So, fix your assembler warnings first :wink:


And IIRC some bioses don't like loading directly above 1MB anyway

Posted: Sat Mar 15, 2008 10:17 am
by suthers
If i change the jc to jnc it just goes into an infinite loop.
Also is there a convention on were to load the kernel?
If not anywere you would recommend loading it so it doesn't mess with anything else?
Thanks in advance,
Jules

Posted: Sun Mar 16, 2008 11:19 am
by xyjamepa
Hi...


If ther was a carry then the reading operation failed,
this means you should jump if there's no carry using "jnc"...
any way here's a simple .com program that loads the first sector
of the root directory and prints it,I'm talking about fat12 floppy driver.