Write it. Load it. Watch it run.
Real AVR instructions, visible memory, one operation at a time. Based on the ATmega328P used by the Arduino Uno.
Program editor · expand to write or load code
Small programs. Visible consequences.
Write one instruction per line. Use labels such as loop:, commas between operands, and ; for comments. Numbers can be decimal, 0xAB, $AB, or 0b1010.
Assemble turns your instructions into opcode words. Load places those words in simulated Flash and resets the CPU.
This lab starts registers, flags, and SRAM at zero for repeatable experiments. Initialize your data with instructions. These are teaching defaults, not hardware SRAM reset values.
Up to 128 program words. Direct memory access is limited to SRAM 0x0100–0x08FF. No directives, expressions, peripherals, interrupts, or stack instructions. Branches use labels. The lab stops at the end of loaded code or after 500 executed instructions.
01 / Code memory
| Word address | Opcode | Instruction / operand |
|---|
Each row holds one 16-bit word. LDS and STS occupy two rows. Select an instruction to read its explanation.
02 / CPU workbench
Operands in focusAll 32 registers
03 / Data memory
SRAM · 8-bit bytesScroll to browse every byte, or enter an address above to jump to it. Select a cell for the enlarged view below. Read and write labels follow execution.
For the selected instruction
This explanation uses the CPU's current values. Selecting a row does not move the PC.
Guided starting values
Execution history
Memory map & teaching notes
| Data byte addresses | Contents |
|---|---|
| 0x0000–0x001F | R0–R31 |
| 0x0020–0x005F | I/O registers |
| 0x0060–0x00FF | Extended I/O |
| 0x0100–0x08FF | 2 KB SRAM |
Flash has a separate address space: 32 KB, or 16K instruction words. Fetch and execute are teaching pauses, not separate hardware clock cycles. The displayed PC is held during fetch and updated after execute.
Only the listed instruction subset is modeled. SRAM addresses outside the permitted range are rejected even though LDS/STS encodings can represent other addresses. A real CPU does not automatically stop at the end of this listing.
The guided example uses R1 as an addend. Arduino's compiler normally reserves R1 as a zero register. This is standalone assembly simulation, not inline assembly for an Arduino sketch.
What the flags mean
C unsigned carry (ADD) or borrow (SUB/CPI); Z zero; N result's sign bit; V signed overflow; S N XOR V; H carry/borrow across bit 3. DEC preserves C and H. Loads, stores, moves, and branches preserve all flags.
I and T are not displayed or changed by this instruction subset. BREQ/BRNE test the most recent Z flag, not the register contents directly.