Question

Write a MIPS assembly language program that uses dynamic memory allocation to create and manage a linked list data structure.

Gives the user the following options:                        

1. To create and add the first node to a linked list.         

2. To add a single node to the pre-existing linked list.        

    The list must already exist before a new node can be added.       

    The nodes should be maintained in ascending order based on the data value within the nodes by inserting new nodes into the proper place within the list. If the data value matches a data value already in the list, then the new node should be inserted after any previous nodes that contain the same data value.                                                       

3. To delete a node from the linked list structure based on the ID field within the node. Remove the node with that ID                              

4. To search the list and display the node found to contain an ID that matches the target search ID.                  

5. To search the list and display all nodes found to contain a specified data value.                      

6. To display the nodes within the list from start to end by printing the ID and data fields of each.                    

7. To terminate the program by entering X as a command.        

Attempts to create a list should be rejected if a list already exits. Attempts to add to or access the list should be rejected if the list does not already exist. Allocate each node as a 3-word unit that contains the ID, data value and a link to the node that follows.

+--------------+-------------------+---------------+           

|   ID field   |   data field     | link field   |             +--------------+-------------------+---------------+            

(Use the sbrk syscall to obtain memory for the nodes.)                                                                       

When adding a node to the list, the new node should be inserted into the proper place within the list so as to keep the list in ascending order based on the data values within the nodes. Multiple nodes are allowed to have the same data value. A new node with the same data value as one or more existing nodes should be inserted after the existing nodes.   The link field within each node contains the address of the node that logically follows. A null link field contains 0 and indicates the final node within the linked list structure.      

A separate head pointer is used to specify the first node within the list. A null head pointer denotes an empty list.    

Sample output from the program is shown below. (Sample shows floating point. You do not need to have values that are floating point. You may have integer values.)

Console Specify an action to take for th linked list: C to create the list to display the list A to add a single node D to de

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

............................................................................................................................................................

data .asciiz Please type in one of the number below and press enter: In 1 - options exit program In 2 next node In 3 - previli Syscall $v0, 5 # move response to the temporary register move St0, Sv0 $10 # Choose what to do based on user choice beq bestart #if list not empty + were at the end of list, just run the menu again # Go to previous node previous beqz Ss7, start b$zero, (Sti) # initialized previous to zero $zero, 16(St1 ) # initialized next to zero sw sw #read input string for node li lstart 3.# To delete node beqz lw delnode: $s7, start #if list is empty, go to menu $t2,-4($a3) $12, de!Head #load address of# To go back to previous node goBack la St5, -4(Sa3) lw Sa3, (St5) jr Sra 4. # Display the node in list printEle move Sa0, StconsolePrint: l Sv0, 4 Syscall jr Sra 6. # Display all nodes from starting to End node in the list # print-string: displays s

Add a comment
Know the answer?
Add Answer to:
Write a MIPS assembly language program that uses dynamic memory allocation to create and manage a...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a linked list of at least 15 different values that are prompted for and entered...

    Create a linked list of at least 15 different values that are prompted for and entered while the program is running. Appending a node attaches that node to the end of the list while inserting a node places it in order maintaining a sorted list. Create a menu driven program where you have the options to appended, insert, display, and delete a node. Display the list after first appending data showing it in no specific order, delete all nodes and...

  • Note: Do it Using CPP Language. Thanks. Implement a program that uses dynamic memory and uses...

    Note: Do it Using CPP Language. Thanks. Implement a program that uses dynamic memory and uses an insertion sort to add items to a singly-linked list. Modify the sorted listed by deleting elements as specified below. Create a sorted list (by state) of nodes containing all the state information (state name, capital, population). Display your list. Remove states whose population is less than four (4) million. Display the resulting list after the states have been removed from the list. Create...

  • python Programming assignment: Let's think about doubly-linked lists. Define a class ListNode2, with three attributes: item,...

    python Programming assignment: Let's think about doubly-linked lists. Define a class ListNode2, with three attributes: item, left, and rightL. Left link points to the previous node in the list, right link points to the next node in the list. You can also add the display method to this class (like we did it in class for the ListNode class). Then test your class. For example, create a linked list of 5 values: 34,1, 23, 7, and 10. Display it. Then...

  • C++. Please note the BOLDED ITEMS. You will create a simple linked structure. You will use...

    C++. Please note the BOLDED ITEMS. You will create a simple linked structure. You will use a simple node that has a pointer to a Node. The data for the Node will be a single data member of type char. You will build a structure where the last node you add will point to the first node created, i.e. it will be a circular linked structure. You will create a program that stores characters provided by the user, stored in...

  • Write a java program implementing the Linked list. It should be on an small office who...

    Write a java program implementing the Linked list. It should be on an small office who has 5 employees. The program ask the user for ID, First name, Last name and what field the work in(eg: accounting, programmer, HR etc). Each employee (with all the information of that paticular employee) should be placed in one node in the program. The program should repeat and ask the user for all 5 employees information. Also when you display the Linked list it...

  • In NetBeans Create a new Java Application to manage Linked Lists: (Note: Do not use java.util.LinkedList)...

    In NetBeans Create a new Java Application to manage Linked Lists: (Note: Do not use java.util.LinkedList) a) Create a DateTime class 1. Add day, month, year, hours, minutes as attributes 2. Add a constructor and a toString() method 3. Implement the Comparable interface, and add a CompareTo() method 4. Add methods to get and set all attributes. b) Add to MyLinkedList class the following methods: 1. Insert a Node to a particular position in the List 2. Insert a Node...

  • Write the following program in C++. Review structures, pointers and dynamic memory allocation from CSIT 839....

    Write the following program in C++. Review structures, pointers and dynamic memory allocation from CSIT 839. Also, review pointers and dynamic memory allocation posted here under Pages. For sorting, you can refer to the textbook for Co Sci 839 or google "C++ sort functions". I've also included under files, a sample C++ source file named sort_binsearch.cpp which gives an example of both sorting and binary search. The Bubble sort is the simplest. For binary search too, you can refer to...

  • You will need those four files: d_node.h, d_nodel.h, d_random.h, and prg9_1.cpp Program Definition 1. Create program...

    You will need those four files: d_node.h, d_nodel.h, d_random.h, and prg9_1.cpp Program Definition 1. Create program definition with the following templates and methods: // returns the sum of all elements in a single linked list template <typename T> int sum(node<T> *front); // outputs the nodes of a single linked list in reverse order. template <typename T> void outputReverse(node<T> *front); Main Method: add before the "cout << "\nOutput in Descending Order: ";" line call sum() to print sum of all elements...

  • Am Specification For this assignment, you will write a multi-file C program to define, implement ...

    Must be written and C, and compile with MinGW. Thank you! am Specification For this assignment, you will write a multi-file C program to define, implement and use a dynamic linked lists. Please refer to Lab 07 for the definition of a basic linked list. In this assignment you will need to use the basic ideas of a node and of a linked list of nodes to implement a suit of functions which can be used to create and maintain...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT