home *** CD-ROM | disk | FTP | other *** search
- ;QuickFormat for MS-DOS
- ;November 30, 1987 version 5
- ; by Ted Beach --- TSR version
-
-
- cseg segment
- assume cs:cseg,ds:cseg,es:cseg,ss:cseg
-
- org 0100h
- start: jmp setup
- db "qformat by Ted Beach" ; id string for install
-
- format$loop:
- db 0cdh ;interrupt op code
- oldint db 0 ;do old interrupt first
- pushf ;save flags
- cmp b cs:busy,1
- jz exit1
- push ax ; save character
- push bx ; and registers we
- push ds ; will be atlering for the test
- xor bx,bx
- mov ds,bx
- mov bx,417h
- cmp byte ptr [bx],7
- jnz exit
- mov b cs:busy,1
-
- cli
- mov byte ptr [bx],0
- mov cs:our$stack,sp
- mov cs:sseg,ss
- mov bx,cs
- mov ss,bx
- mov sp,offset our$stack
- sti
-
- push cx
- push dx
- push si
- push di
- push es
- mov ds,bx
- mov es,bx
- cld
- call format
- pop es
- pop di
- pop si
- pop dx
- pop cx
-
- cli
- mov ss,cs:sseg
- mov sp,cs:our$stack
- mov b cs:busy,0
- sti
-
- exit: pop ds
- pop bx
- pop ax
- exit1: popf
- iret
-
- ; subroutines follow
-
- format:
- mov ax,27h
- mov dx,0201h
- mov di,offset buf
- mov cx,9
-
- init$loop: stosw
- xchg dx,ax
- stosw
- inc ax
- xchg dx,ax
- loop init$loop
-
- mov cx,40 ; do 40 cylinders
- mov b err,0 ; clear error flag
-
- format$loop1: push cx
- xor dx,dx
- call format$track
- test b err,1
- jnz fmterr
- test b format$type,2
- jnz single
- call chg$sides
- mov dx,0100h
- call format$track
- test b err,1
- jnz fmterr
- call chg$sides
-
- single: call next$track
- pop cx
- loop format$loop1
-
- ; next write boot sector and FAT1
-
- xor dx,dx
- mov bx,offset sector1
- mov cx,1
- mov ax,0302h
- int 13h
- jc error
-
- ; next write FAT2 sector
-
- mov bx,offset sector2
- mov ax,0301h
- mov cx,4
- test b format$type,1
- jz sect9
- dec cx ; 8 sectors
- sect9: int 13h
- jc error
- ret
-
- fmterr: pop cx
- error: mov dl,7
- mov ah,2
- int 21h
- clc
- ret
-
- chg$sides: push cx
- mov cx,9
- mov bx,offset buf+1
- cs1: xor byte ptr [bx],1
- add bx,4
- loop cs1
- pop cx
- ret
-
- next$track: push cx
- mov cx,9
- mov bx,offset buf
- nt1: dec byte ptr[bx]
- add bx,4
- loop nt1
- pop cx
- ret
-
- format$track: push cx
- mov bx,offset buf
- mov ax,0509h
- test b format$type,1
- jz ft1
- dec ax
- ft1: mov ch,[bx]
- mov cl,1
- int 13h
- jnc ok
- mov b err,1
- ok: pop cx
- ret
-
-
-
-
-
- err: db 0
- format$type: db 0
- buf db 9*4 dup (0)
-
- sector1:
- db 0E9h,023h,001h,"QFORM"
- db "AT1",00,02,02,01,00
- db 02,70h,00,0d0h,02,0fdh,02,0
- db 00,09,00,02,00,00h,000h,000h
- db 00h,000h,000h,000h,000h,000h,000h,000h
- db 00h,000h,000h,000h,000h,000h,000h,000h
- db 00h,000h,000h,000h,000h,000h,000h,000h
- db 07h,00Dh,00Ah,04Eh,06Fh,06Eh,02Dh,073h
- db 79h,073h,074h,065h,06Dh,020h,064h,069h
- db 73h,06Bh,020h,06Fh,072h,020h,064h,069h
- db 73h,06Bh,020h,065h,072h,072h,06Fh,072h
- db 2Eh,00Dh,00Ah,052h,065h,070h,06Ch,061h
- db 63h,065h,020h,064h,069h,073h,06Bh,020h
- db 61h,06Eh,064h,020h,073h,074h,072h,069h
- db 6Bh,065h,020h,061h,06Eh,079h,020h,06Bh
- db 65h,079h,00Dh,00Ah,024h,049h,04Fh,020h
- db 20h,020h,020h,020h,020h,053h,059h,053h
- db 4Dh,053h,044h,04Fh,053h,020h,020h,020h
- db 53h,059h,053h,053h,08Ah,0E0h,0A0h,018h
- db 7Ch,02Ah,0C1h,0FEh,0C0h,02Ah,0E0h,077h
- db 04h,002h,0C4h,032h,0E4h,050h,08Ah,0E1h
- db 8Bh,0CFh,0D0h,0CDh,0D0h,0CDh,086h,0CDh
- db 0Ah,0CCh,0E8h,042h,000h,052h,098h,0F7h
- db 26h,00Bh,07Ch,003h,0D8h,05Ah,058h,00Ah
- db 0E4h,074h,00Fh,0B1h,001h,0FEh,0C6h,03Ah
- db 36h,01Ah,07Ch,072h,0C9h,032h,0F6h,047h
- db 0EBh,0C4h,05Bh,0C3h,057h,0B9h,00Bh,000h
- db 0F3h,0A6h,05Fh,075h,032h,052h,026h,08Bh
- db 55h,01Eh,026h,08Bh,045h,01Ch,00Bh,0D2h
- db 75h,025h,08Bh,0C8h,0F7h,036h,00Bh,07Ch
- db 0Bh,0D2h,074h,001h,040h,05Ah,0C3h,0BEh
- db 03h,000h,0B4h,002h,050h,0CDh,013h,073h
- db 0Ch,04Eh,074h,00Bh,0B4h,000h,0CDh,013h
- db 72h,005h,058h,0EBh,0EFh,058h,0C3h,0BEh
- db 38h,07Ch,0ACh,03Ch,024h,074h,009h,0B4h
- db 0Eh,0BBh,007h,000h,0CDh,010h,0EBh,0F2h
- db 0B4h,000h,0CDh,016h,0CDh,019h,0FCh,08Ch
- db 0C8h,0FAh,08Eh,0D0h,0BCh,0F4h,07Fh,0FBh
- db 8Eh,0D8h,08Eh,0C0h,01Eh,0C5h,036h,026h
- db 7Ch,0C5h,034h,0BFh,000h,07Ch,0B9h,00Bh
- db 00h,0F3h,0A4h,01Fh,0A1h,02Ch,07Ch,0A2h
- db 04h,07Ch,088h,026h,007h,07Ch,0C4h,03Eh
- db 26h,07Ch,0B8h,000h,07Ch,0ABh,08Ch,0D8h
- db 0ABh,08Ah,036h,02Eh,07Ch,08Bh,03Eh,02Fh
- db 7Ch,08Ah,00Eh,031h,07Ch,0B0h,001h,0C4h
- db 1Eh,022h,07Ch,0E8h,025h,0FFh,08Bh,0FBh
- db 0BDh,00Fh,000h,026h,0F6h,045h,00Bh,008h
- db 75h,00Ch,0BEh,07Dh,07Ch,0B9h,00Bh,000h
- db 57h,0F3h,0A6h,05Fh,074h,008h,083h,0C7h
- db 20h,04Dh,075h,0E7h,0EBh,081h,0E8h,04Ch
- db 0FFh,081h,0F9h,000h,075h,077h,0F5h,095h
- db 83h,0C7h,020h,0BEh,088h,07Ch,0E8h,033h
- db 0FFh,095h,08Ah,036h,032h,07Ch,08Bh,03Eh
- db 33h,07Ch,08Ah,00Eh,035h,07Ch,0C4h,01Eh
- db 1Eh,07Ch,0E8h,0DEh,0FEh,0CDh,011h,091h
- db 0D0h,0C1h,0D0h,0C1h,081h,0E1h,003h,000h
- db 75h,001h,041h,041h,033h,0C0h,0F6h,0C2h
- db 80h,074h,002h,08Bh,0C1h,08Bh,01Eh,036h
- db 7Ch,0FFh,02Eh,01Eh,07Ch,000h,000h,000h
- db 00h,000h,000h,000h,000h,000h,000h,000h
- db 00h,000h,000h,000h,000h,000h,000h,000h
- db 00h,000h,000h,000h,000h,000h,000h,000h
- db 00h,000h,000h,000h,000h,000h,000h,000h
- db 00h,000h,000h,000h,000h,000h,055h,0AAh
-
-
- sector2 db 0fdh,0ffh,0ffh
- db 509 dup (0)
-
- db 60 dup ("STACK")
- our$stack dw (0)
- sseg dw (0)
- busy: db (0)
-
-
- setup: mov ax,351eh
- int 21h ; disk base table in es:bx
- mov ax,es
- cmp ax,0a000h
- jb doit
- erexit: mov dx,offset installnot
- mov ah,9
- int 21h
- int 20h
-
- doit: cld
- mov b format$type,0
- mov si,081h
- parse$loop: lodsb
- cmp al,0dh
- jz get$vec
- cmp al,"1"
- jnz p1
- or b format$type,2
- jmp parse$loop
- p1: cmp al,"8"
- jnz parse$loop
- or b format$type,1
- jmp parse$loop
-
- get$vec: mov ax,351eh
- int 21h
- mov byte ptr es:[bx+8],0
- push ds
- pop es
-
- mov bx, offset fat$type
- add bx,format$type
- mov al,[bx]
- mov bx,offset sector2
- mov [bx],al
-
- xor ax,ax
- mov bx,0100h
- mov ds,ax
- srlp: mov cx,[bx]
- or cx,[bx+2]
- jcxz done
- add bx,4
- cmp bx,0300h
- jnz srlp
- push cs
- pop ds
- jmp erexit
-
-
- done:
- shr bx,1
- shr bx,1
- push bx
- mov cs:oldint,bl
-
-
- mov ax,3509h ;get original int 09
- int 21h
- mov dx,bx
- push es
- pop ds
- pop ax ;interrupt number in al
- mov ah,25h ;transfer to new interrupt
- int 21h
-
- push cs
- pop ds ;set int 09 to our routine
- mov dx,offset format$loop
- mov ax,2509h
- int 21h
-
- push cs
- pop es
- push cs
- pop ds
- mov di,offset sector1+11
- mov ax,format$type
- mov bx,16
- mul bx
- mov si,offset detail
- add si,ax
- mov cx,16
- rep movsb
-
- mov dx,offset installed
- mov ah,9
- int 21h
- mov dx,offset setup
- int 27h
-
- installed db 10,13," Qformat installed",10,13
- db "< CTRL plus both SHIFT keys to format A: >"
- db 13,10,"$"
- installnot db "Unable to install Qformat",7,10,13,"$"
-
- fat$type db 0fdh,0ffh,0fch,0feh
- ; 0 1 2 3 offset to locate
- ; 9 8 9 8 #sectors
- ; \ D / \ S / #sides
-
- detail db 0,2,2,1,0,2,70h,0,0d0h,2,0fdh,2,0,9,0,2
- db 0,2,2,1,0,2,70h,0,080h,2,0ffh,1,0,8,0,2
- db 0,2,2,1,0,2,40h,0,068h,1,0fch,2,0,9,0,1
- db 0,2,1,1,0,2,40h,1,040h,1,0feh,1,0,8,0,1
-
- cseg ends
- end start
-