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

Write an assembly program that first allocates and initializes two 16-bit signed

ID: 2268260 • Letter: W

Question

Write an assembly program that first allocates and initializes two 16-bit signed numbers, A and B. This program will be responsible for passing data to the two subroutines SW_MUL and HW_MUL [100 pts) 1. Create a subroutine; called SW MUL, which should calculate the product of A and B (can use any method to multiply the numbers). The parameters should be passed to the subroutine using the stack and the result is stored in R10 Create a subroutine; called HW_MUL, which should calculate the product of A and B using hardware multiplier. The parameters should be passed to the subroutine using registers and 2. the result is stored in R11. 3. Discuss how many clock cycles does the hardware multiplier requires to calculate the product. Assess the performance of both the subroutines by monitoring the number of clock cycles (Try different inputs before you conclude). Explain which one is more efficient and why?

Explanation / Answer

Let two signed numbers A and B be 40H and 60H

Code :

MOV R1,#A

MOV R2,#B

PUSH R2

PUSH R1

(Using push instruction the A and B signed number goes to Stack )

a)

Subroutine :

SW_MUL

POP R4 // A is moved to register R4

POP R5 // B is moved to R5

MOV @A,R5 //Content of R5 is moved to Accumulator

MUL R4 // This will multiply Content of R4 with accumulator and store result in Accumulator

MOV @R10,A

b)

Subroutine :

HW_MUL

L1: MOV R0,#A

MOV @R4,R2

MOV A,#00H

ADD R4

DJNZ R0 , L1

3)

Number of cycles = Value of signed number 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