Question: Given the matrix multiplication code matrix.c below, please convert the loop body of the nested for - loop into the corresponding inline assembly version. Original
Given the matrix multiplication code matrix.c below, please convert the loop body of the nested forloop
into the corresponding inline assembly version.
Original C Code:
description: matrix multiply benchmarking
h h hx xy y hxhxhx hxhxhx
h h hx xy y hxhxhx hxhxhx
h h hx xy y hxhxhx hxhxhx
Element are to store in following order:
matrix hhhh hhh hhh
vector xxx xx xx
vector yyy yy yy
#include
int main
int fij;
int h x y;
fori ; i ; i scanfd &hi;
fori ; i ; i scanfd ξ
fori ; i ; i scanfd &yi;
int px &x;
int ph &h;
int py &y;
for i ; i ; i
px points to the beginning of the input vector
px &x;
NCKUComputerOrganizationAssignmentmd
do matrix multiply
for j ; j ; j
ph &hi ;
for f ; f ; f
py phpx;
px;
next element
px &x;
py;
return ;
Please modify the above c code to inline assembly version. You should copy the following code and write your
code in asm volatile Beware Your Code is in the for loop.
#include
int main
int f i j;
int h x y;
FILE input fopeninputtxtr;
fori ; i ; i fscanfinputd &hi;
fori ; i ; i fscanfinputd ξ
fori ; i ; i fscanfinputd &yi;
fcloseinput;
int px &x;
int ph &h;
int py &y;
for i ; i ; i
for j ; j ; j
for f ; f ; f
asm volatileYour Code;
py &y;
fori ; i ; i printfd py;
printf
;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
