assembly language programming basics

27
Presentation (Assembly Language Programming) Topic: Disk I/O Presented To: Mam. Shaziya Saqib Presented By: Section-B (4rth Semester) Department of Computer Science Lahore Garrison University (Walton Campus)

Upload: malik-ghulam-murtza

Post on 22-Jan-2018

48 views

Category:

Software


7 download

TRANSCRIPT

Page 1: Assembly Language Programming Basics

Presentation (Assembly Language Programming)Topic:

Disk I/OPresented To:

Mam. Shaziya SaqibPresented By:

Section-B(4rth Semester)

Department of Computer ScienceLahore Garrison University

(Walton Campus)

Page 2: Assembly Language Programming Basics

Introduction to Disk I/O

Page 3: Assembly Language Programming Basics

Types of Storage

I. Hard Disk

II.Floppy Disk

III.There Models (Given on next slides)

IV.Working Area

Page 4: Assembly Language Programming Basics

Models of Floppy and Hard Disks

DD Disk holds 720k of data & HD Disk holds 2.0 MB of data.

Page 5: Assembly Language Programming Basics

Working of Floppy Disk ( 5 ¼ In)

Page 6: Assembly Language Programming Basics

Working of Floppy Disk (3 ¼ In)

Page 7: Assembly Language Programming Basics

Working of Hard Disk (General)

One cylinder: the same track on the top and bottom of a platter.

Page 8: Assembly Language Programming Basics

Disk Access

• The method of accessing information for both Floppy and Hard Disk is similar.

• This is done with the help of moving heads on the disk plates.

Page 9: Assembly Language Programming Basics

The File Directory

• DOS creates a 32-bit directory for each file. The format of an entry is as follows:

• Byte 11 is the attribute file. Each bit specifies a file attribute.(Fig:19.4 , Given on the next slide)

Hidden files ( bit 1) DIR Archive bit ( bit 5) BACKUP

Page 10: Assembly Language Programming Basics

Attribute File

Page 11: Assembly Language Programming Basics

Clusters

• DOS sets aside space for files in clusters.• Clusters always start with ‘0’ .• Number of sectors in a cluster in n^2.

(Here ‘n’ is cluster number)

• Byte 26-27 in directory bits (starting positions of clusters).

• Cluster Size (1024 bytes for 5 ¼ in for DD Disk)

Page 12: Assembly Language Programming Basics

The FAT(File Allocation Table)

FAT provides map for file storage.

FAT entries are 12-bit long.(for Floppy Disks & 10 MB Hard Disk)

FAT for higher Hard Disks it is 16-bit size.

Page 13: Assembly Language Programming Basics

File Processing

• The group of INT 21h Functions are called File Handle Functions.

• This basically involves following functions:

I. Reading

II.Writing

III.Re-writing

Page 14: Assembly Language Programming Basics

What is File Handle ?• When a file opened or created in a program, DOS

assigns it a unique number called “File Handle”.• Five Built-In File Handles:I. KeyboardII. ScreenIII.Error output-screenIV.Auxiliary device (A Piece of equipment that connect to your

computer)

V.Printer NOTE: Three additional file handles are also present.

Page 15: Assembly Language Programming Basics

File Errors

• If error is occurs then CF=1, and code no appear in AX.

Page 16: Assembly Language Programming Basics

Opening a File

Page 17: Assembly Language Programming Basics

Opening a File(Example)

• Write instructions to open a new read_only file called FILE1.

Page 18: Assembly Language Programming Basics

Open an Existing File

• To open an existing file, there is an another function:

Page 19: Assembly Language Programming Basics

Closing a File

• After a file has been processed, it should be closed.

Page 20: Assembly Language Programming Basics

Reading a file

• The following function reads a specified number of bytes from a file and stores them in memory.

Page 21: Assembly Language Programming Basics

Reading a file(Example)

• Write some code to read a 512-byte sector from a file.

Page 22: Assembly Language Programming Basics

Writing a File

• Function 40h writes a specified number of bytes to a file or device.

Page 23: Assembly Language Programming Basics

Writing a File(Example)

• Use function 40h to display a message on the screen.

Page 24: Assembly Language Programming Basics

File Pointer

Page 25: Assembly Language Programming Basics

File Pointer(Example)

Page 26: Assembly Language Programming Basics

Summary

• Today we discuss about:Internal structure & working of both Floppy &

Hard Disk.The File Directory.Cluster & FATDisk File Functions1) 3Ch 2) 3Dh 3) 3Eh4) 3Fh 5) 40h 6) 42h

Page 27: Assembly Language Programming Basics

Any Question ???