Thread: asm for Linux

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    266

    asm for Linux

    Which is the best asm language for Linux? I kind've narrowed it down to as, gas or NASM.

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    as is the system assembler. On Linux, this is always gas.

    What is your measure of "best"? I'm pretty sure NASM has better macro support. I'm also pretty sure that gas has better support for low-level manipulation of the ELF output.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    266
    Ok I have a few more questions if you don't mind. First, what is ELF output? Second, do you know the official website of something of gas(can't find it for my life with google)? Lastly, can gas be used on windows?

  4. #4
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    Quote Originally Posted by lruc View Post
    First, what is ELF output?
    http://en.wikipedia.org/wiki/Executa...inkable_Format


    Quote Originally Posted by lruc View Post
    Second, do you know the official website of something of gas(can't find it for my life with google)?
    http://en.wikipedia.org/wiki/GNU_Assembler This is not the official website, but just looks for the link at the bottom of the page and you'll find out.
    I hate real numbers.

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    And yes, you can use gas in Windows if you like - it comes as part of the mingw suite.

    However, for most assembler code, I tend to use inline assembler in gcc. For nearly all assembler programming, it is only a small portion of code that needs to be written in assembler, the rest can be written in C or C++, and using inline assembler is the best way to achieve that.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Registered User
    Join Date
    Jun 2008
    Posts
    266
    I eventually plan to develop for linux so should I go windows or linux gas now?

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by lruc View Post
    I eventually plan to develop for linux so should I go windows or linux gas now?
    The syntax and such in gas for linux is the same as gas for windows (or perhaps I should have turned those around)- it is the same assembler, it just outputs the object file correctly for the respective OS's it is meant to output object files for. Obviously, you need to use gas for windows if you want to produce a executable on Windows, and if you want an executable for Linux, you need to use the Linux version. As long as your assembler code in itself doesn't use Windows or Linux specific features (such as calling system calls), you should be fine using the same code for both Linux and Windows.

    Obviously, one important question here is "What are you planning to write, that requires assembler". There is very little code that actually NEEDS to be written in assembler.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Registered User
    Join Date
    Jun 2008
    Posts
    266
    I kind've need help seeting up the asm compiler. I downloaded MinGW and set the path variables but I'm not sure which command line argument uses gas. Any help here?

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    In the mingw version that Dev-Cpp includes, "gas" is actually called "as".

    As for command line parameters, you may want to do something like this:
    Code:
    as -o mycode.obj mycode.s
    Of course, there is a whole bunch of other possible command-line arguments that CAN be useful at times. man-page here: http://linux.die.net/man/1/as

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Registered User
    Join Date
    Jun 2008
    Posts
    266
    Ok I found it(as). The only problem is I just get a .out file when I'm looking for an .exe. Why am I getting this?
    edit::Sorry late post matsp

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gcc asm code syntax
    By Uberapa in forum C Programming
    Replies: 4
    Last Post: 06-15-2007, 01:16 AM
  2. Asm + C++
    By JaWiB in forum C++ Programming
    Replies: 17
    Last Post: 06-26-2003, 03:13 PM
  3. Understanding ASM
    By kuphryn in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 07-12-2002, 07:39 PM
  4. asm mov
    By manu in forum C++ Programming
    Replies: 1
    Last Post: 12-15-2001, 12:59 PM
  5. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 06:05 PM