Question

Write a program using PIC24 instructions yo add three 8-bit numbers stored in the successive memory...

Write a program using PIC24 instructions yo add three 8-bit numbers stored in the successive memory locations starting from 0x0800. Store the result in the memory lpcation 0x0855.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Theory:

  • PIC usually is a family of microcontrollers made by Microchip Technology, derived from the PIC 1650 originally developed by the General Instruments Microelectronics Division.
  • Program memory and data memory are separated. Data memory is 8-bit, 16-bit and in the latest models, 32-bit wide. Program instructions vary in bit-count by family of PIC and maybe 12, 14, 16 or 24 bits long. The instructions sets also vary by model with more powerful chips adding instructions for digital signal processing functions.
  • PIC24 MCU has two ADD instructions with two operands and one ADD instruction with three operands. These ADD instructions are designed to perform 8-bit additions. The execution of the result of the ADD instructions will effect all flag bits of the status register.
  • The three-operand ADD instruction will be needed in performing multibyte ADD operations. For an 8-bit MCU, a multibyte addition is also called a multiprecision addition.
  • A multiprecision addition must be performed from the least significant byte toward the most significant byte, just like numbers are added from the least significant digit toward the most significant digit.
  • When dealing with multibyte numbers, there is an issue regarding how the number is stored in memory. If the least significant byte of the number is stored at the lowest address, then the byte order is called little-endian. Otherwise, the byte order is called a big-endian.

_________________________________________________________________________________________

Solution:

The algorithm for adding three numbers as - follows:

Step 1:

Load the number stored in 0x25 into the WREG register.

Step 2:

Add the number stored at 0x35 and the number in the WREG register and the lower the sum in the WREG register.

Step 3:

Add the number stored at 0x45 and the number in the WREG register and leave the sum in the WREG register.

Step 4:

Store the contents of the WREG register in the memory location at 0x55.

The program that implements this algorithm is as follows:

ORG 0x00

GOTO START

ORG 0x0800

RETFIE

ORG 0x24

RETFIE

START MOVF 0x25, W, A   ; copy the contents of 0x25 to WREG

ADDWF 0x35, W, A ; add the value in 0x35 to that of WREG

ADDWF 0x45, W, A ; add the value in 0x45 to that of WREG

MOVWF 0x55, A ; save the sum in memory location 0x55.

END

Add a comment
Know the answer?
Add Answer to:
Write a program using PIC24 instructions yo add three 8-bit numbers stored in the successive memory...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT