You are on page 1of 3

Honorio, Archie A.

IT2104

Laboratory Exercise
Procedural and Loop Instructions
Objectives:

At the end of the exercise, the students should be able to:

▪ Write a simple program that uses a procedural call.


▪ Demonstrate jump instructions via flag conditions and compare instructions.

Instruction: Analyze the given Emu8086 assembly codes and answer the following questions.
Note: You can execute the program if you have the Emu8086 Emulator installed on your computer.

05 Laboratory Exercise 1 *Property of STI


Page 1 of 2
IT2104

Questions: (10 items x 3 points)


1. Enumerate all the jump instructions that were utilized in the program.

• jz (Jump if Zero) in Line 20


• je (Jump if Equal) in Line 67

2. What is the purpose of the loop instruction in Line 10?

• The loop instruction in Line 10 is used to repeat the block of code labeled as next: a certain number of
times specified by the count in the cx register. In this case, it repeats the addition of elements from the
vector array to the al register.

3. Which line (number) indicates the total number of vector elements involved in the process?

• Line 49 (vector db 5,4,5,2,1) indicates the total number of vector elements involved in the process.
There are 5 elements in the vector array.

4. What is the purpose of Lines 39-40?

• Lines 39-40 are preparing for the output of the result. They are calling a procedure print_al to print the
value stored in al which is the result of the addition loop.

5. What is the purpose of Lines 49-50?

• Lines 49-50 define an array named vector with the values 5, 4, 5, 2, 1. This array is used in the
addition loop to accumulate the sum in the al register.

6. What is the purpose of the next: section in the program?

• The next: section is a label marking the beginning of a loop. The purpose of this section is to add the
elements of the vector array to the al register in a loop (Lines 8-10) until all elements are processed.

7. What is the purpose of al and bx in the program?

• al is used as an accumulator for the sum of the elements in the vector array.
• bx is used as an index to access elements in the vector array during the addition loop.

8. In the print: section of the program, what does the jz instruction perform?

• The jz instruction in Line 20 checks if the least significant bit of bl is zero. If it is zero, the program
jumps to the zero: label, indicating that the current bit being processed is a 0.

9. In the print_al procedure of the program, what does the jne instruction perform?

• The jne instruction in Line 55 checks if al is not equal to zero. If true, it proceeds to the print_al_r
section, indicating that there are more digits to be processed.

10. In the print_al_r: section of the program, what does the je instruction perform?

• The je instruction in Line 67 checks if the result of the division (ax) is zero. If true, it jumps to pn_done,
indicating that the entire number has been processed.

05 Laboratory Exercise 1 *Property of STI


Page 2 of 2
IT2104

Essay: (2 items x 5 points)

1. Explain the overall process of the program based on your understanding.

• The program initializes a vector array, performs a loop to add its elements, stores the result in al,
converts the result to ASCII characters, and prints the ASCII representation. It uses bitwise operations
and conditional jumps to handle the printing process.

2. Based on your perspective, discuss the process within the print_al procedure.

• The print_al procedure is responsible for printing the value stored in al. It checks if al is zero, and if
true, it prints '0'. If al is not zero, it enters a recursive process (print_al_r) to print each digit by dividing
al by 10 and converting the remainder to ASCII. The process involves using the BIOS interrupt 10h for
screen output.

Grading rubric for short essay:


Criteria Performance Indicator Points
Content Correct ideas were comprehensively stated. 3
Organization Ideas were presented in an organized manner. 2
TOTAL 5
Note: DO NOT COPY AND PASTE. Students who copy and paste their work from any website or their classmates will automatically receive a failing mark for this assessment task.

05 Laboratory Exercise 1 *Property of STI


Page 3 of 2

You might also like