Assembly
section .data
    msg db "Welcome to Online IDE!", 10, "Start coding in Assembly...", 10
    len equ $ - msg

section .text
    global _start

_start:
    mov rax, 1          ; write(1, msg, len)
    mov rdi, 1
    mov rsi, msg
    mov rdx, len
    syscall

    mov rax, 60         ; exit(0)
    xor rdi, rdi
    syscall

Press Run or Ctrl ↵ to execute main.asm.
Type program input here while it runs.

Assembly

Online Assembly Compiler

main.asm is assembled with NASM 2.16 as 64-bit ELF and linked with ld, without the C library. Your program talks to Linux through syscalls, and a read from descriptor 0 waits for you to type in the terminal.

Try it above

How Assembly runs here

Versions
NASM 2.16, x86-64 Linux
Build
nasm -f elf64 main.asm && ld -o a.out main.o
Run
./a.out
Limits per run
256 MB memory, 15 s of CPU time on half a core, 2 MB of output
Time
Up to 10 minutes a run (30 on a paid plan); waits 2 minutes for input (5 on a paid plan)
Sandbox
Each run gets its own Linux sandbox with no network access. Text files your program writes next to your code open as new tabs.

An x86-64 program that reads input

This main.asm reads a line, turns its lowercase letters into capitals and writes it back:

Assembly
; Read a line, turn its lowercase letters into capitals, print it.
section .data
    prompt  db  "Type a line: "
    plen    equ $ - prompt

section .bss
    buf     resb 256

section .text
    global _start

_start:
    mov     rax, 1              ; write(1, prompt, plen)
    mov     rdi, 1
    lea     rsi, [rel prompt]
    mov     rdx, plen
    syscall

    mov     rax, 0              ; read(0, buf, 256) returns the byte count
    mov     rdi, 0
    lea     rsi, [rel buf]
    mov     rdx, 256
    syscall
    mov     rdx, rax            ; keep the length for write
    xor     rcx, rcx

.next:
    cmp     rcx, rdx
    jge     .print
    mov     al, [buf + rcx]
    cmp     al, 'a'
    jb      .skip
    cmp     al, 'z'
    ja      .skip
    sub     al, 32              ; 'a' - 'A'
    mov     [buf + rcx], al
.skip:
    inc     rcx
    jmp     .next

.print:
    mov     rax, 1              ; write(1, buf, length)
    mov     rdi, 1
    lea     rsi, [rel buf]
    syscall

    mov     rax, 60             ; exit(0)
    xor     rdi, rdi
    syscall
Terminal
$ nasm -f elf64 main.asm && ld -o a.out main.o && ./a.out
Type a line: hello, nasm 2.16
HELLO, NASM 2.16

Input and output with syscalls

  • read (rax = 0) on descriptor 0 returns one line as you typed it, newline included, and puts the byte count in rax.
  • Numbers arrive as ASCII digits: subtract '0' from each byte and multiply as you go. To print a number, divide by 10 repeatedly and add '0' to each remainder.
  • syscall overwrites rcx and r11, so don’t keep a loop counter in them across a call.

What isn’t available here

  • The C library: the program is linked with plain ld, so printf, scanf and malloc don’t exist. The entry point is _start, not main.
  • DOS and Windows: int 21h, MASM and TASM directives such as .model small, and Windows API calls don’t work on Linux.
  • AT&T syntax: NASM takes Intel syntax (mov rax, 1), not GAS syntax (movq $1, %rax).

Errors you’ll see

  • “ld: warning: cannot find entry symbol _start; defaulting to 0000000000401000” The label is missing or not declared with global _start.
  • “error: symbol `msg' not defined” A label used but never defined, often a typo.
  • “undefined reference to `printf'” extern printf assembles, but there’s no C library to link it to.
  • Return code 139 (a segmentation fault): usually a missing exit syscall, so the CPU runs past the end of your code.

Questions

Which assembler does this use?

NASM 2.16, producing 64-bit ELF that ld links into a Linux program. Intel syntax, x86-64 only.

Can I call printf or scanf?

No. The C library isn’t linked. Use the write and read syscalls, and convert numbers to and from text yourself.

Does 8086 or DOS assembly work?

No. int 21h and other DOS services don’t exist on Linux. Programs here use Linux syscalls in 64-bit mode.