Question

In: Computer Science

Write an assembly code in MIPS program that can read 3 numbers from the user and...

Write an assembly code in MIPS program that can read 3 numbers from the user and print the following: a. The summation b. The average c. The minimum d. The maximum e. Print the values between the minimum and maximum f. Write comments to explain each line in your code -look at Fibonacci code- (no comments mean zero for the assignment )

use MARS MIPS .

Solutions

Expert Solution

main:
        daddiu  $sp,$sp,-8032
        sd      $fp,8024($sp)
        move    $fp,$sp
        sw      $0,0($fp)
.L3:
        lw      $2,0($fp)
        slt     $2,$2,2001
        beq     $2,$0,.L2
        nop

        lw      $2,0($fp)
        dsll    $2,$2,2
        daddu   $2,$fp,$2
        lw      $2,8($2)
        sll     $2,$2,2
        move    $3,$2
        lw      $2,0($fp)
        dsll    $2,$2,2
        daddu   $2,$fp,$2
        sw      $3,8($2)
        lw      $2,0($fp)
        addiu   $2,$2,2
        sw      $2,0($fp)
        b       .L3
        nop

.L2:
        move    $2,$0
        move    $sp,$fp
        ld      $fp,8024($sp)
        daddiu  $sp,$sp,8032
        j       $31
        nop

__static_initialization_and_destruction_0(int, int):
        daddiu  $sp,$sp,-48
        sd      $31,40($sp)
        sd      $fp,32($sp)
        sd      $28,24($sp)
        move    $fp,$sp
        lui     $28,%hi(%neg(%gp_rel(__static_initialization_and_destruction_0(int, int))))
        daddu   $28,$28,$25
        daddiu  $28,$28,%lo(%neg(%gp_rel(__static_initialization_and_destruction_0(int, int))))
        move    $3,$4
        move    $2,$5
        sll     $3,$3,0
        sw      $3,0($fp)
        sll     $2,$2,0
        sw      $2,4($fp)
        lw      $3,0($fp)
        li      $2,1                        # 0x1
        bne     $3,$2,.L7
        nop

        lw      $3,4($fp)
        li      $2,65535                    # 0xffff
        bne     $3,$2,.L7
        nop

        ld      $2,%got_page(_ZStL8__ioinit)($28)
        daddiu  $4,$2,%got_ofst(_ZStL8__ioinit)
        ld      $2,%call16(_ZNSt8ios_base4InitC1Ev)($28)
        move    $25,$2
        nop

        ld      $6,%got_disp(__dso_handle)($28)
        ld      $2,%got_page(_ZStL8__ioinit)($28)
        daddiu  $5,$2,%got_ofst(_ZStL8__ioinit)
        ld      $4,%got_disp(_ZNSt8ios_base4InitD1Ev)($28)
        ld      $2,%call16(__cxa_atexit)($28)
        move    $25,$2
        nop

.L7:
        nop
        move    $sp,$fp
        ld      $31,40($sp)
        ld      $fp,32($sp)
        ld      $28,24($sp)
        daddiu  $sp,$sp,48
        j       $31
        nop

_GLOBAL__sub_I_main:
        daddiu  $sp,$sp,-32
        sd      $31,24($sp)
        sd      $fp,16($sp)
        sd      $28,8($sp)
        move    $fp,$sp
        lui     $28,%hi(%neg(%gp_rel(_GLOBAL__sub_I_main)))
        daddu   $28,$28,$25
        daddiu  $28,$28,%lo(%neg(%gp_rel(_GLOBAL__sub_I_main)))
        li      $5,65535                    # 0xffff
        li      $4,1                        # 0x1
        ld      $2,%got_page(__static_initialization_and_destruction_0(int, int))($28)
        daddiu  $2,$2,%got_ofst(__static_initialization_and_destruction_0(int, int))
        move    $25,$2
        nop

        move    $sp,$fp
        ld      $31,24($sp)
        ld      $fp,16($sp)
        ld      $28,8($sp)
        daddiu  $sp,$sp,32
        j       $31
        nop
Let me know if you have any doubts or if you need anything to change. 

If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.

Thank You!
===========================================================================

Related Solutions

Write a program in MIPS Assembly. This program will ask the user to enter 20 numbers....
Write a program in MIPS Assembly. This program will ask the user to enter 20 numbers. The program will store these numbers in an array in memory (sequential memory locations). It will then print out the list of numbers in three different formats: The numbers will be printed each on a separate line. The numbers will be printed on a single line, with spaces between the numbers. The program will ask the user to enter a number n. The program...
Write a mips assembly code program that ask the user to enter an integer value, and...
Write a mips assembly code program that ask the user to enter an integer value, and then print the result of doubling that number.
MIPS Assembly program: Accept N numbers from the user and sort the N numbers using any...
MIPS Assembly program: Accept N numbers from the user and sort the N numbers using any sorting algorithm. Print both the sorted array and unsorted array. N should be greater than or equal to 10.
Use MIPS write an assembly program which asks the user to enter 3 number. The program...
Use MIPS write an assembly program which asks the user to enter 3 number. The program then sorts these numbers, the prints them from largest to smallest.
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 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 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] ?".
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       ...
IN MIPS ASSEMBLY LANGUAGE Write an assembly program to read three 32-bit signed integers from the...
IN MIPS ASSEMBLY LANGUAGE Write an assembly program to read three 32-bit signed integers from the user. Determine the smallest of these three numbers and display this result. Don’t use loops. Prompt the user for each entered integer. Your output should look something like the following example. Enter an integer: 7556 Enter an integer: -22984 Enter an integer: 8875 -22984
Write a MIPS Assembly program that computes the sum of all the odd numbers from 1...
Write a MIPS Assembly program that computes the sum of all the odd numbers from 1 ..99 and print out the answer.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT