How to generate the arm64 assembly of a c program on x86 macOS

Viewed 303

I have a c program:

#include <unistd.h>
#include <stdlib.h>
int main() {
  const char msg[] = "Hello, ARM!\n";   
  write(0, msg, sizeof(msg));
  exit(0);
}   

And I want to generate the Apple Silicon arm64 assembly of this C program. How do I do this on an x86 macOS?

1 Answers

If you have installed the XCode Command Line Developer Tools, you can type in your Terminal:
clang -S FILE.c -o OUTPUTFILE
That's it!

Related