Question
The file list.asm contains a linked list , where the data value in each node represents an ASCII character. First, write the following four LC-3
The file list.asm contains a linked list, where the data value in each node represents an ASCII character. First, write the following four LC-3 assembly language subroutines:
count the number of nodes in a list, given the head, and return the count
print all the characters in a list, given the head, on a single line, followed by a line break (produced by calling the following subroutine)
printnl prints a line break
split a list: given n, count n nodes in and break the list by setting the nth node's next pointer to NULL; return a pointer to the (n+1)th node (that is, the old next pointer).
Use a register-based calling convention for count, and stack-based calling conventions for print and split. The subroutine printnl has no parameters but must still save state on the stack.
Next, call these methods from a main program that will first print the characters from the original list, then will split the list into four(approximately-)equally sized pieces (using count to determine the size), and print each piece in order. The print subroutine must call printnl.
Your program must work with any list, not just the one in the given file. However, you may assume that there are at least four nodes in the list. Include the entire content of the given file in your code. Do not change the structure of the list, access it through the pointer head. You may write additional subroutines, if it helps.
list.asm
head .fill node1 node1 .fill node2 .fill x41 node2 .fill node3 .fill x6E node3 .fill node4 .fill x78 node4 .fill node5 .fill x69 node5 .fill node6 .fill x6F node6 .fill node7 .fill x75 node7 .fill node8 .fill x73 node8 .fill node9 .fill x20 node9 .fill node10 .fill x6F node10 .fill node11 .fill x63 node11 .fill node12 .fill x74 node12 .fill node13 .fill x6F node13 .fill node14 .fill x70 node14 .fill node15 .fill x75 node15 .fill node16 .fill x73 node16 .fill node17 .fill x20 node17 .fill node18 .fill x70 node18 .fill node19 .fill x72 node19 .fill node20 .fill x65 node20 .fill node21 .fill x66 node21 .fill node22 .fill x65 node22 .fill node23 .fill x72 node23 .fill node24 .fill x73 node24 .fill node25 .fill x20 node25 .fill node26 .fill x70 node26 .fill node27 .fill x72 node27 .fill node28 .fill x69 node28 .fill node29 .fill x76 node29 .fill node30 .fill x61 node30 .fill node31 .fill x63 node31 .fill node32 .fill x79 node32 .fill 0 .fill x2E
.end
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