Assemblers and Assembly for Linux

This topic was published by and viewed 613 times since "". The last page revision was "".

Viewing 1 post (of 1 total)
  • Author
    Posts
  • DevynCJohnson
    DevynCJohnson
    Keymaster
    • Topics - 444
    • @devyncjohnson

    Linux and Unix systems, like other operating systems, support Assembly. There are a variety of Assembly compilers for Linux and Unix systems. Each one has its advantages and disadvantages. Also, some assemblers support certain types of processors. Assembly is used by all operating systems, so knowing the general facts about Assembly can be beneficial to many computer users.

    Assembly is a very low level programming language. In fact, it is closer to machine code than C/C++ and Java. Assembly code is not as portable as other programming languages. However, it is faster C/C++, as long as the programmer creates proper code. An assembler is a compiler that reads assembly code and then produces object code or machine code. Object code and machine code are the same thing. They are both binary code (a sequence of 0 and 1). However, the term "machine code" refers to the code read directly by the CPU. Object code typically refers to a file containing machine code that is part of a collection of object-files that produce a whole program.

    Every assembler is different and so is every CPU type. For instance, in Assembly, there is no standard comment symbol. As an example, in the Python programming language and BASH shell scripting, developers use the octothorpe (#) as the comment symbol. However, the GNU Assembler uses "@" as the comment symbol on the ARM processor, "#" on the x86 CPUs, and "!" on the SH platform. Since Assembly differs on each CPU and assembler, Assembly programmers must know Assembly for each processor they intend to support.

    Two main types of Assembly formats are available. Intel-style Assembly is common among Windows and DOS systems while AT&T-style Assembly is seen in Unixoid systems. The two styles differ in the placement of certain parameters and the specific spelling of commands. Some syntax characters may also differ.

    The GNU Assembler (gas) is a popular Linux assembler. The GNU Assembler supports the AT&T assembly syntax. Users can invoke this assembler using the command "as" or by using "gcc".

    NASM (Netwide Assembler - http://www.nasm.us/) is an alternative to the GNU Assembler if the programmer prefers the Intel-style Assembly syntax. Also, NASM acts as a disassembler and supports 16-bit, IA-32, and x86-64 architectures. As for executable-file formats, NASM can produce a.out, COFF, Portable-Executable, Executable and Linkable Format (ELF), Mach-O, .bin, and RDOFF. The usual command-line usage of NASM looks like nasm file.asm -o outfile.

    FASM (Flat Assembler - http://flatassembler.net/) is an assembler that supports IA-32 and x86-64 architectures. FASM also runs on Windows, Unixoid systems, and a variety of other operating systems. This assembler can produce executable files in many formats such as "flat/raw binaries", Common Object File Format (COFF), ELF, MZ, Portable-Executable (PE). FASM is a supposedly a fast assembler that has few command-line options.

    FASARM (http://arm.flatassembler.net/) is an ARM port of FASM.

    "yasm" (http://yasm.tortall.net/) is an assembler and disassembler that supports both the Intel and AT&T assembly syntax. Supported architectures include 16-bit, IA-32, and x86-64 for Unixoid and Windows systems. Yasm is based on NASM.

    Further Reading

Viewing 1 post (of 1 total)