Question: Linked lists are linear collections of elements used to store data. Unlike arrays, the order of a linked list is independent of the position of


Linked lists are linear collections of elements used to store data. Unlike arrays, the order of a linked list is independent of the position of elements in memory. Instead, each element stores a pointer to the next element in the linked list. Assuming familiarity with linked lists as the assignment deals with implementing and manipulating a singly linked list in RISC-V assembly. The linked list will contain a sentinel node, used to indicate the end of the list. The elements in the list should be allocated on the heap, with memory allocated using the syscall available in RARS. Assignment Details The assignment consists of implementing 6 procedures (functions) defined in . Each procedure is documented in the comment above the relevant procedure label. You can assume any pre-conditions are fulfilled when the procedure is called. If applicable, your solution must adhere to the postconditions specified in the documentation. The first procedure you should implement is The tests for every other procedure requires instantiating the linked list, which involves pushing an element to the front of the list. The other procedures can be implemented in any order. You will receive partial credit for each procedure implemented correctly. Specification Your solution must follow the following specification: 1. Use 32-bit RISC-V. 2. Each node in the linked list should store a 4-byte integer as well as a pointer to the next node. 3. Memory for nodes in the linked list should be allocated on the heap using the syscall in RARS. 4. An empty linked list consists of one sentinel node, which points to memory location and has the value 5. The linked list should not allocate more memory than necessary. If implemented correctly, all nodes should be in a contiguous section of memory on the heap if is called successively. If allocations (with 'sbrk") are made in between calls to LL_PUSH_FRONT, then the nodes will not be in a contiguous section of memory. Your code must be able to handle nodes that aren't stored contiguously in memory. 6. You can assume memory addresses returned from are 4-byte aligned. 7. You must save any callee-saved registers before use in the procedures. Failure to do so may result in an incorrect test output. Linked List Example After the following instructions (note, not assembly): push_front(1); push_front(2); push_front(3); The heap should look like the following diagram: Note that the Head of Linked List represents a register containing the address of the integer 3 in the screenshot
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
