 |
 |
 |
 |
 |
 |
Introduction
his book demostrates the usage of file and disk I/O function. The program is reading the
boot sector of drive C: and is writing its content to a file. For reading the boot sector
direct disk access is required. DOS offers a function to directly read sectors on INT 25h.
For writing the data to a file standard DOS file function are being used.
|
 |
Reading the boot sector
his program has hard-coded all of its parameters. Other drives can be accessed by
changing the AL value in the main procedure. Other sectors can be read by changing DX:CX.
;Author : Daniel, Master Sourcerer at Kitana's Cas...
;Last change: June 5, 1998
;Email : sourcerer@kitana.org
;Reads the boot sector of the first hard disk partitio...
;and writes it to the file BOOTSEC.BIN
;Code segment
code SEGMENT
ASSUME CS:code,DS:data
start:
;Init data segment
MOV AX,SEG data
MOV DS,AX
;Read boot sector
LEA BX,sectorbuffer
MOV AL,2 ;drive C:
MOV CX,0 ;read first sector
MOV DX,0
CALL readsector
LEA DX,msg_readerror
JC error
;Write sector to file
LEA DX,filename
CALL createfile
LEA DX,msg_writeerror
JC error
LEA DX,sectorbuffer
MOV CX,512
|
 |
 |