Question

In: Computer Science

I need a MIPS Assembly program that "Display the elements of the linked list in reverse...

I need a MIPS Assembly program that "Display the elements of the linked list in reverse order." It needs subprogram and those subprogram does not have t registers.

Solutions

Expert Solution

Please give positive ratings for my effort. Thanks.

PROGRAM

.LC0:
        .ascii  " \000"
printReverse(Node*):
        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(printReverse(Node*))))
        daddu   $28,$28,$25
        daddiu  $28,$28,%lo(%neg(%gp_rel(printReverse(Node*))))
        sd      $4,0($fp)
        ld      $2,0($fp)
        beq     $2,$0,.L4
        nop

        ld      $2,0($fp)
        ld      $2,8($2)
        move    $4,$2
        ld      $2,%got_disp(printReverse(Node*))($28)
        move    $25,$2
        nop

        ld      $2,0($fp)
        lw      $2,0($2)
        move    $5,$2
        ld      $4,%got_disp(_ZSt4cout)($28)
        ld      $2,%call16(_ZNSolsEi)($28)
        move    $25,$2
        nop

        move    $3,$2
        ld      $2,%got_page(.LC0)($28)
        daddiu  $5,$2,%got_ofst(.LC0)
        move    $4,$3
        ld      $2,%call16(_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc)($28)
        move    $25,$2
        nop

        b       .L1
        nop

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

push(Node**, char):
        daddiu  $sp,$sp,-64
        sd      $31,56($sp)
        sd      $fp,48($sp)
        sd      $28,40($sp)
        move    $fp,$sp
        lui     $28,%hi(%neg(%gp_rel(push(Node**, char))))
        daddu   $28,$28,$25
        daddiu  $28,$28,%lo(%neg(%gp_rel(push(Node**, char))))
        sd      $4,16($fp)
        move    $2,$5
        sll     $2,$2,0
        sb      $2,24($fp)
        li      $4,16                 # 0x10
        ld      $2,%call16(_Znwm)($28)
        move    $25,$2
        nop

        sw      $0,0($2)
        sd      $0,8($2)
        sd      $2,0($fp)
        lb      $2,24($fp)
        move    $3,$2
        ld      $2,0($fp)
        sw      $3,0($2)
        ld      $2,16($fp)
        ld      $3,0($2)
        ld      $2,0($fp)
        sd      $3,8($2)
        ld      $2,16($fp)
        ld      $3,0($fp)
        sd      $3,0($2)
        nop
        move    $sp,$fp
        ld      $31,56($sp)
        ld      $fp,48($sp)
        ld      $28,40($sp)
        daddiu  $sp,$sp,64
        j       $31
        nop

main:
        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(main)))
        daddu   $28,$28,$25
        daddiu  $28,$28,%lo(%neg(%gp_rel(main)))
        sd      $0,0($fp)
        li      $5,4                        # 0x4
        move    $4,$fp
        ld      $2,%got_disp(push(Node**, char))($28)
        move    $25,$2
        nop

        li      $5,3                        # 0x3
        move    $4,$fp
        ld      $2,%got_disp(push(Node**, char))($28)
        move    $25,$2
        nop

        li      $5,2                        # 0x2
        move    $4,$fp
        ld      $2,%got_disp(push(Node**, char))($28)
        move    $25,$2
        nop

        li      $5,1                        # 0x1
        move    $4,$fp
        ld      $2,%got_disp(push(Node**, char))($28)
        move    $25,$2
        nop

        ld      $2,0($fp)
        move    $4,$2
        ld      $2,%got_disp(printReverse(Node*))($28)
        move    $25,$2
        nop

        move    $2,$0
        move    $sp,$fp
        ld      $31,40($sp)
        ld      $fp,32($sp)
        ld      $28,24($sp)
        daddiu  $sp,$sp,48
        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,.L10
        nop

        lw      $3,4($fp)
        li      $2,65535                    # 0xffff
        bne     $3,$2,.L10
        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

.L10:
        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_printReverse(Node*):
        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_printReverse(Node*))))
        daddu   $28,$28,$25
        daddiu  $28,$28,%lo(%neg(%gp_rel(_GLOBAL__sub_I_printReverse(Node*))))
        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

IMAGE OF OUTPUT


Related Solutions

MIPS Assembly LanguageWrite a MIPS assembly language program that asks the user toinput an...
MIPS Assembly LanguageWrite a MIPS assembly language program that asks the user to input an integer and then prints out a string that shows how that integer should be encoded using 16 bits. Your program should handle both positive and negative valued inputs. Your program should also print out an error message if the given input cannot be expressed as a 16 bit signed integer.As an example, if the input is 12, your program should output “0000000000001100”. If the input...
Using MIPS assembly language In this program, you should define an array of 10 elements in...
Using MIPS assembly language In this program, you should define an array of 10 elements in your data segment with these values: ? = {11, 12,−10, 13, 9, 12, 14, 15,−20, 0} a. Write a function which finds the maximum value of this array. b. Write another function which calculates the summation of this array. c. Call these functions in your main program, and print the outputs of these functions to the user i. “The maximum is 15” ii. “The...
This is c++ Create a program where you create, display, search, delete elements within a linked...
This is c++ Create a program where you create, display, search, delete elements within a linked list. Watch your function arguments. Pointer parameters are passed by reference to some functions and by value to others. Functions to make: copy : copies element in linked list destroy all: destroys all elements in linked list wherethisgoes:user  enters element and returns where the element is located insert sorted: inserts element create using linked lists with a head pointer and so forth
In MIPS assembly language, write a function that will display the max and min value in...
In MIPS assembly language, write a function that will display the max and min value in an array. Then write a function to calculate and display the average of all values in an array. This must be done in MIPS assembly language.
The following are to be completed using MIPS Assembly code. A.   Using syscall #4, display a...
The following are to be completed using MIPS Assembly code. A.   Using syscall #4, display a prompt for the user to enter a number. Then using syscall #5, get a decimal number from the user and save it to data memory (not into a register). After you have stored the number, display it back to the user as a 32-bit binary value. B.   Prompt the user to enter a decimal number and save it to data memory. Using addition and/or...
This is to be done using MIPS assembly language. Display the following menus, ask user to...
This is to be done using MIPS assembly language. Display the following menus, ask user to select one item. If 1-3 is selected, display message “item x is selected”, (x is the number of a menu item), display menus again; if 0 is selected, quit from the program. 1. Menu item 1 2. Menu item 2 3. Menu item 3 0. Quit Please select from above menu (1-3) to execute one function. Select 0 to quit
How can I write a simple MIPS program to print out the following elements of an...
How can I write a simple MIPS program to print out the following elements of an array of the size of 10: 5,10,15,20,25,30,35,40,45,50
need a code MIPS assembly language program to implement algorithms of an 8-bit integer "positive integer"...
need a code MIPS assembly language program to implement algorithms of an 8-bit integer "positive integer" to calculate the square root for an-8 bit integer using The Radix-2 SRT-Redundant and Non-Redundant Algorithm to approximate square root
So I need to make a java program that reverse or replace first or lastchar or...
So I need to make a java program that reverse or replace first or lastchar or remove char from user's string input. length, concat, charAt, substring, and equals (or equalsIgnoreCase) thses are the string method that only I can use for example if user put asdf asdf and chose reverse input should be fdsa fdsa if user put asdf asdf and chose replace first a with b input should be bsdf asdf if user put asdf asdf and chose remove...
Coding Problem 1: In this program, you are asked to write a program in assembly (MIPS)...
Coding Problem 1: In this program, you are asked to write a program in assembly (MIPS) which works as a simple calculator. The program will get two integer numbers, and based on the requested operation, the result should be shown to the user. a. The program should print a meaningful phrase for each input, and the result. i. “Enter the first number” ii. “Enter the second number” iii. “Enter the operation type” iv. “The result is” b. The user should...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT