How to install GNU Assembler
Solution 1
GNU assembler, AKA as
, is installed by default on Ubuntu. It is in the package binutils
.
Solution 2
Build from source and use it
#!/usr/bin/env bash
set -eux
# Build.
sudo apt-get build-dep binutils
git clone git://sourceware.org/git/binutils-gdb.git
cd binutils-gdb
git checkout binutils-2_31
./configure --target x86_64-elf --prefix "$(pwd)/install"
make -j `nproc`
make install
# Test it out.
cat <<'EOF' > hello.S
.data
s:
.ascii "hello world\n"
len = . - s
.text
.global _start
_start:
mov $4, %eax
mov $1, %ebx
mov $s, %ecx
mov $len, %edx
int $0x80
mov $1, %eax
mov $0, %ebx
int $0x80
EOF
./install/bin/x86_64-elf-as -o hello.o hello.S
./install/bin/x86_64-elf-ld -o hello hello.o
./hello
TODO: how to configure as
specific options? We have used the ./configure
from the binutils-gdb
top-level, but that contains options from multiple projects such as gdb
I believe, and not as
specific ones?
Tested on Ubuntu 18.04.
Related videos on Youtube
user3699039
Working as Team Member and experienced backend resource. All the time, busy writing clean code, have adopted TDD since start of the career. And translating business requirements to technical solutions. An experienced web, distributed and enterprise application developer with more than 3 years of experience. Primary skills are Java, Spring Framework, SQL, CSS HTML. On the journey to adopt tools like ELK, Prometheus, Kubernetes and Grafana in daily work routine.
Updated on September 18, 2022Comments
-
user3699039 over 1 year
I am trying to write a boot-loader, so I need GNU Assembler. I googled it but didn't find any helpful material. How can I install GNU Assembler (and not GNU Compiler)?
-
user3699039 about 7 yearscan you tell me how i can use it?
-
muru about 7 yearsTeaching you assembly language is well beyond the scope of a post here.
-
user3699039 about 7 yearsany useful link or other material
-
Jean-Marie about 7 years
man as
maybe?