Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

A.8 [5] Using SPIM, write and test a program that reads in a positive integer using the SPIM system calls. If the integer is not positive, the program should terminate with the message “Invalid Entry”; otherwise the program should print out the names of the digits of the integers, delimited by exactly one space. For example, if the user entered “728,” the output would be “Seven Two Eight.”

Short Answer

Expert verified

The required program:

.data

zero: .asciiz "Zero "

one: .asciiz "One "

two: .asciiz "Two "

three: .asciiz "Three "

four: .asciiz "Four "

five: .asciiz "Five "

six: .asciiz "Six "

seven: .asciiz "Seven "

eight: .asciiz "Eight "

nine: .asciiz "Nine "

prompt

lbu $4, digitand $5, $4, 0x80srl $5, $5, 31bgt $5, 0, positiveb Invalid Entry

Step by step solution

01

Define the concept.

  • The MIPS instruction “srl” is used forshifting the value of the register to the right. And it is shifted by the shift amount of the “shamt” and hence it is placed in the register of the destination.
  • One of the MIPS instructions “bgt Rsrc1, Src2, label” is used for Branching on greater than the conditional branch to the instruction at the mentioned- statement “label” if the register “Rsrc1” contents are greater than the register “Src2” content.
  • The MIPS instruction “lbu” is used for loading the byte of unsigned.
  • The MIPS instruction “b label” is used forbranching the instruction unconditionally branch to the instruction at the mentioned statement “label”.
02

Determine the calculation.

The required code:

.data //This is the data section

Str1: .asciiz "Please enter a number:"

zero: .asciiz "Zero " //initialize the names of the digit “0”

one: .asciiz "One " //initialize the names of the digit “1”

two: .asciiz "Two " //initialize the names of the digit “2”

three: .asciiz "Three " //initialize the names of the digit “3”

four: .asciiz "Four " //initialize the names of the digit “4”

five: .asciiz "Five " //initialize the names of the digit “5”

six: .asciiz "Six " //initialize the names of the digit “6”

seven: .asciiz "Seven " //initialize the names of the digit “7”

eight: .asciiz "Eight " //initialize the names of the digit “8”

nine: .asciiz "Nine " //initialize the names of the digit “9”

prompt

lbu $4, digitand $5, $4, 0x80srl $5, $5, 31bgt $5, 0, positive // perform forprinting the names of the digits of the integersif the number is positiveb Invalid Entry // if the number is negative , print “Invalid Entry”

The output of the code:

Set 1:

Please enter a number: 624

Six two four

Set 2:

Please enter a number: -624

Invalid Entry

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Question: 6.17 Benchmarking is field of study that involves identifying representative workloads to run on specific computing platforms in order to be able to objectively compare performance of one system to another. In this exercise we will compare two classes of benchmarks: the Whetstone CPU benchmark and the PARSEC Benchmark suite. Select one program from PARSEC. All programs should be freely available on the Internet. Consider running multiple copies of Whetstone versus running the PARSEC Benchmark on any of systems described in Section 6.11.

6.17.1 [60] what is inherently different between these two classes of workload when run on these multi-core systems?

6.17.2 [60] In terms of the Roofline Model, how dependent will the results you obtain when running these benchmarks be on the amount of sharing and synchronization present in the workload used?

Derive the product-of-sums representation for Eshown on page B-11 starting with the sum-of-products representation. You will need to use DeMorgan’s theorems.

Question Title: Q2E

Question:You are trying to bake 3 blueberry pound cakes. Cake ingredients are as follows:

1 cup butter, softened

1 cup sugar

4 large eggs

1 teaspoon vanilla extract

1/2 teaspoon salt

1/4 teaspoon nutmeg

1 1/2 cups flour

1 cup blueberries

The recipe for a single cake is as follows:

Step 1: Preheat oven to 325°F (160°C). Grease and flour your cake pan.

Step 2: In large bowl, beat together with a mixer of butter and sugar at medium speed until light and fluffy. Add eggs, vanilla, salt, and nutmeg. Beat until thoroughly blended. Reduce mixer speed to low and add flour, 1/2 cup at a time, beating just until blended.

Step 3: Gently fold in blueberries. Spread evenly in a prepared baking pan. Bake for 60 minutes.

6.2.1 Your job is to cook 3 cakes as efficiently as possible. Assuming that you only have one oven large enough to hold one cake, one large bowl, one cake pan, and one mixer, come up with a schedule to make three cakes as quickly as possible. Identify the bottlenecks in completing this task.

6.2.2 Assume now that you have three bowls, 3 cake pans, and 3 mixers. How much faster is the process now that you have additional resources?

6.2.3 Assume now that you have two friends that will help you cook, and that you have a large oven that can accommodate all three cakes. How will this change the schedule you arrived at in Exercise 6.2.1 above?

6.2.4 Compare the cake-making task to computing 3 iterations of a loop on a parallel computer. Identify data-level parallelism and task-level parallelism in the cake-making loop.

Implement the four-input odd-parity function with a PLA.

Assign state numbers to the states in the traffic light example of Exercise B.41 and use the tables of Exercise B.42 to write a set of logic equations for each of the outputs. Including the next-state outputs.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free