SlideShare a Scribd company logo
1 of 20
matmult/Homework3.pdf
Names of Files to Submit: matmult.s, knapsack.s, combs.s
ReadMe.txt
• If you are working in a group ALL members must submit the
assignment
• All programs should compile with no warnings when compiled
with the -Wall option
• All prompts for input and all output must match my
prompts/output. We use a program to grade
your work and tiny differences can cause your work to be
marked as a 0.
◦ The best way to avoid being deducted points is to copy the
prompt/unchanging portion of
the outputs into your code. Make sure to get the spaces as well.
• You must also submit a file called ReadMe.txt. Include the
names of all partners and any
trouble you had on the assignment
• An example ReadMe.txt has been included with this
assignment
• The input in the examples has been underlined to help you
figure out what is input and what is
output
• Submit your work on Smartsite by uploading each file
separately. Do not upload any folders or
compressed files such as .rar, .tar, .targz, .zip etc.
• If you have any questions please post them to Piazza
• RESTRICTIONS:
◦ For all programs in this homework you
▪ May not have a data section. If you need extra space you must
use the stack.
▪ Not call any C functions that you write. You may make use of
any of the library
functions.
1. (Time: 3.5 hours. Lines of Code 257) Write a program called
matmult.s that implements matrix
multiplication in assembly. If you don't know how to do matrix
multiplication your can find a
tutorial here.
1. This program should be callable from C and have the
following signature:
1. int** matMult(int **a, int num_rows_a, int num_cols_a,
int** b, int num_rows_b, int num_cols_b);
2. This function should multiply matrices a and b together and
return the result
3. You must allocate space for this new matrix by calling
malloc
2. You have been given a C file called main.c that accepts as
command line arguments the
names of two files that contain the matrices to be multiplied.
main.c will read in these
matrices, call your function, and then display the result. After it
has displayed the result it
will then free the space that has been malloced.
1. Your function must be callable by this file
3. You have also been given a makefile that should compile
your program. Your program
MUST be able to be compiled by this makefile. For those of you
running 64 bit versions of
Linux you may need to install the 32 bit binaries. I was able to
do this on my machine by
installing multilib for gcc. To do this I clicked on the Ubuntu
Software App and then
searched for multilib. I selected the one for gcc, installed it, and
everything was good to go.
If that doesn't work for you, you might find this this post
helpful. If neither solution works
for you please Google and see what you can find. If you find a
solution that works for you
please post it to Piazza.
Example:
cat mata/0-test.txt
3
3
470 -192 -539
235 -814 -538
-503 -418 541
cat matb/0-test.txt
3
3
313 531 802
26 860 -767
543 870 822
./matmult.out mata/0-test.txt matb/0-test.txt
-150559 -384480 81146
-239743 -1043315 370572
125456 -155903 361902
http://www.purplemath.com/modules/mtrxmult.htm
http://askubuntu.com/questions/454253/how-to-run-32-bit-app-
in-ubuntu-64-bit
2. (Time 1.5 hours) Write a program called knapsack.s that
solves the 0-1 knapsack problem
recursively. In the knapsack problem you have a knapsack that
can hold W weight. You also
have a collection of items that each have their own weight w i
and value vi . The goal is
find the set of items that maximizes the amount of value in the
knapsack but whose weight does
not exceed W.
1. This program should be callable from C and have the
following signature
1. unsigned int knapsack(int* weights, unsigned int* values,
unsigned int num_items, int capacity, unsigned int
cur_value)
2. This function should calculate and return the maximum value
knapsack
3. This function must be implemented recursively
4. Pay very careful attention to the types in this function as it
will affect which machine
instructions you should use. Hint: it will affect the jump
instructions you use
5. You have been provided with a C file called knapsack.c that
implements this function
and should give you a good starting point
1. If you want an extra challenge try solving the problem
without looking at knapsack.c
as this problem boils down to just finding the optimal
combination of items
6. You will find the leal instruction very helpful for this
problem
2. You have also been given a file called main.c that will take
as a command line argument the
name of a file containing a knapsack problem.
1. Please see the comments in main.c to see how these files are
structured
2. Your function must be callable from this file
3. You have also been given a makefile that will compile the
assignment for you as well as
create a version of the executable using only the given C files.
1. Your program must be able to be complied by this makefile
4. Example:
1. cat Tests/0-test.txt
100
4
43 43
3 38
5 17
18 25
./knapsack.out Tests/0-test.txt
123
3. (Time 1.5 Hours) Write a program called combs.s that
generates all the possible combinations
of a set of items of a given size.
1. Your program should be callable from C and have the
following signature
1. int** get_combs(int* items, int k, int len)
2. This function should generate all possible combinations of
items taken k at a time and return
a 2-D array where each row contains one combination
1. The combinations should be added to the 2-D array in their
natural order
2. This 2-D array should be dynamically allocated
3. As a hint you will probably need to develop a helper function
that actually computes the
combinations
3. You have been given a file called main.c that will get the
inputs and call your function
1. Your function must be callable from this file
2. You will also find some helpful functions in main.c that you
can call from your program
4. You have also been given a makefile to compile your
program.
1. Your program must be compilable by this makefile.
4. Examples
1. How many items do you have: 5
Enter your items: 1 2 3 4 5
Enter k: 3
1 2 3
1 2 4
1 2 5
1 3 4
1 3 5
1 4 5
2 3 4
2 3 5
2 4 5
3 4 5
2. How many items do you have: 5
Enter your items: 1 2 3 4 5
Enter k: 4
1 2 3 4
1 2 3 5
1 2 4 5
1 3 4 5
2 3 4 5
matmult/main.c
#include <stdio.h>
#include <stdlib.h>
int** matMult(int **a, int num_rows_a, int num_cols_a, int**
b, int num_rows_b, int num_cols_b);
void displayMat(int** mat, int num_rows, int num_cols);
void readMat(const char* file_name, int*** mat, int*
num_rows, int* num_cols);
void displayMat(int** mat, int num_rows, int num_cols){
//display the contents of the 2D matrix to the scren
//@mat: the matrix to be displayed
//@num_rows: the number of rows in the matrix
//@num_cols: the number of columns in the matrix
int i,j;
for(i = 0; i < num_rows; i++){//for each row
for(j = 0; j < num_cols; j++){ //for each column
printf("%d ", mat[i][j]); //display the value
}
printf("n");
}
}//displayMat
void readMat(const char* file_name, int*** mat, int*
num_rows, int* num_cols){
//read in a file that contains a matrix
//format of file is
//number of rows
//number of columns
//values separated by white space
//@file_name: the name of the file containing the matrix
//@mat: the matrix to be intialized from the file. space will be
allocated for it inside the function
//@num_rows: the number of rows in the matrix. intialized by
this function
//@num_cols: the number of columns in the matrix. intialized
by this function
int i,j;
FILE *fptr;
fptr = fopen(file_name, "r"); //open the file
//read in the dimensions
fscanf(fptr, "%d", num_rows);
fscanf(fptr, "%d", num_cols);
//make space for mat
*mat = (int**)malloc(*num_rows * sizeof(int*));
for(i = 0; i < *num_rows; i++){
(*mat)[i] = (int*)malloc(*num_cols * sizeof(int));
}
//initialize mat
for(i = 0; i < *num_rows; i++){
for(j = 0; j < *num_cols; j++){
fscanf(fptr, "%d", &((*mat)[i][j]));
}//for each row
}//for each column
fclose(fptr);// close the file
}//readMat
int main(int argc, char **argv){
int** mat_a;
int** mat_b;
int** mat_c;
int rows_mat_a, cols_mat_a, rows_mat_b, cols_mat_b;
int i;
if(argc < 3){
printf("matmult.out matrix_A_File matrix_B_Filen");
printf("Not enough arguments given.n");
return(1);
}
//read in matrices
readMat(argv[1], &mat_a, &rows_mat_a, &cols_mat_a);
readMat(argv[2], &mat_b, &rows_mat_b, &cols_mat_b);
//do the multiplication
mat_c = matMult(mat_a, rows_mat_a, cols_mat_a, mat_b,
rows_mat_b, cols_mat_b);
//display solution
displayMat(mat_c, rows_mat_a, cols_mat_b);
//free up malloced space
for(i = 0; i < rows_mat_a; i++){
free(mat_a[i]);
}
for(i = 0; i < rows_mat_b; i++){
free(mat_b[i]);
}
for(i = 0; i < rows_mat_a; i++){
free(mat_c[i]);
}
free(mat_a);
free(mat_b);
free(mat_c);
return 0;
}//main
matmult/main.o
matmult/makefile
matmult.out: main.o matmult.o
gcc -g -m32 -Wall -o matmult.out main.o matmult.o
matmult.o: matmult.s
gcc -g -m32 -Wall -c -o matmult.o matmult.s
#-Wa,-alms
main.o: main.c
gcc -g -m32 -Wall -c -o main.o main.c
clean:
rm -f main.o matmult.o matmult.out
matmult/matmult.o
matmult/matmult.out
matmult/matmult.s
.text
.globlmatMult
matMult:
pushl%ebp
pushl%edi
pushl%esi
pushl%ebx
subl$60, %esp
movl84(%esp), %eax
movl92(%esp), %ebp
sall$2, %eax
movl%eax, (%esp)
callmalloc
movl88(%esp), %ebx
testl%ebx, %ebx
movl%eax, 44(%esp)
jleL2
xorl%ebx, %ebx
movl88(%esp), %esi
movl%eax, %edi
movl%ebp, 32(%esp)
movl%ebx, %ebp
movl88(%esp), %ebx
sall$2, %esi
L3:
movl%esi, (%esp)
callmalloc
movl%eax, (%edi,%ebp,4)
addl$1, %ebp
cmpl%ebx, %ebp
jneL3
movl32(%esp), %ebp
L2:
movl84(%esp), %ecx
testl%ecx, %ecx
jleL4
movl100(%esp), %ebx
xorl%ecx, %ecx
movl%ebp, 32(%esp)
movl44(%esp), %esi
movl84(%esp), %ebp
movl100(%esp), %edi
sall$2, %ebx
L5:
testl%edi, %edi
jleL8
movl(%esi,%ecx,4), %eax
leal(%ebx,%eax), %edx
L6:
movl$0, (%eax)
addl$4, %eax
cmpl%edx, %eax
jneL6
L8:
addl$1, %ecx
cmpl%ebp, %ecx
jneL5
movl32(%esp), %ebp
movl$0, 40(%esp)
movl%ebp, %ebx
L7:
movl100(%esp), %eax
movl$0, 36(%esp)
testl%eax, %eax
jleL10
L18:
movl88(%esp), %edx
testl%edx, %edx
jleL11
movl40(%esp), %eax
movl44(%esp), %edx
movl36(%esp), %esi
movl(%edx,%eax,4), %edi
sall$2, %esi
movl80(%esp), %edx
movl%esi, 32(%esp)
addl%esi, %edi
movl(%edi), %ecx
movl(%edx,%eax,4), %ebp
xorl%eax, %eax
movl%edi, 28(%esp)
L9:
movl(%ebx,%eax,4), %edi
movl32(%esp), %esi
movl0(%ebp,%eax,4), %edx
addl$1, %eax
imull(%edi,%esi), %edx
addl%edx, %ecx
movl28(%esp), %edx
cmpl88(%esp), %eax
movl%ecx, (%edx)
jneL9
L11:
addl$1, 36(%esp)
movl100(%esp), %esi
cmpl%esi, 36(%esp)
jneL18
L10:
addl$1, 40(%esp)
movl84(%esp), %esi
cmpl%esi, 40(%esp)
jneL7
L4:
movl44(%esp), %eax
addl$60, %esp
popl%ebx
popl%esi
popl%edi
popl%ebp
ret
done:
matmult/result.py
class Result(object):
"""
a wrapper to contain the results of a test
@testName: the name of the test run
@correct: True if the output of matched the solution; False
otherwise
@timeTaken is either
the number of seconds it took the program to run
'Timed Out' if the program took too long to complete
'Crashed' if the program encountered some fatal error
"""
def __init__(self, testName, correct, timeTaken):
"""
@testName: the name of the test run
@correct: True if the output of matched the solution; False
otherwise
@timeTaken is either
the number of seconds it took the program to run
'Timed Out' if the program took too long to complete
'Crashed' if the program encountered some fatal error
"""
self.testName = testName
self.correct = correct
self.timeTaken = timeTaken
#end init
def __repr__(self):
if type(self.timeTaken) == str:
format_str = 'Test: {!s} | Correct: {!s} | Time Taken: {!s}'
else:
format_str = 'Test: {!s} | Correct: {!s} | Time Taken: {:.3f}'
s = format_str.format(self.testName, self.correct,
self.timeTaken)
return s
def __str__(self):
return self.__repr__()
matmult/result.pyc
matmult/
Solution
s/0-sol.txt
-150559 -384480 81146
-239743 -1043315 370572
125456 -155903 361902
matmult/

More Related Content

Similar to matmultHomework3.pdfNames of Files to Submit matmult..docx

Learning puppet chapter 3
Learning puppet chapter 3Learning puppet chapter 3
Learning puppet chapter 3Vishal Biyani
 
Buffer overflow tutorial
Buffer overflow tutorialBuffer overflow tutorial
Buffer overflow tutorialhughpearse
 
fileop report
fileop reportfileop report
fileop reportJason Lu
 
Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make YASHU40
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docxwilcockiris
 
(3) cpp abstractions more_on_user_defined_types_exercises
(3) cpp abstractions more_on_user_defined_types_exercises(3) cpp abstractions more_on_user_defined_types_exercises
(3) cpp abstractions more_on_user_defined_types_exercisesNico Ludwig
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabTarun Gehlot
 
Objectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docxObjectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docxdunhamadell
 
[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to TestZsolt Fabok
 
Assignment2 A
Assignment2 AAssignment2 A
Assignment2 AMahmoud
 
GSP 125 Entire Course NEW
GSP 125 Entire Course NEWGSP 125 Entire Course NEW
GSP 125 Entire Course NEWshyamuopten
 
Process Synchronization Producer-Consumer ProblemThe purpose o.docx
Process Synchronization Producer-Consumer ProblemThe purpose o.docxProcess Synchronization Producer-Consumer ProblemThe purpose o.docx
Process Synchronization Producer-Consumer ProblemThe purpose o.docxstilliegeorgiana
 
Implementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphoresImplementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphoresGowtham Reddy
 
Lewis jssap3 e_labman02
Lewis jssap3 e_labman02Lewis jssap3 e_labman02
Lewis jssap3 e_labman02auswhit
 

Similar to matmultHomework3.pdfNames of Files to Submit matmult..docx (20)

ch 2. Python module
ch 2. Python module ch 2. Python module
ch 2. Python module
 
Learning puppet chapter 3
Learning puppet chapter 3Learning puppet chapter 3
Learning puppet chapter 3
 
88 c-programs
88 c-programs88 c-programs
88 c-programs
 
Buffer overflow tutorial
Buffer overflow tutorialBuffer overflow tutorial
Buffer overflow tutorial
 
fileop report
fileop reportfileop report
fileop report
 
Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make
 
Makefiles Bioinfo
Makefiles BioinfoMakefiles Bioinfo
Makefiles Bioinfo
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
 
(3) cpp abstractions more_on_user_defined_types_exercises
(3) cpp abstractions more_on_user_defined_types_exercises(3) cpp abstractions more_on_user_defined_types_exercises
(3) cpp abstractions more_on_user_defined_types_exercises
 
Python Intro-Functions
Python Intro-FunctionsPython Intro-Functions
Python Intro-Functions
 
Lab5
Lab5Lab5
Lab5
 
Unit iii
Unit iiiUnit iii
Unit iii
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Objectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docxObjectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docx
 
[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test
 
Assignment2 A
Assignment2 AAssignment2 A
Assignment2 A
 
GSP 125 Entire Course NEW
GSP 125 Entire Course NEWGSP 125 Entire Course NEW
GSP 125 Entire Course NEW
 
Process Synchronization Producer-Consumer ProblemThe purpose o.docx
Process Synchronization Producer-Consumer ProblemThe purpose o.docxProcess Synchronization Producer-Consumer ProblemThe purpose o.docx
Process Synchronization Producer-Consumer ProblemThe purpose o.docx
 
Implementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphoresImplementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphores
 
Lewis jssap3 e_labman02
Lewis jssap3 e_labman02Lewis jssap3 e_labman02
Lewis jssap3 e_labman02
 

More from andreecapon

MGMT 511Location ProblemGeorge Heller was so successful in.docx
MGMT 511Location ProblemGeorge Heller was so successful in.docxMGMT 511Location ProblemGeorge Heller was so successful in.docx
MGMT 511Location ProblemGeorge Heller was so successful in.docxandreecapon
 
MGMT 464From Snowboarders to Lawnmowers Case Study Case An.docx
MGMT 464From Snowboarders to Lawnmowers Case Study Case An.docxMGMT 464From Snowboarders to Lawnmowers Case Study Case An.docx
MGMT 464From Snowboarders to Lawnmowers Case Study Case An.docxandreecapon
 
MG345_Lead from Middle.pptLeading from the Middle Exe.docx
MG345_Lead from Middle.pptLeading from the Middle Exe.docxMG345_Lead from Middle.pptLeading from the Middle Exe.docx
MG345_Lead from Middle.pptLeading from the Middle Exe.docxandreecapon
 
MGMT 345Phase 2 IPBusiness MemoToWarehouse ManagerFrom[You.docx
MGMT 345Phase 2 IPBusiness MemoToWarehouse ManagerFrom[You.docxMGMT 345Phase 2 IPBusiness MemoToWarehouse ManagerFrom[You.docx
MGMT 345Phase 2 IPBusiness MemoToWarehouse ManagerFrom[You.docxandreecapon
 
MGMT 3720 – Organizational BehaviorEXAM 3(CH. 9, 10, 11, & 12).docx
MGMT 3720 – Organizational BehaviorEXAM 3(CH. 9, 10, 11, & 12).docxMGMT 3720 – Organizational BehaviorEXAM 3(CH. 9, 10, 11, & 12).docx
MGMT 3720 – Organizational BehaviorEXAM 3(CH. 9, 10, 11, & 12).docxandreecapon
 
Mexico, Page 1 Running Head MEXICO’S CULTURAL, ECONOMI.docx
Mexico, Page 1  Running Head MEXICO’S CULTURAL, ECONOMI.docxMexico, Page 1  Running Head MEXICO’S CULTURAL, ECONOMI.docx
Mexico, Page 1 Running Head MEXICO’S CULTURAL, ECONOMI.docxandreecapon
 
MGM316-1401B-01Quesadra D. GoodrumClass Discussion Phase2.docx
MGM316-1401B-01Quesadra D. GoodrumClass Discussion Phase2.docxMGM316-1401B-01Quesadra D. GoodrumClass Discussion Phase2.docx
MGM316-1401B-01Quesadra D. GoodrumClass Discussion Phase2.docxandreecapon
 
METROPOLITAN PLANNING ANDENVIRONMENTAL ISSUESn May 2008, the N.docx
METROPOLITAN PLANNING ANDENVIRONMENTAL ISSUESn May 2008, the N.docxMETROPOLITAN PLANNING ANDENVIRONMENTAL ISSUESn May 2008, the N.docx
METROPOLITAN PLANNING ANDENVIRONMENTAL ISSUESn May 2008, the N.docxandreecapon
 
Methods of Moral Decision Making REL 330 Christian Moralit.docx
Methods of Moral Decision Making       REL 330 Christian Moralit.docxMethods of Moral Decision Making       REL 330 Christian Moralit.docx
Methods of Moral Decision Making REL 330 Christian Moralit.docxandreecapon
 
MEPS_Inpatient Stay database.csduidpiddupersidevntidxeventrnerhevi.docx
MEPS_Inpatient Stay database.csduidpiddupersidevntidxeventrnerhevi.docxMEPS_Inpatient Stay database.csduidpiddupersidevntidxeventrnerhevi.docx
MEPS_Inpatient Stay database.csduidpiddupersidevntidxeventrnerhevi.docxandreecapon
 
METHODS TO STOP DIFFERENT CYBER CRIMES .docx
METHODS TO STOP DIFFERENT CYBER CRIMES                            .docxMETHODS TO STOP DIFFERENT CYBER CRIMES                            .docx
METHODS TO STOP DIFFERENT CYBER CRIMES .docxandreecapon
 
Mexico The Third War Security Weekly Wednesday, February 18.docx
Mexico The Third War Security Weekly Wednesday, February 18.docxMexico The Third War Security Weekly Wednesday, February 18.docx
Mexico The Third War Security Weekly Wednesday, February 18.docxandreecapon
 
Mercy College .docx
Mercy College                                                   .docxMercy College                                                   .docx
Mercy College .docxandreecapon
 
Merger AnalysisMerger Analysis Case Study© 2007 South UniversityFr.docx
Merger AnalysisMerger Analysis Case Study© 2007 South UniversityFr.docxMerger AnalysisMerger Analysis Case Study© 2007 South UniversityFr.docx
Merger AnalysisMerger Analysis Case Study© 2007 South UniversityFr.docxandreecapon
 
MGMT 301 EOY Group” Case Study and Power Point Presentation G.docx
MGMT 301 EOY Group” Case Study and Power Point Presentation G.docxMGMT 301 EOY Group” Case Study and Power Point Presentation G.docx
MGMT 301 EOY Group” Case Study and Power Point Presentation G.docxandreecapon
 
MGMT 464New Manager’s Case Study Case Analysis Worksheet #.docx
MGMT 464New Manager’s Case Study Case Analysis Worksheet #.docxMGMT 464New Manager’s Case Study Case Analysis Worksheet #.docx
MGMT 464New Manager’s Case Study Case Analysis Worksheet #.docxandreecapon
 
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docx
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docxMETA-INFMANIFEST.MFManifest-Version 1.0.classpath.docx
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docxandreecapon
 
Menu Management Options· · APRN504 - 5886 - HEALTH POLICY .docx
Menu Management Options· · APRN504 - 5886 - HEALTH POLICY .docxMenu Management Options· · APRN504 - 5886 - HEALTH POLICY .docx
Menu Management Options· · APRN504 - 5886 - HEALTH POLICY .docxandreecapon
 
MGMT 673 Problem Set 51. For each of the following economic cond.docx
MGMT 673 Problem Set 51. For each of the following economic cond.docxMGMT 673 Problem Set 51. For each of the following economic cond.docx
MGMT 673 Problem Set 51. For each of the following economic cond.docxandreecapon
 
Mental Illness Stigma and the Fundamental Components ofSuppo.docx
Mental Illness Stigma and the Fundamental Components ofSuppo.docxMental Illness Stigma and the Fundamental Components ofSuppo.docx
Mental Illness Stigma and the Fundamental Components ofSuppo.docxandreecapon
 

More from andreecapon (20)

MGMT 511Location ProblemGeorge Heller was so successful in.docx
MGMT 511Location ProblemGeorge Heller was so successful in.docxMGMT 511Location ProblemGeorge Heller was so successful in.docx
MGMT 511Location ProblemGeorge Heller was so successful in.docx
 
MGMT 464From Snowboarders to Lawnmowers Case Study Case An.docx
MGMT 464From Snowboarders to Lawnmowers Case Study Case An.docxMGMT 464From Snowboarders to Lawnmowers Case Study Case An.docx
MGMT 464From Snowboarders to Lawnmowers Case Study Case An.docx
 
MG345_Lead from Middle.pptLeading from the Middle Exe.docx
MG345_Lead from Middle.pptLeading from the Middle Exe.docxMG345_Lead from Middle.pptLeading from the Middle Exe.docx
MG345_Lead from Middle.pptLeading from the Middle Exe.docx
 
MGMT 345Phase 2 IPBusiness MemoToWarehouse ManagerFrom[You.docx
MGMT 345Phase 2 IPBusiness MemoToWarehouse ManagerFrom[You.docxMGMT 345Phase 2 IPBusiness MemoToWarehouse ManagerFrom[You.docx
MGMT 345Phase 2 IPBusiness MemoToWarehouse ManagerFrom[You.docx
 
MGMT 3720 – Organizational BehaviorEXAM 3(CH. 9, 10, 11, & 12).docx
MGMT 3720 – Organizational BehaviorEXAM 3(CH. 9, 10, 11, & 12).docxMGMT 3720 – Organizational BehaviorEXAM 3(CH. 9, 10, 11, & 12).docx
MGMT 3720 – Organizational BehaviorEXAM 3(CH. 9, 10, 11, & 12).docx
 
Mexico, Page 1 Running Head MEXICO’S CULTURAL, ECONOMI.docx
Mexico, Page 1  Running Head MEXICO’S CULTURAL, ECONOMI.docxMexico, Page 1  Running Head MEXICO’S CULTURAL, ECONOMI.docx
Mexico, Page 1 Running Head MEXICO’S CULTURAL, ECONOMI.docx
 
MGM316-1401B-01Quesadra D. GoodrumClass Discussion Phase2.docx
MGM316-1401B-01Quesadra D. GoodrumClass Discussion Phase2.docxMGM316-1401B-01Quesadra D. GoodrumClass Discussion Phase2.docx
MGM316-1401B-01Quesadra D. GoodrumClass Discussion Phase2.docx
 
METROPOLITAN PLANNING ANDENVIRONMENTAL ISSUESn May 2008, the N.docx
METROPOLITAN PLANNING ANDENVIRONMENTAL ISSUESn May 2008, the N.docxMETROPOLITAN PLANNING ANDENVIRONMENTAL ISSUESn May 2008, the N.docx
METROPOLITAN PLANNING ANDENVIRONMENTAL ISSUESn May 2008, the N.docx
 
Methods of Moral Decision Making REL 330 Christian Moralit.docx
Methods of Moral Decision Making       REL 330 Christian Moralit.docxMethods of Moral Decision Making       REL 330 Christian Moralit.docx
Methods of Moral Decision Making REL 330 Christian Moralit.docx
 
MEPS_Inpatient Stay database.csduidpiddupersidevntidxeventrnerhevi.docx
MEPS_Inpatient Stay database.csduidpiddupersidevntidxeventrnerhevi.docxMEPS_Inpatient Stay database.csduidpiddupersidevntidxeventrnerhevi.docx
MEPS_Inpatient Stay database.csduidpiddupersidevntidxeventrnerhevi.docx
 
METHODS TO STOP DIFFERENT CYBER CRIMES .docx
METHODS TO STOP DIFFERENT CYBER CRIMES                            .docxMETHODS TO STOP DIFFERENT CYBER CRIMES                            .docx
METHODS TO STOP DIFFERENT CYBER CRIMES .docx
 
Mexico The Third War Security Weekly Wednesday, February 18.docx
Mexico The Third War Security Weekly Wednesday, February 18.docxMexico The Third War Security Weekly Wednesday, February 18.docx
Mexico The Third War Security Weekly Wednesday, February 18.docx
 
Mercy College .docx
Mercy College                                                   .docxMercy College                                                   .docx
Mercy College .docx
 
Merger AnalysisMerger Analysis Case Study© 2007 South UniversityFr.docx
Merger AnalysisMerger Analysis Case Study© 2007 South UniversityFr.docxMerger AnalysisMerger Analysis Case Study© 2007 South UniversityFr.docx
Merger AnalysisMerger Analysis Case Study© 2007 South UniversityFr.docx
 
MGMT 301 EOY Group” Case Study and Power Point Presentation G.docx
MGMT 301 EOY Group” Case Study and Power Point Presentation G.docxMGMT 301 EOY Group” Case Study and Power Point Presentation G.docx
MGMT 301 EOY Group” Case Study and Power Point Presentation G.docx
 
MGMT 464New Manager’s Case Study Case Analysis Worksheet #.docx
MGMT 464New Manager’s Case Study Case Analysis Worksheet #.docxMGMT 464New Manager’s Case Study Case Analysis Worksheet #.docx
MGMT 464New Manager’s Case Study Case Analysis Worksheet #.docx
 
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docx
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docxMETA-INFMANIFEST.MFManifest-Version 1.0.classpath.docx
META-INFMANIFEST.MFManifest-Version 1.0.classpath.docx
 
Menu Management Options· · APRN504 - 5886 - HEALTH POLICY .docx
Menu Management Options· · APRN504 - 5886 - HEALTH POLICY .docxMenu Management Options· · APRN504 - 5886 - HEALTH POLICY .docx
Menu Management Options· · APRN504 - 5886 - HEALTH POLICY .docx
 
MGMT 673 Problem Set 51. For each of the following economic cond.docx
MGMT 673 Problem Set 51. For each of the following economic cond.docxMGMT 673 Problem Set 51. For each of the following economic cond.docx
MGMT 673 Problem Set 51. For each of the following economic cond.docx
 
Mental Illness Stigma and the Fundamental Components ofSuppo.docx
Mental Illness Stigma and the Fundamental Components ofSuppo.docxMental Illness Stigma and the Fundamental Components ofSuppo.docx
Mental Illness Stigma and the Fundamental Components ofSuppo.docx
 

Recently uploaded

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 

Recently uploaded (20)

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 

matmultHomework3.pdfNames of Files to Submit matmult..docx

  • 1. matmult/Homework3.pdf Names of Files to Submit: matmult.s, knapsack.s, combs.s ReadMe.txt • If you are working in a group ALL members must submit the assignment • All programs should compile with no warnings when compiled with the -Wall option • All prompts for input and all output must match my prompts/output. We use a program to grade your work and tiny differences can cause your work to be marked as a 0. ◦ The best way to avoid being deducted points is to copy the prompt/unchanging portion of the outputs into your code. Make sure to get the spaces as well. • You must also submit a file called ReadMe.txt. Include the names of all partners and any trouble you had on the assignment • An example ReadMe.txt has been included with this assignment • The input in the examples has been underlined to help you figure out what is input and what is output • Submit your work on Smartsite by uploading each file separately. Do not upload any folders or compressed files such as .rar, .tar, .targz, .zip etc.
  • 2. • If you have any questions please post them to Piazza • RESTRICTIONS: ◦ For all programs in this homework you ▪ May not have a data section. If you need extra space you must use the stack. ▪ Not call any C functions that you write. You may make use of any of the library functions. 1. (Time: 3.5 hours. Lines of Code 257) Write a program called matmult.s that implements matrix multiplication in assembly. If you don't know how to do matrix multiplication your can find a tutorial here. 1. This program should be callable from C and have the following signature: 1. int** matMult(int **a, int num_rows_a, int num_cols_a, int** b, int num_rows_b, int num_cols_b); 2. This function should multiply matrices a and b together and return the result 3. You must allocate space for this new matrix by calling malloc 2. You have been given a C file called main.c that accepts as command line arguments the names of two files that contain the matrices to be multiplied. main.c will read in these matrices, call your function, and then display the result. After it has displayed the result it will then free the space that has been malloced.
  • 3. 1. Your function must be callable by this file 3. You have also been given a makefile that should compile your program. Your program MUST be able to be compiled by this makefile. For those of you running 64 bit versions of Linux you may need to install the 32 bit binaries. I was able to do this on my machine by installing multilib for gcc. To do this I clicked on the Ubuntu Software App and then searched for multilib. I selected the one for gcc, installed it, and everything was good to go. If that doesn't work for you, you might find this this post helpful. If neither solution works for you please Google and see what you can find. If you find a solution that works for you please post it to Piazza. Example: cat mata/0-test.txt 3 3 470 -192 -539 235 -814 -538 -503 -418 541 cat matb/0-test.txt 3 3 313 531 802 26 860 -767 543 870 822 ./matmult.out mata/0-test.txt matb/0-test.txt -150559 -384480 81146
  • 4. -239743 -1043315 370572 125456 -155903 361902 http://www.purplemath.com/modules/mtrxmult.htm http://askubuntu.com/questions/454253/how-to-run-32-bit-app- in-ubuntu-64-bit 2. (Time 1.5 hours) Write a program called knapsack.s that solves the 0-1 knapsack problem recursively. In the knapsack problem you have a knapsack that can hold W weight. You also have a collection of items that each have their own weight w i and value vi . The goal is find the set of items that maximizes the amount of value in the knapsack but whose weight does not exceed W. 1. This program should be callable from C and have the following signature 1. unsigned int knapsack(int* weights, unsigned int* values, unsigned int num_items, int capacity, unsigned int cur_value) 2. This function should calculate and return the maximum value knapsack 3. This function must be implemented recursively 4. Pay very careful attention to the types in this function as it will affect which machine instructions you should use. Hint: it will affect the jump instructions you use 5. You have been provided with a C file called knapsack.c that implements this function and should give you a good starting point
  • 5. 1. If you want an extra challenge try solving the problem without looking at knapsack.c as this problem boils down to just finding the optimal combination of items 6. You will find the leal instruction very helpful for this problem 2. You have also been given a file called main.c that will take as a command line argument the name of a file containing a knapsack problem. 1. Please see the comments in main.c to see how these files are structured 2. Your function must be callable from this file 3. You have also been given a makefile that will compile the assignment for you as well as create a version of the executable using only the given C files. 1. Your program must be able to be complied by this makefile 4. Example: 1. cat Tests/0-test.txt 100 4 43 43 3 38 5 17 18 25 ./knapsack.out Tests/0-test.txt 123 3. (Time 1.5 Hours) Write a program called combs.s that
  • 6. generates all the possible combinations of a set of items of a given size. 1. Your program should be callable from C and have the following signature 1. int** get_combs(int* items, int k, int len) 2. This function should generate all possible combinations of items taken k at a time and return a 2-D array where each row contains one combination 1. The combinations should be added to the 2-D array in their natural order 2. This 2-D array should be dynamically allocated 3. As a hint you will probably need to develop a helper function that actually computes the combinations 3. You have been given a file called main.c that will get the inputs and call your function 1. Your function must be callable from this file 2. You will also find some helpful functions in main.c that you can call from your program 4. You have also been given a makefile to compile your program. 1. Your program must be compilable by this makefile. 4. Examples 1. How many items do you have: 5 Enter your items: 1 2 3 4 5 Enter k: 3 1 2 3 1 2 4 1 2 5
  • 7. 1 3 4 1 3 5 1 4 5 2 3 4 2 3 5 2 4 5 3 4 5 2. How many items do you have: 5 Enter your items: 1 2 3 4 5 Enter k: 4 1 2 3 4 1 2 3 5 1 2 4 5 1 3 4 5 2 3 4 5 matmult/main.c #include <stdio.h> #include <stdlib.h> int** matMult(int **a, int num_rows_a, int num_cols_a, int** b, int num_rows_b, int num_cols_b); void displayMat(int** mat, int num_rows, int num_cols); void readMat(const char* file_name, int*** mat, int* num_rows, int* num_cols); void displayMat(int** mat, int num_rows, int num_cols){ //display the contents of the 2D matrix to the scren //@mat: the matrix to be displayed //@num_rows: the number of rows in the matrix //@num_cols: the number of columns in the matrix int i,j;
  • 8. for(i = 0; i < num_rows; i++){//for each row for(j = 0; j < num_cols; j++){ //for each column printf("%d ", mat[i][j]); //display the value } printf("n"); } }//displayMat void readMat(const char* file_name, int*** mat, int* num_rows, int* num_cols){ //read in a file that contains a matrix //format of file is //number of rows //number of columns //values separated by white space //@file_name: the name of the file containing the matrix //@mat: the matrix to be intialized from the file. space will be allocated for it inside the function //@num_rows: the number of rows in the matrix. intialized by this function //@num_cols: the number of columns in the matrix. intialized by this function int i,j; FILE *fptr; fptr = fopen(file_name, "r"); //open the file //read in the dimensions fscanf(fptr, "%d", num_rows); fscanf(fptr, "%d", num_cols); //make space for mat *mat = (int**)malloc(*num_rows * sizeof(int*));
  • 9. for(i = 0; i < *num_rows; i++){ (*mat)[i] = (int*)malloc(*num_cols * sizeof(int)); } //initialize mat for(i = 0; i < *num_rows; i++){ for(j = 0; j < *num_cols; j++){ fscanf(fptr, "%d", &((*mat)[i][j])); }//for each row }//for each column fclose(fptr);// close the file }//readMat int main(int argc, char **argv){ int** mat_a; int** mat_b; int** mat_c; int rows_mat_a, cols_mat_a, rows_mat_b, cols_mat_b; int i; if(argc < 3){ printf("matmult.out matrix_A_File matrix_B_Filen"); printf("Not enough arguments given.n"); return(1); } //read in matrices readMat(argv[1], &mat_a, &rows_mat_a, &cols_mat_a); readMat(argv[2], &mat_b, &rows_mat_b, &cols_mat_b); //do the multiplication mat_c = matMult(mat_a, rows_mat_a, cols_mat_a, mat_b, rows_mat_b, cols_mat_b); //display solution
  • 10. displayMat(mat_c, rows_mat_a, cols_mat_b); //free up malloced space for(i = 0; i < rows_mat_a; i++){ free(mat_a[i]); } for(i = 0; i < rows_mat_b; i++){ free(mat_b[i]); } for(i = 0; i < rows_mat_a; i++){ free(mat_c[i]); } free(mat_a); free(mat_b); free(mat_c); return 0; }//main matmult/main.o matmult/makefile matmult.out: main.o matmult.o gcc -g -m32 -Wall -o matmult.out main.o matmult.o matmult.o: matmult.s gcc -g -m32 -Wall -c -o matmult.o matmult.s #-Wa,-alms main.o: main.c gcc -g -m32 -Wall -c -o main.o main.c
  • 11. clean: rm -f main.o matmult.o matmult.out matmult/matmult.o matmult/matmult.out matmult/matmult.s .text .globlmatMult matMult: pushl%ebp pushl%edi pushl%esi pushl%ebx subl$60, %esp movl84(%esp), %eax movl92(%esp), %ebp sall$2, %eax
  • 12. movl%eax, (%esp) callmalloc movl88(%esp), %ebx testl%ebx, %ebx movl%eax, 44(%esp) jleL2 xorl%ebx, %ebx movl88(%esp), %esi movl%eax, %edi movl%ebp, 32(%esp) movl%ebx, %ebp movl88(%esp), %ebx sall$2, %esi L3: movl%esi, (%esp) callmalloc movl%eax, (%edi,%ebp,4) addl$1, %ebp
  • 13. cmpl%ebx, %ebp jneL3 movl32(%esp), %ebp L2: movl84(%esp), %ecx testl%ecx, %ecx jleL4 movl100(%esp), %ebx xorl%ecx, %ecx movl%ebp, 32(%esp) movl44(%esp), %esi movl84(%esp), %ebp movl100(%esp), %edi sall$2, %ebx L5: testl%edi, %edi jleL8 movl(%esi,%ecx,4), %eax
  • 14. leal(%ebx,%eax), %edx L6: movl$0, (%eax) addl$4, %eax cmpl%edx, %eax jneL6 L8: addl$1, %ecx cmpl%ebp, %ecx jneL5 movl32(%esp), %ebp movl$0, 40(%esp) movl%ebp, %ebx L7: movl100(%esp), %eax movl$0, 36(%esp) testl%eax, %eax jleL10
  • 15. L18: movl88(%esp), %edx testl%edx, %edx jleL11 movl40(%esp), %eax movl44(%esp), %edx movl36(%esp), %esi movl(%edx,%eax,4), %edi sall$2, %esi movl80(%esp), %edx movl%esi, 32(%esp) addl%esi, %edi movl(%edi), %ecx movl(%edx,%eax,4), %ebp xorl%eax, %eax movl%edi, 28(%esp) L9: movl(%ebx,%eax,4), %edi
  • 16. movl32(%esp), %esi movl0(%ebp,%eax,4), %edx addl$1, %eax imull(%edi,%esi), %edx addl%edx, %ecx movl28(%esp), %edx cmpl88(%esp), %eax movl%ecx, (%edx) jneL9 L11: addl$1, 36(%esp) movl100(%esp), %esi cmpl%esi, 36(%esp) jneL18 L10: addl$1, 40(%esp) movl84(%esp), %esi cmpl%esi, 40(%esp)
  • 17. jneL7 L4: movl44(%esp), %eax addl$60, %esp popl%ebx popl%esi popl%edi popl%ebp ret done: matmult/result.py class Result(object): """ a wrapper to contain the results of a test @testName: the name of the test run @correct: True if the output of matched the solution; False otherwise @timeTaken is either
  • 18. the number of seconds it took the program to run 'Timed Out' if the program took too long to complete 'Crashed' if the program encountered some fatal error """ def __init__(self, testName, correct, timeTaken): """ @testName: the name of the test run @correct: True if the output of matched the solution; False otherwise @timeTaken is either the number of seconds it took the program to run 'Timed Out' if the program took too long to complete 'Crashed' if the program encountered some fatal error """ self.testName = testName self.correct = correct self.timeTaken = timeTaken #end init
  • 19. def __repr__(self): if type(self.timeTaken) == str: format_str = 'Test: {!s} | Correct: {!s} | Time Taken: {!s}' else: format_str = 'Test: {!s} | Correct: {!s} | Time Taken: {:.3f}' s = format_str.format(self.testName, self.correct, self.timeTaken) return s def __str__(self): return self.__repr__() matmult/result.pyc matmult/ Solution
  • 20. s/0-sol.txt -150559 -384480 81146 -239743 -1043315 370572 125456 -155903 361902 matmult/