home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 June
/
SIMTEL_0692.cdr
/
msdos
/
dskutl
/
fix_disk.arc
/
FATSWAP.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-03-04
|
4KB
|
96 lines
PAGE ,132
TITLE Copy Second Copy of FAT to First, Version 1.00, 04-Mar-1987
CODE SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:CODE,DS:CODE
ORG 5CH
FCB LABEL BYTE
ORG 100H
START: JMP BEGIN
SIGNON DB "Copy Second Copy of FAT to First Program, Version 1.00",13,10
DB "SMG Software",13,10
DB "(C) Copyright 1987 Steven Georgiades",13,10,10,"$"
DONE_MSG DB "The FAT for drive x: has been recovered!",7,13,10,"$"
ERR_DRV DB "Invalid Drive Letter!",7,13,10,"$"
ERR_FAT DB "This disk has only one copy of the FAT!",7,13,10,"$"
ERR_RD DB "Error Reading FAT!",7,13,10,"$"
ERR_WR DB "Error Writing FAT!",7,13,10,"$"
DRIVE DB ?
FATSEC DW ?
BEGIN: PUSH AX ; Save Drive Validity Info
MOV AH,9 ; Output Sign-On Message
MOV DX,OFFSET SIGNON
INT 21H
POP AX ; Restore Drive Validity Info
CMP AL,0 ; If Invalid,
JE DRV_OK
MOV DX,OFFSET ERR_DRV ; Setup Pointer to Error Msg
ERR_OUT: MOV AH,9 ; Output Error Message
INT 21H
MOV AX,4C01H ; Exit to DOS (Return = 1)
INT 21H
DRV_OK: MOV AL,FCB[0] ; Read Drive Number
DEC AL
JNS NOT_DEF ; If Default,
MOV AH,19H ; Get Default Drive Number
INT 21H
NOT_DEF: MOV DRIVE,AL ; Convert Drive Number to Letter
ADD AL,'A'
MOV DONE_MSG[18],AL
MOV AL,DRIVE ; Read Disk Boot Record
MOV BX,OFFSET FATBUF
MOV CX,1
MOV DX,0
INT 25H
POPF
CMP BYTE PTR FATBUF[16],2 ; If Less than 2 FAT's,
JAE FAT_OK
MOV DX,OFFSET ERR_FAT ; Error
JMP SHORT ERR_OUT
FAT_OK: MOV AX,FATBUF[22] ; Save FAT Sector Count
MOV FATSEC,AX
MOV DX,1 ; Point to First FAT Sector
PUSH DX
MOV AL,DRIVE ; Read FAT Sector
MOV BX,OFFSET FATBUF
MOV CX,FATSEC
ADD DX,CX
INT 25H
JNC RD_OK ; If Error,
POPF
POP DX
MOV DX,OFFSET ERR_RD ; Output Error Message
JMP SHORT ERR_OUT
RD_OK: POPF
POP DX
MOV AL,DRIVE ; Write FAT Sector
MOV BX,OFFSET FATBUF
MOV CX,FATSEC
INT 26H
JNC WR_OK ; If Error,
POPF
POP DX
MOV DX,OFFSET ERR_WR ; Output Error Message
JMP ERR_OUT
WR_OK: POP DX
MOV AH,9 ; Output Done Message
MOV DX,OFFSET DONE_MSG
INT 21H
MOV AX,4C00H ; Exit to DOS
INT 21H
FATBUF LABEL WORD
CODE ENDS
END START