Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

rsum.ys: Recursively sum linked list elements Write a Y86-64 program rsum.ys that recursively sums the elements of a linked list. This code should be similar

rsum.ys: Recursively sum linked list elements

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 list.ys. # Sample linked list

.align 8

ele1:

.quad 0x00a

.quad ele2

ele2:

.quad 0x0b0

.quad ele3

ele3:

.quad 0xc00

.quad 0

Click here for a pdf file describing this lab: http://ece324web.groups.et.byu.net/Labs/archlab/archlab.pdf

Click here for the tar file for this lab: http://ece324web.groups.et.byu.net/Labs/archlab/archlab-handout.tar

image text in transcribed

1 linked list element. 2 typedef struct ELE long val; struct ELE next 5 *list ptr 7 sum list Sum the elements of a linked list 8 long sum list (list ptr ls) 9 long val 0; while (ls) 11 val +S ls- val 12 ls ls next 13 14 return val; 15 16 17 18 rs um list Recursive version of sum list 19 long rsum list (list ptr ls) 20 if (!ls) 21 return 0; 22 else 23 long val ls- val 24 long rest. rsum list (ls- next) 25 return val rest; 26 28 29 30 copy block. Copy src to dest and return xor checksum of src 31 long copy block (long src, long *dest. long len) 32 long result 0; 33 while (len 0) 34 long val Src 35 *dest, val 36 result val 37 len 38 39 return result 40 41 Figure 1: C versions of the Y86-64 solution functions. See sim/misc/examples.c 1 linked list element. 2 typedef struct ELE long val; struct ELE next 5 *list ptr 7 sum list Sum the elements of a linked list 8 long sum list (list ptr ls) 9 long val 0; while (ls) 11 val +S ls- val 12 ls ls next 13 14 return val; 15 16 17 18 rs um list Recursive version of sum list 19 long rsum list (list ptr ls) 20 if (!ls) 21 return 0; 22 else 23 long val ls- val 24 long rest. rsum list (ls- next) 25 return val rest; 26 28 29 30 copy block. Copy src to dest and return xor checksum of src 31 long copy block (long src, long *dest. long len) 32 long result 0; 33 while (len 0) 34 long val Src 35 *dest, val 36 result val 37 len 38 39 return result 40 41 Figure 1: C versions of the Y86-64 solution functions. See sim/misc/examples.c

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions