Page 1 of 1

What's the point of resetting a floppy?

Posted: Sun Nov 16, 2014 1:48 am
by MarkZar
I'm learning to read data from a floppy disk according to this tutorial( http://www.brokenthorn.com/Resources/OSDev5.html ), I just don't understand, what's the meaning by "reset"? What would happen if I don't reset it?

Thank you.

Code: Select all

.Reset:   ; <--why should I reset it?
	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!

Re: What's the point of resetting a floppy?

Posted: Sun Nov 16, 2014 1:54 am
by iansjack
It's the same as resetting any electronic device. It returns it to a known state.

Re: What's the point of resetting a floppy?

Posted: Sun Nov 16, 2014 2:30 am
by Antti
That code is not something you should learn from. A reset should be done after few unsuccessful read tries. Then few read tries and another reset if still unsuccessful. This loop should be run few times and if still unsuccessful, an error message should be displayed. No endless read loops!