DCPU-8 Instruction Set v0.1

General Notes:

  • Each instruction is 1 byte (8 bits).
  • High nibble (upper 4 bits) is the opcode.
  • Low nibble (lower 4 bits) is often an address or register hint.
  • Two general-purpose registers: A and B.
  • Memory is 256 bytes (8-bit address space).
  • No hardware interrupts or stack by default (can be added later).

Instruction Table:

OpcodeMnemonicDescription
0x0XLOAD A, [X]Load the value at memory address X into A
0x1XLOAD B, [X]Load the value at memory address X into B
0x2XSTORE A, [X]Store the value of A into memory address X
0x3XSTORE B, [X]Store the value of B into memory address X
0x40ADD A, BA = A + B
0x41SUB A, BA = A – B
0x42AND A, BA = A & B (bitwise AND)
0x43OR A, BA = A
0x44XOR A, BA = A ^ B (bitwise XOR)
0x50 XJMP XJump to address X (X is the next byte)
0x51 XJZ XJump to X if A == 0
0x52 XJNZ XJump to X if A != 0
0xF0NOPNo operation
0xFFHALTStop execution

Example Program: Simple Adder

This adds the values at memory[0x10] and memory[0x11], and stores the result in memory[0x12]:

assemblyCopyEdit00: 01 10     ; LOAD B, [0x10]
02: 00 11     ; LOAD A, [0x11]
04: 40        ; ADD A, B
05: 20 12     ; STORE A, [0x12]
07: FF        ; HALT

Memory Map (Recommended)

RangeUsage
0x00–0x7FProgram memory (code)
0x80–0xEFGeneral-purpose RAM
0xF0–0xFFReserved / Stack (if added later)