Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question about PIC 16F87/88. Data: http://ww1.microchip.com/downloads/en/DeviceD

ID: 3838769 • Letter: Q

Question

Question about PIC 16F87/88. Data: http://ww1.microchip.com/downloads/en/DeviceDoc/30487D.pdf

One way to multiply two integers A times B is to add A to itself B times. This is not efficient for large numbers (100 times 100) as it requires a large number of additions. But there is a better way using bit shifts. 100 takes only 7 bits (01100100), and by using RLF or RRF operations along with addition the number of iterations can be significantly reduced - depending on the maximum sizes of the numbers allowed in a memory unit. The largest number one can store in the PIC16F88 is 225. With this in mind, consider multiplying two 4-bit numbers together and putting the result into an 8-bit register by using shifting and adding. The table below shows a multiplication of 3 times 13 following such an algorithm where the shifts rotate through carry ("car"). Each row shows the contents of A, B, and C at the end of each iteration, along with the operations performed. The result,0010 0111, is 32 + 7 = 39, which is what you get with 3 times 13. As you can see by the above, when the shift of B sets the carry bit, then one adds A, otherwise one only completes the shifts. Regardless of the numbers A and B, the process always takes exactly 4 iterations. Translate the above algorithm into a functional code block that would allow the multiplication of any 4-bit integers. N.B. Why is it necessary to clear the carry bit between iterations? N.B. Where does B have to sit in a 8-bit register for the shifts to work properly

Explanation / Answer

int1 equ 020

int2 equ 021

product equ 022

mov1w b'00001000'

movwf int1

mov1w b'00000111

movwf int2

SETUP_MULTI

clrf product

MULTI_LOOP

movfw int1

addwf product

decfsz int2

goto MULTI_LOOP

This program performs the multiplication of two number 8 and 7.

The carry flag is affected by the arithematic operations and sometimes the value of carry flag is used in calculation.Most of the instructions used to perform the arithematic operation either read the carry or ignores the carry. Since the carry flag can affect the values in a aritthematic operation the carry bit ahs to be cleared.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote