

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
In this document, students are provided with instructions for lab 13 in mathematics 3670, where they will focus on parameter passing at the machine level, specifically handling pointer values and arrays in the presence of subroutines. Students are required to create and test several new functions, including 'swap' and 'sort3', which will be used to interchange values and sort arrays, respectively.
Typology: Lab Reports
1 / 2
This page cannot be seen from the preview
Don't miss anything!
In this lab, we will continue to emphasize issues of parameter passing at the machine level. Of special interest is how to pass and use pointer values and arrays in the presence of subroutines. The lab asks you to implement a few new functions and to illustrate their use within a main program.
void swap(int* px, int* py);
Each of the two parameters is a pointer to an int variable. The return type, void, indicates there is no value computed by this function. In machine terms, each parameter is a memory address. As shown in the diagram below, we want the swap function to interchange the values of the corresponding words of memory.
py
px
py
px (^) α
β
β
α
y
x
y
x
Before invoking swap After invoking swap
Follow all the conventions for passing parameters and using stack frames that were established for Labs 11 and 12.
a: .fill 10 b: .fill 20 c: .fill 30 d: .fill 40
Your program should invoke swap twice: once for the pair a and b and a second time for c and d.
void sort3(int* px, int* py, int* pz);
This function should make pairwise comparisons and perform swaps as necessary. Your code must make use of the swap function.
Mathematics 3670: Lab 13 2
cd ~/ tar -cvf lab13.tar lab
submit lab13.tar mat