0% found this document useful (0 votes)
8 views10 pages

363-Micro Project

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)
8 views10 pages

363-Micro Project

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/ 10

CpE-364 Embedded Systems Laboratory Summer 2023/2024

Kuwait University
College of Engineering and Petroleum
Computer Engineering Department

CpE-364 Embedded Systems


Semester: Summer 2023/2024
Section No. 2

Project
Lazy caterer’s sequence

Group members:

Student Name: Razan AlNukhailan Student Name: Sara alajmi


Student Id: 2201114425 Student Id: 2202143640

TA Name: Shahad Alenezi

Date: 18 July 2023

______________________________________________________________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

• Execution time in terms of MC:

Number of cycles = 2 + 2 + 1 + 1 + 1 + 1 + 4 + 1 + 1 + 1 + 1 + 1 + 4 + 1 = 22 cycle

MC = 0.5 us

Execution time = number of cycles * MC = 22 * 0.5 = 11 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

Case 3: assigning n=7

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

The assembly code:

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

CLR C ;clear the curry before the subtraction operation

SUBB A, #30H ; we subtract 30 from the value of n to convert it from ascii to number

MOV R0, A ;we saved the value of n

MOV B,A ;to do n^2

MUL AB ; n^2 for the equation and it will be saved in register A

ADD A,R0 ; n^2 +n

DA A; for the BCD correction

ADD A,#2 ; n^2 +n

DA A ; for the BCD correction

MOV B,#2 ;we moved 2 to register B for the division operation

DIV AB ; n^2 +n \2 the value will be stored in A register

MOV 30H, A ;saving the final result in location 30H in RAM

NUM: DB '7',0 ;we get the valu of n from rom as strin

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

input that the user can insert is 15.

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

assigned to each one of us:

• Sara Alajmi did the summary and components needed.

• Razan AlNukhailan did the System requirements and the flowchart.

And the rest of the project was done during an on-campus meeting to accomplish the task as a group.

______________________________________________________________Page 10 of
10

You might also like