Page 1 of 1

bootloader issue with USB stick

Posted: Thu Sep 18, 2008 11:50 am
by mrnoob
hi guys, as this is my first post id like to say i really like the look of the community and hope to stay here for a while :)

Right then, im quite new to the OS development scene, although ive been programming in C/++ and ASM for a while. Im trying to create a purely USB stick-based operating system, but im struggling to load sectors from the drive with my bootloader. I think its an issue with the drive number, but ive tried all drive numbers from 0 to 255 without luck, and im completely stumped. Doubtless itl be a really obvious typo or bug, so could you please flick through this code to see if you spot anything? Thanks a lot :)

Code: Select all

entry start
start:
	nop
	mov ax, #0x0600
	mov bh, #0x4f
	mov cx, #0
	mov dh, #25
	mov dl, #80
	int 0x10		;clear screen, just in case
	mov ax, #0x0e47
	mov bh, #0x00
	int 0x10		;output "G"
;gooo:	jmp gooo		;repeater, for debugging
	mov dl, #0x80
	mov ah, #0x02
	mov al, #1
	mov ch, #0
	mov cl, #2
	mov dh, #0
	mov bx, #0
	push #0x1000
	pop es
	int 0x13		;try to load sector 2 from drive at dh
;woop:	jmp woop		;enter infinite woop
	jmp 0:0x1000		;enter the boot code
[edit] my assembler and linker are as86 and ld86 for ubuntu if that helps.

Re: bootloader issue with USB stick

Posted: Thu Sep 18, 2008 4:07 pm
by kubeos
Although I have no experience whatsoever booting with USB with my own OS, most bioses will provide the drive being booted with in dl before your bootloader is run.

Also, usually your USB stick is booted as a hard drive so you could try 0x80 as the drive number. Other than that I haven't really looked at your code since it's been awhile since I used realmode. :)

Re: bootloader issue with USB stick

Posted: Thu Sep 18, 2008 5:30 pm
by mrnoob
im happy now, i both have the bootloader working and have a working emulator environment :D thanks for the help bud