Professional Documents
Culture Documents
2 - Macros - Arithmetic - FIle Handling
2 - Macros - Arithmetic - FIle Handling
2 - Macros - Arithmetic - FIle Handling
Experiment 12
Using Macros
I. Objective
Experiment 13
Arithmetic Instructions (Part I)
5. Assemble and run the above program. After finishing this activity, I can
What is the output?
perform a simple arithmetic operation,
A2
like addition and subtraction of binary in
The 2 represents the one’s digit in
the result stored in BX, which is the an assembly language program.
3032 I also learned that the result of the
operation is not the correct ASCII value,
so we need the AAA or AAS instruction
6. Open the program using to adjust the result of the addition or
DEBUG.EXE. Try stepping through subtraction, respectively.
each instruction and observe the
Aside from this, we need to restore its
result of each trace operation. How is
the result displayed by the program? ASCII representation by adding 3030h in
the AX register (which holds the result of
our arithmetic operation).
COURSE/YEAR/SECTION INSTRUCTOR
Experiment 14
Arithmetic Instructions (Part II)
COURSE/YEAR/SECTION INSTRUCTOR
Experiment 15
Procedures
I. Objective …
ret
procl endp
After performing this activity, you end begin
should be able to
The RET instruction is used to return
1. create and use procedures in your
program control to the main program
assembly language programs.
once the procedure is finished.
II. Introduction
III. Procedures
A procedure is a sequence of
1. Run EDIT.COM from the DOS
instructions that perform a single task. It
prompt. Then type the following lines
begins with the PROC directive and ends
of code.
with ENDP.
.mode tiny
The general format is .data
msgl db ‘Inside the main program$’
procedure_name PROC NEAR msg2 db ‘Inside the procedure$’
… .code
procedure_name ENDP org 100h
begin
A procedure is used by calling the mov ah,09h
lea dx,msgl
procedure name. Normally we use the int 21h
CALL instruction to enter a procedure call procl
(we can also use the JMP instruction). exit
ret
For example, to call the procedure procl proc near
mov ah,09h
PROC1, lea dx,
int 21h
.model tiny ret
.code procl endp
org 100h end begin
begin:
call procl Save the above program as
…
ret
EXER22.ASM
proc1 proc near
2. Assemble and run the above program. Save as PROB13.ASM and
What is displayed on the screen? PROB14.ASM, respectively.
IV. Observation
V. Conclusion
COURSE/YEAR/SECTION INSTRUCTOR
Experiment 16
File Handling
I. Objective
The value in CX defines the attribute or
the type of file. A file may contain more
After performing this activity, you than one of the following attribute:
should be able to
1. create, delete, and rename DOS 00H Normal File
01H Read-only File
files in assembly language. 02H Hidden File
04H DOS System File
II. Introduction 10H Directory
20H Archive File
Save as PROB15.ASM.
PROB16.ASM, and PROB17.ASM,
respectively
NAME DATE REMARKS
COURSE/YEAR/SECTION INSTRUCTOR
Experiment 17
Directories
currentdir db ?
…
mov ah,47h
mov dl,0
lea si,currentdir
int 21h
mov bl,actlen
VI. Programming Problem
III. Procedures
Write a program that allows a user to
1. Run EDIT.COM from the DOS input the directory name and perform the
prompt. Then type the following lines following file operations.
of code
• Create a subdirectory with the
.model tiny specified name.
.data
pathname db ‘C:\UNTITLED’,0
• Delete a subdirectory with the
.code specified name
org 100h • Go to the specified director
begin • Retrieve the current working
mov ah,39h
lea dx,pathname
directory.
int 21h
ret Hint: Use a parameter list for file input.
end begin To convert the input string to an ASCII
string, use the following lines of code:
Save the program as EXER26.ASM.