RealMode Drive Detection Routine Using BIOS [Problems]

Programming, for all ages and all languages.
Post Reply
cr0PE
Posts: 2
Joined: Tue Oct 06, 2009 5:39 pm

RealMode Drive Detection Routine Using BIOS [Problems]

Post by cr0PE »

I have a drive number detection routine that works fine on every computer I have tried it on except one. Here is the code:

Code: Select all

drivedet:		;Detect the number of floppy and hard drives present and save their numbers
	mov ah, 0x15	;INT 0x13 AH=0x15: get disk type
	int 0x13
	jc .next
	cmp ah, 0	; ah=0: no disk present
	jz .next
	cmp ah, 02	; ah=1: floppy without change-line. ah=2: floppy with change-line
	jnbe .drv3
	dec byte [count]
	inc byte [floppies]    ;increment the total floppy count
	push bx
	xor bx, bx
	mov byte bl , [floppies]
	dec bl
	mov byte [fd0+bx], dl   ;save drive number in dl to proper drive number variable
	pop bx
	jmp .next
.drv3:
	dec byte [count]
	inc byte [hds]	;ah=3: hard disk
	push bx
	xor bx, bx
	mov byte bl, [hds]
	dec bl
	mov byte [hd0+bx], dl   ;save drive number in dl to proper drive number variable
	pop bx
.next:
	inc dl
	cmp byte [count], 0	;some retarded BIOSs report duplicate high number drives
	jz .end		
	jmp drivedet	
Before, calling this code I set up the total number of drives (from BIOS) in the byte variable [count] and zero out dl.

The problem computer is a gateway, sorry don't know the model, but it has a AMD Athlon Thunderbird at 1.2Ghz and on it the code just goes into an infinite loop. Like I said this is the only computer it does that on. At first I suspected that the BIOS was giving me an incorrect number of drives, but I found this to be false.

Any ideas would be appreciated. Thanks in advance,
cr0PE
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: jz falls through on one computer but not others

Post by jal »

cr0PE wrote:the code just goes into an infinite loop
Are you sure it's in this code? If so, at what point does it do the infinite loop? And why (i.e. which condition fails)?


JAL
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: RealMode Drive Detection Routine Using BIOS [Problems]

Post by AJ »

Hi,

If one of your first conditions fails (cf set or ah == 0), you jmp to the .next label without decrementing [count].

Cheers,
Adam
cr0PE
Posts: 2
Joined: Tue Oct 06, 2009 5:39 pm

Re: RealMode Drive Detection Routine Using BIOS [Problems]

Post by cr0PE »

AJ wrote:Hi,

If one of your first conditions fails (cf set or ah == 0), you jmp to the .next label without decrementing [count].

Cheers,
Adam
Of course. Thanks.
Post Reply