[ASM] How to compile ASM with C in macOS

Homebrew

brew install nasm
  • If you successfully install nasm, you should restart your terminal.

Compile without Makefile

  • To make object file and compile with C file, use command below.
nasm -f macho64 sourcefile.sgcc main.c sourcefile.o

Compile with Makefile

  • If you have your own Makefile make it first and then,
gcc main.c -L ./ -lasm
  • My Makefile was like below. If you want to see my assembly code tested with C language, visit my github.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store