View Single Post
Old May 16th, 2006, 1:25 PM   #8
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3 kruptof is on a distinguished road
before you create a bootloader you have to understand that the bios looks for the value 0x55 in the 510 location of the device (which is a drive A) and 0xaa in the 511 location. here is the code to write a simple bootdisk in C but this is not very good because it just goes into the bootloader and comes straight out.

Here is the code
Quote:
#include <stdio.h>
#include <sys/types.h>
#include<unistd.h>
#include <fcntl.h>
int main(int argc, char *argv[])
{
char buffer[512];
int fhandle;
buffer[510]=0x55;
buffer[511]=0xaa;
fhandle=open("a:", O_RDWR);
lseek(fhandle,0,SEEK_CUR);
write(fhandle,buffer,512);
close(fhandle);
return 0;
}
for more in depth explaination please refer to Krishnakumar tutorial here is the link for his tutorial: http://linuxgazette.net/issue77/krishnakumar.html
kruptof is offline   Reply With Quote