Reputation: 145
I am trying to read disk sectors by the following code:
disk_load :
push dx
mov ah , 0x02 ; BIOS read sector function
mov al , dh ; Read DH sectors(dh is initialized before calling the routine)
mov ch , 0x01 ;
mov dh , 0x00 ; Select head 0
mov cl , 0x02 ; Start reading from second sector ( i.e.
; after the boot sector )
mov dl,0x80 (tried with 0x00 as well)
int 0x13 ; BIOS interrupt
pop dx ; Restore DX from the stack
jc cset
cmp dh,al ; if AL ( sectors read ) != DH ( sectors expected )
jne disk_error ;
Problem is ,Carry flag is set every time denoting an error. Initially I tried boot disk 0x00 which when I checked AL register afterwards found out that no sectors are being read. Then I changed to 0x80 ,now AL register would have the exact number of sectors requested but still Carry flag is being set!
So what could be the problem here? Carry seems to be set always after int 0x13! I am running an iso file in Virtual Box if that matters.
Upvotes: 2
Views: 3115
Reputation: 58762
Some hints:
CH
with zero, not one, beause cylinders are numbered from zero.AH
, have you looked at that?DL
so there should be no need to overwrite that.Using floppy image and fixing point #1, it works for me with bochs and qemu (don't have virtualbox).
Upvotes: 4