Practice problem 72 in this problem let refxi defxk

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cessor (cpp), which translates the C source file main.c into an ASCII intermediate file main.i: cpp [other arguments] main.c /tmp/main.i Next, the driver runs the C compiler (cc1), which translates main.i into an ASCII assembly language file main.s. cc1 /tmp/main.i main.c -O2 [other arguments] -o /tmp/main.s Then, the driver runs the assembler (as), which translates main.s into a relocatable object file main.o: as [other arguments] -o /tmp/main.o /tmp/main.s 7.2. STATIC LINKING 351 code/link/swap.c 1 code/link/main.c 1 2 3 4 5 6 7 8 9 10 /* main.c */ void swap(); int buf[2] = {1, 2}; int main() { swap(); return 0; } code/link/main.c 2 3 4 5 6 7 8 9 10 11 12 13 14 15 /* swap.c */ extern int buf; int *bufp0 = &buf[0]; int *bufp1; void swap() { int temp; bufp1 = &buf[1]; temp = *bufp0; *bufp0 = *bufp1; *bufp1 = temp; } code/link/swap.c (a) main.c (b) swap.c Figure 7.1: Example program 1: The example program consists of two source files, main.c and swap.c. The main function initializes a two-element array of ints, and then calls the swap function to swap the pair. The...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online