Chapter 9 Using Disks and Files Objectives: The difference between Floppy and Hard Disks What the Boot Sector is for What the File Allocation Table is.

Slides:



Advertisements
Similar presentations
DAT2343 File Storage and Access © Alan T. Pinck / Algonquin College; 2003.
Advertisements

Operating Systems File Management.
Chapter 2 (cont.) An Introduction to the 80x86 Microprocessor Family Objectives: The different addressing modes and instruction types available The usefulness.
DOS and BIOS Interrupts DOS and BIOS interrupts are used to perform some very useful functions, such as displaying data to the monitor, reading data from.
Writing and reading files. Creating a file on a disk Get a file handle from system Use INT 21H function 3C to create a directory entry for the file Use.
ICS312 Set 6 Operands. Basic Operand Types (1) Register Operands. An operand that refers to a register. MOV AX, BX ; moves contents of register BX to.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 14: Disk Fundamentals (c) Pearson Education, All rights reserved. You may modify.
11/13/01CS-550 Presentation - Overview of Microsoft disk operating system. 1 An Overview of Microsoft Disk Operating System.
Chapter 7 Programming with DOS and BIOS Function Calls Objectives: The use of DOS and BIOS function call How to read the PC’s keyboard How to send text.
8.7 Memory management Program E Program D System memory DOS INT 21, function 48H: Allocate Memory Specification: allocates a number of memory paragraphs.
Assembly Language for Intel-Based Computers Chapter 13: 16-Bit MS-DOS Programming Kip R. Irvine.
Operating Systems File systems
Structure of DOS application programs. Contents: 1. PSP 2..COM and.EXE 3. TSR: Terminate and Stay Resident Programs.
8.4 Instruction Execution Times TOBIN PROC FAR SUB AX,AX MOV DX,AX MOV CX,4 NEXTD: PUSH CX SUB BP,BP MOV CX,4 GETNUM: RCL BX,1 RCL BP,1 LOOP GETNUM.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#8) By Dr. Syed Noman.
CS 346 – Chapter 10 Mass storage –Advantages? –Disk features –Disk scheduling –Disk formatting –Managing swap space –RAID.
PC Maintenance: Preparing for A+ Certification Chapter 29: Managing Files.
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
BIOS1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer.
Lecture 11 Last notes on interrupts and exam review Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
BIOS1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer.
ECE291 Computer Engineering II Lecture 13 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign.
1/2002JNM1 Positional Notation (Hex Digits). 1/2002JNM2 Problem The 8086 has a 20-bit address bus. Therefore, it can access 1,048,576 bytes of memory.
Programming the Microprocessor A Course in Microprocessor Electrical Engineering Dept. University of Indonesia.
BIOS and DOS Programming in DOS INT 10 and 21H. Interrupts There are some extremely useful subroutines within BIOS or DOS that are available to the user.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 14: Disk Fundamentals (c) Pearson Education, All rights reserved. You may.
1 Screen and Keyboard Operations Suthida Chaichomchuen
Chapter 3 Examining Computer Memory and Executing Instructions.
ENGI 3655 Lab Sessions 1Richard Khoury.  Linked Allocation ◦ Section Richard Khoury2.
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
Assembly Language for Intel-Based Computers Chapter 13: 16-Bit MS-DOS Programming Kip R. Irvine.
Getting Started Additional information. Important DOS Commands Getting Started dirlists disk directories verdisplays OS version clsclear command prompt.
A+ Guide to Managing and Maintaining Your PC Fifth Edition Chapter 7 Floppy Drives.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
DISK THEORY. Disk Theory n How information is stored on disk n How we can take advantage of that when bad things happen.
File I/O MS-DOS Interrupt 21h has many functions dealing with file and directory I/O services. Both MS-DOS and MS_Windows use 16- bit integers called HANDLES.
1 Floppy Drive Formatting ©Richard Goldman February, 2001.
Video systems. Lesson plan Review the code for the previous exercise Video systems Review for midterm exam.
21/11/2005CAP2411 Input & Output Instructions CPU communicates with the peripherals through I/O registers called I/O ports. There are 2 instructions, IN.
Writing and Reading Files Methods for processing disk files File Control Blocks (FCBs) –Supported by DOS –Can address drives and filenames.
Chapter 8 Advanced Programming Applications Objectives: Linking separate object files together Creating and using an object code library Predicting the.
Lecture 27. Extended Read Service used for extended read is int 13h/42h On Entry AH=42H DL=drive # DS:SI= far address of Disk address packet On Exit If.
BOOT SECTOR, RDE AND FAT ANALYSIS AND STUDY. FLOPPY CONSTRUCTION 1.Write - Protect Notch. 2.Hub. 3.Shutter. 4.Outer Jacket. 5.Protective Woolen Film.
Control Structure vs. Assembly Language NASM. If-then-else If conditional then then_actions jump to endif else else_actions endif.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 13: 16-Bit MS-DOS Programming Interrupts (c) Pearson Education, All rights reserved.
File Operations. FILE PROCESSING For the purposes of the following discussion, reading means copying all or part of an existing file into memory Writing.
File System Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki CS 314.
DOS- Disk Operating System. Contents Internals of DOS, DOS loading, DOS memory map, Concepts of TSR,
BITS Pilani Pilani Campus Pawan Sharma Lecture ES C263 INSTR/CS/EEE F241 Microprocessor Programming and Interfacing.
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
mPMCI Introduction Basic block diagram of computer
1st prog! Q: Read a char – from a keyboard & display it at the beginning of the next line! ====== A.
Microprocessor and Assembly Language
A “Walk Through” Experiment
CS-401 Computer Architecture Assembly Language Programming
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
Introduction to Assembly Language
CS-401 Computer Architecture & Assembly Language Programming
Operation System Program 4
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
CS-401 Computer Architecture & Assembly Language Programming
Symbolic Instruction and Addressing
Disk Structure Analysis
UNIT-II Assembly Language Programs Involving Logical
Chapter 6 –Symbolic Instruction and Addressing
By Nasser Halasa Assembly Language.
Department of Computer Science
Presentation transcript:

Chapter 9 Using Disks and Files Objectives: The difference between Floppy and Hard Disks What the Boot Sector is for What the File Allocation Table is for How to access disk sectors trough BIOS INT 13H How to navigate trough DOS’s directory structure Using DOS INT 21H functions to access disk files EE314 Microprocessor Systems Based on "An Introduction to the Intel Family of Microprocessors" by James L. Antonakos

9.2 Organization of Floppy and Hard Disks sector 1 sector 2 sector 3 sector 4 sector 5 sector 6 sector 7 sector 8 sector 9 track 0 track 1 track 2 track 79 side (head) 1 side (head) 0 Bytes/sector = 512 Examples of Floppy Disks: Typical Hard-Drive construction Read/Write Heads head 0 head 1 Bytes/sector = 512 Examples of Hard Disks: Cylinder = all the tracks accessed at same time by all the heads. Capacity = heads X cylinders X sectors/track X bytes/sector. Spindle Platters

debug -l d 100 1AA5:0100 EB 3C 90 4D F E <.MSDOS AA5: A0 05 F P AA5: E 4F 20 4E )VfF.NO NA 1AA5:0130 4D FA 33 ME FAT12.3 1AA5:0140 C0 8E D0 BC 00 7C BB C5 37 1E |...x.6.7.V 1AA5: BF 3E 7C B9 0B 00-FC F3 A4 06 1F C6 45 FE.S.>| E. 1AA5:0160 0F 8B 0E 18 7C 88 4D F C7 07 3E 7C FB....|.M..G...>|. 1AA5:0170 CD C C B 0E 13 7C..ry3.9..|t....| 9.2 Organization of Floppy and Hard Disks The Boot Sector (sector 0) load at address 100h from drive 0, starting at sector 0, 1 sector dump from address 100h

debug -l d 100 1AA5: F RAR EXE.).O 1AA5:0110 9E 24 9E B-AC F $.$..`[....h.. 1AA5:0120 E F SDOS SYS AA5: E 1B BE 03 FA > AA5:0140 E5 45 5A A EZA ZIP.... 1AA5: BD 8C-2B 23 6E 03 CE D #n AA5:0160 E5 42 4C E BLSPACEBIN AA5: E 1B F6 FA > Organization of Floppy and Hard Disks The Directory (sector 7...) load at address 100h from drive 0, starting at sector 7 (directory), 1 sector

debug -l d 100 1ff 1AA5:0100 F0 FF FF A0 00 1AA5:0110 C0 00 0D E0 00 0F AA5: A0 01 1B-C0 01 1D E0 01 1F AA5: A0 02 2B 1AA5:0140 C0 02 2D E0 02 2F AA5: FF 0F AA5: AA5: Organization of Floppy and Hard Disks The FAT (File Allocation Table) load at address 100h from drive 0, starting at sector 1, 1 sector dump from address 100h bytes 2 FAT entries FAT entry for cluster 2 FAT entry for cluster 3 FAT entry for Floppy disk = 12 bit (HD 16 bit) 000: cluster available 002-FEF: number of next cluster in file or directory FF0-FF6: reserved FF7: Bad sector in cluster FF8-FFF: Last cluster in file or directory

9.3 Reading and Writing Disk Sectors BIOS INT 13, function 00H: Reset Disk System Specification: resets the specified disk drive. Relocates the disk head to track 0. Input: AH = 00 (function code), DL = the drive to be reset (0 =>A, 1 =>B,...) Output: CF = 0 if succeed, CF = 1 if failed, AH = error code: 00h No error 01h Invalid function request 02h Address mark not found 03h Write protect error 04h Sector not found 06h Disk change line active 08h DMA overrun operation 09h Data boundary error 0Ch Media type not found 10h Uncorrectable ECC or CRC error 20h General controller failure 40h Seek operation failed 80h Timeout BIOS INT 13, function 01H: Read Disk Status Specification: returns the specified disk drive status. Input and Output similar to function 00 (but AH = 01 (function code). BIOS INT 13, function 02H: Read Disk Sectors Specification: copies the content of specified sectors into DTA (Disk Transfer memory Area). BIOS INT 13, function 03H: Write Disk Sectors Specification: copies the content of DTA (Disk Transfer memory Area) into specified sectors. Input and Output similar to function 02 (but AH = 03 (function code). Constrain: does not update the FAT (higher level DOS INTs perform FAT housekeeping). Input: AH = 02 (function code), AL = Number of sectors to be read, CH = Track number, CL = First sector to be read, DH = Head number, DL = Drive number, BX pointer to DTA, ES = DTA’s segment Output: CF = 0 if succeed, CF = 1 if failed, AH = error code, AL = number of sectors read.

9.4 Directory Functions DOS INT 21, function 47H: Get current Directory Specification: returns the path of the current directory at DS:SI. Input: AH = 47h, DL = drive ID (0 => current drive, 1 =>A (!!!), 2 =>B,...), DS:SI = memory buffer address. Output: CF = 0 if succeed, CF = 1 if failed, AX = error code (see below), memory(DS:SI) = the ASCIIZ string representing the current directory path (an ASCIIZ string use the byte “0” as terminator (similar with “$” for display string function). 00h No error 01h Invalid function number02h File not found 03h Path not found 04h No more handles available05h Access denied 06h Invalid Handle 07h Bad memory control blocks08h Insufficient memory 09h Invalid memory block address0Ah Invalid environment 0Bh Invalid format 0Ch Invalid access code0Dh Invalid data 0Eh Reserved 0Fh Invalid drive specification10h Removing current directory 11h Not same device 12h Not more files to be found13h Disk is write protected 14h Unknown disk 15h Drive is not ready16h Unknown command 17h Data error (CRC) 18h Bad request length 19h Seek error 1Ah Unknown media type 1Bh Sector not found1Ch Printer out-of-paper 1Dh Write fault 1Eh Read fault1Fh General failure Example: MOV AH,47h MOV DL,0 MOV SI, 200h INT 21h 1C3F: C 50 5C Drive not specified, the current one is considered. String terminatorASCIIZ string

9.4 Directory Functions DOS INT 21, function 3BH: Set (Change) Current Directory Specification: sets the current directory to the path found in memory at address DS:DX. Input: AH = 3Bh (function code), DS:DX = pointer to ASCIIZ string, memory(DS:SI) = the ASCIIZ string representing the new directory path. DOS INT 21, function 39H: Create Subdirectory Specification: Creates a new directory, heaving the path found in memory at address DS:DX. Output: CF = 0 if succeed, CF = 1 if failed, AX = error code (similar to function 47h). DOS INT 21, function 3AH: Delete Subdirectory Specification: Deletes the directory heaving the path found in memory at address DS:DX. DOS INT 21, function 19H: Get Current Drive Specification: returns the ID for the current drive (0 =>A (!!!), 1 =>B,...(similar to INT13H) ). Note: The rules for path specifying are the known DOS rules. Ex: - A path beginning with a letter followed by ”:” specifies a new drive to be used. - A path beginning with ”\” is considered relative to the root directory. Input and output: Similar to function 3B (but AH = 39h). Input and output: Similar to function 3B (but AH = 3Ah). Input: AH = 19h (function code) Output: AL = The current drive ID. - A path beginning otherwise is considered relative to the current directory. Constrain: The directory must be empty to complete successfully.

9.4 Directory Functions ;Program PATHNAME.ASM: ;Display current directory path..MODEL SMALL.DATA PMSG DB ' Path for current directory: $ ' DRIVE DB ? DB ':\$' PATH DB 128 DUP(?) CRLF DB 0DH,0AH,'$' EMSG DB ' Error getting pathname. ',0DH,0AH,'$'.CODE.STARTUP MOV AH,19H ;get current drive function INT 21H ;DOS call ADD AL,41H ;add alpha bias MOV DRIVE,AL ;save for later LEA SI,PATH ;set pointer to pathname buffer SUB DL,DL ;current drive MOV AH,47H ;get current directory INT 21H ;DOS call JC EROR ;error if carry set LEA DX,PMSG ;set up pointer to dir message MOV AH,9 ;display string function INT 21H ;DOS call LEA DX,DRIVE ;set pointer to drive string MOV AH,9 ;display string function INT 21H ;DOS call LEA SI,PATH ;set up pointer to path SHPA: MOV DL,[SI] ;get path character OR DL,DL ;is it zero? JZ FIN MOV AH,2 ;display character function INT 21H ;DOS call INC SI ;advance to next position JMP SHPA FIN: LEA DX,CRLF ;set pointer to newline string MOV AH,9 ;display string function INT 21H ;DOS call JMP EXIT EROR: LEA DX,EMSG ;set pointer to error message MOV AH,9 ;display string function INT 21H ;DOS call EXIT:.EXIT END DL = 0=> the drive is not specified => the current drive is used. Function 09h could not be used because the string doesn’t ends with “$”.