home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.update.uu.se
/
ftp.update.uu.se.2014.03.zip
/
ftp.update.uu.se
/
pub
/
rainbow
/
msdos
/
latrobe
/
b
/
biodif.arc
/
FORMAT.DIF
< prev
next >
Wrap
Text File
|
1987-07-18
|
13KB
|
428 lines
----------dsformat.asm
TITLE DSFORMAT
;++
----------format.asm
TITLE FORMAT
;++
-----------------------------------------------
----------dsformat.asm
; If the /2 option is chosen, then the program
; formats a double-sided disk.
;
; It automatically sets the /V option to request a volume label.
----------format.asm
; It automatically sets the /V option to request a volume label.
-----------------------------------------------
----------dsformat.asm
; RGT 17 Jan 1987 Modified to use hard disk information,
; and to format double/sided disks.
; Also split the program into smaller files.
;
----------format.asm
; RGT 17 Jan 1987 Modified to split the program into smaller files.
;
-----------------------------------------------
----------dsformat.asm
; Define some public symbols to aid in debugging
;
PUBLIC START_DISK_FORMAT, INITIALIZE_FAT, WRITE_VOL_LABEL
PUBLIC READY_DISKS, FORMAT_DISK, VERIFY_DISK_SECTORS
PUBLIC WRITE_FAT_SECTORS_TO_DISK, COPY_RESERVED_SECTORS
PUBLIC READ_SECTORS, WRITE_SECTORS, CHECK_SECTOR
PUBLIC DISP_ERROR_AND_RET, WRITE_DISK_SECTORS, PROCESS_DISK_SECTORS
PUBLIC READ_DISK_SECTORS, SETUP_CMD_BUF
PUBLIC READ_HARD_DISK_CTL, READ_HARD_DISK_BLOCK
PUBLIC PHYS_FMT_FLOPPY
;
; Define the files to be included
----------format.asm
; Define the files to be included
-----------------------------------------------
----------dsformat.asm
INCLUDE DISKPAR.INC ;Disk parameter information
INCLUDE MSCALLS.INC ;Define MS-DOS calls
----------format.asm
INCLUDE MSCALLS.INC ;Define MS-DOS calls
-----------------------------------------------
----------dsformat.asm
EXTRN FAT_BUFFER:BYTE, PROG_END:ABS
EXTRN READ_FILE:NEAR, WRITE_FILE:NEAR
EXTRN BAT_BUFFER:BYTE, BAT_BUFFER_2:BYTE
EXTRN BAT_BUFFER_3:BYTE, BAT_BUFFER_4:BYTE
;
; Define the starting location for the program
----------format.asm
EXTRN READ_FILE:NEAR, WRITE_FILE:NEAR
;
; Define some sizes for the floppy disks
;
F_MAX_FAT_SECTORS EQU 3 ;Assume 3 sectors per FAT
F_MAX_NUM_FATS EQU 2 ;2 FATs on disk
F_SECTOR_SIZE EQU 512 ;Sector size
F_CLUSTER_SIZE EQU 1 ;Cluster size
F_MAX_SECT_PER_TRACK EQU 10 ;Normal sectors
F_MAX_SURFACES EQU 1 ;Number of surfaces
;
; Define some sizes for the hard disks
;
H_MAX_FAT_SECTORS EQU 6 ;Assume 3 sectors per FAT
H_MAX_NUM_FATS EQU 2 ;2 FATs on disk
H_SECTOR_SIZE EQU 512 ;Sector size
H_CLUSTER_SIZE EQU 4 ;Cluster size
H_MAX_SECT_PER_TRACK EQU 16 ;Normal sectors
H_MAX_SURFACES EQU 4 ;Number of surfaces
;
; Define the starting location for the program
-----------------------------------------------
----------dsformat.asm
DB 'Rainbow Double-Sided Disk Formatter Version 1.0.',CR,LF
DB 'Copyright 1987 Flame-Point Computer Products, Inc.',CR,LF
DB CR,LF
----------format.asm
DB 'Rainbow Disk Formatter Version 2.7.',CR,LF
DB CR,LF
-----------------------------------------------
----------dsformat.asm
;
; Define the number of valid options
;
NUM_VALID_OPTIONS DB 6 ;Number of valid options
;
; Define the symbols for the valid options
----------format.asm
; Start of buffer for reading in hard disk BAT information
;
BAT_BUFFER DB 0 ;First byte of BAT buffer
BAT_BUFFER_2 DB 0 ;Second byte of BAT buffer
BAT_BUFFER_3 DB 0 ;Third byte of BAT buffer
BAT_BUFFER_4 DB 0 ;Fourth byte of BAT buffer
DB 7164 DUP(0) ;Rest of BAT buffer
;
; Define the number of valid options
;
NUM_VALID_OPTIONS DB 5 ;Number of valid options
;
; Define the symbols for the valid options
-----------------------------------------------
----------dsformat.asm
FOPT_DOUBLE EQU 020H ;Option is /2 (double-sided)
;
----------format.asm
;
-----------------------------------------------
----------dsformat.asm
VALID_OPTIONS DB '2CIOVS' ;Valid options for format
;
----------format.asm
VALID_OPTIONS DB 'CIOVS' ;Valid options for format
;
-----------------------------------------------
----------dsformat.asm
; Disk parameter buffer for single-sided floppy disk drive
;
F1_DISK_PARAM DW F_SECTOR_SIZE ;Sector size of disk
DB F_CLUSTER_SIZE ;Cluster size of disk
DW F_NUM_RESERVED_SECT ;Number of reserved sectors
DB F_MAX_NUM_FATS ;Number of FATs on disk
DW F_NUM_DIR_ENTRIES ;Number of directory entries
DW F_NUM_SECTORS_TOTAL ;Number of sectors on disk
DB F_DISK_MEDIA_TYPE ;Disk media type code
DW F_MAX_FAT_SECTORS ;Number of FAT sectors
DW F_MAX_SECT_PER_TRACK ;Number of sectors per track
DW F_MAX_SURFACES ;Number of surfaces
DW 0 ;Unknown
;
; Disk parameter buffer for double-sided floppy disk drive
;
F2_DISK_PARAM DW F2_SECTOR_SIZE ;Sector size of disk
DB F2_CLUSTER_SIZE ;Cluster size of disk
DW F2_NUM_RESERVED_SECT ;Number of reserved sectors
DB F2_MAX_NUM_FATS ;Number of FATs on disk
DW F2_NUM_DIR_ENTRIES ;Number of directory entries
DW F2_NUM_SECTORS_TOTAL ;Number of sectors on disk
DB F2_DISK_MEDIA_TYPE ;Disk media type code
DW F2_MAX_FAT_SECTORS ;Number of FAT sectors
DW F2_MAX_SECT_PER_TRACK ;Number of sectors per track
DW F2_MAX_SURFACES ;Number of surfaces
DW 0 ;Unknown
;
; Disk parameter buffer for source disk drive, if hard disk
----------format.asm
; Disk parameter buffer for floppy disk drive
;
FLOPPY_DISK_PARAM DW F_SECTOR_SIZE ;Sector size of disk
DB F_CLUSTER_SIZE ;Cluster size of disk
DW 20 ;Number of reserved sectors
DB F_MAX_NUM_FATS ;Number of FATs on disk
DW 96 ;Number of directory entries
DW 800 ;Number of sectors on disk
DB 0FAH ;Disk media type code
DW F_MAX_FAT_SECTORS
;Number of FAT sectors
DW F_MAX_SECT_PER_TRACK
;Number of sectors per track
DW F_MAX_SURFACES ;Number of surfaces
DW 0 ;Unknown
;
; Disk parameter buffer for source disk drive, if hard disk
-----------------------------------------------
----------dsformat.asm
MOV SI,OFFSET F1_DISK_PARAM ;Get the address of the disk
;parameter block for floppies
CMP AL,3 ;See if floppy disk
----------format.asm
MOV SI,OFFSET FLOPPY_DISK_PARAM ;Get the address of the disk
;parameter block for floppies
CMP AL,3 ;See if floppy disk
-----------------------------------------------
----------dsformat.asm
MOV SI,OFFSET F1_DISK_PARAM ;Get the address of the disk
;parameter block for floppies
CMP DISK_TO_FORMAT,3 ;Check disk to be formatted
----------format.asm
MOV SI,OFFSET FLOPPY_DISK_PARAM ;Get the address of the disk
;parameter block for floppies
CMP DISK_TO_FORMAT,3 ;Check disk to be formatted
-----------------------------------------------
----------dsformat.asm
; Formatting a floppy disk -- see if double-sided
;
TEST WORD PTR OPTION_MASK,FOPT_DOUBLE
;See if double-sided disk
JZ FMT_FLOPPY_DISK ;If not, get address of buffer area
MOV SI,OFFSET F2_DISK_PARAM ;Otherwise, get the address of the disk
;parameter block for double-sided
;floppy disks
FMT_FLOPPY_DISK:
----------format.asm
; Formatting a floppy disk
;
FMT_FLOPPY_DISK:
-----------------------------------------------
----------dsformat.asm
; Now get the disk control information and store it in parameter block
;
PUSH SI ;Save reg DI
MOV SI,TARGET_PARAM_ADR ;Get address of disk parameter buffer
MOV AX,HOM_SECPERTRK[BX] ;Get number of sectors per track
MOV DP_SECT_PER_TRACK_OFF[SI],AX ;And store this information
MOV AX,HOM_SECSIZE[BX] ;Get sector size
MOV DP_SECTOR_SIZE_OFF[SI],AX ;And store this information
MOV AL,HOM_NOSURFACE[BX] ;Get number of surfaces
CBW ;Convert to word
MOV DP_NUM_SURFACES_OFF[SI],AX ;And store this information
POP SI ;Restore reg DI
;
; Now read in the DPD blocks
----------format.asm
; Now read in the DPD blocks
-----------------------------------------------
----------dsformat.asm
MOV CX,(BAT_NUM_BYTES/2) ;Set count to number of words
;in rest of block
----------format.asm
MOV CX,250 ;Set count to number of words
;in rest of block
-----------------------------------------------
----------dsformat.asm
ADD BAT_BUFFER_ADR,BAT_NUM_BYTES
;Increment address to end of block read
MOV BX,BAT_BUFFER_ADR ;Get new address of block
INC AL ;Increment sector number
MOV SI,TARGET_PARAM_ADR ;Get address of target disk parameters
CMP AL,DP_SECT_PER_TRACK_OFF[SI] ;Compare sector number to
;number of sectors per track
JLE READ_BAT_BLOCK_CONTINUE ;If less, then go on to next sector
INC DX ;Otherwise, increment track number
MOV AL,1 ;And set to sector 1 of track
READ_BAT_BLOCK_CONTINUE:
DEC NUM_BAT_SECTORS ;Decrement count of sectors to read
----------format.asm
ADD BAT_BUFFER_ADR,001F4H ;Increment address to end of block read
MOV BX,BAT_BUFFER_ADR ;Get new address of block
INC AL ;Increment sector number
DEC NUM_BAT_SECTORS ;Decrement count of sectors to read
-----------------------------------------------
----------dsformat.asm
;
; Now convert track number into cylinder and track number
;
MOV BX,TARGET_PARAM_ADR ;Get address of disk parameter buffer
MOV AX,DX ;Move track number into reg AX
XOR DX,DX ;Clear upper word
DIV WORD PTR DP_NUM_SURFACES_OFF[BX]
;Divide by number of surfaces
MOV DIRECT_CMD_TRACK,AX ;Store track to be read
;
; Combine the surface number with the drive number
;
MOV AX,DX ;Get surface to be read
OR AL,40H ;Set to physical disk
MOV DIRECT_CMD_PHYS_UNIT,AL ;Store physical unit number
;
; Now set up the call to MS-DOS to format the track
----------format.asm
MOV AX,DX ;Get disk to be formatted
AND AL,3 ;Mask out all but lower 2 bytes
OR AL,40H ;Set to physical disk
MOV DIRECT_CMD_PHYS_UNIT,AL ;Store physical unit number
SHR DX,1 ;Shift out head from track number
SHR DX,1
MOV DIRECT_CMD_TRACK,DX ;Store track to be formatted
MOV CX,14 ;Set number of bytes
;
; Now set up the call to MS-DOS to format the track
-----------------------------------------------
----------dsformat.asm
MOV SI,TARGET_PARAM_ADR ;Otherwise, Get address of
;target disk parameters
MOV CX,DP_SECTOR_SIZE_OFF[SI] ;Get sector size of target disk
SHR CX,1 ;Divide by 2 to get no. of words
MOV SI,BX ;Get address of buffer
XOR BX,BX ;Clear checksum
----------format.asm
MOV SI,BX ;Otherwise, get address of buffer
MOV CX,H_SECTOR_SIZE / 2 ;Get number of words in block
XOR BX,BX ;Clear checksum
-----------------------------------------------
----------dsformat.asm
MOV DIRECT_CMD_DRIVE,0FFH ;Set physical drive
SHL AX,1 ;Shift drive to upper limit
SHL AX,1
SHL AX,1
SHL AX,1
MOV DIRECT_CMD_PHYS_UNIT,AL ;Store drive to be formatted
MOV AX,BORROWED_MEM_START ;Get offset to format buffer
----------format.asm
MOV DIRECT_CMD_DRIVE,AL ;Store drive to be formatted
MOV AX,BORROWED_MEM_START ;Get offset to format buffer
-----------------------------------------------
----------dsformat.asm
;
; Formatted side zero of disk -- if error, then just return
;
JC PHYS_FMT_FLOPPY_RET ;If error, return it
;
; Formatted size zero of disk -- see if double-sided disk
;
MOV SI,TARGET_PARAM_ADR ;Get address of disk parameter buffer
CMP WORD PTR DP_NUM_SURFACES_OFF[SI],F2_MAX_SURFACES
;See if double-sided
JNZ PHYS_FMT_FLOPPY_RET ;If not, just return
;
; Double-sided disk -- format second side
;
MOV DIRECT_CMD_CMD,3 ;Set command to format track
MOV AL,DISK_TO_FORMAT ;Get drive to be formatted
AND AL,3 ;Mask out all but lower 2 bits
MOV DIRECT_CMD_DRIVE,0FFH ;Set physical drive
SHL AX,1 ;Shift drive to upper limit
SHL AX,1
SHL AX,1
SHL AX,1
OR AX,1 ;OR in second side
MOV DIRECT_CMD_PHYS_UNIT,AL ;Store drive to be formatted
MOV AX,BORROWED_MEM_START ;Get offset to format buffer
MOV DIRECT_CMD_BUF_OFFSET,AX ;Store it in format command buffer
MOV DIRECT_CMD_BUF_SEGMENT,0 ;Set segment of format buffer to zero
MOV DIRECT_CMD_TRACK,0FFH ;Set track number (all tracks)
MOV DIRECT_CMD_SECTOR,0 ;Set sector number to zero
MOV DIRECT_CMD_COUNT,0 ;Set sector count to zero
MOV BX,OFFSET DIRECT_CMD_BUF ;Get address of format command buffer
FLOPPY_DIRECT ;Call direct floppy interrupt
;to perform the call
;
; Done with format -- return to caller
;
PHYS_FMT_FLOPPY_RET:
RET ;And return to caller
;
SCODE ENDS ;End of segment
----------format.asm
RET ;And return to caller
;
;
; Define the end of the program as a large buffer for formatting
; Make it long enough to hold all sectors of the maximum number
; of FATs.
;
FAT_BUFFER_SIZE EQU H_MAX_NUM_FATS * H_MAX_FAT_SECTORS * H_SECTOR_SIZE
FAT_BUFFER DB FAT_BUFFER_SIZE DUP (0) ;Buffer for FAT sectors
;
; Define a symbol for the end of the program
;
PROG_END EQU $ ;End of program
;
SCODE ENDS ;End of segment
-----------------------------------------------
----------dsformat.asm
----------format.asm
END PROG_START
RET ;And return to caller