Can I read discs with interrupts?

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.
Post Reply
xtex
Posts: 4
Joined: Wed Apr 01, 2020 1:43 am
Contact:

Can I read discs with interrupts?

Post 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?
:?: :?: :?: :?:
sunnysideup
Member
Member
Posts: 106
Joined: Sat Feb 08, 2020 11:11 am
Libera.chat IRC: sunnysideup

Re: Can I read discs with interrupts?

Post 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?
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Re: Can I read discs with interrupts?

Post 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 .
Octocontrabass
Member
Member
Posts: 5575
Joined: Mon Mar 25, 2013 7:01 pm

Re: Can I read discs with interrupts?

Post 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.
Post Reply