Professional Documents
Culture Documents
Submitted by:
Andamon, Jerald
Evangelista, Renzo
Gutang, Cristian Jay
Tamesis, Zyra Mae
[Names]
3CS-A
[Section]
Submitted to:
GRADE
10/25/22
[Date]
Laboratory Exercise No. 9 - 10
I. OBJECTIVES
II. EQUIPMENT/MATERIALS
Emulator 8086
Internet Connection for the submission
USB for backup and file storage
III. PROCEDURE/DISCUSSION
Model Directives:
An assembly language program is written according to the following structure and includes the
following assembler directives:
.MODEL SMALL - Assembler directive that defines the memory model to use in the
program. The memory model determines the size of the code, stack
and data segments of the program
.DATA - Assembler directive that reserves a memory space for constants and
variables
Memory
Model Size of Code and Data
Stack Directive:
End of Program:
- Directive is end
- Tells assembler that this is the end of the program
Note:
The sequence of instructions at the beginning of a program used to assign the data
segment: MOV AX, @DATA
MOV DS, AX
May be replaced by the following directive .STARTUP which assigns both DATA and CODE
segments, and hence no warning will be issued by the assembler. However, it should be noted
that the program would start at address CS:0017h. The Startup directive occupies the bytes
CS:0000 to CS:0017. Identically, the sequence used to terminate and exit DOS can be replaced by
the .EXIT directive, which has exactly the same effect.
Data Representation
Numbers
• 11011 decimal
• 11011B binary
• 64223 decimal
• -21843D decimal
• 1,234 illegal, contains a non-digit character
• 1B4DH hexadecimal number
• 1B4D illegal hex number, does not end with “H”
• FFFFH illegal hex number, does not begin with a digit
• 0FFFFH hexadecimal number
Characters
• A character must be enclosed in single or double quotes: e.g. “Hello”, ‘Hello’, “A”, ‘B’
• The ASCII code is used to encode characters
• Examples:
Note: The value of a variable, the content of registers or memory is based on the programmer
interpretation:
• AL = FFH
•represents the unsigned number 255
•represents the signed number -1 (in 2’s complement)
• AH = 30H
•represents the decimal number 48
•represents the character ‘0’
• BL = 80H
•represents the unsigned number +128
•represents the signed number -128
Variable Declaration
Byte Variables
Examples:
I DB 4 define variable I with initial value 4
J DB ? Define variable J with no initial value
Name DB “Course” allocate 6 bytes for the variable Name
K DB 5, 3, -1 allocates 3 bytes
Word Variables
Constant Definition
Example 1:
LF EQU
0AH
MOV DL,
LF
Example 2:
Program Listing
Program 1
TITLE “Program 1”
; This program displays a string terminated by a $ sign using INT 21H function 09H.
.MODEL SMALL
.STACK 200
.DATA
.CODE
END
--------------------------------------------------------------------------------------------------------------------------------------
Program 2
.MODEL SMALL
.STACK 200
.DATA
.CODE
.STARTUP ; this directive initializes the DS and CS segments.
END
--------------------------------------------------------------------------------------------------------------------------------------
Program 3
.MODEL SMALL
.STACK 200
.DATA
CR EQU 0DH
LF EQU 0AH
MSG1 DB 'Enter a lower case letter: $'
MSG2 DB CR, LF, 'In upper case it is: '
CHAR DB ?, '$'
.CODE
.STARTUP ; initialize data segment
END
--------------------------------------------------------------------------------------------------------------------------------------
PRE-LABORATORY WORK:
1. Compile and run the Program 1 (see program listing above), then save as
CSP107LE9-10A.asm.
2. Compile and run the Program 2 (see program listing above), then save as
CSP107LE9-10B.asm
3. Compile and run the Program 3 (see program listing above), then save as
CSP107LE9-10C.asm
LABORATORY WORK:
Write a program that prompts the user to enter a string, in capital letters, of a maximum length
of 20 characters. Read the string in capital letters and convert it to its lowercase. Then display the
new string and save the program as CSP107LE9-10.asm.
Note:
; Read character
MOV AL, character_read
ADD AL, 20H
; Display character in AL register
Use the following to loop through the string you just entered.
Program 1
It
displays the first message
Save as CSP107LE9-10A.asm
Program 2
Length of the
character – 13
Length of the
character –
14
Length of the
character – 30
Save as CSP107LE9-10B.asm
Program 3
It will display the first message
LABORATORY WORK:
Save as CSP107LE9-10.asm
V. RESULTS INTERPRETATION/OBSERVATION
Program 1
In program 1, the program shows a string terminated by a $ sign by using the 21h
function 09h. According to the code, if the user enters the message that we want to be
displayed, the program will display the message that we entered. As you can see in the
picture, the input that we entered is PNC. After pressing the enter key, another display
message will appear, which is the input that we just entered. Based on our
observations, we discovered that if the user entered a character which is pamantasan,
the message that the user entered would not be displayed because the number of
characters to be read in the program has a maximum length of 9 characters.
Program 2
As you can see on the first picture, that what it’s look like when running the program.
The program will prompt a message where the user needs to enter a name max. length
30 characters. Based on the code, if the user enters a character that has a length that
less than 10. It will be converted into its equivalent in number and after that it will going
to be display. For example, on the second picture, user enter a character that has a
length of 5 and see what will going to be the output. Based on our observation we don’t
know if it is right, but we found out that if the user tries to enter a character that has a
length of 10 to 16 it will convert into a symbol and display it like on the next pictures.
Lastly, we observe that if the user tries to enter a character which has a length of 17 to
30 it will convert into a capital letter from A to N and display it. Example length of the
character is 17 & 30, if the user reaches the maximum length of the character, it will
display what name of character did the user enter, see the output on the next pictures.
Program 3
As shown in the fourth image in program 3, the program indicates that the
user can enter a lowercase letter. According to the code, if the user can enter a
lowercase letter, it will be converted to an uppercase letter. As you can see in our
emulator screen, we use the letter z for lowercase letters. And in the following display
message, another message will be displayed in the program, which is the uppercase
letter that we entered in the lowercase letter. Based on our observations in the code,
we found out that when we enter a lowercase letter, it will be converted into an
uppercase letter.
Lab Work:
Based on my observation it appears when the software is running. The user will
receive a notification from the application asking for a top name which is 20 character
maximum. If the user type upper case it automatically converts into lower case, after
clicking enter. However, if the user types lowercase characters or strings with wrong
inputs it automatically loops in the program until the user was enter the uppercase.
After that, the program creates a string in the program. If you see your name in there it
will be written using the reverse order of your name, so the top part will be upper case,
then lower case, and finally the special characters or characters in the middle part.
However, there are other problems too.
VI. CONCLUSIONS
Program 1
Program 2
This was the first time that we make and give an insight together in this group
laboratory. Some of us didn’t understand well the program but we tried to make others
understand. At first, we were all a bit confused as to how this program should work but
we did manage to observe it good like entering the name length by length. And after
many tries, we understand the output and that’s all.
Program 3
Lab Work:
I've concluded my conclusion that in order to successfully change the upper case to the
lower case, we need to read a character or string that has been entered into the
application, I need the code MOV AL to read the character or string in the program. In
order the event that the user types the incorrect input during the conversion, we require
the MOV CX, the number of bytes read in order to continue looping the program. To
avoid having the incorrect letter in the capital, we must find a means to change each
word to lowercase. We return the cursor since it should come before the return value
because the conversion was done inside of a loop. When the input line is finished or
the word quit is pressed, return values that do so. I must create and assign a number
between each byte in the text and the number between and within the line for this to
work on the first line of the program. I would advise only having a 1-6 digit number
between each program byte and the 1-6 digit within the line when these parameters
are set to lowercase. We can set the current state of the word character by altering the
current state of the input character when changing the beginning character name from
"L" to "B." I must use the set of settings from above to modify this system in any way.
VII. STUDENT OUTCOMES ADDRESSED
VIII. APPENDICES