A curated collection of pure 8051 assembly language programs, simulations, and system-level microcontroller implementations.
This repository treats the 8051 not as a legacy MCU, but as a transparent machine for mastering low-level computation.
This repository is tightly integrated with a web-based 8051 Assembly Language Simulator, built to execute, debug, and analyze programs written for the Intel 8051 architecture.
π Live Simulator
https://8051sim.vercel.app
|
|
|
|
|
|
- Step-by-step execution with register, flag, and memory visibility
- Observe PSW, carry, overflow, and parity behavior in real time
- Validate timing-sensitive logic before hardware deployment
- Learn instruction-level effects without relying on physical kits
Primary validation environment: 8051 Simulator
Level 1: Data Movement & Addressing Modes
- Register Operations β Data transfer between registers and accumulator-based operations
- Direct Addressing β Move data to and from fixed internal RAM addresses
- Indirect Addressing β Use R0/R1 as pointers to access internal RAM
- Indexed Addressing β Access lookup tables in code memory using DPTR and MOVC
- Block Data Transfer β Copy a block of data from one memory region to another
- Stack Operations β PUSH/POP usage, stack growth behavior, subroutine parameter passing
- Bit Addressable RAM β Manipulate individual bits in the 20Hβ2FH address range
Level 2: Arithmetic Operations
- 8-bit Addition β Perform addition with carry flag handling
- 16-bit Addition β Multi-byte addition with carry propagation
- 8-bit Subtraction β Subtraction with borrow and carry analysis
- 16-bit Subtraction β Multi-byte subtraction with borrow handling
- BCD Addition β Binary Coded Decimal addition using DA instruction
- BCD Subtraction β Decimal-adjusted subtraction for BCD values
- Multiplication (Repetitive Addition) β 8-bit multiply without MUL instruction
- Division (Repetitive Subtraction) β 8-bit divide without DIV instruction
- 16-bit Multiplication β Multi-byte multiplication algorithm
- 16-bit Division β Multi-byte division with quotient and remainder
- Boothβs Multiplication β Signed multiplication using Boothβs algorithm
- Binary to BCD Conversion β Convert binary number to packed or unpacked BCD
- BCD to Binary Conversion β Convert BCD representation to binary
- Binary to ASCII β Convert binary value to ASCII hexadecimal characters
- ASCII to Binary β Convert ASCII hexadecimal characters to binary value
Level 3: Logical Operations & Bit Manipulation
- Bit Set / Clear / Toggle β Individual bit control using SETB, CLR, CPL
- Bit Testing β Conditional branching using JB, JNB, and JBC
- Nibble Swap β Swap upper and lower nibbles using SWAP instruction
- Bit Rotation β Rotate accumulator left or right with and without carry
- Parity Check β Use PSW parity flag for data integrity checks
- Bit Counting β Count number of logic-1 bits in a byte
- AND / OR / XOR β Logical masking, clearing, and bit testing
- Bit Reversal β Reverse the bit order within a byte
Level 4: Flags & Program Status Word (PSW)
- Carry Flag Operations β Explicit manipulation and dependency analysis
- Auxiliary Carry Flag β Understand AC behavior in BCD arithmetic
- Overflow Flag β Detect signed arithmetic overflow conditions
- Parity Flag β Use parity bit for error detection and validation
- Register Bank Selection β Switch register banks using RS0 and RS1
- User Flag (F0) β Employ PSW user-defined flag for logic control
- Multi-precision Arithmetic β Implement 32-bit and 64-bit arithmetic using flags
Level 5: Comparison & Conditional Operations
- Byte Comparison β Compare two values using SUBB and flag analysis
- String Comparison β Compare byte sequences stored in memory
- Find Maximum β Identify the largest value in an array
- Find Minimum β Identify the smallest value in an array
- Range Checking β Verify whether a value lies within defined bounds
- CJNE Instruction Mastery β Conditional branching using CJNE semantics
- Conditional Subroutines β Execute different routines based on comparison results
Level 6: Array & Table Operations
- Array Initialization β Fill arrays with constants or computed values
- Linear Search β Search an unsorted array sequentially
- Binary Search β Search a sorted array using divide-and-conquer
- Bubble Sort β Sort array elements using adjacent comparisons
- Selection Sort β Sort array by selecting minimum or maximum iteratively
- Array Reversal β Reverse array elements in memory
- Lookup Tables β Access precomputed tables using MOVC
- Code Table Access β Use tables for 7-segment patterns or character sets
- Checksum Calculation β Compute and verify data integrity checksums
Primary validation environment: 8051 Simulator
Level 7: Timer Programming
- Timer 0 Mode 0 β 13-bit timer/counter configuration
- Timer 0 Mode 1 β 16-bit timer/counter operation
- Timer 0 Mode 2 β 8-bit auto-reload timer mode
- Timer 0 Mode 3 β Split timer operation of TL0 and TH0
- Timer 1 All Modes β Full practice of Timer 1 modes
- Precise Delay Generation β Exact delay calculation using machine cycles
- Event Counting β Count external pulses using counter mode
- Frequency Measurement β Measure input signal frequency
- Pulse Width Measurement β Measure high and low pulse durations
- Software PWM β Generate PWM signals using timers
Level 8: Interrupt Handling
- External Interrupt 0 β Edge and level triggered handling
- External Interrupt 1 β Independent interrupt configuration
- Timer 0 Interrupt β Overflow-based ISR design
- Timer 1 Interrupt β Time-critical ISR handling
- Serial Interrupt β RI and TI interrupt servicing
- Interrupt Priority β Configure high and low priority interrupts
- Nested Interrupts β Allow controlled interrupt nesting
- Context Saving β Preserve registers and PSW in ISRs
- Interrupt Latency β Measure and minimize response delay
- Critical Sections β Atomic operations using interrupt control
- Interrupt-driven Tasks β Foreground and background task separation
Level 9: Serial Communication
- Serial Mode 0 β Synchronous shift-register communication
- Serial Mode 1 β 8-bit UART with variable baud rate
- Serial Mode 2 β 9-bit UART with fixed baud rate
- Serial Mode 3 β 9-bit UART with variable baud rate
- Baud Rate Calculation β Timer-based baud generation
- 9th Bit Operations β Multiprocessor communication support
- Interrupt-driven Transmission β Non-blocking serial transmission
- Interrupt-driven Reception β Buffered serial reception
- Ring Buffer Implementation β Circular buffer for serial data
- Framing Error Detection β Detect and handle communication errors
- Protocol Implementation β Design packet-based serial protocol
Level 10: LCD Programming
- LCD 4-bit Mode Initialization β Reduced pin interface initialization
- LCD 8-bit Mode Initialization β Full data bus operation
- Busy Flag Checking β Poll LCD status instead of fixed delays
- Custom Character Generation β Define characters using CGRAM
- Cursor Positioning β Direct cursor movement control
- Display Shift Control β Shift display without altering data
- Entry Mode Control β Configure cursor increment or decrement
- LCD Command Timing β Respect minimum timing constraints
Level 11: Advanced Algorithms
- Square Root Algorithm β Compute square root using NewtonβRaphson or digit-by-digit method
- GCD (Greatest Common Divisor) β Implement Euclidean algorithm
- LCM (Least Common Multiple) β Derive LCM using GCD computation
- Prime Number Check β Determine whether a number is prime
- Factorial Calculation β Compute factorial using iterative or recursive logic
- Fibonacci Series β Generate Fibonacci sequence iteratively
- CRC Calculation β Implement Cyclic Redundancy Check for error detection
- Hamming Code β Perform error detection and correction
- Linear Feedback Shift Register β Generate pseudo-random sequences
- Fixed-Point Arithmetic β Simulate floating-point math using integers
Level 12: Code Optimization Techniques
- Loop Unrolling β Reduce loop overhead for speed optimization
- Register Optimization β Minimize memory access using registers
- Code Size Reduction β Optimize jumps and calls for smaller binaries
- Jump Table Implementation β Efficient multi-way branching
- Inline vs Subroutine β Decide between speed and modularity
- Instruction Cycle Counting β Precise execution time calculation
- Memory Banking β Efficient use of register banks
Level 13: Low-Level Hardware Control
- Port Latch Reading β Understand latch versus pin behavior
- Read-Modify-Write β Avoid unintended port bit changes
- Quasi-bidirectional Ports β Internal port structure understanding
- Pull-up Resistor Effects β Analyze loading and fan-out
- Glitch-free Output β Prevent hazards during port updates
- Power Mode Control β IDLE and POWER-DOWN modes
- Watchdog Timer β Software watchdog implementation
Level 14: System-Level Programming
- Reset Vector Handling β Code execution from address 0000H
- Interrupt Vector Table β Proper ISR placement and redirection
- Memory Map Management β Organize code, data, and stack
- Relocatable Code β Position-independent programming techniques
- Self-Modifying Code β Controlled runtime code modification
- Bootloader Concepts β Jump from bootloader to application
- Checksum Verification β Validate program memory integrity
- Execute programs instantly: https://8051sim.vercel.app
- Use this repository as the reference implementation set
- Treat the simulator as the ground truth for instruction behavior
Distributed under the MIT License. See LICENSE for more information.






