Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop a complete program in Nios II assembly language to perform the computation specified by the pseudocode given below. /* globals: list, n, above_upper, below_lower,

Develop a complete program in Nios II assembly language to perform the computation specified by the pseudocode given below.

/* globals: list, n, above_upper, below_lower, in_between */

main:: above_upper = CountAboveUpperLimit(list, n, 7) below_lower = CountBelowLowerLimit(list, n, 2) in_between = n - above_upper - below_lower

CountAboveUpperLimit(list, n, upper):: count = 0 for i = 0 to n-1 do count = count + GreaterThan(list[i], upper) end for return count

/* note different arg. order in subroutine call */ CountBelowLowerLimit(list, n, lower):: count = 0 for i = 0 to n-1 do count = count + GreaterThan(lower, list[i]) end for return count

GreaterThan(first, second) if (first > second) then ret_val = 1 else ret_val = 0 end if return ret_val

Note that in this program, the global variables are only accessed directly by name in the main routine.

All other symbols appearing in the body of the subroutines represent variables local to each subroutine, or they represent incoming arguments to each subroutine which also means they are local.

Follow the required register-usage convention for arguments into subroutines (r2, r3, ...) and for a return value (r2). As necessary, use additional registers to hold information so that arguments can be passed in the required registers.

Follow the guidelines to systematically generate assembly-language code for subroutines, loops, and conditional statements. Make labels unique for loops and conditional statements with different prefixes or different numeric suffixes.

Prepare modular code by saving/restoring registers in the appropriate manner.

For the data, use a list consisting of the following items: { 9, 5, 4, 8, 1 }.

Use the Web-based simulator to assemble and debug your program for correct functionality. To ensure that you maintain a local up-to-date copy of your code, use a separate text editor and bring code into the Web-based simulator. If you rely on the editor within the Web-based simulator, save your code often.

When complete and when verification has been achieved successfully, copy/paste the syntax-error-free code for the entire program into the space below.

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

What do you consider abnormally high? Are these suspicious?

Answered: 1 week ago

Question

Are there any KPIs that would be appropriate here?

Answered: 1 week ago

Question

Which orders were created after shipment?

Answered: 1 week ago