x86 Assembly on a Mac

前端 未结 9 1462
温柔的废话
温柔的废话 2020-11-28 01:15

Does anyone know of any good tools (I\'m looking for IDEs) to write assembly on the Mac. Xcode is a little cumbersome to me.

Also, on the Intel Macs, can I use gener

相关标签:
9条回答
  • 2020-11-28 02:07

    Recently I wanted to learn how to compile Intel x86 on Mac OS X:

    For nasm:

    -o hello.tmp - outfile
    -f macho - specify format
    Linux - elf or elf64
    Mac OSX - macho
    

    For ld:

    -arch i386 - specify architecture (32 bit assembly)
    -macosx_version_min 10.6 (Mac OSX - complains about default specification)
    -no_pie (Mac OSX - removes ld warning)
    -e main - specify main symbol name (Mac OSX - default is start)
    -o hello.o - outfile
    

    For Shell:

    ./hello.o - execution
    

    One-liner:

    nasm -o hello.tmp -f macho hello.s && ld -arch i386 -macosx_version_min 10.6 -no_pie -e _main -o hello.o hello.tmp && ./hello.o
    

    Let me know if this helps!

    I wrote how to do it on my blog here:

    http://blog.burrowsapps.com/2013/07/how-to-compile-helloworld-in-intel-x86.html

    For a more verbose explanation, I explained on my Github here:

    https://github.com/jaredsburrows/Assembly

    0 讨论(0)
  • 2020-11-28 02:08

    Don't forget that unlike Windows, all Unix based system need to have the source before destination unlike Windows

    On Windows its:

    mov $source , %destination

    but on the Mac its the other way around.

    0 讨论(0)
  • 2020-11-28 02:10

    For a nice step-by-step x86 Mac-specific introduction see http://peter.michaux.ca/articles/assembly-hello-world-for-os-x. The other links I’ve tried have some non-Mac pitfalls.

    0 讨论(0)
提交回复
热议问题