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.
I started to work on some code to install my OS to the HDD, but I'm having issues with the RealMode detection code (figures out if the HDD already has the OS on it or not). I put a arbitrary value at sector 1 of the HDD and wish to read it in my bootloader upon next bootup, but this is failing miserably. There is no error code being returned so it seeems fine, but the value is always 0. I'm not sure if it is my PMode HDD PIO driver that is misplacing the value or if it is my RealMode code.
I see you check the status of the int 13h operation by comparing AH with zero. The official way to do it with interrupt 13h is checking the carryflag, you can simply use "jc hdd_error". I have had a rare situation where carry=1, the sectors I wanted to read where not read right while AH was zero..
You read a sector and check if the first byte has value 0x0C in it.
What do you want to check? The bootsector of your OS?
If you read from harddisk, the firstsector is mostly the MBR (I assume that's also the case on your harddisk). You read 16 sectors in address 1000h:0000h, first sector cyl=0, head=0, sect=1, thats the first LBA=sector, so you are reading the MBR first and checking for a 0x0C.
Did you put that 0x0C value on the MBR of your harddisk or on the first sector of the partition of your OS?
It's important to make clear what's goes wrong: Writing the sector or reading the sector.
Read the sector with a 3th-party program, like dd and hexedit with a Linux bootdisk. Check manually which value the first byte has. If that's ok you know for sure the problem is at the read program.
I ended up creating two seperate bootloaders, one for booting off of the floppy, and one that gets installed on the HDD, I had to tweak my linker a bit, but all is well now...
it is official, my OS can now be installed on a HDD and then booted.. yay =) lol.