Question

Specifics:  Use only the instructions covered to date. No jal and jr. Do not use...

Specifics:

 Use only the instructions covered to date. No jal and jr. Do not use any pseudo-instructions.

 Do not store any values into memory. There are no lw or sw instructions in this program. Just read the integers and process them.

 Document the beginning of your program with your name, project description, and class ID.

 comment every instruction.

Write a MIPS assembly language program to do the following:

1. Print your name

2. Prompt the user for the number of times to repeat the testing of your logic for step 4. (See the example below.)

3. Read an integer

4. If the integer that is input is less than 1 Print an error message.

Else

Repeat the following steps the number of times input in step 3. This will require a loop.

a. Read in a list of integers ending with a 0. The 0 marks the end of the input and is not considered part of the list.

b. Print the largest and smallest numbers in the input list. If only a zero appears in the list, print an error message

5. Print an ending message and then end your program. Note: your program should not end with an error message.

Example input and output for the program.

In this example, the number of times the logic is tested in this example is 3.

Tom Jones

Enter the number of times to test: 3

Enter a number 1 Enter a number 0

The smallest number is 1 The largest number is 1

Enter a number 0

Error: there are no numbers to test

Enter a number -1 Enter a number 8 Enter a number 5 Enter a number 0

The smallest number is -1 The largest number is 8

Program complete

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program (with no pseudo codes):-

.data

prompt_name: .asciiz " MY NAME "

prompt_test: .asciiz "Enter the number of times to test :"

prompt_inp: .asciiz "Enter the number : "

prompt_small: .asciiz "The smallest number is :"

prompt_large: .asciiz "The largest number is :"

prompt_complete: .asciiz "Program complete "

error_msg: .asciiz "Error:there are no numbers to test "

.text

.globl main

main:

addi $v0,$0,4 #Print string

lui $a0, prompt_name_hi

ori $a0, $a0, prompt_name_lo

syscall

addi $v0,$0,4 #Print string

lui $a0, prompt_test_hi

ori $a0, $a0, prompt_test_lo #load prompt

syscall

addi $v0,$0,5 #read int

syscall

add $s0, $v0,$0

addi $s1,$0,0

TEST_LOOP:

beq $s0, $s1, PROGRAM_END

addi $t0,$0,1 #number counter

addi $s2,$0,1

NUMBER_LOOP:

addi $v0,$0,4 #Print string

lui $a0, prompt_inp_hi

ori $a0, $a0, prompt_inp_lo #load prompt

syscall

addi $v0,$0,5 #read int

syscall

add $t1,$v0,$0

bne $t0,$s2,SKIP_FIRST

add $t2,$t1,$0 #smallest number

add $t3,$t1,$0 #largest number

bne $t1,$0,SKIP_FIRST

addi $v0,$0,4 #Print string

lui $a0, error_msg_hi

ori $a0, $a0, error_msg_lo #load error msg

syscall

beq $zero,$zero,NUMBER_LOOP_EXIT

SKIP_FIRST:

beq $t1,$0,PRINT_SMALL_LARGE

slt $t5,$t1,$t2

beq $t5,$zero,GREAT_CHECK

addiu $t2,$t1,0

GREAT_CHECK:

slt $t5,$t3,$t1

beq $t5,$zero,NEXT

addiu $t3,$t1,0

NEXT:

addi $t0,$t0,1

beq $zero,$zero,NUMBER_LOOP

PRINT_SMALL_LARGE:

addi $v0,$0,4 #Print string

lui $a0, prompt_small_hi

ori $a0, $a0, prompt_small_lo #load prompt

syscall

addi $v0,$0,1 #display int

add $a0,$t2,$0

syscall

addi $v0,$0,4 #Print string

lui $a0, prompt_large_hi

ori $a0, $a0, prompt_large_lo #load prompt

syscall

addi $v0,$0,1 #display int

add $a0,$t3,$0

syscall

NUMBER_LOOP_EXIT:

addi $s1,$s1,1

beq $zero,$zero,TEST_LOOP

PROGRAM_END:

addi $v0,$0,4 #Print string

lui $a0, prompt_complete_hi

ori $a0, $a0, prompt_complete_lo #load prompt

syscall

EXIT:

addi $v0,$0,10

syscall

Add a comment
Know the answer?
Add Answer to:
Specifics:  Use only the instructions covered to date. No jal and jr. Do not use...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA turn this psuedo code into java code. USING NO LOOPS! ALL LOOPS MUST BE TURNED...

    JAVA turn this psuedo code into java code. USING NO LOOPS! ALL LOOPS MUST BE TURNED INTO RECURSIVE CALLS. English: 1. Prompt for and read a number between 1 and 5. Repeat this step until the input is 1..5. 2. Repeat the following multiple times according to the number read in step 1. a. Read in a list of integers ending with a 0. The 0 marks the end of the input and is not considered part of the list...

  • Write a single program in java using only do/while loops for counters(do not use array pls)...

    Write a single program in java using only do/while loops for counters(do not use array pls) for the majority of the program and that asks a user to enter a integer and also asks if you have any more input (yes or no) after each input if yes cycle again, if not the program must do all the following 4 things at the end of the program once the user is finished inputting all inputs... a.The smallest and largest of...

  • In Python 3 - Write a program that reads a sequence of integer inputs from the...

    In Python 3 - Write a program that reads a sequence of integer inputs from the user. When the user is finished entering the integers, they will enter a 'q'. There is no need to check if the entry is a valid integer. All integers in the test data (input) will be between -255 and 255. The program should then print: The smallest and largest of the inputs. The number of even and odd inputs (0 should be considered even)...

  • Swapping Values in python Summary In this lab, you complete a Python program that swaps values...

    Swapping Values in python Summary In this lab, you complete a Python program that swaps values stored in three variables and determines maximum and minimum values. The Python file provided for this lab contains the necessary input and output statements. You want to end up with the smallest value stored in the variable named first and the largest value stored in the variable named third. You need to write the statements that compare the values and swap them if appropriate....

  • 5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters...

    5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Enter 7, 2, bob, 10, and 4 and match the output below. ​ 1 largest = None 2 smallest = None 3 while True: 4...

  • Python Script format please! 1. Write a script that takes in three integer numbers from the...

    Python Script format please! 1. Write a script that takes in three integer numbers from the user, calculates, and displays the sum, average, product, smallest, and largest of the numbers input. Important things to note: a. You cannot use the min() or max() functions, you must provide the logic yourself b. The calculated average must be displayed as an integer value (ex. If the sum of the three values is 7, the average displayed should be 2, not 2.3333). Example:...

  • urgent Help needed in python program ! Thanx # This is a function definition. You can...

    urgent Help needed in python program ! Thanx # This is a function definition. You can ignore this for now. def parse_integer_list_from_string(string): """ Returns a list of integers from a string containing integers separated by spaces. """ # Split the line into a list of strings, each containing a number. number_string_list = string.split() # Create an empty list to store the numbers as integers. numbers = [] # Convert each string to an integer and add it to the list...

  • Write a program in C that meets the following requirements: 1. Your program will read n...

    Write a program in C that meets the following requirements: 1. Your program will read n + 1 integers from the keyboard where n is the first integer read. 2. If n is less than 1 print an error message and return a status of 1. 3. If there are no positive numbers, print “no positive numbers”. This is not an error. 4. If there are positive numbers, print the average of the positive numbers. 5. 0 is neither positive...

  • 1. Prompt the user for one of the arithmetic operators ('op'): +, -, *,/, or **...

    1. Prompt the user for one of the arithmetic operators ('op'): +, -, *,/, or ** 2. Prompt the user for two input integers ('a' and'b') 3. The input numbers can be positive or negative 4. Perform the arithmetic operation using the two input numbers 5. The first entered number ('a') is the left side, the second ('b') the right side of the operation For exponentiation, the first number is the base, the second the exponent Print (display) the following...

  • Write a program that writes a series of random numbers to a file. Each random number...

    Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500 inclusive. 1.Use a file called randoms.txt as a input file and output file a. If you go to open the file and its not there then ask the user to create the file     and then quit 2. Ask the user to specify how many random numbers the file will hold. a.Make sure that the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT