OS limited to 512 bytes

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
1ottsco
Posts: 2
Joined: Mon Jun 18, 2012 1:59 pm

OS limited to 512 bytes

Post 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!
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: OS limited to 512 bytes

Post 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.
1ottsco
Posts: 2
Joined: Mon Jun 18, 2012 1:59 pm

Re: OS limited to 512 bytes

Post 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.
KiithNabaal
Posts: 1
Joined: Fri Jun 22, 2012 8:57 pm

Re: OS limited to 512 bytes

Post 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?
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: OS limited to 512 bytes

Post by JamesM »

Indeed.
Post Reply