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

There are multiply instructions in the PIC24 instruction set. These per- form un

ID: 1846222 • Letter: T

Question

There are multiply instructions in the PIC24 instruction set. These per-

form unsigned multiplication on a 16-bit multiplier and multiplicand.


A) Use these instructions to implement a subroutine which implements

signed 16X16 bit multiplication (multiplier in W0, multiplicand in W1) to

produce a 32-bit signed result.


B) Implement, as a subroutine, an unsigned multiplication which takes a

32-bit multiplicand (inW1:W0) and 32-bit multiplier (inW3:W2) with 32-

bit result in (W3:W2). (The result truncates the 64-bit result, if necessary,

to 32 bits.)


C) Give the number of instruction clock cycles and the bytes of program

memory required for your subroutines.

Explanation / Answer

n1_h equ 0x37 ; upper byte of the first number

n1_1 equ 0x23 ; lower byte of the first number

m1_h equ 0x66 ; upper byte of the second number

m1_1 equ 0x45 ; lower byte of the second number

W0 set 0x00 ; multiplicand

W1 set 0x02 ; multiplier

PR set 0x06 ; product

org 0x00

goto start

org 0x08

retfie

org 0x18

retfie

start movlw m1_h ; set up test numbers

movwf W0 + 1,A ;

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