Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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





imageimage

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Accounting

Authors: Gail Fayerman

1st Canadian Edition

9781118774113, 1118774116, 111803791X, 978-1118037911

More Books

Students also viewed these Computer Network questions

Question

Was it ethical to deny treatment to the control group?

Answered: 1 week ago

Question

What is meant by significant influence?

Answered: 1 week ago