Page 1 of 1

icant read sectors. please help

Posted: Sat May 28, 2011 8:53 pm
by sagar474

Code: Select all

BITS 16
start:
	mov ax, 07C0h						; Set data segment to where we're loaded
	mov ds, ax						; 
	mov ax,9000h						;initlise the stack 
	mov ss,ax						;
	mov sp,100h						;



call read_sector;


read_sector:
.Reset:
	mov		ah, 0					; reset floppy disk function
	mov		dl, 0					; drive 0 is floppy drive
	int		0x13					; call BIOS
	jc		.Reset					; If Carry Flag (CF) is set, there was an error. Try resetting again
 
	mov		ax, 0x1000				; we are going to read sector to into address 0x1000:0
	mov		es, ax
	xor		bx, bx
 
.Read:
	mov		ah, 0x02				; function 2
	mov		al, 1					; read 1 sector
	mov		ch, 1					; we are reading the second sector past us, so its still on track 1
	mov		cl, 2					; sector to read (The second sector)
	mov		dh, 0					; head number
	mov		dl, 0					; drive number. Remember Drive 0 is floppy drive.
	int		0x13					; call BIOS - Read the sector
	jc		.Read					; Error, so try again
 
	jmp		0x1000:0x0				; jump to execute the sector!
;---------------------------------------------------------------------------------------

times 510-($-$$) db 0	; Pad remainder of boot sector with 0s
	dw 0xAA55		; The standard PC boot signature
mov al,41h;
mov ah,0eh;
int 10h;

Re: icant read sectors. please help

Posted: Sat May 28, 2011 9:08 pm
by thepowersgang
Very helpful</sarcasm>

Please read the forum rules, specifically the link about "Asking questions the smart way"

That said, I suggest looking at Ralf Brown's Interrupt List to make sure you are passing the correct arguments to INT 0x13.

From a quick look, I believe that the track number should be 0 (unless you want to be reading from the second track)

Re: icant read sectors. please help

Posted: Sun May 29, 2011 5:36 am
by Coty
Also note that it's possible that your emu crashes because you IMG is less than 2 sectors... If you load a sector that is incomplete QEmu will crash! Also some other emu doesn't like images less than 360kb...

QEmu will load this successfully if I pad out the second sector, and adjust the track number (first track isn't 1).

Re: icant read sectors. please help

Posted: Sun May 29, 2011 6:37 am
by Combuster
If your floppy image is not the full 1.44MB, emu's will indeed blow up in various degrees of nastiness.

Try bochs as your emulator, it will complain whenever you screw up your write commands instead of silently doing something unexpected - in this case it would probably have saved you from asking the question altogether.

Re: icant read sectors. please help

Posted: Sun May 29, 2011 11:16 am
by Chandra
At any case, the 'read sector' function shouldn't have failed at all(unless you are reading from a defective media). So I'm assuming the original issue is with loading the kernel/2nd stage loader(and not loading the sector) which shall be worked out by correcting the cylinder no.
Cheers.

Re: icant read sectors. please help

Posted: Tue May 31, 2011 2:41 pm
by Bietje
You should try

Code: Select all

xor ch, ch
instead of setting it to 1.