x86 BIOS Interrupt 13,2
According to the image, the DL register has to contain a specific value in order to know what drive number to read from, however, in the following code (using intel syntax), we are instead moving the dl register into the value of the ebr_drive_number (that we defined above), instead of the other way around. How then is it able to function correctly, as I am able to read data from the disk.
ebr_drive_number: DB 0
; other code
main:
MOV ax,0
MOV ds,ax ;start address of data segment
MOV es,ax ;start address of extended segment
mov ss,ax ;start address of stack segments
MOV sp,0x7C00
MOV [ebr_drive_number],dl ;Drive number to read from <------------- HERE
MOV ax, 1 ;LBA Index
MOV cl, 1 ; sector number
MOV bx, 0x7E00 ;pointer to a buffer
CALL disk_read
MOV si,os_boot_msg
CALL print
HLT
when switching the order of the operation,
MOV dl,[ebr_drive_number}
which makes more sense in my head, as we are moving the value that we defined as ebr_drive_number into the dl register, which the interrupt needs, no data is read from the disk, but no build errors are present either.
MiEdCaLe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.