A complete Intel 8080 microprocessor emulator with virtual filesystem, assembler compiler, and vim-like text editor.
- โ All 256 opcodes implemented
- โ Full instruction set: MOV, MVI, ADD, SUB, JMP, CALL, etc.
- โ Flag management: Zero, Sign, Parity, Carry, Auxiliary Carry
- โ 64KB addressable memory
- โ Accurate cycle timing for each instruction
- โ Stack operations with SP register
- โ I/O ports: IN and OUT instructions
- โ Interrupt support: EI, DI, RST
- โ Persistent storage - files survive between sessions
- โ Directory hierarchy - organize your projects
- โ Unix-like commands: ls, cd, mkdir, touch, del
- โ Import from host - bring files into the emulator
- โ Dynamic prompt showing current directory
- โ Vim-like interface with familiar commands
- โ
Save with
:w - โ
Quit with
:q - โ
Save and quit with
:wq - โ Line editing: append and delete
- โ Integrated with the filesystem
- โ Full 8080 assembly support
- โ All mnemonics: 74 instruction types
- โ Multiple formats: decimal, hexadecimal, octal
- โ
Comments support with
; - โ Direct compilation from filesystem
- โ Hello World - classic first program
- โ Factorial - calculate factorial of 4
- โ Sum - compute sum from 0 to 10
- โ
Pre-loaded in
/root/examples
# Ubuntu/Debian
sudo apt-get install build-essential
# macOS
xcode-select --install
### Build
```bash
# Clone the repository
https://github.com/Clesiaaa/Virtual-Machine-Intel8080.git
cd Virtual-Machine-Intel8080
# Compile
make
# Run
./emulator$ ./emulator
booting....
Filesystem initialized
root>
root> cd examples
root/examples> ls
Directory: root/examples
================================================
[FILE] hello.asm 567 B
================================================
1 item(s)
root/examples> compile
source file (.asm): hello.asm
output file (.hex): hello.hex
Compilation complete: hello.hex
root/examples> exec
file: hello.hex
ROM loaded: 29 bytes
HELLO WORLD
| Command | Description | Example |
|---|---|---|
help |
Show all commands | help |
clear |
Clear the screen | clear |
exit |
Save and quit | exit |
| Command | Description | Example |
|---|---|---|
ls |
List files in current directory | ls |
cd <dir> |
Change directory | cd examples |
cd .. |
Go to parent directory | cd .. |
mkdir |
Create directory | mkdir myproject |
touch |
Create empty file | touch test.asm |
del |
Delete file or directory | del oldfile.hex |
cat |
Display file contents | cat hello.asm |
editor |
Edit file (vim-like) | editor hello.asm |
import |
Import from host system | import |
| Command | Description | Example |
|---|---|---|
load |
Load ROM into memory | load program.hex |
run |
Execute loaded ROM | run |
exec |
Load and execute ROM | exec hello.hex |
compile |
Compile assembly to hex | compile |
The emulator includes a vim-like text editor.
root> editor hello.asm
| Command | Description |
|---|---|
:w |
Save file |
:q |
Quit editor |
:wq |
Save and quit |
a |
Append new line |
d NUM |
Delete line NUM |
=== EDITOR: hello.asm ===
Press ESC then :w to save, :q to quit, :wq to save and quit
--------------------------------------------------
1 | ; Hello World
2 | MVI A, 72
3 | OUT 1
4 | HLT
--------------------------------------------------
Commands:
:w - Save
:q - Quit
:wq - Save and quit
a - Append new line
d NUM - Delete line NUM
> a
Enter line (empty to finish):
MVI A, 69
Line added
> :wq
File saved
; Comments start with semicolon
LABEL:
INSTRUCTION OPERAND1, OPERAND2; Hello World for Intel 8080
MVI A, 72 ; 'H'
OUT 1
MVI A, 69 ; 'E'
OUT 1
MVI A, 76 ; 'L'
OUT 1
MVI A, 76 ; 'L'
OUT 1
MVI A, 79 ; 'O'
OUT 1
MVI A, 10 ; '\n'
OUT 1
HLTMOV,MVI,LXI,LDA,STA,LHLD,SHLD,LDAX,STAX
ADD,ADC,SUB,SBB,INR,DCR,INX,DCX,DAD
ANA,XRA,ORA,CMP,ANI,XRI,ORI,CPI
JMP,JZ,JNZ,JC,JNC,JP,JM,JPE,JPO
PUSH,POP,XTHL,SPHL
IN,OUT
HLT,NOP,EI,DI,RST
The emulator maintains a persistent virtual filesystem stored in .emulator_fs.dat.
root/
โโโ examples/
โโโ hello.asm - Hello World program
root> mkdir myproject
root> cd myproject
root/myproject> mkdir src
root/myproject> mkdir bin
root/myproject> cd src
root/myproject/src> touch main.asm
root/myproject/src> editor main.asm
You can import assembly files from your host system:
root> import
host path: /home/user/programs/test.asm
name in filesystem: test.asm
Imported 'test.asm' from host
The file is now available in the virtual filesystem and persists between sessions.
# 1. Create project structure
root> mkdir calculator
root> cd calculator
root/calculator> mkdir src
root/calculator> mkdir build
# 2. Write code
root/calculator> cd src
root/calculator/src> touch add.asm
root/calculator/src> editor add.asm
# ... write your assembly code ...
> :wq
# 3. Compile
root/calculator/src> compile
source file (.asm): add.asm
output file (.hex): ../build/add.hex
Compilation complete: ../build/add.hex
# 4. Execute
root/calculator/src> cd ../build
root/calculator/build> exec
file: add.hex
ROM loaded: 15 bytes
8typedef struct {
uint8_t A, B, C, D, E, H, L; // 8-bit registers
uint16_t PC; // Program Counter
uint16_t SP; // Stack Pointer
FLAGS f; // Flags register
uint8_t memory[0x10000]; // 64KB RAM
uint64_t cycles; // Cycle counter
uint8_t interrupt_enable; // Interrupt state
} cpu;| Bit | Flag | Description |
|---|---|---|
| 0 | CY | Carry flag |
| 2 | P | Parity flag |
| 4 | AC | Auxiliary Carry (BCD) |
| 6 | Z | Zero flag |
| 7 | S | Sign flag |
0x0000 - 0xFFFF RAM (64KB)
For Space Invaders compatibility:
0x2000 - 0x3FFF ROM
0x2400 - 0x3FFF Video RAM (7KB)
To add a new instruction:
- Open
src/execution_engine/instructions.c - Add your case in the switch statement
- Update the cycle table
- Recompile with
./compile.sh
root> cd examples
root/examples> compile
source file (.asm): hello.asm
output file (.hex): hello.hex
root/examples> exec
file: hello.hex
HELLO WORLDroot/examples> exec
file: sum.hex
55On a modern Intel i7:
- Emulation speed: ~50-100 MHz (25-50x faster than real 8080)
- Instruction overhead: ~20 nanoseconds
- Memory usage: ~100KB (64KB RAM + structures)
# Remove corrupted filesystem
rm .emulator_fs.dat
# Restart emulator
./emulatorCheck your assembly syntax:
- Instructions must be uppercase
- Operands separated by commas
- Values can be decimal, hex (0x), or octal (0)
Verify:
- File exists:
ls - File is .hex format:
cat filename.hex - ROM is loaded: Check for "ROM loaded" message
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details
- Intel for the 8080 processor
- The retro computing community
- All contributors
Author: Robert Folga
Issues: Please report bugs on GitHub
Mail: robert.folga@ens.uvsq.fr
If you find this project useful, please consider giving it a star on GitHub!
Happy Emulating! ๐ฎ๐