The GNU assembler is probably already installed on your system. Try man as see full usage information. You can use as to compile individual files and ld to link if you really want to.
However, GCC makes a great interface. It can collect .s files for you. For example:
$ cat >hello.s <<EOF .data .globl hello hello: .string "Hello, world!" .text .global main main: pushq %rbp movq %rsp, %rbp movq $hello, %rdi call puts movq $0, %rax leave ret EOF $ gcc hello.s -o hello $ ./hello Hello, world!
The code above is AMD64. It would be different if you are still on a 32-bit machine.
You can also compile C / C ++ code directly to the assembly if you are interested in how something works:
$ cat >hello.c <<EOF #include <stdio.h> int main(void) { printf("Hello, world!\n"); return 0; } EOF $ gcc -S hello.c -o hello.s
Jay Conrod Jul 23 '10 at 3:44 2010-07-23 03:44
source share