gcc2 - CS3214 Fall 2011 Exercise 3 Due: Monday, Sep 19,...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS3214 Fall 2011 Exercise 3 Due: Monday, Sep 19, 2011. 11:59pm (no extensions). What to submit: A tar file that should contain the following files: answers.txt - an ASCII file with answers for questions 1, 2, and 3. For answers 4-6, which ask for code, include files named log-solution.c , vadd-asm.c , vadd-intrinsics.c , nested-test-solution.c in your tar file. Use the submit.pl script in ˜ cs3214/bin/submit.pl to submit your tar file from the com- mand line, or use the submit website. Use the identifier ’ex3.’ This exercise is intended to reinforce the content of lectures 3-6. As before, you’re asked to use gcc 4.1.2 as installed on the rlogin cluster. Specify the -O switch unless the question asks otherwise. 1. Structure Alignments. As discussed in lecture and the book, a C compiler may use padding to align fields in a struct according to a set of conventions, which vary between architectures, OSs, and sometimes compiler versions. The directory ˜ cs3214/bin contains three compilers mgcc1 , mgcc2 , and mgcc3 . Find out at which multiples these compiler align fields of types short , int , and long . Which com- piler uses the default alignment used on Linux/x86 64? Type mgcc1 mgcc2 mgcc3 short int long x86 64 default alignment rules (yes/no)? 2. Variations on Passing Arguments. As discussed in lecture, there are different ways in which a function might prepare the arguments for the function(s) it calls, without violating the assumptions made by the IA32 ABI specification. It is useful to gain an intuition regarding these variations. Consider the following variation of the call_swap() function shown in Lecture. void swap(int * xp, int * yp) { int t0 = * xp; int t1 = * yp; * yp = t0; * xp = t1; } int zip1 = 15213; int zip2 = 91125; void call_swap(void) { swap(&zip1, &zip2); swap(&zip1, &zip2); } 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS3214 Fall 2011 Exercise 3 Compile this code with the following flags (in this order): A gcc -m32 -S -O -mno-accumulate-outgoing-args swap.c B gcc -m32 -S -O -fno-defer-pop -mno-accumulate-outgoing-args swap.c C gcc -m32 -S -O swap.c D gcc -m32 -S -O -mregparm=2 swap.c For each variant, trace the value of the stack pointer relative to the position it had
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/31/2011 for the course CS 3214 taught by Professor Staff during the Fall '11 term at Virginia Tech.

Page1 / 6

gcc2 - CS3214 Fall 2011 Exercise 3 Due: Monday, Sep 19,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online