How To Get Assembler Listing Of C++ Program In Xcode

I teach a computer architecture class. The students are roughly 2/3rds Visual Studio users and 1/3rd Xcode users. Google searches all seem to provide responses for older versions of Xcode.


I am at a point in the class where we look at assembler programs generated by compilers as a prelude to writing Intel assembler projects. I would like to have the same exercise available for both platforms. Can anyone guide me to a method to do this which works in Xcode 6.4 or 7.0.1?


Thank you,


Hank Murphy

Replies

That feature is now in the Assistant Editor.


Open a source file, open it again in the Assistant Editor (by option clicking it). Then from the leftmost menu in the jump bar above the source file (the icon with 4 squares) select "Assembly".

Answering a slightly different question:

In Xcode 7.1, select your C or Objective C source code file in the file inspector; then, in Xcode's Product menu, select Perform Action > Assemble "yourSourceFile.m"

You may have to play with Architectures in the selected Target's Build settings to select the 32 or 64 bit ISA you want to see.


Also, with Xcode 7.x installed, from the OSX Terminal command-line, you could try:

xcrun -sdk macosx swiftc -emit-assembly yourSourceFile.swift

or

clang -S yourSourceFile.c