Page 1 of 1

Can I read discs with interrupts?

Posted: Wed Apr 01, 2020 2:04 am
by xtex
As the title. Can I use the int command to read some sectors in the compact disc (CD)?
By the way, the CD can also store the boot code in the first sector, right?
:?: :?: :?: :?:

Re: Can I read discs with interrupts?

Posted: Thu Apr 02, 2020 5:37 am
by sunnysideup
Architecture?
If x86, are you in real mode/pmode?
I'm guessing you're in real mode and you want to read the disc using BIOS interrupts.. Is that right?

Re: Can I read discs with interrupts?

Posted: Thu Apr 02, 2020 12:04 pm
by Klakap
You can read with BIOS int 13h from CDROM:

Code: Select all

  ;read CDROM
  mov ax, 0x1000  ;segment for your data - edit it for you
  mov es, ax  ;set segment register
  mov bx, 0  ;offset for your data - edit it for you
  mov ah, 0x02  ;read function
  mov al, 1  ;number of read sectors - max 72 sectors(two cylinders)
  mov ch, 0  ;cylinder
  mov dh, 0  ;head
  mov cl, 1  ;sector
  mov dl, 0xE0  ;CDROM / 0x00 if you want read from boot CDROM, 0x00 works on boot USB too
  int 13h  ;read with BIOS interrupt
Please make sure that BIOS interrupts work only in real mode or VM8086 mode. And yes, you are right, first sector on CDROM is bootable sector, but it is probably format by filesystem ISO9660 https://wiki.osdev.org/ISO_9660 .

Re: Can I read discs with interrupts?

Posted: Thu Apr 02, 2020 12:40 pm
by Octocontrabass
xtex wrote:Can I use the int command to read some sectors in the compact disc (CD)?
Only if there is a BIOS to run that interrupt for you. New UEFI PCs may not provide a BIOS CSM anymore, or it may not be enabled by default.
xtex wrote:By the way, the CD can also store the boot code in the first sector, right?
No. The location of the boot code on a CD is determined by the boot catalog. For more information about that, refer to El Torito on the wiki or find a copy of the El Torito specification.

The El Torito specification allows the BIOS to emulate a floppy disk or hard disk through INT 0x13, so if you access the emulated disk through INT 0x13, you will see your boot code in the first sector of the emulated disk. In reality, there is no boot code in the first sector of the CD.
Klakap wrote:

Code: Select all

  mov dl, 0xE0
This is a bad example. The ID of the CD drive is not guaranteed to be the same on every computer.