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:
Opcode | Mnemonic | Description |
---|
0x0X | LOAD A, [X] | Load the value at memory address X into A |
0x1X | LOAD B, [X] | Load the value at memory address X into B |
0x2X | STORE A, [X] | Store the value of A into memory address X |
0x3X | STORE B, [X] | Store the value of B into memory address X |
0x40 | ADD A, B | A = A + B |
0x41 | SUB A, B | A = A – B |
0x42 | AND A, B | A = A & B (bitwise AND) |
0x43 | OR A, B | A = A |
0x44 | XOR A, B | A = A ^ B (bitwise XOR) |
0x50 X | JMP X | Jump to address X (X is the next byte) |
0x51 X | JZ X | Jump to X if A == 0 |
0x52 X | JNZ X | Jump to X if A != 0 |
0xF0 | NOP | No operation |
0xFF | HALT | Stop 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)
Range | Usage |
---|
0x00–0x7F | Program memory (code) |
0x80–0xEF | General-purpose RAM |
0xF0–0xFF | Reserved / Stack (if added later) |