$ cat overview.md
This project implements a complete assembly system for the LC-2K instruction set architecture, consisting of an assembler and linker. The system enables multi-file program development by supporting separate compilation and linking of LC-2K assembly files. It's designed to teach fundamental concepts of assembly, linking, and low-level programming.
The assembler is a two-pass system that processes LC-2K assembly files and produces object files containing:
Key features include:
c// Example symbol table entry structure
struct SymbolEntry {
char *label;
char type; // 'T'ext, 'D'ata, or 'U'ndefined
int offset;
};
The assembler handles both local and global symbols, with local symbols starting with lowercase letters and global symbols with uppercase. This distinction is crucial for proper scope handling during linking.
The object file structure follows a specific format with sections for:
Example object file layout:
6 1 1 2 // Header
0x00810006 // Text section
0x00840000
...
0x00000005 // Data section
SubAdr U 0 // Symbol table
0 lw five // Relocation table
1 lw SubAdr
The linker combines multiple object files into a single executable by:
A key feature is handling the special Stack
label, which is automatically resolved to point beyond the combined text and data segments.
One of the most complex aspects was implementing correct symbol resolution, particularly:
The relocation system required careful attention to:
The system implements robust error checking including:
Careful consideration was given to memory layout, particularly:
This project provided deep insights into:
Potential enhancements could include:
cvoid processRelocation(RelocationEntry *entry, int baseAddr) {
int finalAddr = baseAddr + entry->offset;
// Apply relocation to the instruction/data
memory[entry->location] += finalAddr;
}
cint resolveSymbol(char *symbol, SymbolTable *table) {
for (int i = 0; i < table->size; i++) {
if (strcmp(table->entries[i].name, symbol) == 0) {
return table->entries[i].address;
}
}
return -1; // Symbol not found
}
The complete implementation demonstrates fundamental concepts in systems programming while providing practical experience with assembly language processing and program linking.
$ cat features.txt