Lab 6 Arithmetic Operations I
Lab 6 Arithmetic Operations I
Lab 6 Arithmetic Operations I
ARITHMETIC OPERATIONS I
OBJECTIVES:
To code a program to add hex numbers.
To code a program to add BCD numbers.
To code a program to add two multi-byte BCD numbers.
To practice converting data from decimal to binary and hexadecimal systems.
REFERENCE:
Mazidi and Mazidi, “The 8051 Microcontroller and Embedded Systems,” Chapter 6.
MATERIALS:
8051 assembler and simulator.
ACTIVITY 1
Write a program to add 10 bytes of data and store the result in
registers R2 and R3. The bytes are stored in the ROM space starting at
200H. The data would look as follows:
Notice that you must first bring the data from ROM space into the CPU's
RAM, then add them together. Use a simulator to single-step the program
and examine the data.
ACTIVITY 2
Write a program to add 10 bytes of BCD data and store the result in
R2 and R3. The bytes are stored in ROM space starting at 300H. The data
would look as follows:
Notice that you must first bring the data from ROM space into the CPU's
RAM, then add them together. Use a simulator to single-step the program
and examine the data.
ACTIVITY 3
Write a program to add two multi-byte BCD numbers together and
store the result in RAM locations 40H - 44H. The two multi-byte items are
stored in the ROM space starting at 120H and 150H. See the following
example data.
ORG 120H
DATA_1: DB 54H,76H,65H,98H ;number 98657654H
DATA_2 DB 93H,56H,77H,38H ;number 38775693H
Lab Manual for “The 8051 Microcontroller and Embedded Systems” LAB 6
LAB 6
WORKSHEET
Pick your own data for your program. Notice that you must first bring the
data from ROM space into the CPU's RAM and then add them together. Use
a simulator to single-step the program and examine the data.
4. True or False. "DA A" must be used for adding BCD data only.
5. Can we use the "DA A" instruction to convert data such as 9CH into BCD
without
first performing an ADD instruction? Explain your answer.
Lab Manual for “The 8051 Microcontroller and Embedded Systems” LAB 6