Search code examples
assemblycd16-bitsector

Loading Sectors From CD


I am new to OS design, and so far have designed one "OS" (Really just a single bootsector), and have decided to try to make a distinct bootloader and "kernel" (still very simple). My question is simple, yet has managed to elude me, through googling, and searching this site (okay, I did find one similar question, but the answer was to vague / advanced for me to be able to use it).

I've looked at int 0x13 AH=02, but that uses tracks, which I don't think CD's use. I saw somewhere that I should use extended read sector (AH=0x42), but I don't see how to use it, because I don't see where I can specify which sector to read, and where the sector should go in RAM.

Here is the question: How do I load sectors from a CD that uses El Torito no emulation. I would appreciate it if you could put the answer in 'simplest form', and try to provide some code, as I am new to this. Thanks in advance!

EDIT:

I don't know if you need it, but I'm using NASM syntax, so if you could give me the answer in NASM, that would be great.


Solution

  • By convention, the BIOS puts the drive number you should use for int 13h into the DL register. Then you can use int 13h, ax=4B01h (get emulation status) to determine the disk info, and int 13x function 42h to read 0x800-sized CD sectors with the sector number in the LBA field. Check the ISOLINUX bootloader for more details. Entrypoint is _start, routine to read sectors is getlinsec_cdrom.

    Edit: read the documentation on int 13h extensions about how to use it. Basically, you need to pass a filled structure, with the sector number, count, and address of the buffer where to put the read data.