Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a MIPS assembly language program that a. prompts the user for a zip code (as a 5-digits unsigned integer, or 0) with the string

Write a MIPS assembly language program that

a. prompts the user for a zip code (as a 5-digits unsigned integer, or 0) with the string "Give me your zip code (0 to stop): ". No error checking is necessary, assuming that the user will give correct numbers.

b. if the input is 0 stops

c. otherwise, calculates the sum of all digits, then print out the result with the leading string "The sum of all digits in your zip code is: "

d. repeats from a.

For example, if the user gave the input 75081 the program will print out "The sum of all digits in your zip code is: 21"

Requirements:

1. The program has a main part that asks for inputs from the user, does the calculation by calling the two versions of the subroutine that does the summing, ensures that the results are the same and then displays the result, then repeat the process until a 0 was given.

2. The two subroutine versions are: one is iterative using looping while the other is recursive. Obviously, both versions receive an unsigned integer and return an unsigned integer but they do the calculation differently.

3. Each version of the summing subroutine should display the result (the sum of digits) with a string that can be used to distinguish which version (iterative or recursive) before returning.

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

Students also viewed these Databases questions