x86 Assembly on a Mac

前端 未结 9 1502
温柔的废话
温柔的废话 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:00

    Running assembly Code on Mac is just 3 steps away from you. It could be done using XCODE but better is to use NASM Command Line Tool. For My Ease I have already installed Xcode, if you have Xcode installed its good.

    But You can do it without XCode as well.

    Just Follow:

    1. First Install NASM using Homebrew brew install nasm
    2. convert .asm file into Obj File using this command nasm -f macho64 myFile.asm
    3. Run Obj File to see OutPut using command ld -macosx_version_min 10.7.0 -lSystem -o OutPutFile myFile.o && ./64

    Simple Text File named myFile.asm is written below for your convenience.

    global start
    section .text
    
    start:
        mov     rax, 0x2000004 ; write
        mov     rdi, 1 ; stdout
        mov     rsi, msg
        mov     rdx, msg.len
        syscall
    
        mov     rax, 0x2000001 ; exit
        mov     rdi, 0
        syscall
    
    section .data
    
    msg:    db      "Assalam O Alaikum Dear", 10
    .len:   equ     $ - msg
    

提交回复
热议问题