Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will learn to program in assembly language using the MARS MIPS simulator. You will learn: How to perform input and output

In this assignment, you will learn to program in assembly language using the MARS MIPS simulator. You will learn:

How to perform input and output of integers.

Use conditional branches, including creating a loop.

Perform basic math operations, including multiplication and addition.

Setting up MARS. You will develop and test your assembly program using the MARS MIPS simulator (Links to an external site.)Links to an external site.. As described on the MARS download page, be sure you have Java installed on your computer first. Once the JAR file is downloaded, place it somewhere easy to find on your computer (e.g. on your Desktop). Double-clicking the JAR file should open up the simulator. Be sure to set the memory configuration option of MARS to "compact text at 0". We will grade your program with the option set that way. Once MARS has started, you can take it for a test spin. First create a new file then paste the following code:

# Read an integer number from the user li $v0, 5 # syscall 5 requests reading an integer, placing result in $v0 syscall # Read in number should now be in register $v0, copy in $t0 move $t0, $v0 # Print out the number move $a0, $t0 li $v0, 1 # syscall 1 prints the integer value stored in $a0 syscall # Print a line feed li $v0, 11 # syscall 11 prints chracter stored in $a0 addi $a0, $0, 0xA # ASCII code 10 is a line feed syscall # Negate the number by subtracting it from zero sub $t0, $0, $t0 # Print out the negated result move $a0, $t0 li $v0, 1 # syscall 1 prints the integer value stored in $a0 syscall # Terminate execution li $v0, 10 # syscall 10 terminates program execution syscall 

Click on the assemble button in the toolbar (the one with a wrench and screwdriver). If the program assembles successfully, you should be brought to the execute tab. Hit the play button to run the program. Click on the Run I/O window and the bottom and type in an integer. The program should print out the number followed by the negation of the integer.

Overview. Develop a MIPS assembly program named IntegerSequence.asm that reads in a sequence of non-negative integers from the user. It keeps reading integers until the user enters any negative number. The program then prints various tallies about the sequence of integers. The sequence does not include the negative number that terminated the input. On separte lines the program should print the following (in this order):

Count - count of integers that were read in

Sum - the sum of the integers

Product - the result of multiplying all the integers together

Maximum - the largest integer in the sequence

If no non-negative integers are entered (i.e. the user entered a negative number immediately), the program should produce no output.

You will need to use the temporary registers ($t0-$t7) and/or saved registers ($s0-$s7) as variables in your program. Do not assume registers contain any particular value when your program starts. While MARS initializes registers to zero, relying on this is a bad habit as this wouldn't happen in real-world assembly language programming. Furthermore in C programming you will also need to initialize all variables so you might as well get use to it!

Here are some example runs:

1 5 4 2 -1 4 12 40 5 -- program is finished running -- 1 -20 1 1 1 1 -- program is finished running -- 8 8 8 0 -1 4 24 0 8 -- program is finished running -- -1 -- program is finished running -- 12 89 8743 3 1 0 2 -1 7 8850 0 8743 -- program is finished running -- 

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

Recommended Textbook for

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions

Question

Is the person willing to deal with the consequences?

Answered: 1 week ago

Question

Was there an effort to involve the appropriate people?

Answered: 1 week ago