Online 8086 assembler and emulator

Assemble and run 8086 programs in MASM/TASM style, with DOS input and output, in your browser. Errors are explained, and every register and flag can be followed step by step.

Opening the compiler…

About the 8086 Assembly compiler

How to use the 8086 compiler

Write a program with .MODEL SMALL, .DATA and .CODE, or start from a template: printing a message, reading a key, adding two digits, a LOOP, case conversion and comparing two values. Press Run or Ctrl+Enter. The output is the DOS screen as the program left it.

End MAIN with MOV AH, 4CH and INT 21H, which hands control back to DOS; without it the CPU runs on past the last instruction and the run stops with an explanation.

How input works

INT 21H with AH = 1, 7 or 8 reads one key from the Input tab, one character at a time, and AH = 0AH reads a whole line into a buffer. A new line in the Input tab is the Enter key (0DH). If the program waits for a key when the input is used up, the run stops and says so.

What runs your code

StepVioz's 8086 emulator runs in your browser. It assembles MASM/TASM/emu8086 style source with two passes, so labels may be used before they are defined, and runs the real 8086 instruction set: data movement, arithmetic with flags, logic and shifts, jumps, loops, the stack, procedures, string instructions and MUL/DIV. Its arithmetic is checked against a real CPU. DOS services for keys, characters, strings and exit are supported.

A run may take 5 seconds; an endless loop is stopped there. Output is kept up to 10,000 lines.

See it step by step

Visualize this run opens the program in the 8086 visualizer: each instruction shows the registers, the flags it changed and why, the stack and memory, with the calculation worked out in hexadecimal and decimal.

Questions

Is this emu8086 or MASM?
Neither: it is StepVioz's own assembler and emulator, which accepts their syntax for 8086 programs.
How do I print a number?
Turn each digit into a character by adding '0' (30H), then print it with AH = 2 and the character in DL.
Why does my program run past its end?
MAIN must end with MOV AH, 4CH and INT 21H, which returns to DOS.
Can it run 32-bit or 64-bit assembly?
No, only the 16-bit 8086, as university courses teach it.
How do I read a number with more than one digit?
Read the digits one key at a time. For each, subtract '0', then multiply the number so far by 10 and add the digit.

See also