SlideShare una empresa de Scribd logo
1 de 39
DISK
STRUCTURES
&
FILE HANDLING
FLOPPY
DISK
3 ½ INCH
5 ¼ INCH
HARD DISK
FILE ALLOCATION
DISK STRUCTURES:
Tracks, sectors, and
cylinders.
Disk partitions.
Disk capacity.
DISK STRUCTURES
FILE
FILE HANDLING
FILE HANDLE
FILE ERRORS
FILE POINTER
OPERATIONS OF
FILE
• 3CH
• 3DH
• 3EH
• 3FH
• 40H
• 41H
• 42H
FILE HANDLING
DISK STRUCTURES
The actual physical details of disk
FLOPPY DISK
1)Internal parts of a 3½-inch floppy disk.
2)A hole that indicates a high-capacity disk.
3)The hub that engages with the drive motor.
4)A shutter that protects the surface when
removed from the drive.
5)The plastic housing.
6)A polyester sheet reducing friction against the
disk media as it rotates within the housing.
7)The magnetic coated plastic disk.
8)A schematic representation of one sector of
data on the disk; the tracks and sectors are
not visible on actual disks.
9)The write protection tab (unlabeled) is upper
left.
 3 ½ INCH
 5 ¼ INCH
HARD DISK
1) Actuator that moves the
read-write arm.
2) Read-write arm swings
read-write head back and
forth across platter.
3) Central spindle allows
platter to rotate at high
speed.
4) Magnetic platter stores
information in binary form.
5) Plug connections link hard
drive to circuit board in
personal computer.
6) Read-write head is a tiny
magnet on the end of the
read-write arm.
7) Circuit board on underside
controls the flow of data to
and from the platter.
8) Flexible connector carries
data from circuit board to
read-write head and platter.
9) Small spindle allows read-
write arm to swing across
platter.
WORKING OF HARD DISK
STRUCTURE OF
DISK
CAPACITY OF THE 5 ¼ INCH DOUBLE
DENSITY FLOPPY DISK
CAPACITY OF HARD DISK
FILE ALLOCATION
To keep the track of data stored on a disk, DOS uses
a directory structure. The first tracks and sectors of a
disk contain information about the disk’s file
structure.
FILE DIRECTORY:
ATTRIBUTE BYTE
Cluster
“A fixed number of sector (depends on the kind of
disk) is called cluster”
(File Allocation Table):
“A table that the operating system uses to
locate files on a disk. Due to fragmentation, a file
may be divided into many sections that are
scattered around the disk. The FAT keeps track of all
these pieces.”
F
A
T
DOS
HOW DOS READ A FILE?
• DOS gets the starting
cluster number from
directory.
• DOS read that particular
cluster number from disk
and stored in DTA (Data
Transfer Area). The
program that initiated the
read retrieves data from
HOW DOS STORES A FILE?
• DOS locates an unused
directory entry and stores
the filename, attribute,
creation time and date.
• DOS searches the FAT for
the first entry indicating
unused cluster (000 means
unused) and stores the
starting cluster number in
the directory. Let’s suppose
FILE HANDLING
FILE
FILE HANDLING
FILE HANDLE
FILE ERRORS
FILE POINTER
OPERATIONS OF
FILE
• 3CH
• 3DH
• 3EH
• 3FH
• 40H
• 41H
• 42H
FILE HANDLING
File ?
File Handling ?
A file is an object on a computer that stores data, information, settings, or commands
that are used with a computer program.
Through file handling, one can perform operations like create, modify , delete etc
on File.
File Create Write Rename Delete
FILE HANDLES
When file is created or open in a
program, DOS assign it a unique
number called file handle.
FILE ERRORS
OPERATIONS OF FLE
3CH
3DH
3EH
3FH40H
41H
42H
3CH
42H
3EH3DH
40H 41H3FH
OPEN A NEW FILE /
REWRITE A NEW FILE
MOVE A FILE POINTER
DELETE A FILEWRITE A FILEREAD A FILE
CLOSE A FILE
OPEN AN
EXISTING A FILE
Creating File & Writing
FILE DB "c:example_newhello.txt",0
TEXT DB "HELLO I AM TEXT",0
TEXT_SIZE = $ - OFFSET TEXT
HANDLE DW ?
System Call AH BX CX DX
File Open 3CH 0 Offset Filename
File Write 40H Handle Text Size Offset Text
File Close 3EH Handle
Handle ?
Handle is some resources/memory to store temporary data , used in file operation
Create File Operation
MOV CX,0
MOV DX, OFFSET FILE ; FILENAME
MOV AH, 3CH ; 3CH FOR CREATING FILE
INT 21H
Write into File
MOV HANDLE, AX ; MAKE RESOURCES HANDLE
MOV AH, 40H ; 40H FOR WRITING INTO FILE
MOV BX, HANDLE ; COPY RESOURCES HANDLE
MOV DX, OFFSET TEXT ; TEXT TO WRITE
MOV CX, TEXT_SIZE ; TEXT SIZE
INT 21H;
Close File
MOV AH, 3EH ; 3EH FOR CLOSE FILE
MOV BX, HANDLE ; COPY RESOURCES HANDLE
INT 21H
Delete File
.DATA
FILE DB "C:EXAMPLE_NEWWORLD.TXT",0
.CODE
MOV DX, OFFSET FILE ; OLD FILENAME
MOV AH, 41H ; 41H FOR DELETE FILE
INT 21H
System Call AH BX CX DX
File Delete 41H Offset OldFilename
File pointer
 The file pointer is used to locate a position in the file.
 File is opened – file pointer is at the beginning of file.
 After read operation – it the next byte to be read.
 After writing – file pointer at end of file.
File pointer
Move File pointer
INT 21H, FUNCTION 42H
INPUT AH = 42H
AL = MOVEMENT CODE:
• 0 MOVE RELATIVE TO BEGINNIG
• 1 MOVE RELATIVE TO CUUERENT POINTER LOCATION
• 2 MOVE RELATIVE TO THE EOF
BX = FILE HANDLE
CX:DX = NUMBER OF BYTES TO MOVE
OUTPUT DX:AX = NEW POINTER LOCATION IN BYTES FROM THE BEGNNING OF FILE.
IF CF = 1 ERROR CODE IN AX (1,6).
System Call AH BX CX:DX
File pointer 42H File
handle
Number of
byte to
move
Caption

Más contenido relacionado

La actualidad más candente

Asif Jamal disk (it)
Asif Jamal disk (it)Asif Jamal disk (it)
Asif Jamal disk (it)
Asif Jamal
 
Overview of physical storage media
Overview of physical storage mediaOverview of physical storage media
Overview of physical storage media
Srinath Sri
 

La actualidad más candente (20)

Mass Storage Devices
Mass Storage DevicesMass Storage Devices
Mass Storage Devices
 
Secondary storage structure
Secondary storage structureSecondary storage structure
Secondary storage structure
 
Chap2 hdd2
Chap2 hdd2Chap2 hdd2
Chap2 hdd2
 
Mass storage systemsos
Mass storage systemsosMass storage systemsos
Mass storage systemsos
 
Disk
DiskDisk
Disk
 
Massstorage
MassstorageMassstorage
Massstorage
 
Hard drive partitions
Hard drive partitionsHard drive partitions
Hard drive partitions
 
Asif Jamal disk (it)
Asif Jamal disk (it)Asif Jamal disk (it)
Asif Jamal disk (it)
 
Disk formatting
Disk formattingDisk formatting
Disk formatting
 
Chapter 12 - Mass Storage Systems
Chapter 12 - Mass Storage SystemsChapter 12 - Mass Storage Systems
Chapter 12 - Mass Storage Systems
 
Unit3 ppt3 hard drive
Unit3 ppt3 hard driveUnit3 ppt3 hard drive
Unit3 ppt3 hard drive
 
Fat 32 file system
Fat 32 file systemFat 32 file system
Fat 32 file system
 
Operating Systems: Device Management
Operating Systems: Device ManagementOperating Systems: Device Management
Operating Systems: Device Management
 
Partitioning a Hard Drive
Partitioning a Hard DrivePartitioning a Hard Drive
Partitioning a Hard Drive
 
Overview of physical storage media
Overview of physical storage mediaOverview of physical storage media
Overview of physical storage media
 
Types of secondary storage devices ppt
Types of secondary storage devices pptTypes of secondary storage devices ppt
Types of secondary storage devices ppt
 
Ch10
Ch10Ch10
Ch10
 
Introduction to Storage technologies
Introduction to Storage technologiesIntroduction to Storage technologies
Introduction to Storage technologies
 
storage and file structure
storage and file structurestorage and file structure
storage and file structure
 
OSCh14
OSCh14OSCh14
OSCh14
 

Destacado

OakTableWorld 2013: Ultimate Exadata IO monitoring – Flash, HardDisk , & Writ...
OakTableWorld 2013: Ultimate Exadata IO monitoring – Flash, HardDisk , & Writ...OakTableWorld 2013: Ultimate Exadata IO monitoring – Flash, HardDisk , & Writ...
OakTableWorld 2013: Ultimate Exadata IO monitoring – Flash, HardDisk , & Writ...
Kristofferson A
 
What is storage from Qsan Technology
What is storage from Qsan TechnologyWhat is storage from Qsan Technology
What is storage from Qsan Technology
qsantechnology
 

Destacado (20)

Disk structure & File Handling
Disk structure & File HandlingDisk structure & File Handling
Disk structure & File Handling
 
Cs419 lec10 left recursion and left factoring
Cs419 lec10   left recursion and left factoringCs419 lec10   left recursion and left factoring
Cs419 lec10 left recursion and left factoring
 
Hard Disk
Hard DiskHard Disk
Hard Disk
 
Hard Disk 2.0
Hard Disk 2.0Hard Disk 2.0
Hard Disk 2.0
 
20160902 DW Debate:Aproblemática Das Crianças E Adolescente Vivendo Nas Ruas ...
20160902 DW Debate:Aproblemática Das Crianças E Adolescente Vivendo Nas Ruas ...20160902 DW Debate:Aproblemática Das Crianças E Adolescente Vivendo Nas Ruas ...
20160902 DW Debate:Aproblemática Das Crianças E Adolescente Vivendo Nas Ruas ...
 
Storage devices
Storage devicesStorage devices
Storage devices
 
Materi Pembelajaran TIK Kelas 9 BAB 6
Materi Pembelajaran TIK Kelas 9 BAB 6Materi Pembelajaran TIK Kelas 9 BAB 6
Materi Pembelajaran TIK Kelas 9 BAB 6
 
Disco duro
Disco duroDisco duro
Disco duro
 
Disk drives
Disk drivesDisk drives
Disk drives
 
Pace IT - Storage Devices (part 1)
Pace IT - Storage Devices (part 1)Pace IT - Storage Devices (part 1)
Pace IT - Storage Devices (part 1)
 
Harddisk
HarddiskHarddisk
Harddisk
 
Partes internas de la computadora
Partes internas de  la computadoraPartes internas de  la computadora
Partes internas de la computadora
 
Arquitectura controlador sata
Arquitectura   controlador sataArquitectura   controlador sata
Arquitectura controlador sata
 
Disco duro jancel
Disco duro jancelDisco duro jancel
Disco duro jancel
 
Storage networks
Storage networksStorage networks
Storage networks
 
OakTableWorld 2013: Ultimate Exadata IO monitoring – Flash, HardDisk , & Writ...
OakTableWorld 2013: Ultimate Exadata IO monitoring – Flash, HardDisk , & Writ...OakTableWorld 2013: Ultimate Exadata IO monitoring – Flash, HardDisk , & Writ...
OakTableWorld 2013: Ultimate Exadata IO monitoring – Flash, HardDisk , & Writ...
 
Storage Networks
Storage NetworksStorage Networks
Storage Networks
 
Marvell FMS Preso
Marvell FMS PresoMarvell FMS Preso
Marvell FMS Preso
 
What is storage from Qsan Technology
What is storage from Qsan TechnologyWhat is storage from Qsan Technology
What is storage from Qsan Technology
 
Storage (Hard disk drive)
Storage (Hard disk drive)Storage (Hard disk drive)
Storage (Hard disk drive)
 

Similar a Coal presentationt

filesystem-120405093921-phpapp02 (1).pdf
filesystem-120405093921-phpapp02 (1).pdffilesystem-120405093921-phpapp02 (1).pdf
filesystem-120405093921-phpapp02 (1).pdf
TESTFALTU
 
Ie Storage, Multimedia And File Organization
Ie   Storage, Multimedia And File OrganizationIe   Storage, Multimedia And File Organization
Ie Storage, Multimedia And File Organization
MISY
 

Similar a Coal presentationt (20)

Windowsforensics
WindowsforensicsWindowsforensics
Windowsforensics
 
filesystem-120405093921-phpapp02 (1).pdf
filesystem-120405093921-phpapp02 (1).pdffilesystem-120405093921-phpapp02 (1).pdf
filesystem-120405093921-phpapp02 (1).pdf
 
Chapter13
Chapter13Chapter13
Chapter13
 
File system
File systemFile system
File system
 
File system
File systemFile system
File system
 
Windows Forensics- Introduction and Analysis
Windows Forensics- Introduction and AnalysisWindows Forensics- Introduction and Analysis
Windows Forensics- Introduction and Analysis
 
AdvFS/Advanced File System Ccncepts
AdvFS/Advanced File System CcnceptsAdvFS/Advanced File System Ccncepts
AdvFS/Advanced File System Ccncepts
 
DBMS
DBMSDBMS
DBMS
 
Os
OsOs
Os
 
Disk and File System Management in Linux
Disk and File System Management in LinuxDisk and File System Management in Linux
Disk and File System Management in Linux
 
File and fat
File and fatFile and fat
File and fat
 
File and fat 2
File and fat 2File and fat 2
File and fat 2
 
File system
File systemFile system
File system
 
009709863.pdf
009709863.pdf009709863.pdf
009709863.pdf
 
Ch 17 disk storage, basic files structure, and hashing
Ch 17 disk storage, basic files structure, and hashingCh 17 disk storage, basic files structure, and hashing
Ch 17 disk storage, basic files structure, and hashing
 
Fat File Systems
Fat File SystemsFat File Systems
Fat File Systems
 
presentations
presentationspresentations
presentations
 
Ie Storage, Multimedia And File Organization
Ie   Storage, Multimedia And File OrganizationIe   Storage, Multimedia And File Organization
Ie Storage, Multimedia And File Organization
 
Internal representation of file chapter 4 Sowmya Jyothi
Internal representation of file chapter 4 Sowmya JyothiInternal representation of file chapter 4 Sowmya Jyothi
Internal representation of file chapter 4 Sowmya Jyothi
 
OS_Assignment for Disk Space & File System & File allocation table(FAT)
OS_Assignment for Disk Space & File System & File allocation table(FAT)OS_Assignment for Disk Space & File System & File allocation table(FAT)
OS_Assignment for Disk Space & File System & File allocation table(FAT)
 

Más de fika sweety

Más de fika sweety (20)

Query optimization and performance
Query optimization and performanceQuery optimization and performance
Query optimization and performance
 
Program design techniques
Program design techniquesProgram design techniques
Program design techniques
 
Plsql
PlsqlPlsql
Plsql
 
Shift rotate
Shift rotateShift rotate
Shift rotate
 
Graphss
GraphssGraphss
Graphss
 
Modeling and simulation ch 1
Modeling and simulation ch 1Modeling and simulation ch 1
Modeling and simulation ch 1
 
Macros...presentation
Macros...presentationMacros...presentation
Macros...presentation
 
Pseudocode algorithim flowchart
Pseudocode algorithim flowchartPseudocode algorithim flowchart
Pseudocode algorithim flowchart
 
Diversity (HRM)
Diversity (HRM)Diversity (HRM)
Diversity (HRM)
 
Howtowriteamemo 090920105907-phpapp02
Howtowriteamemo 090920105907-phpapp02Howtowriteamemo 090920105907-phpapp02
Howtowriteamemo 090920105907-phpapp02
 
1 Computer Architecture
1 Computer Architecture1 Computer Architecture
1 Computer Architecture
 
3 Pipelining
3 Pipelining3 Pipelining
3 Pipelining
 
19 primkruskal
19 primkruskal19 primkruskal
19 primkruskal
 
Warehouse chapter3
Warehouse chapter3   Warehouse chapter3
Warehouse chapter3
 
Quick sort
Quick sortQuick sort
Quick sort
 
Query optimization and performance
Query optimization and performanceQuery optimization and performance
Query optimization and performance
 
L2
L2L2
L2
 
Master theorem
Master theoremMaster theorem
Master theorem
 
Database security copy
Database security   copyDatabase security   copy
Database security copy
 
Programming
ProgrammingProgramming
Programming
 

Último

Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 

Último (20)

Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 

Coal presentationt

  • 2. FLOPPY DISK 3 ½ INCH 5 ¼ INCH HARD DISK FILE ALLOCATION DISK STRUCTURES: Tracks, sectors, and cylinders. Disk partitions. Disk capacity. DISK STRUCTURES
  • 3.
  • 4. FILE FILE HANDLING FILE HANDLE FILE ERRORS FILE POINTER OPERATIONS OF FILE • 3CH • 3DH • 3EH • 3FH • 40H • 41H • 42H FILE HANDLING
  • 5. DISK STRUCTURES The actual physical details of disk
  • 7. 1)Internal parts of a 3½-inch floppy disk. 2)A hole that indicates a high-capacity disk. 3)The hub that engages with the drive motor. 4)A shutter that protects the surface when removed from the drive. 5)The plastic housing. 6)A polyester sheet reducing friction against the disk media as it rotates within the housing. 7)The magnetic coated plastic disk. 8)A schematic representation of one sector of data on the disk; the tracks and sectors are not visible on actual disks. 9)The write protection tab (unlabeled) is upper left.
  • 8.  3 ½ INCH  5 ¼ INCH
  • 10. 1) Actuator that moves the read-write arm. 2) Read-write arm swings read-write head back and forth across platter. 3) Central spindle allows platter to rotate at high speed. 4) Magnetic platter stores information in binary form. 5) Plug connections link hard drive to circuit board in personal computer. 6) Read-write head is a tiny magnet on the end of the read-write arm. 7) Circuit board on underside controls the flow of data to and from the platter. 8) Flexible connector carries data from circuit board to read-write head and platter. 9) Small spindle allows read- write arm to swing across platter.
  • 13.
  • 14. CAPACITY OF THE 5 ¼ INCH DOUBLE DENSITY FLOPPY DISK
  • 16. FILE ALLOCATION To keep the track of data stored on a disk, DOS uses a directory structure. The first tracks and sectors of a disk contain information about the disk’s file structure.
  • 17.
  • 20. Cluster “A fixed number of sector (depends on the kind of disk) is called cluster”
  • 21. (File Allocation Table): “A table that the operating system uses to locate files on a disk. Due to fragmentation, a file may be divided into many sections that are scattered around the disk. The FAT keeps track of all these pieces.” F A T
  • 22. DOS HOW DOS READ A FILE? • DOS gets the starting cluster number from directory. • DOS read that particular cluster number from disk and stored in DTA (Data Transfer Area). The program that initiated the read retrieves data from HOW DOS STORES A FILE? • DOS locates an unused directory entry and stores the filename, attribute, creation time and date. • DOS searches the FAT for the first entry indicating unused cluster (000 means unused) and stores the starting cluster number in the directory. Let’s suppose
  • 24. FILE FILE HANDLING FILE HANDLE FILE ERRORS FILE POINTER OPERATIONS OF FILE • 3CH • 3DH • 3EH • 3FH • 40H • 41H • 42H FILE HANDLING
  • 25. File ? File Handling ? A file is an object on a computer that stores data, information, settings, or commands that are used with a computer program. Through file handling, one can perform operations like create, modify , delete etc on File. File Create Write Rename Delete
  • 26. FILE HANDLES When file is created or open in a program, DOS assign it a unique number called file handle.
  • 27.
  • 29.
  • 32. 3CH 42H 3EH3DH 40H 41H3FH OPEN A NEW FILE / REWRITE A NEW FILE MOVE A FILE POINTER DELETE A FILEWRITE A FILEREAD A FILE CLOSE A FILE OPEN AN EXISTING A FILE
  • 33. Creating File & Writing FILE DB "c:example_newhello.txt",0 TEXT DB "HELLO I AM TEXT",0 TEXT_SIZE = $ - OFFSET TEXT HANDLE DW ? System Call AH BX CX DX File Open 3CH 0 Offset Filename File Write 40H Handle Text Size Offset Text File Close 3EH Handle Handle ? Handle is some resources/memory to store temporary data , used in file operation
  • 34. Create File Operation MOV CX,0 MOV DX, OFFSET FILE ; FILENAME MOV AH, 3CH ; 3CH FOR CREATING FILE INT 21H Write into File MOV HANDLE, AX ; MAKE RESOURCES HANDLE MOV AH, 40H ; 40H FOR WRITING INTO FILE MOV BX, HANDLE ; COPY RESOURCES HANDLE MOV DX, OFFSET TEXT ; TEXT TO WRITE MOV CX, TEXT_SIZE ; TEXT SIZE INT 21H;
  • 35. Close File MOV AH, 3EH ; 3EH FOR CLOSE FILE MOV BX, HANDLE ; COPY RESOURCES HANDLE INT 21H
  • 36. Delete File .DATA FILE DB "C:EXAMPLE_NEWWORLD.TXT",0 .CODE MOV DX, OFFSET FILE ; OLD FILENAME MOV AH, 41H ; 41H FOR DELETE FILE INT 21H System Call AH BX CX DX File Delete 41H Offset OldFilename
  • 37. File pointer  The file pointer is used to locate a position in the file.  File is opened – file pointer is at the beginning of file.  After read operation – it the next byte to be read.  After writing – file pointer at end of file.
  • 38. File pointer Move File pointer INT 21H, FUNCTION 42H INPUT AH = 42H AL = MOVEMENT CODE: • 0 MOVE RELATIVE TO BEGINNIG • 1 MOVE RELATIVE TO CUUERENT POINTER LOCATION • 2 MOVE RELATIVE TO THE EOF BX = FILE HANDLE CX:DX = NUMBER OF BYTES TO MOVE OUTPUT DX:AX = NEW POINTER LOCATION IN BYTES FROM THE BEGNNING OF FILE. IF CF = 1 ERROR CODE IN AX (1,6). System Call AH BX CX:DX File pointer 42H File handle Number of byte to move