Question

Assembly Programming in MIPS Write a program in MIPS assembler that performs the following computations: Prompts...

Assembly Programming in MIPS

Write a program in MIPS assembler that performs the following computations:

  1. Prompts the user to enter two integers and stores the smaller one in the first data memory word (with the lowest address) and the larger one in the second data memory word.
  2. Then divides the larger word by the smaller one in integer and stores the integer quotient in the third data memory word and the remainder in the fourth data memory word.
  3. Finally, it prints the four data memory words on separate lines each starting with a label (fist integer, second integer, quotient, remainder).

Requirements and restrictions

  1. Use integer arithmetic only.
  2. Include at least one instruction from each instruction type: R-type arithmetic, I-type arithmetic, Memory transfer (lw, sw) and Branch (beq, bne).
  3. Use input and output through system calls including print string for prompting the user and printing labels.
  4. Do NOT use pseudo-instructions or non-machine level instructions. The program must load and run with "Allow pseudo instructions" unchecked (in Simulator/Settings).
  5. For each instruction Include as comment in the source file: its type, format and meaning in the program.
  6. Use the SPIM simulator to run the program.

Homework Answers

Answer #1

MEMORY ADDRESS   MNEMONICS   COMMENT
2000   LDA 2050   A<-[2050]
2003   MOV H, A   H<-A
2004   LDA 2051   A<-[2051]
2007   DIV B   B <-A/H
2008 QUT C C <- A%H

.data #Section that declares variables for program
firstPromptString: .asciiz "first integer"
SecondromptString: .asciiz "second integer"
quotientromptString: .asciiz "quotient integer"
remainderromptString: .asciiz "remainder integer"

firstPromptString : A
SecondromptString : H
quotientromptString: B
remainderromptString: C

Know the answer?
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
Similar Questions
(MIPS Assembly Language): Assume the following piece of MIPS code: label1: .text 0x4000fc lui $t0, 1022...
(MIPS Assembly Language): Assume the following piece of MIPS code: label1: .text 0x4000fc lui $t0, 1022 ori $t0, $t0, 2048 srl $t1, $t0, 18 sw $t0, 101($t1) slti $t2, $t1, 5 beq $t2, $0, label3 label2:... ... label3:... a) The code modifies a word in memory at the following address (circle one): (i) 1022 (ii) 101 (iii) 5 (iv) 10220000 (v) Other (provide your own answer): _________________ b) The following value is stored in memory (circle one): (i) 0x17 (ii)...
Write the following program in MIPS: a) declare an array A of the following numbers: 3,...
Write the following program in MIPS: a) declare an array A of the following numbers: 3, 5, 8, 10, 12, 2, 76, 43, 90, 44 b) declare a variable called size which stores the number of element in array A, that is 10. c) write a subroutine to search for a number stored in an array and return true or false. In C++ the subroutine is as follows: search(array, size, number_To_Search) e.g. search(A, 10, 12) The subroutine should return 0...
program has to be written in X86 processor assy language. Write a program that find the...
program has to be written in X86 processor assy language. Write a program that find the minimum number of coins that can represent an amount of money under $1. The amount of money is a random number between 0 and 99 (cents). The randomRange procedure is used to get a random number. Review the sample code in lab4.asm and run it to see how randomRange works. Each time randomRange is called, it creates a random number between 0 and the...
Consider a program having following sequence of instructions, where the syntax consists of an opcode followed...
Consider a program having following sequence of instructions, where the syntax consists of an opcode followed by the destination register followed by one or two source registers: Instruction no Instructions 1 ADD R3, R1, R2 2 LOAD R6, [R3] 3 AND R7, R5, 3 4 ADD R1, R6, R0 5 SUB R2, R1, R6 6 AND R3, R7, 15 7 SUB R5, R3, R4 8 ADD R0, R1, R10 9 LOAD R6, [R5] 10 SRL R7, R0, 8 Assume the...
Written in MASM Assembly Problem Definition: Write a program to calculate Fibonacci numbers. • Display the...
Written in MASM Assembly Problem Definition: Write a program to calculate Fibonacci numbers. • Display the program title and programmer’s name. Then get the user’s name, and greet the user. • Prompt the user to enter the number of Fibonacci terms to be displayed. Advise the user to enter an integer in the range [1 .. 46]. • Get and validate the user input (n). • Calculate and display all of the Fibonacci numbers up to and including the nth...
In this assignment you will write a program that compares the relative strengths of two earthquakes,...
In this assignment you will write a program that compares the relative strengths of two earthquakes, given their magnitudes using the moment magnitude scale. Earthquakes The amount of energy released during an earthquake -- corresponding to the amount of shaking -- is measured using the "moment magnitude scale". We can compare the relative strength of two earthquakes given the magnitudes m1 and m2 using this formula: f=10^1.5(m1−m2) If m1>m2, the resulting value f tells us how many times stronger m1...
Section 2: Using the MARS or SPIM simulator develop a program that will implement the following...
Section 2: Using the MARS or SPIM simulator develop a program that will implement the following conditional statement. If ( n is even) { n = n / 2; } else { n = 3 * n + 1; } In this case, n is to be input by the user (assume they input a non-negative value), the conditional is performed, and the resulting n is to be output. Again, use the system calls for input, output, and exiting the...