title: Why is the Xcode command line nasm assembly issuing error: unknown use of instruction mnemonic without a size suffix
body: <p>My goal is to use Xcode (10.2-beta) to write C and Assembly for MacOS (14.1); I want to use the NASM instead of the default GNU compiler, the GAS syntax is quite horrible.</p>
  
  <p><strong><em>BTW, although I configured Xcode to use NASM, as you will see below, I suspect it is not using it!</em></strong></p>
  
  <p>I've built my project using the GNU compiler. It runs fine. </p>
  
  <pre><code>// main.c
  # include &lt;stdio.h&gt;
  
  int myOperation(int a, int b);
  
  int main(int argc, char * argv[]) {
      // insert logic here
      int x = 10;
      int y = 12;
      int z = myOperation(x, y);
      printf("The sum of %d and %d is %d\n", x, y, z);
      return 0;
  }
  
  //  assembly.s
  .text
  .globl _myOperation
  
  _myOperation:
      add %esi, %edi
      mov %edi, %eax
      ret
  </code></pre>
  
  <p>I installed the XCode command line tools and changed the build rules to compile NASM files. The C file is the same:</p>
  
  <pre><code>//  assembly.s
  .text
  .globl _myOperation
  
  _myOperation:
      add edi, esi
      mov eax, edi
      ret
  </code></pre>
  
  <p>Building rules
  <a href="https://i.stack.imgur.com/MVXA4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MVXA4.png" alt="Xcode build rule"></a></p>
  
  <p>I get the following errors:</p>
  
  <pre><code>/Users/rodrigomattososilveira/projects/asm/NASM Tutorial/Tutorial_01AA/Tutorial_01AA/assembly.s:12:5: error: unknown use of instruction mnemonic without a size suffix
      add edi, esi
      ^
  /Users/rodrigomattososilveira/projects/asm/NASM Tutorial/Tutorial_01AA/Tutorial_01AA/assembly.s:13:5: error: unknown use of instruction mnemonic without a size suffix
      mov eax, edi
      ^
  Command CompileC failed with a nonzero exit code
  </code></pre>
  
  <p>Some of the links I've checked out:</p>
  
  <ul>
  <li><a href="https://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax" rel="nofollow noreferrer">X86 Assembly/GAS Syntax</a></li>
  <li><a href="https://metricpanda.com/compiling-nasm-with-xcode-in-a-cpp-project" rel="nofollow noreferrer">Compiling NASM Assembly with Xcode in a C/C++ Project</a></li>
  <li><a href="https://stackoverflow.com/questions/20556241/xcode-and-nasm-coding">Xcode and NASM coding</a></li>
  <li><a href="http://www.idryman.org/blog/2014/12/02/writing-64-bit-assembly-on-mac-os-x/" rel="nofollow noreferrer">Writing 64 Bit Assembly on Mac OS X</a></li>
  <li>The top links suggested at the time I created this issue</li>
  </ul>