Answered step by step
Verified Expert Solution
Question
1 Approved Answer
READ THE ASSIGNMENT IN ITS ENTIRETY BEFORE STARTING Part 1 . Linked List and The Heap Linked lists are linear collections of elements used to
READ THE ASSIGNMENT IN ITS ENTIRETY BEFORE STARTING
Part Linked List and The Heap
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.
the assignment deals with implementing and manipulating a singly linked list in RISCV 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 sbrk syscall available in RARS.
Assignment Details
The assignment consists of implementing procedures functions defined in linkedlist.asm. Each procedure is documented in the comment above the relevant procedure label. You can assume any preconditions 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 LLPUSHFRONT. 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:
Use bit RISCV
Each node in the linked list should store a byte integer as well as a pointer to the next node.
Memory for nodes in the linked list should be allocated on the heap using the sbrk syscall in RARS.
An empty linked list consists of one sentinel node, which points to memory location x and has the value
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 LLPUSHFRONT is called successively. If allocations with sbrk are made in between calls to LLPUSHFRONT, 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.
You can assume memory addresses returned from sbrk are byte aligned.
You must save any calleesaved 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:
Linked List Example
After the following instructions note not assembly:
The heap should look like the following diagram:
Note that the Head of Linked List represents a register containing the address of the integer in the screenshot.
Note that the Head of Linked List represents a register containing the address of the integer in the screenshot.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started