[net.micro.pc] Park source code and COM file.

langet@ecn-pc.UUCP (Timothy Lange) (01/23/86)

Here is the assembly source and uuencode of the .COM file for the
program PARK.  This will 'park' the heads on a hard disk IBM PC/XT system.
I don't know how well it will function on other systems.  I got this
from a article in PC Tech Journal, December, 1985.
----------
page	60, 132
title	Park, park the hard disk heads for relocation.
;
; Taken out of PC Tech Journal, December, 1985 issue.
;
; Equates.
;
cr	equ	00dh
lf	equ	00ah
;
; Macros.
;
doscall macro	func
	mov	ah, func
	int	21h
	endm
;
code	segment para	public	'code'
	assume	cs:code, ds:code
	org	100h
park	proc	near
	jmp	start
;
; Messages.
;
mess_1	db	cr, lf, 'No fixed disks installed', cr, lf, '$'
mess_2	db	cr, lf, 'Fixed disk in parked position', cr, lf, '$'
mess_3	db	cr, lf, 'Both fixed disk in parked position', cr, lf, '$'
mess_4	db	cr, lf, 'TURN OFF COMPUTER', '$'
;
; Local storage.
;
oldint	dd	?			; original INT 41 vector
parms	db	64 dup (?)		; substitue parameter table
;
start:	mov	al, 41h			; get and store original vector
	doscall 35
	mov	word ptr oldint, bx
	mov	word ptr oldint + 2, es
	lds	si, oldint		; source starting address
	mov	ax, cs			; destination starting address
	mov	es, ax
	mov	di, offset parms
	mov	cx, 64			; number of bytes to move
	cld				; move increasing direction
	rep	movsb			; move them
	mov	ax, cs			; restore DS addressability
	mov	ds, ax
;
; Increase maximum number of cylinders in new table by 16.
;
	mov	ax, 16
	lea	bx, parms
	add	[bx], ax
	add	10h[bx], ax
	add	20h[bx], ax
	add	30h[bx], ax
;
; Check for existence of hard drive.
;
	mov	ah, 11h			; attempt to recalibrate
	mov	dx, 80h			; first hard disk
	push	dx
	int	13h
	or	ah, ah			; was command performed ok?
	lea	dx, mess_1		; set up no-drive message and
	jnz	stop			; exit if no fixed drives
	pop	dx
	call	mover
;
; Check for existence of second hard drive.
;
	mov	ah, 11h			; attempt to recalibrate
	mov	dx, 81h			; second hard drive
	push	dx
	int	13h
	or	ah, ah			; did it do it ok?
	lea	dx, mess_2		; one-drive message
	jnz	stop			; exit if no second drive
	pop	dx
	call	mover
	lea	dx, mess_3		; two-drive message
stop:	doscall 09h			; display "drive" message
	lea	dx, mess_4		; display final message
	doscall 09h
	cli				; disable interrupts and quit
	hlt
;
; Move to highest track on disk.
; Get original drive parameters.
;
mover:	mov	ah, 08
	push	dx
	int	13h
;
; Install new vector for INT 41.
;
	mov	al, 41h
	lea	dx, parms
	doscall 25h
;
; Initialize drive parameters with new table.
;
	mov	ah, 09
	pop	dx
	push	dx
	int	13h
;
; Move head past highest pre-formatted cylinder.
;
moveit: clc				; clear carry flag
	add	ch, 1			; next cylinder
	jnc	m2			; if register overflowed
	add	cl, 40h			; increase high bits
m2:	mov	ax, 0401h		; move and verify sector
	int	13h
	or	ah, ah			; past end?
	jz	moveit			; if not, try one more
;
; Return to shipping cylinder.
;
	clc
	sub	ch, 1
	jnc	m3			; in case of underflow
	sub	cl, 40h			; decrease high bits
m3:	mov	ax, 0401h
	int	13h
;
; Restore original INT 41 vector.
;
	lds	dx, oldint
	mov	al, 41h
	doscall 25h
;
; Restore DS addressability.
;
	mov	ax, cs
	mov	ds, ax
;
; Initialize to original drive parameters.
;
	mov	ah, 09
	pop	dx
	int	13h
	ret
park	endp
code	ends
	end	park
----------

Run this though uudecode
----------
begin 640 park.com
MZ;X`#0I.;R!F:7AE9"!D:7-K<R!I;G-T86QL960-"B0-"D9I>&5D(&1I<VL@
M:6X@<&%R:V5D('!O<VET:6]N#0HD#0I";W1H(&9I>&5D(&1I<VL@:6X@<&%R
M:V5D('!O<VET:6]N#0HD#0I455).($]&1B!#3TU0551%4B0`````````````
M````````````````````````````````````````````````````````````
M`````````````````+!!M"/-(8D>?0&,!G\!Q39]`8S(CL"_@0&Y0`#\\Z2,
MR([8N!``C1Z!`0$'`4<0`4<@`4<PM!&Z@`!2S1,*Y(T6`P%U'%KH)@"T$;J!
M`%+-$PKDC18@`74(6N@2`(T60@&T"<TAC19I`;0)S2'Z]+0(4LT3L$&-%H$!
MM"7-(;0)6E+-$_B`Q0%S`X#!0+@!!,T3"N1T[OB`[0%S`X#I0+@!!,T3Q19]
8`;!!M"7-(8S(CMBT"5K-$\,`````````
`
end
-- 
Tim Lange		Engineering Business Offices
317-494-5338		Rm 120 Engineering Administration Bldg.
Purdue University 	West Lafayette, IN  47907
{decvax|harpo|ihnp4|inuxc|seismo|ucbvax}!pur-ee!langet