Page 1 of 1

OS limited to 512 bytes

Posted: Wed Jun 27, 2012 12:14 pm
by 1ottsco
I am new to OSDev and searched the wiki for something that will solve my problem, but can't find anything.
My OS is 16-bit real mode, and the .bin file is 512 bytes, but when I add new stuff it runs out of room. When I changed the 510 below to 1022, my computer said "Missing operating system".
At the end of my OS I always have this:

Code: Select all

times 510-($-$$) db 0
db 0x55
db 0xAA
So, can someone please tell me what to do without switching to 32-bit or protected mode?
Thanks!

Re: OS limited to 512 bytes

Posted: Thu Jun 28, 2012 1:43 am
by JamesM
To expand on what Berkus said, When the machine boots, the BIOS will load one sector and one sector only from disk. A sector is 512 bytes in length, and this "boot sector" must end with 0xAA55, which is why when you change that "510" everything dies.

In that 466 or whatever bytes you have to play with, you need to instruct the BIOS to load more sectors and then jump to them. This is called a first-stage bootloader.

Re: OS limited to 512 bytes

Posted: Thu Jun 28, 2012 10:00 am
by 1ottsco
Thanks, everyone. I also found something on the wiki which vaguely solves my problem at http://wiki.osdev.org/Boot_Sequence, but I am still confused on how to compile it.
If I have one file called boot.s with this in it:

Code: Select all

ORG 0x0000
jmp 0x0020:start
start:
And one file called kernel.s with this in it:

Code: Select all

ORG 0x0020
jmp 0x0000:start
start:
How would I compile it to get it to work?
By the way, I am using Linux Xubuntu 11.10 and nasm 2.09.08.

Re: OS limited to 512 bytes

Posted: Mon Jul 02, 2012 12:45 am
by KiithNabaal
JamesM wrote:To expand on what Berkus said, When the machine boots, the BIOS will load one sector and one sector only from disk. A sector is 512 bytes in length, and this "boot sector" must end with 0xAA55, which is why when you change that "510" everything dies.

In that 466 or whatever bytes you have to play with, you need to instruct the BIOS to load more sectors and then jump to them. This is called a first-stage bootloader.
So then am I to understand that the following tutorial: http://wiki.osdev.org/Real_mode_assembly_I

isn't actually a "kernel", as it says? Rather, it seems to be what is really a bootloader (or what it should be, but isn't), since it has the bios signature at the end of it. Is this correct?

Re: OS limited to 512 bytes

Posted: Mon Jul 02, 2012 1:01 am
by JamesM
Indeed.