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
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
Specifics: Use only the instructions covered to date. No jal and jr. Do not use...
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...
Only used main method please. (Count positive and negative numbers and compute the average, of numbers) Write a program that reads an unspecified number of integers , determines how many positive and negative values have been read, and computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number. Display the total as a floating-point number. Display the lowest number in the list. Display the...
Write a JAVA program to read a list of nonnegative integers and to display the largest integer, the smallest integer and the average of all the integers. The user indicates the end of the input by entering a negative sentinel value that is not used in finding the largest, smallest and average values. The average should be a value of type double so that it is computed a fractional part. * Java program free from syntax, logic and run time...
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 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)...
Write a c++ complete program to meet the specifications. The program should prompt the user for a positive integer. The program should print a message whether the integer is even or odd. The looping should end when the user enters a negative number. The negative number will not be tested for even or odd. The program will print out a message of how many numbers were entered (not counting the negative number) and how many even and odd numbers were...
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 '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...
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 num...
Do pseudocode in java Design (pseudocode) and implement (source code) a program (name it LargestOccurenceCount) that read from the user positive non-zero integer values, finds the largest value, and counts it occurrences. Assume that the input ends with number 0 (as sentinel value to stop the loop). The program should ignore any negative input and should continue to read user inputs until 0 is entered. The program should display the largest value and number of times it appeared as shown...