Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Writing 32-bit x86 assembly with NASM, the Netwide Assembler, is the classic rite of passage in computer architecture and operating systems courses: you talk to Linux directly through int 0x80 software interrupts, manage registers like eax and ebx by hand, and see exactly what a CPU does with every instruction. NASM has been the standard open source assembler since the 1990s, with Intel syntax that most university materials and osdev tutorials use. Setting up an assembler, linker, and 32-bit libraries locally is genuinely fiddly, which is what this page removes: your source is assembled, linked, and executed in a real terminal, with syscall-driven output streaming back instantly.
section .data
prompt db "Hello from 32-bit x86 assembly!", 0xA
plen equ $ - prompt
msg2 db "Registers, syscalls, no safety net.", 0xA
m2len equ $ - msg2
section .text
global _start
_start:
mov eax, 4 ; sys_write
mov ebx, 1 ; stdout
mov ecx, prompt
mov edx, plen
int 0x80
mov eax, 4 ; sys_write again
mov ebx, 1
mov ecx, msg2
mov edx, m2len
int 0x80
mov eax, 1 ; sys_exit
xor ebx, ebx ; status 0
int 0x80
This environment serves computer architecture and systems courses where assignments require hand-written loops, register arithmetic, and direct Linux syscalls in 32-bit mode. Reverse engineers and CTF players practice reading and writing the int 0x80 calling convention that older binaries and shellcode examples still use. It is also useful for compiler students inspecting what their code generators should emit, and for anyone working through classic texts like 'Programming from the Ground Up' whose examples target exactly this NASM-on-Linux 32-bit setup.
Yes. Invoke sys_read by setting eax to 3, ebx to 0 for stdin, ecx to a buffer address in .bss, and edx to the byte count, then trigger int 0x80. Because the page provides a live terminal, the syscall blocks until you type, and the entered bytes land in your buffer including the newline.
Source is assembled by NASM producing 32-bit ELF objects and linked into an executable targeting the i386 Linux ABI, so int 0x80 syscall numbers from asm/unistd_32.h apply: 1 for exit, 3 for read, 4 for write. Use _start as your entry point since there is no C runtime wrapping main.
After your last instruction the CPU keeps executing whatever bytes follow in memory, which typically causes a segmentation fault. Always end with mov eax, 1 and int 0x80 to invoke sys_exit, passing the status code in ebx. This is the assembly equivalent of returning from main, and forgetting it is the single most common beginner crash.
main.asmgassys_read syscall; NASM Assembly
section .data
msg db "Hello from NASM!", 0xA
len equ $ - msg
section .text
global _start
_start:
mov eax, 4
mov ebx, 1
mov ecx, msg
mov edx, len
int 0x80
mov eax, 1
xor ebx, ebx
int 0x80