16 Getting started Assembly Code (.s) Code Assembly (.exe) Executable Source Code (.) Code Source (.o) Code Object Substitutions (.i) Substitutions Assembler • • • • : new a generate each which stages, separate four undergoes actually process compilation the file code source C original an from file executable an producing In Understanding report an error and the executable file will not be created. be not will file executable the and error an report will it files object multiple in defined name same the of function a finds linker the functions. Where re-usable contain each may modular from programs large of creation the file. allows executable This single a generates ultimately and files object multiple on operate hand,can other linker, the The on fail. will compilation and compiler the by reported be will parenthesis, they missing a or terminator statement semi-colon missing a as errors, such syntax contains code source program the file.Where object binary single a generate ultimately and file text code source single a on operate above, which stages three “compilation”speaking first the Strictly describes

format and typically hasa.exe fileextension andtypically format files intoasingleexecutable file. Thefileisinbinary generated hasa typically and format object filecontaining theconversion isinbinary inthe text instructions hasa andtypically text format instructions. The filetranslationgenerated containing theisin inthe instructions a has containing andtypically thesubstitutions isintextformat code issubstitutedfor code thatimplementsthosedirectives. For instance, directives source intheoriginal code Linking –the Assembling –the Translating –the Preprocessing –the .i fileextension .o linker combines one or more binary object linker combines one ormore binary fileextension compiler translates the high-level compiler thehigh-level translates assembler converts the assembler converts theAssembly .i preprocessor preprocessor substitutesall file intolow-level #include .s fileintomachinecode. The generated .s compilation directives. The file generated fileextension .c file with actual library filewith actual library Assembly language Assembly object files that files object .o

17 develop and maintain. For traditional C is almost always the first choice. Programs tediously written in Assembly language can run faster than those written in C but are more difficult to

library code directory, type directory, -save-temps stdio.h then hit Return to MyPrograms file in a plain to see the file in a plain such text as editor, hello.s hello.i temporary files created during the intermediary

re-compile re-compile the program and save the temporary files gcc hello.c -save-temps -o hello.exe translation into low-level Assembly code and note how unfriendly that appears in contrast to the C code version Windows’ Notepad, to Notepad, see Windows’ your source code at the very end of the file precededby substituted Now Now open the Open the At At a command prompt in the

3 2 1 l l stages stages of the compilation process are automatically but deleted, they can be retained for inspection by including a option in the compiler command: l …cont’d Normally the