This project is a fully functional multi-pass assembler implemented in strict ANSI-C (C90), built as part of a system programming course.
It includes macro processing, symbol table management, two-pass parsing, memory handling, and generation of machine code output files.
- Macro Processing: Pre-assembler that expands user-defined macros.
- Two-Pass Assembly:
- First pass: Symbol table creation, instruction/data counting, error detection.
- Second pass: Resolving addresses, encoding instructions, and writing machine code.
- Complete Output Generation:
.ob– machine code in base-4 format.ent– entry labels.ext– external label references
- Error Handling: Comprehensive syntax and semantic error detection.
assembler.c– Main assembly flowfirst_pass.c/second_pass.c– Parsing and encoding logiccode_image.c– Machine code image handlingerrors_handler.c– Error reporting system*.as– Example assembly input files
Compile using a standard ANSI-C compiler such as gcc:
gcc -ansi -Wall -pedantic *.c -o assembler
./assembler input.as