A lightweight Intel 8085 microprocessor simulator written in C++. The project emulates the core components of the 8085 CPU, supports execution of assembly programs, and includes a small assembler that converts assembly code into machine code.
This project was built to understand CPU architecture, instruction decoding, and emulator design.
The simulator implements the core behavior of the Intel 8085 processor:
-
8-bit registers
A B C D E H L -
16-bit registers
PC (Program Counter)SP (Stack Pointer) -
Flags register
- Zero (Z)
- Sign (S)
- Parity (P)
- Carry (CY)
- Auxiliary Carry (AC structure defined)
The CPU supports execution of several 8085 instruction groups.
MOV r1,r2MVI r,data
ADD rSUB rADI dataSUI data
ANA rXRA rORA rANI dataORI dataCMP r
INR rDCR r
JMP addrJZ addrJNZ addrCALL addrRET
NOPHLT
Each instruction execution prints:
- Program Counter
- Opcode
- Executed instruction
- Register state
Example output:
PC=0000 OPCODE=06
MVI executed
A=00
B=05
C=00
D=00
E=00
H=00
L=00
This helps trace program execution step-by-step.
The project includes a simple two-pass assembler that converts assembly programs into machine code.
Supported assembly instructions include:
MVI
MOV
ADD
SUB
INR
DCR
JMP
JZ
JNZ
HLT
The assembler supports labels for branching.
Example:
MVI B,05
LOOP:
DCR B
JNZ LOOP
HLT
The assembler automatically resolves label addresses.
8085Simulator
│
├── assembler/
│ └── assembler.cpp
│
├── cpu/
│ ├── cpu.cpp
│ └── cpu.h
│
├── memory/
│ ├── memory.cpp
│ └── memory.h
│
├── program.asm
│
├── main.cpp
└── CMakeLists.txt
The simulator models a simplified 8085 execution cycle:
Fetch → Decode → Execute
-
Fetch
- Read opcode from memory using PC.
-
Decode
- Identify instruction type using opcode masks.
-
Execute
- Perform register, memory, or control operation.
MVI B,05
LOOP:
DCR B
JNZ LOOP
HLT
Assembly completed successfully
PC=0000 OPCODE=06
MVI executed
PC=0002 OPCODE=05
DCR executed
PC=0003 OPCODE=C2
JNZ executed
The loop continues until register B becomes zero, after which the CPU executes HLT.
- Build the project
mkdir build
cd build
cmake ..
make
- Run the simulator
./8085Simulator
- Modify
program.asmto test your own assembly programs.
This project demonstrates:
- CPU emulator design
- instruction decoding using bit masks
- assembler implementation
- program counter control
- stack operations
- debugging through execution tracing
Planned features:
-
Memory instructions
LDA,STA,LHLD,SHLD -
Instruction dispatch table (faster decoding)
-
Memory viewer and debugger tools
-
Graphical interface using Qt
-
Full 8085 instruction set support
Ashutosh Upreti Computer Science Student Interested in systems programming, CPU architecture, and low-level software development.