C Assembler is a two-pass assembler written in C, designed as a comprehensive systems programming project. It demonstrates mastery of bit-field methods, dynamic memory management, and modular programming architecture. The assembler processes assembly language source files and generates corresponding machine code through a sophisticated two-pass compilation process.
- Two-Pass Architecture: Implements a complete two-pass assembly algorithm for symbol resolution
- Memory Management: Efficient dynamic memory allocation and deallocation
- Modular Design: Clean separation of concerns across multiple source files
- Robust Error Handling: Comprehensive syntax and semantic error detection
- Standards Compliant: Written in standard C with portable code practices
- assembler.c: Main entry point containing
main()andexecutePasses()orchestration - assemblerHelper.c/.h: Argument validation and pass control logic
- dataStructure.c/.h: Core data structures (line/label structs) and initialization routines
- firstPass.c/.h: First pass implementation handling symbol table construction
- secondPassHelper.c/.h: Second pass logic for code generation and symbol resolution
- reservedWords.c/.h: Assembly language keyword recognition and instruction parsing
- strHandle.c/.h: String manipulation and parsing utilities
- outputPrint.c/.h: Machine code generation and output file creation
- makefile: Automated build configuration with dependency management
- GCC compiler (or compatible C compiler)
- Make utility
- POSIX-compliant system (Linux/Unix/macOS)
# Clone the repository
git clone <repository-url>
cd C_Assembler
# Compile the project
make
# Clean build artifacts (optional)
make clean# Basic usage
./assembler source_file.as
# Example with multiple files
./assembler prog1.as prog2.as prog3.as- Input: Assembly source files with
.asextension - Output: Generated files include:
.ob- Object file (machine code).ext- External symbols file.ent- Entry symbols file
The assembler supports a custom assembly language instruction set including:
- Data manipulation instructions
- Control flow operations
- Memory addressing modes
- Symbol definitions and references
- Directive handling (
.data,.string,.entry,.extern)
Comprehensive error detection including:
- Syntax errors (invalid instruction format)
- Semantic errors (undefined symbols, duplicate labels)
- Memory allocation failures
- File I/O errors
- Invalid command-line arguments
This project was developed as the final assignment for a Systems Programming Laboratory course, focusing on:
- Low-level programming concepts
- Assembly language processing
- File I/O operations
- Data structure design
- Modular programming practices
- Final Grade: 95/100
- Language: C
- Architecture: Modular, multi-file design
- Compilation: Standard makefile with dependency tracking
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch
- Implement changes with appropriate tests
- Submit a pull request with detailed description
This project is part of academic coursework. Please respect academic integrity policies when referencing or using this code.
Built with precision and attention to detail as a demonstration of systems programming mastery.
