Seeing the Generated Assembly Code

The real hard-core hackers can look at the assembly code generated by the compiler. Sometimes you need this to track down compiler problems or OS problems. Or you can browse around just for general amusement and education. To get the assembly code, compile with the -S flag, and the results will be put into an .s file based on the name of your source file. For instance, running

$​ ​g​c​c​ ​-​g​ ​-​W​a​l​l​ ​-​S​ ​p​r​e​p​r​o​c​T​e​s​t​.​m​

will create a preprocTest.s. If you want to assemble the resulting file, feed it to the compiler like this:

$​ ​g​c​c​ ​-​o​ ​p​r​e​p​r​o​c​T​e​s​t​ ​p​r​e​p​r​o​c​T​e​s​t​.​s​

Xcode 3 provides a Show Assembly Code item in the editor’s contextual menu so you can see what ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.