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

/* *fix the below C Program to Display the Nodes of a Linked List in Reverse...
/* *fix the below C Program to Display the Nodes of a Linked List in Reverse */ #include <stdio.h> #include <stdlib.h> struct node { int visited; int a; struct node *next; }; int main() { struct node *head = NULL; generate(head); printf("\nPrinting the list in linear order\n"); linear(head); printf("\nPrinting the list in reverse order\n"); display(head); delete(head); return 0; } void display(struct node *head) { struct node *temp = head, *prev = head; while (temp->visited == 0) { while (temp->next !=...
Write a program to swap the first and last elements of a linked list. (i) by...
Write a program to swap the first and last elements of a linked list. (i) by exchanging info part (ii) through pointers Need the program in java with no direct usage of packages use node and link.
Write a MIPS assembly program that calculates the sum of all the elements in the following...
Write a MIPS assembly program that calculates the sum of all the elements in the following array: int array[10]={12,21,3,40,15,6,17,8,29,10}
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...
Part 2- - Create and display a singly Linked List with 5 elements (see below)                 Node*...
Part 2- - Create and display a singly Linked List with 5 elements (see below)                 Node* head                  Node*second                  Node*third                 Node*forth                  Node*fifth 2-Assign the data 5, 6, 8, 10, 12 to each node 3-Display the output GIVEN CODE: #include <studio.h> struct Array { int A[10]; int size; int length; }; void Display(struct Array arr) {      int i; printf("\nElements are\n");      for(i=0;ilengthsize) arr->A[arr->length++]=x; } void Insert(struct Array *arr,int index,int x) {      int i;          if(index>=0 && index <=arr->length) {      for(i=arr->length;i>index;i--)      arr->A[i]=arr->A[i-1]; arr->A[index]=x; arr->length++; }...
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.
Translate the following C program into MIPS assembly language, allocate registers as you need, but document...
Translate the following C program into MIPS assembly language, allocate registers as you need, but document the allocation. int A[10]; // assume initialized elsewhere int sum = 0; int I = 0; while (i<0) { sum += A[i++]; sum+= 2 ;} plz do not copy from other answer, thx.
Hello I need a small fix in my program. I need to display the youngest student...
Hello I need a small fix in my program. I need to display the youngest student and the average age of all of the students. It is not working Thanks. #include <iostream> #include <iomanip> #include <fstream> #include <vector> #include <algorithm> using namespace std; struct Student { string firstName; char middleName; string lastName; char collegeCode; int locCode; int seqCode; int age; }; struct sort_by_age { inline bool operator() (const Student& s1, const Student& s2) { return (s1.age < s2.age); // sort...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT