363-Micro Project
363-Micro Project
Kuwait University
College of Engineering and Petroleum
Computer Engineering Department
Project
Lazy caterer’s sequence
Group members:
______________________________________________________________Page 1 of
10
CpE-364 Embedded Systems Laboratory Summer 2023/2024
Table of Contents
Summary: .......................................................................................................................... 3
System requirements: ....................................................................................................... 3
Components needed:......................................................................................................... 4
Flowchart: .......................................................................................................................... 5
Detailed analysis: .............................................................................................................. 6
Testcases: ........................................................................................................................... 6
The assembly code: ........................................................................................................... 9
Conclusion: ...................................................................................................................... 10
References:....................................................................................................................... 10
Credits:............................................................................................................................. 10
List of Figures
Figure 1: Flowchart ............................................................................................................. 5
Figure 2: Case 1 .................................................................................................................. 6
Figure 3: Case 2 .................................................................................................................. 7
Figure 4: Case 3 .................................................................................................................. 7
Figure 5: Case 4 .................................................................................................................. 8
______________________________________________________________Page 2 of
10
CpE-364 Embedded Systems Laboratory Summer 2023/2024
Summary:
In this project, we were requested to create a system that calculates how many parts are in any circular
form when we add several lines in the shape, and this is known as the "lazy caterer's sequence”. The
implementation should be done using the assembly language. And this system should work as follows,
we will get the number of lines (n) from ROM then we will do the calculations to know how many parts
will appear in the circular shape after we add the number of lines. And there are two options to do these
calculations. First, the direct way using this equation f(n) = (n^2 + n+2)/2 where f (n ) is the number of
parts that will appear after adding the number of lines. The second option to do this calculation is the
recursive way using the equation f(n) =n + f(n-1). In addition, we utilize registers/RAM locations to
store values during calculations. Furthermore, the number of cuts was retrieved from ROM. Finally, this
system can be used for any circular shape such as pizza, pancakes or huge circular building.
System requirements:
The Keil Vision version 5 software tool provided us with a user-friendly interface and a wide range of
features that facilitated the development of efficient assembly code. By utilizing this tool, we were able
build a program to accurately calculate the number of pieces that can be formed by making straight cuts
on a circular object, meeting all the necessary project specifications. This assembly code is written in
order for the instructions to be transformed into a machine language that an 8051 microcontroller can
understand by a utility program referred to as an assembler. By using the debugger tool, we were able
to identify and rectify any logical errors that occurred during the execution of the assembly code. This
helped ensure the accuracy and efficiency of the lazy caterer's sequence calculation on the 8051
microcontrollers.
______________________________________________________________Page 3 of
10
CpE-364 Embedded Systems Laboratory Summer 2023/2024
Components needed:
In this project, we used many components to implement this system. For example, we used register A
which is also called the accumulator register to store numbers on lines that we get from ROM. Also,
register B for the division and multiplication operations. And all the used registers are 8-bit (1-byte)
registers. The dptr register is 16-bit ( 2 bytes )which is used to get the value of N( number of lines )
from the ROM and then transfer it to the A register to do the equation requirements. In addition,
register R0 to store the number of lines ( N variable) so the n value will not be lost during the
calculations. Moreover, we used several belt-in instructions such as Mov which works in many ways:
1- mov A,source
2-mov A ,#data
3-mov destination,A
4-mov destination, source
5-mov dptr, #data; dptr is 16-bit register.
Also, we used the mul instruction to multiply the given values and it worked just in one way:
1- Mul AB.
In addition to the addition instruction called ADD and its work into way:
1-ADD A,Source
2-ADD A ,#data .
We used DA instruction which make the corrections for the bcd addition. In addition to the div
instruction which does the division operation which works as following:
1- DIV AB.
where the result will be stored in the A register and the remainder will be stored in the B register.
Also, we used the SUBB instruction to convert the value on N from ASCII to a normal number so we
can do our calculation and this instruction works as follows:
1- SUBB A,Rn
2- SUBB A,direct
3- SUBB A,@Ri
4- SUBB A,# data.
In addition to Clr instruction, we used it to clear the value of carry. And it works as follows:
1- CLR C.
Also, we used the MOVC instruction we use when we are dealing with 16-bit registers and its works
as follows :
1- MOVC A,@A+DPTR
2- MOVC A,@A+PC .
______________________________________________________________Page 4 of
10
CpE-364 Embedded Systems Laboratory Summer 2023/2024
Flowchart:
A flow chart is a graph of a computer program's function sequence that shows the actions and choices
made while running the program. It is frequently used in software development to help in
understanding and troubleshooting program logic because it gives programmers a clear and
comprehensive perspective of the program's execution route. As a result, the flowchart below was
created to explain what will be executed in our project’s assembly code.
Figure 1: Flowchart
______________________________________________________________Page 5 of
10
CpE-364 Embedded Systems Laboratory Summer 2023/2024
Detailed analysis:
• Memory Calculations in bytes (ROM and RAM storage):
Memory = 3 + 1 + 1 + 2 + 1 + 1 + 1 + 1 + 1 + 2 + 1 + 2 + 1 + 2 = 20 bytes
MC = 0.5 us
Testcases:
Case 1: Assigning n = 5
Figure 2: Case 1
______________________________________________________________Page 6 of
10
CpE-364 Embedded Systems Laboratory Summer 2023/2024
Case 2: assigning n = 1
Figure 3: Case 2
Figure 4: Case 3
______________________________________________________________Page 7 of
10
CpE-364 Embedded Systems Laboratory Summer 2023/2024
Case 4: assigning n = 15
Figure 5: Case 4
______________________________________________________________Page 8 of
10
CpE-364 Embedded Systems Laboratory Summer 2023/2024
ORG 0
MOV DPTR, #NUM ;we saved n value in dptr
MOVC A, @A+DPTR ; move the n value from dptr to register A using this instruction
SUBB A, #30H ; we subtract 30 from the value of n to convert it from ascii to number
END
______________________________________________________________Page 9 of
10
CpE-364 Embedded Systems Laboratory Summer 2023/2024
Conclusion:
During the 364 course, we gained more experience implementing basic microcontroller-based
applications using assembly language. We used our skills and knowledge and worked as a group to
accomplish the project objectives. As a result, we were able to program the lazy caterer's sequence of
any circular form only by obtaining the given equation and using the assembly code techniques and
protocols. As shown previously in this report, we explained in detail all the project steps from the
beginning to the end. Although this project taught us lots of experience working with the basic hardware
part of the machine, it has some limitations that may affect its performance, for instance, the maximum
References:
• Ali, M. M. (2007, January 1). The 8051 Microcontroller and Embedded
Systems: Using Assembly and C.
Credits:
All credit goes to the two of us as we worked as a team to write this report, but some specific parts were
And the rest of the project was done during an on-campus meeting to accomplish the task as a group.
______________________________________________________________Page 10 of
10