Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Random Array Write an assembly function fill _ array that takes two arguments: a 6 4 - bit signed integer array pointer and the number
Random Array
Write an assembly function fillarray that takes two arguments: a bit signed integer array pointer and the number of elements. It should fill the array with random values generated using your randint
We don't want our array values to be too big, so we'll keep the array elements in the range but still as bit integers Hint:
call randint
and $xffrax
sub $rax
Dot Product
Write an assembly function dot that takes two bit signed integer array pointers and a length assumed to be the same for both arrays It should return the dot product of the two arrays, ie
arrarr arrarr arrnarrn
Array of Structs
Instead of working with pairs of arrays, maybe we should work with arrays of pairs. The provided labh defines this struct:
typedef struct
intt a;
intt b;
pairt;
In C we know that array elements are guaranteed to be adjacent in memory, but struct members are also guaranteed to be arranged in memory in the order they're declared. We generally expect them to be adjacent, so this struct should take bytes: the first bytes are a and the next are bIts actually a little more complicated than that because of padding and alignment, but we can ignore those for now.
Repeat the dot product calculation, but taking a single array of pairt and a length as arguments.
Speed
The included timing.c will do some timing of your implementations, as well as C implementations in labcc Have a look.
Questions
Answer these questions in a text file answers.txt
What commands did you use to compileassemble and run your code for this lab?
How did the running times compare for the various dot product implementations?
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