Lab 2 -- Conditionals and Loops

Due date: 9/27, 2010, by 6am

Introduction

In this lab you will be exploring the C to assembly mapping. You may work in groups but each member should submit his/her own writeup. Please note all collaborators on your writeup.

The assignment consists of the following steps:

  1. Place the three following code snippet is three separate functions.
  2. Compile the C-code to assembly.
  3. Produce a side-by-side comparison of the produced assembly to the C-code. (Just focus on the 32-bit assembly, i.e., the Jazz machines.)

Code Snippet 1

int x = 32; if(x < 24) { x++; } else { x--; } return x;

Code Snippet 2

int x = 0; int z = 0; while (x < 32) { z += 34; x++; } return z;

Code Snippet 3

int x; int z = 0; for (x = 0; x < 32; x++) { z += 34; } return z;

Complete the Lab by emailing your reports to taylorm. Note, your lab will be graded based on the organization of your report.