views:

60

answers:

2

Hey, I'm pretty interested in OS writing, I was for a long time, but still just could not swallow it (I mostly go with "What can't you understand on first read you should not do at all" - and it applies well for everything else I do, like PHP, HTML, AS3.0, C++... a lot more) just now I KIND of got it. The problem is - really, ASM was not that interesting until now that I need a specific bootloader (I KNOW there are others, like GRUB or such, but it is just a long story).

Obviously the most important part is to actually read something from the disk to the image sector and jump there. However, the INT 0x13 with AH 0x02, ie. read sector(s) from disk is not really working (or I just don't get it).

So, I found this info: Click

And after a little research in Bochs I found out the number of sectors, cylinders, heads, everything about the disk.

Now, to test it, I wanted to read the first sector, and print out a few characters from it - because I know on the beginning there is this very bootloader, and I would see a part of the messages used.

But, it just... does not work. I am trying to put the buffer to a different place, the message, different sector... Can anybody show me an example of such reading of a specified point?

Thanks.

A: 

You could have a look at the source code of one of the bootloaders you know about, e.g. grub...

Or even simpler: store the MBR or boot sector of a working Installation in a file and disassemble it. This is great because it will give you loader code that only does the bare minimum due to space constraints (max 512 bytes)

JeSuisse
I looked at one, a FAT16 to 32, but... I am just too new to assembler, so I could not really understand it (lots of opcodes for converting to FAT32 sector locations and I don't know what) - can anyone provide an explanation to this interrupt (with not just what are the inputs and outputs, but also how to use it)?
Aurel300
OK, in that case, install an old Dos OS and disassemble its boot record, it won't have anything more complicated than reading in a few sectors from the HD using Int 13h yet
JeSuisse
Have you checked wikipedia? http://en.wikipedia.org/wiki/INT_13 It has a pretty good description of inputs/ouputs. *How* to use the interrupt and the data it provides is highly dependent upon what you're trying to accomplish, and will likely vary greatly according the how the disk is formatted.
Nathan Ernst
A: 

Finally got it!

It seems the Drive Number (DL) was wrong... Since I switched to HDD (instead of floppy) I forgot to change it to 0x80. Also, sector number is in bits 2-7 in CH, not 0-5.

:D Thanks anyways.

Aurel300