Languages
Assembly
Installing NASM for Assembly on Ubuntu in TIDE
Assembly
Assembly is a low-level programming language that has a direct 1-to-1 mapping with machine architecture instructions. Programming in assembly provides complete control over hardware registers, memory allocation, and system calls.
Installation
To compile and link assembly programs on Ubuntu (x86_64), install the Netwide Assembler (nasm), GNU linker, and standard build utilities:
apt update
apt install -y nasm build-essential gdbVerification
Check that NASM and GCC are properly installed:
nasm -v
gcc --versionWriting, Assembling, and Running Code
Create a 64-bit Linux assembly source file named hello.asm:
section .data
msg db "Hello from Assembly in TIDE!", 10
len equ $ - msg
section .text
global _start
_start:
; sys_write (rax=1, rdi=stdout, rsi=buffer, rdx=len)
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, len
syscall
; sys_exit (rax=60, rdi=status)
mov rax, 60
mov rdi, 0
syscallAssembling the Source File
Assemble the .asm file into an ELF64 object file using NASM:
nasm -f elf64 hello.asm -o hello.oLinking the Object File
Link the object file into a standalone executable using ld:
ld hello.o -o helloRunning the Executable
Execute the binary:
./hello