


Bootsectors are hard, but if you make your own, with help, you can know all about your bootsector.
it is the first code executed after BIOS finishes its boot-up. the bootsector is exactly 512 bytes long, with the last two bytes 0x55 and 0xAA, which leaves 510 bytes of code that loads the kernel from the disk (either by using the file system or by loading the next sector).Berserk wrote: Ok, here are some questions before i start learning assembler.
What does a bootsector contain??
the kernel does everything an OS is responsible for: memory management, process management, thread management, device management and communication, etc.It loads a kernel, what does a kernel do??
the bootsector is not a file. it is the first sector of the disk or partition and ends with the boot sector signature (0x55, 0xAA) as i said above.what file format is the bootsector in??
the signature.how does the BIOS know that that file is the bootsector??
the BIOS does this for you.how do i load the bootsector to boot off a floppy??
any questions?Please help me out:D
it is what the name implies: a sector.Berserk wrote: how do i put the signature on a bootsector, and if a bootsector is not a file, what the hell is it??
you compile a boot sector just like you would any other assembly code. the output file must be a flat binary file and then must be written to the first sector of a floppy. one way is to use MS debug to write the file to the first sector, or you can create an image file with your bootsector code filling the first 512 bytes of the imagei've seen bootsector files before, they just look like a normal file, but with no extension? how do i compile a boot sector ASM file with NASM?
it has no name, since it is the first sector of the disk.and can the bootsector file be called anything i like??
or does it have a specific name like "boot"??
i'm willing to answer your questions one by one if i have toI have other questions, but first i want to learn the basics. I'll ask the questions later, so please if a moderator is reading this, please don't delete this topic, if i do not reply in a long time (a week or more) please don't think that i have given up or gone.....i will probably have gone to learn something or write some code before moving on and asking more questions ;D
ciao![]()
Code: Select all
padding times (510 - $) db 0
bootsig db 0x55, 0xAA
Code: Select all
int main(int arg, char* args[])
{
return 0;
}
Code: Select all
[ORG 0]
entry:
cli
mov ax,0x7c0 ; set segments to boot code's location
mov es,ax
mov ds,ax
mov ax,0x9000 ; set stack segment and pointer
mov ss,ax
mov sp,ax
sti
; put your ASM boot code here
size equ $ - entry
%if size+2 > 512
%error "code is too large for boot sector"
%endif
padding times (510 - size) db 0
bootsig db 0x55, 0xAA
Code: Select all
debug bootsector.bin
> w 0 0 0 1
> q
Code: Select all
debug C:\os\kernel32.bin
-w 0 0 0 2
this does not seems quite correct to me ... virtually 1% of your code will be written in assembly, rest will be higher language ... of course you'll need a good understanding of the machine internals (i.e. why "hello"+"world" result in a compilation error in C should be obvious to you as well as why you cannot do { int x=2; return &x}), but assembly programming ... sorry, it is absolutely not mandatory except if you believe you have to start with a bootsector to do an OS ...Ben wrote: Hi, i've never posted here before but i really need to say something about this 'Berserk' person, how can you even think about creating an OS when you know nothing about Asm coding, y