0% found this document useful (0 votes)
28 views11 pages

5 - Turbo Assembler

The document discusses using interrupts in assembly language programs to display characters on the screen. It explains how DOS interrupt 21h service 02h can be used to print a single character by putting the character code in the DL register and calling interrupt 21h. The document provides an example assembly language program that uses this to display the letter A.

Uploaded by

T ENGA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views11 pages

5 - Turbo Assembler

The document discusses using interrupts in assembly language programs to display characters on the screen. It explains how DOS interrupt 21h service 02h can be used to print a single character by putting the character code in the DL register and calling interrupt 21h. The document provides an example assembly language program that uses this to display the letter A.

Uploaded by

T ENGA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

NAME DATE REMARKS

Onin John Paul P. Binuya 09-29-23


COURSE/YEAR/SECTION INSTRUCTOR

BSCpE 3 Hilda Wycoco Santos

Experiment 05
Assembling, Linking, and Executing Programs

I. Objective TASM.EXE is Borland’s assembler


program. An assembler is used to convert
After performing this activity, you the assembly language source codes
should be able to (ASM) into object codes (OBJ).
1. Use DOS’ EDIT.COM to create
assembly language source codes, Assembling the Program
and;
2. Use Borland’s Turbo Assembler To assemble a source program (for
(TASK. EXE) and Turbo Linker example CLEAR.ASM), enter the
(TLINK. EXE) to assemble and following command lines at the DOS
link assembly language programs. prompt:

C:\> tasm clear.asm


II. Introduction
Note: You can also enter the source file
Using EDIT.COM without the ASM extension

EDIT.COM is MS-DOS’s text editor If you typed the program without any
used for creating batch files and small errors the screen should display the
text documents. In this activity and for following:
the rest of the course, we will use EDIT
to create the source code for our assembly C:\> tasm clear.asm
language programs. Turbo Assembler Version .01
Copyright (c) 1988, 1990 Borland
The figure below shows EDIT window International

Assembling file : CLEAR.ASM


Error messages : None
Warning Messages : None
Passes : 1
Remaining memory : 443K

If an error occurs, check your source


code for possible omissions or
misspellings.
Use TLINK. EXE
Using TASM.EXE
TLINK.EXE is Borland’s linker
program. A linker is used to convert
object codes (.OBJ) into executable codes 2. Try entering the following lines of
(.EXE or .COM) code:
.model tiny
Linking the Program .code
org 100h
Once your program is free of error begin:
messages, next step is to link the resulting mov ax, 3
object module. int 10h
ret
end begin
To link our object code, we enter the
following command lines. Save the program by pressing Alt+F,
S. Save the file as EXER01.ASM.
c:\> tlink /t clear.obj
Press Alt+F, X to close EDIT and
NOTE: The /t option is used to create a return to DOS.
COM program, which is shorter and runs
3. To assemble our source program,
faster than .EXE program. If you want to
enter the following command lines at
create .EXE programs, you only need to
the DOS prompt
omit this option.
C:\> tasm exer01.asm
The screen should display the
following: 4. To link our program enters the
following command lines.
C:\> tlink /t clear.obj
C:\> tlink / t exer01.obj
Turbo Link Version 3.1
Copyright (c) 1987, 1990
Borland International 5. Run the program by entering

Executing the Program C:\> exer01

Having assembled and linked the 6. Press the Enter key. Note what
program, you can now execute it. You happens when you execute the
can run the program by entering its file program.
name and pressing Enter.
IV. Observation
C:\> clear After performing the procedures, I
noticed that when I executed the exer01
III. Procedures program, the previous prompts I entered
were cleared. It is similar to the “cls”
1. Run the text editor by typing EDIT at command of DOS where it will erase all
the DOS prompt and pressing the the commands and any output they
enter key. generate in the screen or console window.
With this, I am able to obtain an idea
of how to program an instruction similar
to those in MS-DOS.

V. Conclusion
At the end of this activity, I learned
how to use the DOS EDIT.COM to create
language source codes and use the Turbo
Assembler and Turbo Linker to link them
and assemble an assembly language
program.
Also, this experiment guided me to
create and execute an assembly language
program similar to the “cls” instruction of
MS-DOS, which it will clear all the
previously entered commands and output
in the console window.

Documentation
NAME DATE REMARKS

Onin John Paul P. Binuya 09-29-23


COURSE/YEAR/SECTION INSTRUCTOR

BSCpE 3 Hilda Wycoco Santos

Experiment 06
Printing a Single Character

I. Objective DOS Service 02H is the function


number for printing a single character to
After performing this activity, you the screen. We can access this function by
assigning the value in AH and then using
should be able to
INT 21H. The value in the DL register is
1. Display a single character on the displayed at the current position once
screen using interrupts, and; INT 21H is invoked.
2. Discuss how interrupts are used in
assembly language programs. mov ah,02h
mov dl,char
int 21h
II. Introduction
You can also print ASCII characters
The INT (interrupt) instruction is using function 02h of INT 21H. The tab,
used to allow assembly language carriage return, and line field characters
programs to request services from the are displayed normally
operating system and the built-in
software in the ROM BIOS. Most of
III. Procedures
these services handle input and output.

In this activity and in succeeding 1. Run edit.com FROM the DOS


experiments we will be using two types prompt. Type the following lines of
of interrupts: INT 10H used for common code
BIOS operations (i.e, screen handling) .model tiny
and INT 21H for handling DOS .code
operations (i.e, accepting input). These org 100h
operations use what is called a service (or begin:
mov ah, 02h
function) call: you insert a value in the mov dl, ‘A’
AH register to identify what operation to int 21h
perform. ret
end begin
INT 21H Service 02H: Printing a
Single Character 2. Assemble and run the program.
Observe the output of the program.
What is displayed on the screen? an instruction above it and display the
Answer: A output of the next code.
On the other hand, 0Ah represents
3. Run EDIT. COM from the DOS
a line feed operation that moves the
prompts. Type the following lines of
code cursor position to the next line.
Therefore, if we have an output of ‘A’ in
.model tiny the code, following it with the ‘0Ah’, and
.code
org 100h
another character ‘B’, the output A and B
begin: will be displayed on separate lines,
mov ah, 02h making it vertically displayed.
mov dl, ‘A’
int 21h Ex. A
ret B
end begin
IV. Observation
Save the program as EXER03.ASM. Based on the output, we can display a
character using the service call operation
1. Assemble and run the above program. INT 21h and assign its service, 02h, in the
Observe the output of the program. AH register to print a single character.
What is displayed on the screen?
Additionally, 0Dh and 0Ah can also
2. Run EDIT.COM from the DOS be utilized to modify the format of our
prompt. Type the following lines of output, like overwriting and moving the
code. text entry point to the next line.

Save the program as EXER04.ASM V. Conclusion


After this activity, I learned how to
3. Assemble and run the above program.
display a single character on the screen
Observe the output of the program.
utilizing the INT 21h interrupt and its
What is displayed on the screen? service for printing a character – 02h,
which is a function call for managing
What do the characters ODH and DOS operations, like accepting an input,
OAH represent? specifically.
Answer:
I also implemented the 0Dh and 0ah
From my observation after
control characters in an assembly
implementing 0Dh and 0Ah in an
language program, which are responsible
assembly language program, they are
for the carriage return and line feed.
ASCII control characters that
With all that said, I am able to
represent carriage return and line
understand how different interrupts, such
feed, respectively.
as INT 10h and INT 21h are used in this
0Dh moves the cursor to the
program.
beginning of the current line, which
can be used to overwrite the output of
VI. Programming Problem

1. Modify EXER02 ASM to display your


name on the screen.

For example, Aira’s program should


display.

JILLIAN

Save the program as PROB01.ASM


2. Write a program that will display your
name vertically.

For example, Aira’s program should


display
J
I
L
L

Save the program as PROB02.ASM


NAME DATE REMARKS

Onin John Paul P. Binuya 09-29-23


COURSE/YEAR/SECTION INSTRUCTOR

BSCpE 3 Hilda Wycoco Santos

Experiment 07
Entering a Single Character

I. Objective
DOS Service 08h can be used for
After performing this activity, you programs that require hiding the input
(such as password protection used in
should be able to
programs).
1. Accept input from the keyboard
using interrupts. III. Procedures

II. Introduction 1. Run EDIT.COM from the DOS


prompt. The type the following lines
The INT (interrupt) instruction is of code:
used to allow assembly language
programs to request services from the
.model tiny
operating system and the built-in .code
software in the ROM BIOS. Most of org 100h
these services handle input and output. begin:
mov ah,01h
mov dl,‘A’
INT 21H Service 01H: Keyboard Input int 21h
with Echo ret
end begin
DOS Service 01H is the function
number for accepting as single character Save the program as EXER05.ASM.
from the keyboard. Echoing simply
means that the character is displayed as it 1. Assemble and run the program. Type
is entered. The input character is then any letter from the keyboard. Write
stored in the AL register. your observation.

INT 21H Service 08H: 2. Run EDIT.COM from the DOS


Keyboard Input without Echo prompt. Type the following lines of
code.
DOS Service 08h is also used for
accepting a single character from the .model tiny
.code
keyboard. However, unlike in Service org 100h
01H, the character is not displayed as it is begin
typed in.
mov ah, 08h For example, if the IP register
int 21h
contains 0102, type G 104 and then
ret
end begin press Enter.

Save the program as EXER06.ASM. IV. Observation


In step 1, where we implement the
3. Assemble and run the program. Type INT 21H Service 01H, I noticed that
any letter from the keyboard. Write when I input a character, it immediately
your observations.
displayed what I entered.
4. Run EDIT.COM from the DOS On the other hand, when using 08H in
prompt. Then try entering the an assembly language program, I think it
following lines of code. still accepts the character I entered but it
.model tiny is not displayed like the 01H. Instead, it
.code prints an empty new line, which indicates
org 100h that it is likely hiding the output. From
begin:
mov ah, 08h that, we can conclude that 08H may be
mov dl, 02A used for password encryption and
int 21h
ret program protection.
end begin In step 4, we tried to display a
character by using 08H to read a character
Save the program as EXER07.ASM.
from input, but as mentioned above it will
5. Assemble and run the program, then not be displayed as it only hides the
try entering a character from the output.
keyboard. What does the above As for the status of the AL register
program do? after stepping through each instruction,
Answer: the character entered by the user is stored
The above program accepts a
in it but remains constant throughout the
character input from the user and
reads it with the 08H service but does program because there is no other
not echo or displayed the output on instruction that displays or uses the
the screen. character stored in AL.

6. At the DOS prompt, type V. Conclusion


At the end of this activity, I am able
C:\> debug exer07.com
to use the interrupts to accept character
7. Try single stepping through each inputs from the user’s keyboard. These
instruction. Note the contents of the interrupts are mainly the INT 21H
AL register after each instruction. Service 01H and 08H.
01H service reads the entered
For the INT instructions, use the G
character and immediately echoes it in
command followed by the number in
the IP register plus 2. the new line of the console. However,
08H only accepts and reads it but does not
display the character as it is typed in.
Therefore, this type of service is best used
for program protection, password hiding,
and password encryption.

VI. Programming Problem

Write an assembly language program that


will accept up to 8 characters. Save the
program as PROB03.ASM

You might also like