; Call DOS 32H from C. This is an undocumented function call documented in
; PC Tech. Journal May 1986. This function returns a pointer to a disk
; description table that contains the following:
;
;   offset  length  what
;   ------  ------  ----
;      0     byte   assigned physical disk (A=0, B=1, ...)
;      1     byte   same as above but 0 for RAM disk
;      2     word   bytes per sector
;      4     byte   sectors per cluster minus 1
;      5     byte   #heads minus 1
;      6     word   reserved sectors
;      8     byte   #copies of FAT (normally 2 for real disks, 1 for RAM disks)
;      9     word   max directory entries
;     11     word   first usable sector (i.e. data area)
;     13     word   total cluster count plus 1
;     15     byte   #sectors occupied by each FAT
;     16     word   first sector of the root's directory
;     18    dword   device driver address
;     22     word   media descriptor
;     24    dword   chain to next disk table
;     28     word   cluster of current working directory
;
; in C, use
;   unsigned char drv,	/* drive number: 1=A, 2=B, ...; 0=current drive */
;		  status;  /* if 0xFF means invalid drive */
;   unsigned short tabseg,  /* disk description table segment */
;		   taboff;  /* disk description table offset */
;
;   status = func32h(drv, &tabseg, &taboff);
;
; The reason for writing this procedure in assembly is because the
; function returns the description table segment address in DS which
; cannot be accessed by using intdosx() function in C.
;
; Written by Peter Wu 6/27/86
;
_text	segment public byte 'code'
	assume cs:_text

	public	_func32h
_func32h proc	 near
	push	bp
	mov	bp,sp
	push	ds		; save DS

	mov	dl,[bp+4]	; drive number
	mov	ah,32h
	int	21h

	mov	cx,bx		; stupid move, but I need bx
	mov	si,ds
	pop	ds

	mov	bx,[bp+6]	; &tabseg
	mov	[bx],si 	; store tabseg
	mov	bx,[bp+8]	; &taboff
	mov	[bx],cx 	; store taboff
	mov	ah,0		; al contains ffh if error

	pop	bp
	ret
_func32h endp

_text	ends
	end
