aaronbloomfield/pdr

lab 8: x86: clang++ outputting assembly in the Intel flavor

aaronbloomfield opened this issue · 3 comments

Apparently the latest version of clang can, in fact, output assembly in the Intel flavor for Mac OS X. Investigate and update the 08-x86.html slide set.

It's the same as g++, i.e., it's -masm=intel. In the previous version of OS X's version of clang++ it used to be clang++ -S -mllvm --x86-asm-syntax=intel <cppfile>. Note -mllvm takes in the argument --x86-asm-syntax=intel, so it is order-specific.

Here's an example I just ran on my 2015 MacBook Pro running OS X 10.11.1.

$ clang++ -v
Apple LLVM version 7.0.0 (clang-700.0.72)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
$ cat test.cpp
#include<iostream>

int main() {
    int z = 10;
    int *y = &z;
    int x = 3 + *y;
    std::cout << x << std::endl;
    return 0;
}
$ clang++ -m32 -S -masm=intel test.cpp
$ mv test.s test-masm.s
$ clang++ -m32 -S -mllvm --x86-asm-syntax=intel test.cpp
$ diff test-masm.s test.s
$

Some external sources:

This did not get completed in time for the spring 2016 semester. We are moving to 64-bit assembly for the fall. So changing the target date for this to the fall 2016 semester, although it may not be relevant due to the assembly flavor switch