Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your first task will be to implement the function dumb_multiply: @ Multiply two numbers together by brute force @ro - First unsigned value @r1 -

image text in transcribedimage text in transcribed

Your first task will be to implement the function dumb_multiply: @ Multiply two numbers together by brute force @ro - First unsigned value @r1 - Second unsigned value @ Returns ro * r1 dumb_multiply: bx lr This function works like this: unsigned int dumb_multiply(unsigned int a, unsigned int b) unsigned int i; unsigned int sum = 0; for(i=0; i num) { return; n_sar = n * 2 + 1; return 1; This function determines if a number is a perfect square, meaning that sqrt(num)2 == num. It does this in the dumbest way possible. If computes 12, 22, 34, etc. Starting at 1, it computes n2 for all values up to 32768. When it finds a value that is equal to num, we have found the square root and the number is a perfect square, so it returns a value of 1 (for true). If it finds a value greater than num, we have gone past the square root, so the number is not a perfect square. In that case, it returns a value of 0 (for false). The function computes (n+1)2 from n?, avoiding the multiply, which you know how to do, but we don't know how to call, yet. It takes advantage of this relation: (n+1)(n+1) = n2 + 2n + 1 You are to implement that function in assembly language. You are not allowed to use any assembly language operations beyond those we have covered up till now. + Can this be done in only four registers? + How do I implement break? # How to I implement n * 2? You are not required to account for overflows in any way. You may use this new assembly instruction: cmp: Name Effect Example Description cmp Rd - operand2 cmp ro, r1 Subtract and set flags* The cmp instruction works like a subtract instruction except there is no destination register. It performs the subtraction and sets the flags, but does not store the result. It's very useful for comparing two values. Your first task will be to implement the function dumb_multiply: @ Multiply two numbers together by brute force @ro - First unsigned value @r1 - Second unsigned value @ Returns ro * r1 dumb_multiply: bx lr This function works like this: unsigned int dumb_multiply(unsigned int a, unsigned int b) unsigned int i; unsigned int sum = 0; for(i=0; i num) { return; n_sar = n * 2 + 1; return 1; This function determines if a number is a perfect square, meaning that sqrt(num)2 == num. It does this in the dumbest way possible. If computes 12, 22, 34, etc. Starting at 1, it computes n2 for all values up to 32768. When it finds a value that is equal to num, we have found the square root and the number is a perfect square, so it returns a value of 1 (for true). If it finds a value greater than num, we have gone past the square root, so the number is not a perfect square. In that case, it returns a value of 0 (for false). The function computes (n+1)2 from n?, avoiding the multiply, which you know how to do, but we don't know how to call, yet. It takes advantage of this relation: (n+1)(n+1) = n2 + 2n + 1 You are to implement that function in assembly language. You are not allowed to use any assembly language operations beyond those we have covered up till now. + Can this be done in only four registers? + How do I implement break? # How to I implement n * 2? You are not required to account for overflows in any way. You may use this new assembly instruction: cmp: Name Effect Example Description cmp Rd - operand2 cmp ro, r1 Subtract and set flags* The cmp instruction works like a subtract instruction except there is no destination register. It performs the subtraction and sets the flags, but does not store the result. It's very useful for comparing two values

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

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

Excel caculation on cascade mental health clinic

Answered: 1 week ago

Question

9. Explain the relationship between identity and communication.

Answered: 1 week ago

Question

a. How do you think these stereotypes developed?

Answered: 1 week ago

Question

a. How many different groups were represented?

Answered: 1 week ago