Question

In: Computer Science

Write MIPs program that will read two intergers from the user and compute for the sum...

Write MIPs program that will read two intergers from the user and compute for the sum and difference of the two intergers. Ask the user whether he wants to repeat the program : "[Y/y] / [N/n] ?".

Solutions

Expert Solution

For addition:

.data
msg1: .asciiz "Enter the first number: "
msg2: .asciiz "\nEnter the second number: "
result: .asciiz "\nThe result of addition is: "

.text
li $v0,4
la $a0,msg1
syscall

li $v0,5
syscall
move $t1,$v0

li $v0,4
la $a0,msg2
syscall

li $v0,5
syscall
move $t2,$v0

Add $t3,$t1,$t2

li $v0,4
la $a0,msg3
syscall

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

li $v0,10
syscall

For Subtraction:

.data

msg1: .asciiz "Enter the first number: "
msg2: .asciiz "Enter the second number: "
result: .asciiz "The result of subtraction is: "

.text

li $vo,4
la $a0,msg1
syscall

li $v0,5
syscall
move $v0,$t1


li $vo,4
la $a0,msg1
syscall

li $v0,5
syscall
move $v0,$t2

sub $t1,$t1,$t2

li $v0,4
la $a0,result
syscall

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

li $v0,10
syscall

For prompting the user to repeat the program:

.data
again:
.asciiz "Again (y or n)? "
answer:
.space 256

.text
.globl main
main:
li $v0, 4
la $a0, again
syscall

la $a0, answer
li $a1, 3
li $v0, 8
syscall

lb $t4, 0($a0)

beq $t4, 'y', main
beq $t4, 'Y', main

li $v0, 10
syscall


Related Solutions

Write MIPs program that will read two integers from the user and compute for the sum...
Write MIPs program that will read two integers from the user and compute for the sum and difference of the two integers. Ask the user whether he wants to repeat the program : "[Y/y] / [N/n] ?".
Write a MIPS program that asks the user for 2 numbers. Output the sum of the...
Write a MIPS program that asks the user for 2 numbers. Output the sum of the 2 numbers. The difference between the 2 numbers (num1-num2) and (num2-num1) The value that is 305 more than the 1st number. The value that is 305 less than the 2nd number
Write a MIPS program that will ask the user to enter two numbers at the console...
Write a MIPS program that will ask the user to enter two numbers at the console and pass the values to a function that does multiplication
Write a mips assembly language program to ask the user to enter two integers A and...
Write a mips assembly language program to ask the user to enter two integers A and B and then display the result of computing the expression: A + 2B - 5.
Write code in MIPS ,read tow number from the user that do the following: 1- multiply...
Write code in MIPS ,read tow number from the user that do the following: 1- multiply 2- Dividing 3- sum 4- average 5- minimum 6- maximum 7- print message to thank the user for using my program
Write a MIPS Assembly language program to request a file name from the user, open the...
Write a MIPS Assembly language program to request a file name from the user, open the file, read the contents, and write out the contents to the console. This is what I have so far: .data    fileName:   .space 100    prompt1:   .asciiz "Enter the file name: "    prompt2:    .asciiz ""    prompt3:   .asciiz "\n"    buffer:    .space 4096 .text    main:        #        li $v0, 4        la $a0, prompt1       ...
Write a MIPS assembly program that prompts the user first for a string, then for a...
Write a MIPS assembly program that prompts the user first for a string, then for a character. The program should then search the string for the character and print out the number of times the character appears in the string. You can use as many restrictions as you want, just be sure to list them. You must allocate space in the .data segment of your program for the user string.
Write a simple MIPS program that asks the user to input a string and then a...
Write a simple MIPS program that asks the user to input a string and then a character. The program should then count how many times that character appears in the string and print out that value. Please use comments.
Write a MIPS assembly language program to read an arbitrary number of integer pairs from a...
Write a MIPS assembly language program to read an arbitrary number of integer pairs from a file. Each pair will then be multiplied together with the results being accumulated (added together) forming a sum-of-products operation. Submit your report and code here.
Write a mips program that would function in QTSPIM that asks the user to enter a...
Write a mips program that would function in QTSPIM that asks the user to enter a list of integer values, one per line, with the last value being a negative. The program should read in these integers until a negative number is entered. Afterwards the program should print 1) sum, 2) minimum value, 3) max value, 4) mean and 5) variance value. of the numbers that were entered.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT