Lab 3 - FL13 - ECE 198 JL - University of Illinois - Engineering Wiki

Step 2 compile the c ompiler then tak es preproc es s

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: ives . Can y ou figure out what the "#define" direc tive did? Step 2: Compile The c ompiler then tak es preproc es s ed C c ode and trans lates it into as s embly language, in this c as e x 86 as s embler. The following c ompiles hello-world.i into the as s embly language file hello-world.s : gc- - hlowrdshlowrdi c S o el-ol. el-ol. Run this and look at the as s embly language file. One day y ou will learn about the as s embly language. For now, jus t note that our program written in mac hine-independent high-level language C got trans lated into a low-level mac hine-s pec ific as s embly language. Step 3: Assemble The x 86 as s embler tak es the as s embly language file hello-world.s and outputs an objec t file hello-world.o c ontaining x 86 mac hine c ode: a - hlowrdohlowrds s o el-ol. el-ol. Go ahead and run this . The x 86 as s embler outputs a s ingle file, whic h c ontains both s y mbols and mac hine c ode. To s ee the s y mbol table of the file (remember that it's a binary file, s o y ou c an't jus t open it with a tex t editor) us e objdump: ojup- hlowrdo bdm t el-ol. There are two rows of 64-bit hex values (the 0000000000000000s ). The firs t row is the (relative) addres s , the s ec ond is the s iz e of eac h s ec tion. You'll s ee a "main" s y mbol with s iz e x 15, that's y our main s ubroutine. You'll als o s ee a s y mbol c alled "puts " mark ed "UND" for undefined, c an y ou gues s what that is ? Step 4: Link Link ing c ombines multiple objec t files into one pac k age, inc luding s hared ob jec t files that are s hared by many different programs running on the s y s tem, als o k now as lib raries . Run the following to us e the link er program "ld" to link hello-world.o with the objec t files it needs to run, produc ing the exec utab le b inary "hello-world": l - hlowrd-yai-ikr/i6/dlnxx66.o2/s/i6/r1o/s/i6/rio d o el-ol dnmclne lb4l-iu-8-4s. urlb4ct. urlb4ct. /s/i/c/8_4rda-iu/../rbgno-chlowrdo/s/i/c/8_4rdaurlbgcx66-ehtlnx445ctei. l el-ol. urlbgcx66-eht l...
View Full Document

This document was uploaded on 03/22/2014.

Ask a homework question - tutors are online