Question

1. Write and debug a MIPS program that performs the following operations . Prompt for and input three integers a, b and c using syscalls (3 points) Print all numbers starting from a upto b (including, but not exceeding b) at an increment equal to value ofc(5 points) If ba, then no numbers are printed, and a message is printed to inform it to the user. (3 points) Print the number and average of the generated numbers printed. (3 points) Return to the operating system 2. Initial comments in your code must include Your name IT 320 Lab Assignment 1 I certify that this program is entirely my own creation. I have not shared this code with any other person. # Explain your steps 3. Your code must be appropriately commented. 4. Your runs output must look exactly in format like the sample below. Note that only the output result will vary depending on the input numbers. The values shown in bold here (not in your console window) are user inputs for this run Enter the Starting Number 10 Enter the Ending Number 23 Enter the increment value: 4 The generated numbers are 10, 14, 18, 22 The total generated numbers 4 Average of the generated numbers: 16

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

Please find the code below:

.data
prompt: .asciiz "Enter the starting Number : " #prompt for string
prompt1: .asciiz "Enter the Ending Number : " #prompt for string
prompt2: .asciiz "Enter the increment Value : " #prompt for string
prompt3: .asciiz "The generated numbers are : " #prompt for string
prompt4: .asciiz "\nTotal generated numbers : " #prompt for string
prompt5: .asciiz "\nAverage of the generated numbers : " #prompt for string
prompt6: .asciiz " " #prompt for string
prompt7: .asciiz "Invalid entry!!! Starting number is greater than ending number : " #prompt for string
.text
li $v0,4
la $a0,prompt #it will print prompt
syscall
li $v0,5
syscall #ask user input
move $t0,$v0 #get starting number

li $v0,4
la $a0,prompt1 #it will print prompt
syscall

li $v0,5
syscall #ask user input
move $t1,$v0 #get ending number


li $v0,4
la $a0,prompt2 #it will print prompt
syscall
li $v0,5
syscall #ask user input
move $t2,$v0 #get difference

blt $t1,$t0,totalExit

li $v0,4
la $a0,prompt3 #it will print prompt
syscall

li $s0,0 #load total number of elements
li $s1,0 #load total of the number

loop:
ble $t1,$t0,skip
add $s0,$s0,1 #increase number by one
add $s1,$s1,$t0 #add sum
li $v0,1
move $a0,$t0
syscall

li $v0,4
la $a0,prompt6 #it will print prompt
syscall
add $t0,$t0,$t2
j loop
skip:
li $v0,4
la $a0,prompt4 #it will print prompt
syscall

move $a0,$s0
li $v0,1
syscall


div $s1,$s1,$s0 #get average
li $v0,4
la $a0,prompt5 #it will print prompt
syscall

move $a0,$s1
li $v0,1
syscall

li $v0,10 #terminate
syscall

totalExit:

li $v0,4
la $a0,prompt7 #it will print prompt
syscall

output:

Add a comment
Know the answer?
Add Answer to:
1. Write and debug a MIPS program that performs the following operations . Prompt for and...
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
  • Your program  write a program to test whether a number is prime or not. Your program should...

    Your program  write a program to test whether a number is prime or not. Your program should ask user to input an integer and respond: "Prime" or "Not prime". Don't use any library function that tests for prime numbers. The program should continue to ask for input, till it sees a 0, when it exits. Please submit printed pseudocodeshould ask user to input an integer and respond: "Prime" or "Not prime". Don't use any library function that tests for prime numbers....

  • Practice Problem [no points]: You should read and understand Fibonacci algorithm, write a code in a...

    Practice Problem [no points]: You should read and understand Fibonacci algorithm, write a code in a high level language of your choice and in Assembly to find a Fibonacci number and check your result. At the end of this assignment a possible solution to this problem is given both in Python and MIPS assembler. Note that it would have been possible to write the Python differently to achieve the same function. . [20 points] Write and debug a MIPS program...

  • MIPS 1(a): Using MARS (MIPS assembly simulator), write and debug a program with comments that will...

    MIPS 1(a): Using MARS (MIPS assembly simulator), write and debug a program with comments that will store words in a RAM array using the instruction sw and indirect addressing as specified in the data table below. Although the addresses and data are in given hexadecimal, your code will contain corresponding values in decimal. Use (268501056)_10 = (10010040)_16 as the base address of the array. Since the instruction sw and indirect addressing (using offsets) are needed to store the data in...

  • For each problem, you must: Write a Python program Test, debug, and execute the Python program...

    For each problem, you must: Write a Python program Test, debug, and execute the Python program Save your program in a .py file and submit your commented code to your Student Page. Note regarding comments: For every class, method or function you create, you must provide a brief description of the what the code does as well as the specific details of the interface (input and output) of the function or method. (25 pts.) Write a program that reads in...

  • Write a MIPS program to that will take two 4x4 matrices, and calculate their sum and...

    Write a MIPS program to that will take two 4x4 matrices, and calculate their sum and product, using row major, and column major math (so this is actually 4 problems, but obviously they’re all pretty related). I generated two sample arrays to test 2   1       9       2 7   9       10      10 3   4       4       4 2   5       4       4 8 7 1 2 2 7 8 6 7 5 6 8 9 4 8 9 The output of your program...

  • Complete the Python program below that performs the following operations. First prompt the user to input...

    Complete the Python program below that performs the following operations. First prompt the user to input two integers, n and m. If n<m, then print the odd positive integers that are less than m (in order, on a single line, separated by spaces). If man, then print the even positive integers that are less than n (in order, on a single line, separated by spaces). If neem, then print nothing. For instance, if the user enters 5 followed by 10,...

  • Introduction: In this lab, you will write a MIPS program to read in (up to) 50...

    Introduction: In this lab, you will write a MIPS program to read in (up to) 50 integer values from the user, store them in an array, print out the amay, one number per line, reverse the elements in the array and finally print out the elements in the just-reversed) array. Feel free to do this lab and all assembly programming labs) in Windows. You must use MARS Getting started: l. In MARS, create a new assembly file with the name...

  • C++ (1) Write a program to prompt the user for an input and output file name....

    C++ (1) Write a program to prompt the user for an input and output file name. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs. For example, (user input shown in caps in first line, and in second case, trying to write to a folder which you may not have write authority in) Enter input filename: DOESNOTEXIST.T Error opening input file: DOESNOTEXIST.T...

  • Write MIPS code, please. Following: Write a program to be used by the Wisconsin DNR to...

    Write MIPS code, please. Following: Write a program to be used by the Wisconsin DNR to track the number of Deer Hunting Licenses issued in a county and the state. It will display a menu with 5 choices numbered 1-5. They are (1) update the count, (2) display the number of licenses already issued to a county whose number is input, (3) display the county number and the number of licenses already issued to a range of counties whose starting...

  • Create a program that performs the following operations: 1. Prompt for and accept a string of...

    Create a program that performs the following operations: 1. Prompt for and accept a string of up to 80 characters from the user. • The memory buffer for this string is created by: buffer: .space 80 #create space for string input The syscall to place input into the buffer looks like: li $v0,8 # code for syscall read_string la $a0, buffer #tell syscall where the buffer is li $a1, 80 # tell syscall how big the buffer is syscall 2....

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