NASM and Mac format

Discussion in 'Mac Programming' started by davidlt, Jul 23, 2008.

  1. davidlt macrumors member

    Joined:
    May 22, 2007
    Location:
    Lithuania
    #1
    Hello, I have never did Asm programming on UNIX type operating system and now I have tried it. I am using preisntalled NASM as compiler. I took simple Hello World program to try it for the first time and compiled like this:
    nasm -f macho -o hello hello.asm

    and tried to launch it:
    ./hello

    I got message that permission was denied and then I tried with sudo the same and got message: "sudo: ./hello: command not found".

    The question would be how to compile to Mac executive file and run it without any problems?
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
  3. davidlt thread starter macrumors member

    Joined:
    May 22, 2007
    Location:
    Lithuania
    #3
    Okay, Linux was even easier, I did not know that UNIX is using stack for the arguments, thanks... :)

    Any doc with full syscalls information for Mac?
     
  4. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #4
    Any FreeBSD documentation should be fine.

    Edit : If you want the specific numbers to use for specific system calls they are located in /usr/include/sys/syscall.h

    Edit 2 : This is a useful document :

    http://www.freebsd.org/doc/en/books/developers-handbook/x86.html
     
  5. larkost macrumors 6502a

    Joined:
    Oct 13, 2007
    #6
    I don't know a thing about asm, but it seems to be that the problem might be that the output file is not set as executable. If you "chmod +x" it, then it might work.
     
  6. Muncher macrumors 65816

    Muncher

    Joined:
    Apr 19, 2007
    Location:
    California
    #7
    That could do it. :D
     
  7. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #8
    As long as you are assembling using the following commands it should just work.

    Code:
    nasm -f macho myfile.s
    ld -o my_test_asm_prog myfile.o
     

Share This Page