Category : Miscellaneous Language Source Code
Archive   : BDISK10.ZIP
Filename : FFF.ASM

 
Output of file : FFF.ASM contained in archive : BDISK10.ZIP
;============================================================================
; Fast Floppy Format
;
; This program uses the BDISK library routines to perform a format of a
; 5 1/4" 360K floppy diskette. The file BDISK.INC is necessary for assembly,
; and the file BDISK.LIB is necessary for linking.

DOSSEG
.MODEL small

INCLUDE bdisk.inc

.STACK 200H

.DATA

Mess1 db 13,10
db 'Fast Floppy Format, ASM - Version 1.0, by Eric Tauck',13,10
db '$'

Mess2 db 13,10
db 'Usage: FFF ',13,10
db '$'

Mess3 db 13,10
db 'About to format diskette in drive A:',13,10
db 'Press any key to begin',13,10
db '$'

Mess4 db 13,10
db 'Error: Illegal drive specifier',13,10
db '$'

Mess5 db 13,10
db 'Error: Could not format disk',13,10
db '$'

.DATA?

Drive dw ? ;drive to format
SecBuf db (9 * 512) DUP (?) ;buffer for whole track

.CODE

;--- initialize

Start: push ds
mov ax, @DATA
mov ds, ax ;set data segment
mov ah, 9 ;display function
mov dx, OFFSET Mess1 ;message
int 21h

mov ax, 2523h ;set int function
push cs
pop ds ;interrupt segment
mov dx, OFFSET Break ;interrupt offset
int 21h ;install break trap
pop ds

setbase 9, 512 ;set disk base

;--- get drive number

mov si, 81h ;command tail location
Main1: lodsb ;load length
cmp al, 13 ;check if end
je Main2
cmp al, ' ' ;skip delimiters
jbe Main1

mov dx, @DATA
mov ds, dx ;set data segment
or al, 'a'-'A' ;make lower case
sub al, 'a' ;convert to number
cmp al, 26 ;check range
jae Main3

;--- prepare to format

sub ah, ah
mov drive, ax ;save drive number
add Mess3 + 36, al ;fix message
mov dx, OFFSET Mess3
mov ah, 9 ;display function
int 21h

mov ax, 0c08h ;function number
int 21h ;wait for key
jmp short Main4

;--- no input

Main2: mov dx, OFFSET Mess2
jmp Main8

;--- invalid drive

Main3: mov dx, OFFSET Mess4
jmp Main8

;--- format disk, loop for each track and head

Main4:
sub bx, bx ;track count
mov dx, OFFSET Mess5 ;message if format error
Main5:
sub cx, cx ;head count
Main6:
trkfrm drive, cx, bx, 9, 512 ;format track
or ax, ax ;check if error
jz Main7
jmp Main8

Main7: inc cx ;next head
cmp cx, 2 ;check if done
jne Main6
inc bx ;next track
cmp bx, 40 ;check if done
jne Main5

;--- write boot sector

mov ax, SEG _BOOTSEC
mov ds, ax
mov di, OFFSET _BOOTSEC ;location of boot sector

secwrt drive, 0, 0, 1, 1, ds, di ;write sector

;--- write FAT's

mov ax, @DATA
mov es, ax
mov di, OFFSET SecBuf ;location of sector buffer

push di
mov al, _BOOTSEC + 21 ;get the media descriptor byte
stosb
mov al, 0ffH ;reserved FF
stosb
stosb
sub al, al
mov cx, (9 * 512) - 3 ;remaining bytes in buffer
rep stosb ;clear buffer
pop di

secwrt drive, 0, 0, 2, 2, es, di ;write sectors
secwrt drive, 0, 0, 4, 2, es, di ;write sectors

;--- write directories

push di
sub al, al
stosb
stosb
stosb ;clear the first bytes
pop di

secwrt drive, 0, 0, 6, 4, es, di ;write sectors
secwrt drive, 1, 0, 1, 3, es, di ;write sectors

resbase
mov ax, 4c00h ;exit function and code
int 21h

;--- error formatting disk, error message location in DX

Main8: mov ax, @DATA
mov ds, ax ;set data segment
mov ah, 9 ;display function
int 21h

resbase ;restore disk data
mov ax, 4cffh ;exit function and code
int 21h

;--- ^C (break) interrupt handler

Break: resbase ;restore disk data
stc ;set carry
retf ;far return to DOS

END Start


  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : BDISK10.ZIP
Filename : FFF.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/