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.
NASM, the Netwide Assembler, is a widely used assembler for the x86 processor family, first released in 1996 and known for its clean, readable Intel syntax. This page targets 32-bit (i386) assembly, the level at which each mnemonic corresponds almost directly to a machine instruction the CPU runs: you move values between registers like `eax` and `ebx`, do arithmetic, compare and branch, and call into the operating system. There is no standard library at this level, so anything beyond pure computation — printing a line, reading a key — is done by asking the Linux kernel directly through the `int 0x80` software interrupt. That directness is exactly why people learn it: operating-system and bootloader work, reverse engineering, security research, and simply seeing how a program really talks to the machine. On XCODX your `.asm` is assembled by NASM to a 32-bit ELF object and linked into a Linux executable, with the assembler version shown in the badge above the editor.
; NASM x86 (32-bit): write to stdout via the int 0x80 interrupt
section .data
msg db "Hello from x86 assembly!", 10
len equ $ - msg
section .text
global _start
_start:
mov eax, 4 ; sys_write
mov ebx, 1 ; fd = stdout
mov ecx, msg ; buffer address
mov edx, len ; byte count
int 0x80
mov eax, 1 ; sys_exit
xor ebx, ebx ; status 0
int 0x80
Assembly is for understanding and controlling the machine at the lowest practical level: learning how registers, the stack, and system calls fit together, dissecting or writing exploits, reverse-engineering binaries, and hand-tuning tiny performance- or boot-critical routines. On XCODX the 32-bit toolchain assembles and links your program so that `int 0x80` syscalls such as `sys_write` (eax 4) and `sys_read` (eax 3) behave as they do on real Linux, and stdin you type reaches your `sys_read` buffer. The catch is that there is no C runtime and no libraries at all: you have registers, memory, and syscalls, so even printing an integer means converting it to characters yourself. It is well suited to study and small programs, and deliberately unsuited to building anything large.
The 32-bit (i386) tool makes system calls with `int 0x80` and passes arguments in `eax`, `ebx`, `ecx`, and `edx`; the 64-bit tool uses the `syscall` instruction with `rax`, `rdi`, `rsi`, and `rdx` and a different set of call numbers. Code is not portable between them without changes. Pick the 32-bit tool for classic i386 tutorials and `int 0x80` examples.
Use the `sys_read` syscall: set `eax` to 3, `ebx` to 0 for stdin, `ecx` to a buffer address, and `edx` to the maximum byte count, then `int 0x80`. Type your input into the Stdin Box so it reaches that read. You get raw bytes, usually including the trailing newline, so converting the text into a number is your own job.
You call `sys_write` yourself: `eax` = 4, `ebx` = 1 for stdout, `ecx` = the address of the bytes, `edx` = the length, then `int 0x80`. There is no `printf`, so you track the buffer and its length and convert any numbers to ASCII digits by hand before writing them.
The sandbox links your object directly without the C runtime, so the entry symbol is the ELF default `_start`, not C's `main()`. There is nothing to return into, so you must end with `sys_exit` (`eax` = 1, status in `ebx`); otherwise execution runs off the end of your code and the program faults.
No. There is no libc linked, and no package installation or network is available, so you have only CPU instructions and raw Linux syscalls. Anything a library would give you — formatting, string length, memory allocation — you write yourself, which is part of the point of working at this level.
Not as written. The I/O here uses Linux-specific `int 0x80` calls and Linux syscall numbers, so the same source on another OS would need entirely different system calls. The NASM syntax and the x86 instructions carry over; the operating-system interface does not.
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