Sunteți pe pagina 1din 7

COMPUTER ENGINEERING DEPARTMENT

Computer Systems Organization and Architecture Manual

ACTIVITY8: File Handling Services

8.1 Program Outcomes (POs) Addressed by the Activity


a. ability to apply knowledge of mathematics and science to solve engineering
problems
b. ability to design and conduct experiments, as well as to analyze and interpret data
c. ability to design a system, component, or process to meet desired needs within
realistic constraints such as economic, environmental, social, political, ethical, health
and safety, manufacturability, and sustainability, in accordance with standards
d. ability to identify, formulate, and solve engineering problems
e. ability to use techniques, skills, and modern engineering tools necessary for
engineering practice.
f. knowledge and understanding of engineering and management principles as a
member and leader in a team, to manage projects and in multidisciplinary
environments

8.2 Activity’s Intended Learning Outcomes (AILOs)


At the end of this activity, the student shall be able to:
a. Discuss the different File Handling services and its function..
b. Apply and Demonstrate the different File Handling Services in Assembly Language
Code.

8.3 Objectives of the Activity


The objectives of this activity are to:
a. Identify the different file handling services and its functions.
b. Create an assembly language code using different file handling service.

8.4 Principle of the Activity


A file handle is simply a number that refers to a specific device. The following standard
file handles are preset and do not require defining:

ACTIVITY 8: FILE HANDLING SERIVES 1


HANDLE DEVICE
00 Input, normally keyboard (CON), may be redirected
01 Output, normally display (CON), may be redirected
02 Error output, display (CON) , may not be redirected
03 Auxiliary device ( AUX)
04 Printer ( LPT1 or PRN)

As shown normal file handles are 00 for keyboard and 01 for screen display, File handles
for disk device have to be set by your program. You can also use these services for redirecting
input and output to other devices.

Other I/O services involve the use of a file handle for operations that access file; for these
you have to request the file handles number from the system. A disk file must first be opened;
unlike transferring data from the keyboard or to the screen, the system has to address disk files
through entries in its directory and FAT, and must update these entries. Each file that a program
reference during execution must be assigned its own unique file handle.

The system delivers a file handle when you open a file for input or create a file for
output. The operations involve the use of ASCIIZ string and INT 21 function 3CH or 3DH. The
file handle is a unique one-word number returned in AX that you save in a word data item and
use for all subsequent requests to access the file. Typically, the first file handle returned is 05, the
second is 06 and so forth.

The PSP contain a default file handle table that provides for 20 handles, but you can use
INT 21H function 67H to increase the limit.

The file handle operation for disk delivery a completion status via the Carry Flag and the
AX register. A successful operation clears the Carry Flag to 0 and performs other appropriate
functions. An unsuccessful operation sets the Carry flag to 1and returns an error code in AX
depending on the operation.

8.5 Materials/Equipment

1 unit Personal Computer


DOS / Command Prompt
Text Editor (SK, Notrepad, Wordpad)
Assembler (TASM.EXE)
Linker (TLINK.EXE )
Storage unit

ACTIVITY 8: FILE HANDLING SERIVES 2


8.6 Circuit Diagrams / Figures / Source Codes (if Applicable)

Figure 1. Title

8.7 Procedure/s

1. Encode the given program.


(Filename: sam8.asm)

2. Write the following program using SK’s notepad or any of your text editor using the
filename sam8.asm

.model small
.code
org 100h

start: jmp main


buff db 30
total db 0
char db 30 dup (0)
x db “input a string : $”

main proc near


call prompt
call input
mov bh, 0
mov bl, total
add bx, offset char
mov byte ptr [bx], 0
mov dx, offset char
mov ah, 39h
int 21h
int 20h
main endp

prompt proc near


mov dx,offset x
mov ah, 9

ACTIVITY 8: FILE HANDLING SERIVES 3


int 21h
ret
prompt endp

input proc near


mov dx, offset buff
mov ah, 0ah
int 21h
ret
input endp

end start

3. Execute the program. When the prompt appears, input the string “RED” then press enter.

4. Look at the contents of the directory by using the DIR command.

5. Write down your observations.

8.8 Activity Report

Section: Date Performed:


Course Code: Date Submitted:
Course Title:
Instructor:
Group No.: Activity No.:
Group Members: Signature:

ACTIVITY 8: FILE HANDLING SERIVES 4


1.
2.
3.
4.
5.

8.8.1 Data and Results

1. Given the sample output coming from your instructor, write down and compile the
required program that will provide the expected sample output using expt8.com as
the filename.

expt8.asm

2. Encode the program.

3. Ask your instructor to check your work

4. Save the program to your data disk..

8.8.2 Calculations

8.8.3 Observations

Creating a file you just need mov ah, 3 int 21h and for creating directory you just
need mov ah, 39h int 21.

8.8.4 Conclusion/s
Creating directory you can choose many attributes such as hidden, normal, archive, etc.

ACTIVITY 8: FILE HANDLING SERIVES 5


8.8.5 Rating (include Rubric)
Criteria Grade

Activity Conduct (1-5)

Correctness of Command(s)/Program(s) (1-5) x 2

Completeness of Tasks (1-5)

Data Analysis and Results Interpretation (1-5)

Total Score

Mean Score = (Total Score / 5)

Percentage Score = (Total Score/25) * 100


Other Comments:

ACTIVITY 8: FILE HANDLING SERIVES 6


ACTIVITY 8: FILE HANDLING SERIVES 7

S-ar putea să vă placă și