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





Write an assembly program that first allocates and initializes two 16-bit signednumbers, A and B. This program will be responsible for passing data

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] 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 the result is stored in R11. 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? Question 2: Stack and subroutines -Solve this question by writing subroutines which get parameters and return value via the stack! -Explain the purpose of each instruction! a) Write a 32-bits addition subroutine that gets two operands from the stack and returns the sum. Each operand must be a 32-bits integer. b) A recursive subroutine that computes fib(n) = fib(n-1)+fib(n-2), fib(0) = 0, fib(1) = 1. SUBROUTINE: Similar to functions in C Starts with label Ends with RET Example: Subroutine Example RESET: loop: mov.w bis.b bic.b bis.b call bic.b bis.b call bic.b bis.b call bic.b jmp ; delay subroutine delay: mov.w dloop: sub.w jne ret #WDTPW|WDTHOLD,&WDTCTL; Stop watchdog timer ; Make ports 2.1, 2.3 and 2.5 Output Turn off all three LEDs Make port 2.1 ON, RED Make port 2.1 OFF, RED Make port 2.3 ON, GREEN :Make port 2.3 OFF, GREEN Make port 2.5 ON, BLUE : Make port 2.5 OFF, BLUE #0x2A, &P2DIR #0x2A, &P2OUT #0x02, &P2OUT #delay # 0x02, &P2OUT #0x04, &P2OUT #delay #0x04, &P2OUT #0x20, &P2OUT #delay #0x20, &P2OUT loop #0, r15 #1,r15 dloop ; Count down starts at 0 : Continue delay until back to zero

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Network Questions!