LAB REPORT Lab 7 Loops
LAB REPORT Lab 7 Loops
DE-43 Mechatronics
Syndicate – B
LAB REPORT
Introduction to Loops and Lookup Tables in
Assembly language
Introduction:
the introduction of simple loop commands allows us to create efficient and structured code.
These loop commands, often implemented through instructions like "LOOP" or "JMP"
(Jump), enable the repetition of a specific set of instructions for a number of iterations that
we define or until a certain condition is met. Simple loops streamline the execution of
repetitive tasks, enhancing code readability and reduces the complexity of the code. As a
crucial component of control in assembly language, mastering these loop commands will
enable us to create more concise and organized code, optimizing the performance of low-
level operations.
Objective:
Our objectives with this lab are to understand and implement loop command such as
DJNZ in our code in order to understand its working and significance in our codes.
Lab Work:
We started off with an example in which we added 3 to the accumulator 10 times:
Example 1
Example Number 2:
We wrote a code which stores data in memory positions 40 to 44,
initializing the load pointer to the 40th position. It loads this value into a register, assigns 5 to
another register, and executes the 'again' loop. Data is iteratively stored in register A as long
as the carry flag remains zero. The loop precisely iterates five times, corresponding to the
value in register R2, ensuring efficient data handling and controlled repetition in the
program's execution.
Example 2
Lab Task 1:
Lab Example 3:
Lab Task 2:
Lab Task 3: