I'm using Ubuntu, and I was looking for an assembler compiler for Linux, and I found GAS.
I'm trying to install it and run it, but I can't.
The GNU Assembler, commonly known as gas or as, is the assembler developed by the GNU Project. It is the default back-end of GCC. It is used to assemble the GNU operating system and the Linux kernel, and various other software. It is a part of the GNU Binutils package.
GNU Compiler Collection (GCC): a compiler suite that supports many languages, such as C/C++ and Objective-C/C++. GNU Make: an automation tool for compiling and building applications. GNU Binutils: a suite of binary utility tools, including linker and assembler. GNU Debugger (GDB).
as
is the GNU Assembler. It's found in binutils
but if you do:
sudo apt-get install build-essential
You will get gas
along with gcc
(which default uses gas
for assembling on the back end).
For a 'tutorial' about using gas
, you probably want to read Programming From the Ground Up, which uses it.
To build a static executable from a .s
file,
#!/bin/bash
f="${1:-}"
as "${f}" -o "${f%%.s}.o" && ld "${f%%.s}.0" -o "${f%%.s}"
gcc -nostdlib -static "${f}" -o "${f%%.s}"
If you want to link with libraries, it's normally easiest to let gcc use the right command line options for as
and ld
when building an executable from an asm source file.gcc foo.s -o foo
will work if your foo.s
defines a main
function.
Also related: Assembling 32-bit binaries on a 64-bit system (GNU toolchain) if you're writing 32-bit programs on an x86-64 system.
It's in the binutils
package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With