0% found this document useful (0 votes)
86 views3 pages

PIC Soft Lab6

This lab covers arithmetic operations on the PIC microcontroller. Students will write programs to add hexadecimal and BCD numbers. For activity 1, students will write a program to add 10 bytes of hexadecimal data stored in ROM and store the result in registers. For activity 2, students will write a program to add 10 bytes of BCD data stored in ROM and store the result in registers. The lab aims to practice adding different data types on the PIC microcontroller.

Uploaded by

Hassan Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views3 pages

PIC Soft Lab6

This lab covers arithmetic operations on the PIC microcontroller. Students will write programs to add hexadecimal and BCD numbers. For activity 1, students will write a program to add 10 bytes of hexadecimal data stored in ROM and store the result in registers. For activity 2, students will write a program to add 10 bytes of BCD data stored in ROM and store the result in registers. The lab aims to practice adding different data types on the PIC microcontroller.

Uploaded by

Hassan Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

LAB 6

ARITHMETIC OPERATIONS I
OBJECTIVES:
To code a program to add hex numbers.
To code a program to add BCD numbers.
.

REFERENCE:
Mazidi, McKinlay, and Causey The PIC Microcontroller and Embedded Systems, Chapters 5
and 6.

MATERIALS:
MPLAB assembler and simulator.

ACTIVITY 1
Write a program to add 10 bytes of data and store the result in fileReg
locations 22H and 23H. The bytes are stored in the ROM space starting at
200H. The data would look as follows:

MYDATA: DB 92,34,84,129,... ;pick your own data.

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
fileReg locations 0x24 and 0x25. The bytes are stored in ROM space starting
at 300H. The data would look as follows:

MYDATA: DB 92H,34H,84H,29H,... ;pick your own data.

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.

Lab Manual for PIC Microcontroller and Embedded Systems LAB 6


LAB 6
WORKSHEET

Name: Date: Class:

1. Explain the difference between the ADD and ADDC instructions.

2. Show how to perform the subtraction: 29H - 21H.

4. True or False. "DAW" must be used for adding BCD data only.

5. Can we use the "DAW" instruction to convert data such as 9CH into BCD
without
first performing an ADD instruction? Explain your answer.

6. Show a simple program to add 2345H and 56F8H.

7. Show a simple program to subtract 2345H from 56F8H.

8. Show a simple program to read the value from PORTB and multiply it by
0x25. Place the result in PORTC and PORTD.

9. In the PIC, when multiplying two numbers what is the largest value for
each number?

LAB 6 Lab Manual for PIC Microcontroller and Embedded Systems


LAB 6
ARITHMETIC OPERATIONS I

Lab Manual for PIC Microcontroller and Embedded Systems LAB 6

You might also like