Implement the following C program in MIPS assembly language (name the file pattern.s): //count number of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Implement the following C program in MIPS assembly language (name the file pattern.s): //count number of items that match the pattern (have '1' bits in the same place as the pattern) // pu32_a points to first element of the array // u32_n is the number of elements in the array // u32 pat is the pattern to match uint32_t pmatch (uint32_t* pu32_a, uint32_t u32_n, uint32_t u32_pat) { uint32_t u32_result; u32 result = 0; while (u32_n != 0) { if ((*pu32_a & u32_pat) == u32 pat) u32_result++; pu32_a++; u32_n--; } // this is pointer arithmetic! actually is pu32_a + 4! } return u32_result; uint32_t au32_k[] = {0x80000000, 0xFFFFFFFF, 0x0000A5AA, 0xFOFOFOFO}; uint32_t u32_count; main() { u32 count pmatch (au32_k, 4, 0x000000F0); printf("Number of matches is: %d\n", u32_count); } This program has you write a subroutine that processes the elements of an array. The array contains 32-bit unsigned integers. The subroutine returns the number of elements of array that have '1' bits in the same locations as a 'pattern' value that is passed in. Implement the following C program in MIPS assembly language (name the file pattern.s): //count number of items that match the pattern (have '1' bits in the same place as the pattern) // pu32_a points to first element of the array // u32_n is the number of elements in the array // u32 pat is the pattern to match uint32_t pmatch (uint32_t* pu32_a, uint32_t u32_n, uint32_t u32_pat) { uint32_t u32_result; u32 result = 0; while (u32_n != 0) { if ((*pu32_a & u32_pat) == u32 pat) u32_result++; pu32_a++; u32_n--; } // this is pointer arithmetic! actually is pu32_a + 4! } return u32_result; uint32_t au32_k[] = {0x80000000, 0xFFFFFFFF, 0x0000A5AA, 0xFOFOFOFO}; uint32_t u32_count; main() { u32 count pmatch (au32_k, 4, 0x000000F0); printf("Number of matches is: %d\n", u32_count); } This program has you write a subroutine that processes the elements of an array. The array contains 32-bit unsigned integers. The subroutine returns the number of elements of array that have '1' bits in the same locations as a 'pattern' value that is passed in.
Expert Answer:
Answer rating: 100% (QA)
assembly data u32pat word 0x000000F0 au32k word 0x80000000 word 0xFFFFFFFF word 0x0000A5AA word 0xF0... View the full answer
Related Book For
Computer Organization And Design The Hardware Software Interface
ISBN: 9780123747501
4th Revised Edition
Authors: David A. Patterson, John L. Hennessy
Posted Date:
Students also viewed these programming questions
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Light Sweet Petroleum, Inc., is trying to evaluate a generation project with the following cash flows: Year Cash Flow 0 %u2013$ 39,200,000 1 63,200,000 2 %u2013 12,200,000 a-1 What is the NPV for the...
-
Bart and Kesha are in the 35% tax bracket. They are interested in reducing the taxes they pay each year. They are currently considering several alternatives. For each of the following alternatives,...
-
An article in Health Economics [Estimation of the Transition Matrix of a Discrete-Time Markov Chain (2002, Vol.11, pp. 3342)] considered the changes in CD4 white blood cell counts from one month to...
-
What are the two categories of data mining and knowledge discovery software?
-
Churchill Co. uses a job order cost system. The following data summarize the operations related to production for November: a. Materials purchased on account, $ 528,000. b. Materials requisitioned, $...
-
Connect each yearly salary to the correct paycheck payment. A. $55,000 B. $60,000 C. $26,000 D. $129,000 E. $56,000 OS $500 weekly $5,000 monthly $2,333 semi-monthly $4,961 biweekly $4,583 monthly
-
Shreyas bought an article and sold for 150% per cent of its cost price. What was the cost price of the article, if Shreyas sold it for Rs. 750? 1. Rs. 500 2. Rs. 480 3. Rs. 520 4. Rs. 560 None of...
-
Submissions attempt.d21?ou-375815&q=3482798a-572 A Question 27 0/15 points Dr. Gregory Whittpenn is a respected local plastic surgeon in Nacogdoches who performs reconstructive nose surgeries....
-
Let k, L > 0 and suppose u(x, t) satisfies the Dirichlet problem u(x, 0) = 0, u(0, t) = u(L, t) = 0, ut - kurr - sin u, where 0 < x < L and t 0. Show that there exists a constant C> 0 such that for...
-
If Gary's Shoes pays Al Bundy a salary of $25,000 per year and decided to pay all of it shoe managers overtime (even though this is not required by law for salaried workers) for all hours over 40...
-
how has recent inflation impacted financial planning. In your initial post, address the following: Describe the monetary impact of inflation. Describe what a CFP professional will need to communicate...
-
You short-sell 200 shares of Tommy co. now selling for $37 per share. If you wish to limit your loss to $1,450, you should place a stop-buy order at what price? You purchased 250 shares of common...
-
The case: Trk Kzlay (Turkish Red Crescent) is the largest blood-product supplier in the country. All blood collected by Kzlay is from volunteer donors. Approximately 95 percent of that blood is...
-
Show that, given a maximum flow in a network with m edges, a minimum cut of N can be computed in O(m) time.
-
In a 2-issue static superscalar whose predictor can only handle one branch per cycle, what speedup is achieved by adding the ability to predict two branches per cycle? Assume a stall-on-branch policy...
-
The first three problems in this Exercise refer to a critical section of the form lock(lk); operation unlock(lk); where the operation updates the shared variable shvar using the local (nonshared)...
-
How many 16-byte cache lines are needed to store all 32-bit matrix elements being referenced? Locality is affected by both the reference order and data layout. The same computation can also be...
-
A certain radar has range resolution of \(300 \mathrm{~m}\) and is observing a target somewhere in a line of high towers each having RCS \(\sigma_{\text {tower }}=10^{6} \mathrm{~m}^{2}\). If the...
-
An implementation of a double delay line canceler with feedback is shown below. (a) What is the transfer function, \(H(z)\) ? (b) Plot the frequency response for \(K_{1}=0=K_{2}, K_{1}=0.2\), and...
-
Plot the frequency response for the filter described in the previous problem for \(K=-0.5,0\), and 0.5. Data From Problem 2 One implementation of a single delay line canceler with feedback is shown...
Study smarter with the SolutionInn App