๐ Interactive web-based 8051 microcontroller assembler and simulator for educational and development purposes
๐ง Features โข ๐ Installation โข ๐ฎ Usage โข ๐๏ธ Architecture
Transform embedded systems education with an interactive 8051 simulator! This comprehensive tool revolutionizes how students and engineers learn microcontroller programming by:
- ๐ง Real-time Assembly Compilation - Write and compile 8051 assembly code instantly
- ๐ Live Register Monitoring - Visualize register and flag changes in real-time
- ๐ Educational Focus - Perfect for learning embedded systems programming
- ๐ Web-based Interface - No installation of complex IDEs required
- ๐ Error Detection - Comprehensive syntax and semantic error checking
- ๐ฆ Data Transfer:
MOVoperations with registers and immediate values - โ Arithmetic Operations:
ADD,SUBB,INC,DECwith flag updates - ๐ Logical Operations:
ANL,ORL,XRL,CPLfor bit manipulation - ๐ Bit Manipulation:
RL,RR,RLC,RRC,SWAPfor data rotation - ๐ฏ Register Support: Complete A, R0-R7, DPTR register set
- ๐ Live Register Display: Monitor accumulator and working registers
- ๐ฉ Flag Status Monitoring: Track Carry (CY), Auxiliary Carry (AC), Overflow (OV), Parity (P)
- ๐ Program Status Word: Real-time PSW register visualization
- ๐ Step-by-step Execution: Watch how instructions affect system state
- โจ Syntax Highlighting: Assembly code editor with 8051-specific highlighting
- ๐ Dark Theme: Modern Monokai theme for comfortable coding
- ๐ฑ Responsive Design: Works seamlessly on desktop and tablet devices
- โก Real-time Compilation: Instant feedback on code changes
graph TD
A[๐ Code Editor] --> B[๐ Parser Module]
B --> C[๐ Syntax Validation]
C --> D[โ๏ธ Instruction Execution]
D --> E[๐ Register Updates]
D --> F[๐ฉ Flag Updates]
E --> G[๐ Display Tables]
F --> G
style A fill:#ff6b6b
style D fill:#4ecdc4
style G fill:#45b7d1
- Python 3.8+
- Modern web browser
- Basic understanding of assembly language
# Clone the repository
git clone https://github.com/het004/8051_Assembler-GUI.git
cd 8051_Assembler-GUI
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtstreamlit run main.pyOpen your browser and navigate to: http://localhost:8501
MOV A, #4F ; Load 4F hex into accumulator
SUBB A, #10 ; Subtract 10 hex from A
ANL A, #0FH ; AND with 0F hex
CPL A ; Complement accumulatorExpected Output:
- A Register:
4FHโ3FHโ0FHโF0H - Flags: Carry, Overflow, and Parity flags updated accordingly
MOV A, #0AA ; Load pattern 10101010
RL A ; Rotate left
RRC A ; Rotate right through carry
SWAP A ; Swap nibblesMOV R0, #10 ; Load 10 into R0
MOV R1, #20 ; Load 20 into R1
MOV A, R0 ; Transfer R0 to A
ADD A, R1 ; Add R1 to A| Category | Instructions | Description |
|---|---|---|
| ๐ฆ Data Transfer | MOV A, #data |
Move immediate data to accumulator |
MOV A, Rn |
Move register to accumulator | |
MOV Rn, #data |
Move immediate data to register | |
| โ Arithmetic | ADD A, #data |
Add immediate data to A |
SUBB A, #data |
Subtract with borrow from A | |
INC A/Rn |
Increment accumulator/register | |
DEC A/Rn |
Decrement accumulator/register | |
| ๐ Logical | ANL A, #data |
Logical AND with A |
ORL A, #data |
Logical OR with A | |
XRL A, #data |
Logical XOR with A | |
CPL A |
Complement accumulator | |
| ๐ Rotation | RL A |
Rotate A left |
RR A |
Rotate A right | |
RLC A |
Rotate A left through carry | |
RRC A |
Rotate A right through carry | |
SWAP A |
Swap nibbles in A |
๐ง 8051_Assembler-GUI/
โโโ ๐ main.py # Application entry point
โโโ ๐จ assembler_gui.py # Streamlit UI implementation
โโโ ๐ parser.py # Assembly code parser
โโโ โ๏ธ executor.py # Instruction execution engine
โโโ ๐ state.py # Register and flag definitions
โโโ ๐ฉ flags.py # Flag update logic
โโโ ๐ ๏ธ utils.py # Utility functions
โโโ ๐ฆ requirements.txt # Project dependencies
โโโ ๐ Instructions/ # Instruction implementations
โ โโโ ๐งฎ arithmetic.py # Arithmetic operations
โ โโโ ๐ logic.py # Logical operations
โ โโโ ๐ฆ data_transfer.py # Data transfer operations
โ โโโ ๐ shift_rotate.py # Bit manipulation operations
โ โโโ ๐ฏ control_flow.py # Control flow operations (future)
โโโ ๐ README.md # Project documentation
- Microcontroller Courses: Interactive learning tool for embedded systems
- Laboratory Sessions: Hands-on programming without hardware requirements
- Assignment Grading: Quick verification of student assembly programs
- Concept Demonstration: Visual representation of instruction execution
- Algorithm Testing: Quick prototyping of embedded algorithms
- Code Verification: Testing assembly routines before hardware implementation
- Training Programs: Corporate embedded systems training
- Interview Preparation: Practice assembly programming concepts
- Algorithm Development: Research new embedded processing techniques
- Academic Papers: Generate examples and demonstrations
- Proof of Concepts: Validate theoretical concepts practically
- Student Projects: Final year and graduate project development
| Aspect | Details |
|---|---|
| ๐ฏ Target Architecture | Intel 8051 Microcontroller |
| ๐ Supported Formats | Hexadecimal (#4FH), Decimal (#79), Binary |
| ๐ Register Coverage | A, R0-R7, DPTR, PSW |
| ๐ฉ Flag Support | CY, AC, OV, P flags |
| ๐ง Instruction Count | 20+ core instructions |
| โก Performance | Real-time execution simulation |
- ๐ฏ Complete Instruction Set - Support all 255 8051 instructions
- ๐๏ธ Memory Visualization - Internal and external RAM display
- โฐ Timer/Counter Simulation - Complete peripheral simulation
- ๐ฑ Mobile App - React Native mobile application
- ๐ Hardware Integration - Connect to real 8051 development boards
- ๐ Code Analysis - Performance metrics and optimization suggestions
- ๐จ Multiple Themes - Light/dark theme options
- ๐พ Project Management - Save and load assembly projects
- ๐ Advanced Debugger - Breakpoints and step-through debugging
- ๐ Execution Statistics - Instruction count and timing analysis
The 8051 microcontroller, developed by Intel in 1980, features:
- 8-bit CPU with Harvard architecture
- 4KB ROM and 128 bytes RAM on-chip
- 32 I/O pins for interfacing
- 2 Timer/Counters for timing operations
- 5 Interrupt sources for real-time processing
- Register Optimization: Use working registers (R0-R7) for temporary storage
- Flag Awareness: Monitor carry and overflow flags for arithmetic operations
- Addressing Modes: Understand immediate, register, and direct addressing
- Memory Management: Efficiently use internal RAM space
We welcome contributions from embedded systems enthusiasts and educators!
- ๐ด Fork the repository
- ๐ฟ Create your feature branch (
git checkout -b feature/NewInstruction) - ๐ง Add new instructions or features
- ๐พ Commit your changes (
git commit -m 'Add SFR support') - ๐ค Push to the branch (
git push origin feature/NewInstruction) - ๐ฏ Open a Pull Request
- ๐ New Instructions: Implement additional 8051 instructions
- ๐จ UI Improvements: Enhance user interface and experience
- ๐ง Bug Fixes: Resolve issues and improve stability
- ๐ Documentation: Improve guides and examples
- ๐งช Test Cases: Add comprehensive test coverage
๐ง Common Issues & Solutions
Q: "ModuleNotFoundError: No module named 'state'"
# Ensure you're in the correct directory and state.py exists
ls -la state.py
python main.pyQ: Invalid instruction error
# Check syntax: Use #10H for hex, not #10
# Verify register names: Use A, R0-R7
# Example: MOV A, #4FH (correct) vs MOV A, #4F (incorrect)Q: UI not loading properly
# Clear Streamlit cache
streamlit cache clear
# Restart the application
streamlit run main.py --server.port 8502This project is licensed under the MIT License - see the LICENSE file for details.
๐ Special Thanks To:
- ๐ Intel Corporation - For the 8051 microcontroller architecture
- ๐ Streamlit Team - For the excellent web framework
- ๐จโ๐ Educational Community - For feedback and testing
- ๐ป Open Source Contributors - For inspiration and guidance
โญ Star this repository if you found it helpful!
Built with โค๏ธ for embedded systems education and development