Question
Write a Y86-64 program sum.ys that iteratively sums the elements of a linked list. Your program should consist of some code that sets up the
Write a Y86-64 program sum.ys that iteratively sums the elements of a linked list. Your program should consist of some code that sets up the stack structure, invokes a function, and then halts. In this case, the function should be Y86-64 code for a function (sum list) that is functionally equivalent to the C sum list function in Figure 1. Test your program using the following three-element list: # Sample linked list .align 8 ele1: .quad 0x00d .quad ele2 ele2: .quad 0x0e0 .quad ele3 ele3:
int sum_list(list_ptr ls) { int val = 0; while (ls) { val += ls->val; ls = ls->next; }
return val;
}
Write a Y86-64 program rsum.ys that recursively sums the elements of a linked list. This code should be similar to the code in sum.ys, except that it should use a function rsum list that recursively sums a list of numbers, as shown with the C function rsum list in Figure 1. Test your program using the same three-element list you used for testing sum.ys.
int rsum_list(list_ptr ls)
{
if (!ls)
return 0;
else {
int val = ls->val;
int rest = rsum_list(ls->next);
return val + rest;
}
}
int copy_block(int *src, int *dest, int len)
{
int result = 0;
while (len > 0) {
int val = *src++;
*dest++ = val;
result = val;
len--;
}
return result;
}
Write a program (copy.ys) that copies a block of words from one part of memory to another (nonoverlapping area) area of memory, computing the checksum (Xor) of all the words copied. Your program should consist of code that sets up a stack frame, invokes a function copy block, and then halts. The function should be functionally equivalent to the C function copy block shown in Figure Figure 1. Test your program using the following three-element source and destination blocks:
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